import { AddIcon, Box, Button, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, Text, } from '@metafam/ds'; import React, { useState } from 'react'; import { FaArrowLeft } from 'react-icons/fa'; import { UnverifiedGuildForm } from '#components/Guild/UnverifiedGuildForm'; import { GuildSearchBar } from '#components/GuildSearchBar'; import { Player, useAddUnverifiedGuildMutation } from '#graphql/autogen/hasura-sdk'; import { GuildListingSmall, SmallGuild } from './GuildListing'; export const AddPlayerGuild: React.FC<{ isOpen: boolean; onClose: () => void; player: Player; hydratePlayer: () => void; }> = ({ isOpen, onClose, player, hydratePlayer }) => { const [showGuildForm, setShowGuildForm] = useState(false); const [showSearchForm, setShowSearchForm] = useState(true); const [currentGuilds, setCurrentGuilds] = useState([]); const [, addUnverifiedGuild] = useAddUnverifiedGuildMutation(); return ( {(!showSearchForm || currentGuilds.length > 0) && !showGuildForm && ( )} {!showSearchForm && currentGuilds.length > 0 && !showGuildForm && 'New Guild Added!'} {(showGuildForm || (!currentGuilds.length && !showSearchForm)) && 'Create New Guild'} {(showSearchForm || (!currentGuilds.length && !showGuildForm)) && 'Search for a Guild'} {currentGuilds.length > 0 && !showSearchForm && !showGuildForm && 'Your membership has been added to your guild info.'} {(showSearchForm || showGuildForm) && 'Add Guild Membership'} {!showGuildForm && !showSearchForm && currentGuilds.length > 0 && currentGuilds.map((guild) => ( ))} {showGuildForm && ( { const ret = await addUnverifiedGuild(...args); if (ret.data) { setCurrentGuilds([ ...currentGuilds, { ...ret.operation.variables, id: ret.data.insert_guild?.returning[0].id, }, ]); setShowGuildForm(false); } // if (!ret.error) onClose(); return ret; }} {...{ player, hydratePlayer }} /> )} {showSearchForm && } {!showGuildForm && ( )} {!currentGuilds.length && ( )} ); };