From d52dd4661cc89a7a4a61260793bff1747666820e Mon Sep 17 00:00:00 2001 From: jordan Date: Thu, 22 Aug 2024 00:17:28 -0700 Subject: [PATCH 01/32] badge manager form --- src/components/grant/FacilitatorActions.tsx | 1 + src/layout/MobileNav/MobileNav.tsx | 6 +- src/pages/BadgeManager.tsx | 170 ++++++++++++++++++++ src/pages/FacilitatorDashboard.tsx | 18 ++- src/routes.tsx | 2 + 5 files changed, 188 insertions(+), 9 deletions(-) create mode 100644 src/pages/BadgeManager.tsx diff --git a/src/components/grant/FacilitatorActions.tsx b/src/components/grant/FacilitatorActions.tsx index 340f8a2..cfae7e0 100644 --- a/src/components/grant/FacilitatorActions.tsx +++ b/src/components/grant/FacilitatorActions.tsx @@ -17,6 +17,7 @@ export const FacilitatorActions = () => { const { grant, project, ship, refetchGrant } = useGrant(); const isReadyToApprove = grant?.status === GrantStatus.MilestonesApproved; + return ( <> diff --git a/src/layout/MobileNav/MobileNav.tsx b/src/layout/MobileNav/MobileNav.tsx index 2c4c4c9..3a80cb6 100644 --- a/src/layout/MobileNav/MobileNav.tsx +++ b/src/layout/MobileNav/MobileNav.tsx @@ -49,11 +49,7 @@ export const MobileNav = () => { const [menuOpen, setMenuOpen] = useState(false); - const { - data: grants, - isLoading, - error, - } = useQuery({ + const { data: grants } = useQuery({ queryKey: ['user-project-grants', address, GAME_MANAGER.ADDRESS], queryFn: () => getAllUserGrants(address as Address, GAME_MANAGER.ADDRESS), enabled: !!address, diff --git a/src/pages/BadgeManager.tsx b/src/pages/BadgeManager.tsx new file mode 100644 index 0000000..0074d5d --- /dev/null +++ b/src/pages/BadgeManager.tsx @@ -0,0 +1,170 @@ +import { useState } from 'react'; +import { MainSection, PageTitle } from '../layout/Sections'; +import { + ActionIcon, + Avatar, + Box, + FileButton, + InputLabel, + NumberInput, + Radio, + Stack, + Tabs, + Text, + Textarea, + TextInput, + useMantineTheme, +} from '@mantine/core'; +import { IconCameraPlus } from '@tabler/icons-react'; +import { getGatewayUrl } from '../utils/ipfs/get'; +import { pinFileToIPFS } from '../utils/ipfs/pin'; + +export const BadgeManager = () => { + return ( + + + + + + Manager + Minter + Create + + + + + + + + + + + + + ); +}; + +const Create = () => { + const [isLoading, setLoading] = useState(false); + const [ipfsHash, setIpfsHash] = useState(''); + const theme = useMantineTheme(); + + const handleUpload = async (e: File | null) => { + if (!e) { + return; + } + setLoading(true); + try { + const res = await pinFileToIPFS(e); + if (typeof res.IpfsHash !== 'string') return; + setIpfsHash(res.IpfsHash); + setLoading(false); + } catch (error: any) { + setLoading(false); + } + }; + + const avatarPreview = ipfsHash ? getGatewayUrl(ipfsHash) : null; + const canPreview = avatarPreview && !isLoading; + return ( + + + Create a Badge + + + + + + + {(props) => ( + + + + )} + + + + +