mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-02-08 21:15:05 -05:00
* Remove unused pages / components * Add WrapItem around components inside Wrap component New version of Chakra requires WrapItem around any components that have Wrap * Update LoginButton to link to own profile and show Avatar (#285) * Update LoginButton to link to own profile and show Avatar * Change SetupUsername to explicitly mention "username"
24 lines
990 B
TypeScript
24 lines
990 B
TypeScript
import BackgroundImage from 'assets/tile-background.jpg';
|
|
import { ethers } from 'ethers';
|
|
|
|
import { PlayerFragmentFragment } from '../graphql/autogen/types';
|
|
|
|
export const getPlayerImage = (player: PlayerFragmentFragment): string =>
|
|
player.box_profile?.imageUrl ||
|
|
`https://avatars.dicebear.com/api/jdenticon/${player.username}.svg`;
|
|
|
|
export const getPlayerCoverImage = (player: PlayerFragmentFragment): string =>
|
|
player.box_profile?.coverImageUrl || BackgroundImage;
|
|
|
|
export const getPlayerName = (player: PlayerFragmentFragment): string =>
|
|
player.box_profile?.name || formatUsernameIfAddress(player.username);
|
|
|
|
export const getPlayerDescription = (player: PlayerFragmentFragment): string =>
|
|
player.box_profile?.description || '';
|
|
|
|
export const formatAddress = (address = ''): string =>
|
|
`${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
|
|
export const formatUsernameIfAddress = (username = ''): string =>
|
|
ethers.utils.isAddress(username) ? formatAddress(username) : username;
|