import { Box, Button, Flex, FlexProps, Link, MetaTheme, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, Select, Text, useDisclosure, VStack, } from '@metafam/ds'; import { Maybe } from '@metafam/utils'; import React, { ChangeEvent, useCallback, useEffect, useState } from 'react'; import { SetupPlayerLinks } from '#components/Setup/SetupPlayerLinks'; import { GuildFragment, Player } from '#graphql/autogen/hasura-sdk'; import { BoxMetadata, BoxType, BoxTypes } from '#utils/boxTypes'; import { CustomTextSectionMetadata } from './CustomTextSection'; import { EmbeddedUrlMetadata } from './EmbeddedUrlSection'; type Props = FlexProps & { player?: Player; guild?: GuildFragment; boxes: Array; onAddBox: (arg0: BoxType, arg1: BoxMetadata) => void; previewComponent: (props: { metadata: BoxMetadata; type: BoxType; player?: Player; guild?: GuildFragment; }) => JSX.Element | null; }; export const AddBoxSection = React.forwardRef( ( { player, guild, boxes = [], onAddBox, previewComponent: Preview, ...props }, ref, ) => { const { isOpen, onOpen, onClose } = useDisclosure(); const [type, setType] = useState>(null); const [metadata, setMetadata] = useState({}); const selectBoxType = useCallback( ({ target: { value: boxId } }: ChangeEvent) => setType(boxId as BoxType), [], ); const addSection = useCallback(() => { if (!type) return; onAddBox(type, metadata); onClose(); }, [type, metadata, onAddBox, onClose]); useEffect(() => { setMetadata({}); setType(null); }, [isOpen]); return ( Add New Block {type && ( )} {type && ( )} Not seeing what you need? Consider Building a new block! ); }, ); export const EditMetadata: React.FC<{ type: BoxType; player?: Player; metadata: BoxMetadata; setMetadata: React.Dispatch>; }> = ({ type, player, ...props }) => { switch (type) { case BoxTypes.EMBEDDED_URL: { return ; } case BoxTypes.PLAYER_LINKS: { if (player) { return ; } throw new Error('`player` not set for Player Links.'); } case BoxTypes.CUSTOM_TEXT: { return ; } default: { return null; } } };