import { Box, Flex, IconButton } from '@metafam/ds';
import React, { forwardRef, useMemo } from 'react';
import { FaTimes } from 'react-icons/fa';
import { PlayerAchievements } from '#components/Player/Section/PlayerAchievements';
import { PlayerCompletedQuests } from '#components/Player/Section/PlayerCompletedQuests';
import { PlayerGallery } from '#components/Player/Section/PlayerGallery';
import { PlayerHero } from '#components/Player/Section/PlayerHero';
import { PlayerMemberships } from '#components/Player/Section/PlayerLinks/PlayerMemberships';
import { PlayerPersonalityType } from '#components/Player/Section/PlayerPersonalityType';
import { PlayerRoles } from '#components/Player/Section/PlayerRoles';
import { PlayerSkills } from '#components/Player/Section/PlayerSkills';
import { PlayerType } from '#components/Player/Section/PlayerType';
import { CustomTextSection } from '#components/Section/CustomTextSection';
import { EmbeddedUrl } from '#components/Section/EmbeddedUrlSection';
import { Player } from '#graphql/autogen/hasura-sdk';
import { useUser } from '#lib/hooks';
import { BoxMetadata, BoxType, BoxTypes, createBoxKey } from '#utils/boxTypes';
import { PlayerDework } from './Section/PlayerDework';
import { PlayerEAS } from './Section/PlayerEAS';
import { PlayerLinks } from './Section/PlayerLinks';
type Props = {
type: BoxType;
player?: Player;
metadata?: BoxMetadata;
ens?: string;
editing?: boolean;
onRemoveBox?: (boxKey: string) => void;
};
const PlayerSectionInner: React.FC<
Props & {
player: Player;
ens?: string;
isOwnProfile?: boolean;
}
> = ({ metadata, type, player, isOwnProfile, editing, ens }) => {
switch (type) {
case BoxTypes.PLAYER_HERO:
return ;
case BoxTypes.PLAYER_SKILLS:
return ;
case BoxTypes.PLAYER_NFT_GALLERY:
return ;
case BoxTypes.PLAYER_DAO_MEMBERSHIPS:
return ;
case BoxTypes.PLAYER_COLOR_DISPOSITION:
return ;
case BoxTypes.PLAYER_TYPE:
return ;
case BoxTypes.PLAYER_ROLES:
return ;
case BoxTypes.PLAYER_LINKS:
return ;
case BoxTypes.DEWORK:
return ;
case BoxTypes.PLAYER_ACHIEVEMENTS:
return ;
case BoxTypes.PLAYER_COMPLETED_QUESTS:
return ;
case BoxTypes.PLAYER_ATTESTATIONS:
return
case BoxTypes.EMBEDDED_URL: {
const { url } = metadata ?? {};
return url ? : null;
}
case BoxTypes.CUSTOM_TEXT: {
const { title, content } = metadata ?? {};
return title && content ? (
) : null;
}
default:
return null;
}
};
export const PlayerSection = forwardRef(
({ metadata, type, player, editing = false, onRemoveBox, ens }, ref) => {
const key = createBoxKey(type, metadata);
const { user } = useUser();
const isOwnProfile = useMemo(
() => !!user && user.id === player?.id,
[user, player?.id],
);
if (!player) return null;
return (
{editing && (
)}
{editing && type && type !== BoxTypes.PLAYER_HERO && (
}
_hover={{ color: 'white' }}
onClick={() => onRemoveBox?.(key)}
onTouchStart={() => onRemoveBox?.(key)}
_focus={{
boxShadow: 'none',
backgroundColor: 'transparent',
}}
_active={{
transform: 'scale(0.8)',
backgroundColor: 'transparent',
}}
isRound
/>
)}
);
},
);