diff --git a/src/.graphclient/index.ts b/src/.graphclient/index.ts index 53b5ceb..510863f 100644 --- a/src/.graphclient/index.ts +++ b/src/.graphclient/index.ts @@ -10310,6 +10310,7 @@ export type getShipFundsAvailableQuery = { GrantShip: Array; @@ -10956,8 +10957,8 @@ export const getShipFundsAvailableDocument = gql` } ` as unknown as DocumentNode; export const getShipIdByHatIdDocument = gql` - query getShipIdByHatId($hatId: String!) { - GrantShip(where: {hatId: {_eq: $hatId}}) { + query getShipIdByHatId($hatId: String!, $gameId: String!) { + GrantShip(where: {hatId: {_eq: $hatId}, gameManager_id: {_eq: $gameId}}) { id } } diff --git a/src/components/grant/GrantCard.tsx b/src/components/grant/GrantCard.tsx index 30a37be..9ea69d0 100644 --- a/src/components/grant/GrantCard.tsx +++ b/src/components/grant/GrantCard.tsx @@ -1,5 +1,6 @@ import { Avatar, + Box, Group, Paper, Text, @@ -7,8 +8,21 @@ import { useMantineTheme, } from '@mantine/core'; import { GrantStatus } from '../../types/common'; -import { IconCheck } from '@tabler/icons-react'; +import { + IconCheck, + IconChecks, + IconFileCheck, + IconFileDescription, + IconFilePlus, + IconFileX, + IconPennant, + IconPennantOff, + IconRoute, + IconRouteX, + IconShieldX, +} from '@tabler/icons-react'; import { Link } from 'react-router-dom'; +import { ReactNode } from 'react'; export const GrantCard = ({ avatarUrls, @@ -16,12 +30,18 @@ export const GrantCard = ({ isActive, linkUrl, status, + hasPending, + hasRejected, + allCompleted, }: { linkUrl: string; isActive: boolean; avatarUrls: string[]; label: string; status: GrantStatus; + hasPending: boolean; + hasRejected: boolean; + allCompleted: boolean; }) => { const theme = useMantineTheme(); @@ -33,22 +53,159 @@ export const GrantCard = ({ component={Link} to={linkUrl} > - - - {avatarUrls.map((url) => ( - - ))} - - - {label} - - - - + + + + {avatarUrls.map((url) => ( + + ))} + + + {label} + + + + + + ); }; + +const GrantStatusIndicator = ({ + status, + hasPending, + hasRejected, + allCompleted, +}: { + status: GrantStatus; + hasPending: boolean; + hasRejected: boolean; + allCompleted: boolean; +}) => { + const theme = useMantineTheme(); + + if (status === GrantStatus.ProjectInitiated) + return ( + } /> + ); + if (status === GrantStatus.ShipInitiated) { + return ( + } /> + ); + } + if (status === GrantStatus.ApplicationSubmitted) { + return ( + } + /> + ); + } + if (status === GrantStatus.ApplicationRejected) { + return ( + } + /> + ); + } + if (status === GrantStatus.ApplicationApproved) { + return ( + } + /> + ); + } + if (status === GrantStatus.MilestonesSubmitted) { + return ( + } + /> + ); + } + if (status === GrantStatus.MilestonesRejected) { + return ( + } + /> + ); + } + + if (status === GrantStatus.MilestonesApproved) { + return ( + } + /> + ); + } + if (status === GrantStatus.FacilitatorRejected) { + return ( + } + /> + ); + } + + if (status === GrantStatus.Allocated) { + if (hasPending) { + return ( + } + /> + ); + } + if (hasRejected) { + return ( + } + /> + ); + } + + // state to tell project that the milestone has been approved + return ( + } /> + ); + } + + if (status === GrantStatus.AllMilestonesComplete) { + return ( + } + /> + ); + } + + if (status === GrantStatus.Completed) { + return ( + } /> + ); + } +}; + +const StatusIndicator = ({ text, icon }: { text: string; icon: ReactNode }) => { + return ( + + {text} + {icon} + + ); +}; diff --git a/src/components/grant/MilestonesDrawer.tsx b/src/components/grant/MilestonesDrawer.tsx index 010ad29..b5afc51 100644 --- a/src/components/grant/MilestonesDrawer.tsx +++ b/src/components/grant/MilestonesDrawer.tsx @@ -7,7 +7,6 @@ import { NumberInput, Stack, Text, - TextInput, Textarea, useMantineTheme, } from '@mantine/core'; diff --git a/src/graphql/newQueries/getShipByHatId.graphql b/src/graphql/newQueries/getShipByHatId.graphql index ec9399a..65b4e15 100644 --- a/src/graphql/newQueries/getShipByHatId.graphql +++ b/src/graphql/newQueries/getShipByHatId.graphql @@ -1,5 +1,7 @@ -query getShipIdByHatId($hatId: String!) { - GrantShip(where: { hatId: { _eq: $hatId } }) { +query getShipIdByHatId($hatId: String!, $gameId: String!) { + GrantShip( + where: { hatId: { _eq: $hatId }, gameManager_id: { _eq: $gameId } } + ) { id } } diff --git a/src/pages/Grant.tsx b/src/pages/Grant.tsx index 65b4085..ab671b1 100644 --- a/src/pages/Grant.tsx +++ b/src/pages/Grant.tsx @@ -1,13 +1,5 @@ import { MainSection, PageTitle } from '../layout/Sections'; -import { - Button, - Center, - Flex, - SegmentedControl, - Stack, - Text, - useMantineTheme, -} from '@mantine/core'; +import { Center, Flex, SegmentedControl, useMantineTheme } from '@mantine/core'; import { useBreakpoints } from '../hooks/useBreakpoint'; import { Route, @@ -19,26 +11,13 @@ import { import { IconFileDescription, IconGitCommit, - IconPencil, IconPennant, - IconPlus, - IconRoute, } from '@tabler/icons-react'; -import { Player } from '../types/ui'; import { TopSection } from '../components/grant/TopSection'; import { GrantContextProvider } from '../contexts/GrantContext'; import { useGrant } from '../hooks/useGrant'; import { GrantTimeline } from '../components/grant/GrantTimeline'; -import { PostGrantDrawer } from '../components/grant/PostGrantDrawer'; -import { useDisclosure } from '@mantine/hooks'; -import { ApplicationDrawer } from '../components/grant/ApplicationDrawer'; -import { GameStatus, GrantStatus } from '../types/common'; -import { MilestonesDrawer } from '../components/grant/MilestonesDrawer'; import { useUserData } from '../hooks/useUserState'; -import { FacilitatorApprovalDrawer } from '../components/grant/FacilitatorApprovalDrawer'; -import { PageDrawer } from '../components/PageDrawer'; -import { SubmitMilestoneDrawer } from '../components/grant/SubmitMilestoneDrawer'; -import { formatEther, parseEther, weiUnits } from 'viem'; import { ProjectActions } from '../components/grant/ProjectActions'; import { FacilitatorActions } from '../components/grant/FacilitatorActions'; import { ShipActions } from '../components/grant/ShipActions'; diff --git a/src/pages/Project.tsx b/src/pages/Project.tsx index e72fca1..7e85274 100644 --- a/src/pages/Project.tsx +++ b/src/pages/Project.tsx @@ -381,6 +381,9 @@ export const Project = () => { label={`Grant with ${grant.ship.name}`} isActive={grant.status >= GrantStatus.Allocated} status={grant.status} + hasPending={grant.hasPendingMilestones} + hasRejected={grant.hasRejectedMilestones} + allCompleted={grant.allMilestonesApproved} /> ))} diff --git a/src/pages/Ship.tsx b/src/pages/Ship.tsx index 8c0f9e9..3ac1ab6 100644 --- a/src/pages/Ship.tsx +++ b/src/pages/Ship.tsx @@ -293,6 +293,9 @@ export const Ship = () => { {grants?.map((grant) => ( { const { getShipIdByHatId } = getBuiltGraphSDK({}); const result = await getShipIdByHatId({ hatId: isOperator.hatId.toString(), + gameId: GAME_MANAGER.ADDRESS, }); const shipAddress = result?.GrantShip?.[0]?.id;