Skip to content

Commit

Permalink
Edit button visible only to Quest owner
Browse files Browse the repository at this point in the history
Was visible to all during design feedback phase
  • Loading branch information
HHH-GH authored and alalonde committed Jun 28, 2023
1 parent 4245d5c commit 71c3fa3
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions packages/web/components/Quest/QuestDetailsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@metafam/ds';
import { MetaLink } from 'components/Link';
import { PlayerAvatar } from 'components/Player/PlayerAvatar';
import { Quest, QuestFragment } from 'graphql/autogen/types';
import { Quest, QuestFragment, QuestStatus_Enum } from 'graphql/autogen/types';
import { useUser } from 'lib/hooks';
import { usePlayerName } from 'lib/hooks/player/usePlayerName';
import { usePlayerURL } from 'lib/hooks/player/usePlayerURL';
Expand Down Expand Up @@ -86,25 +86,25 @@ export const QuestDetailsHeader: React.FC<Props> = ({ quest }) => {
</Flex>
</Box>

{/* isMyQuest conditional here to show edit/delete {isMyQuest && ...} */}
<Box w="full" maxW={{ base: '100%', md: '12rem' }}>
{/* Stacked vertically after md breakpoint */}
<Stack spacing={5} direction={{ base: 'row', md: 'column' }}>
<Button
variant="outline"
borderWidth={2}
size="lg"
fontSize="md"
w="full"
>
Edit quest
</Button>

<Button variant="warning" size="lg" fontSize="md" w="full">
Delete quest
</Button>
</Stack>
</Box>
{/* Edit button is displayed to the Quest Owner */}
{isMyQuest && status === QuestStatus_Enum.Open && (
<Box w="full" maxW={{ base: '100%', md: '12rem' }}>
{/* Stacked vertically after md breakpoint */}
<Stack spacing={5} direction={{ base: 'row', md: 'column' }}>
<Button
as="a" // so it can be used as a link
href={`/quest/${quest.id}/edit`}
variant="outline"
borderWidth={2}
size="lg"
fontSize="md"
w="full"
>
Edit quest
</Button>
</Stack>
</Box>
)}
</Flex>
);
};

0 comments on commit 71c3fa3

Please sign in to comment.