Skip to content

Commit

Permalink
Claim button jump to Discord for complex bounties
Browse files Browse the repository at this point in the history
  • Loading branch information
tescher committed Oct 25, 2022
1 parent bbc14d9 commit a762164
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions packages/react-app/src/components/pages/Bounties/Bounty/claim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ const BountyClaim = ({ bounty }: { bounty: BountyCollection }): JSX.Element => {
<>
{
// TODO This is obsolete...
bounty.discordMessageId ? (
bounty.evergreen || bounty.requireApplication ? (
// If we have discord message info for the bounty, the user is taken into discord to claim
<ClaimDiscord discordMessageId={bounty.discordMessageId} />
<ClaimDiscord canonicalCard={bounty.canonicalCard} />
) : (
// else, they must use the web form variant
<ClaimWeb user={user} bounty={bounty} onOpen={onOpen} />
Expand Down Expand Up @@ -153,26 +153,29 @@ const BountyClaim = ({ bounty }: { bounty: BountyCollection }): JSX.Element => {
};

export const ClaimDiscord = ({
discordMessageId,
canonicalCard,
}: {
discordMessageId: string;
canonicalCard: { messageId: string | undefined, channelId: string | undefined };
}): JSX.Element => {
const {
customer: { customerId, bountyChannel },
customer: { customerId },
} = useContext(CustomerContext);
const url = `${baseUrl}/${customerId}/${bountyChannel}/${discordMessageId}`;
const url = `${baseUrl}/${customerId}/${canonicalCard.channelId}/${canonicalCard.messageId}`;
const { colorMode } = useColorMode();
return (
<AccessibleLink href={url} isExternal={true}>
<Button
boxShadow={'md'}
transition="background 100ms linear"
bg={colorMode === 'light' ? 'primary.300' : 'primary.700'}
size='md'
width='200px'
>
Claim It
</Button>
<Box p={2}>
<Button
boxShadow={'md'}
transition="background 100ms linear"
bg={colorMode === 'light' ? 'primary.300' : 'primary.700'}
size='md'
width='200px'
disabled={!canonicalCard || !canonicalCard.channelId || !canonicalCard.messageId}
>
Claim It
</Button>
</Box>
</AccessibleLink>
);
};
Expand Down

0 comments on commit a762164

Please sign in to comment.