Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: shipping information * feat: rewards shipping
- Loading branch information
Showing
20 changed files
with
732 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ export const FRAGMENT_PROJECT_REWARD_FOR_CREATE_UPDATE = gql` | |
deleted | ||
stock | ||
sold | ||
hasShipping | ||
} | ||
` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
src/pages/projectView/projectActivityPanel/components/ContributionShippingBox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Text, VStack } from '@chakra-ui/react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { useProjectContext } from '../../../../context' | ||
import { CreatorEmailButton } from './CreatorEmailButton' | ||
import { CreatorEmailContentButton } from './CreatorEmailContentButton' | ||
|
||
export const ContributionShippingBox = () => { | ||
const { t } = useTranslation() | ||
const { project } = useProjectContext() | ||
const ownerEmail = project?.owners[0]?.user.email || '' | ||
return ( | ||
<VStack | ||
padding={2} | ||
width={'full'} | ||
borderRadius="8px" | ||
backgroundColor="primary.100" | ||
spacing={2} | ||
justify="flex-start" | ||
alignItems="flex-start" | ||
> | ||
<Text variant="body1">{t('Shipping')}</Text> | ||
<Text> | ||
{t( | ||
"To receive the selected items, you need to send your shipping details to the creator's email.", | ||
)} | ||
</Text> | ||
|
||
<CreatorEmailButton email={ownerEmail} /> | ||
<CreatorEmailContentButton /> | ||
</VStack> | ||
) | ||
} |
37 changes: 37 additions & 0 deletions
37
src/pages/projectView/projectActivityPanel/components/CreatorEmailButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { CopyIcon } from '@chakra-ui/icons' | ||
import { Box, Button, ButtonProps } from '@chakra-ui/react' | ||
import { useState } from 'react' | ||
|
||
import { copyTextToClipboard } from '../../../../utils' | ||
|
||
export const CreatorEmailButton = ({ | ||
email, | ||
...props | ||
}: { email: string } & ButtonProps) => { | ||
const [isEmailCopied, setEmailCopied] = useState(false) | ||
|
||
const handleCopyEmail = () => { | ||
copyTextToClipboard(email) | ||
|
||
setEmailCopied(true) | ||
setTimeout(() => { | ||
setEmailCopied(false) | ||
}, 1000) | ||
} | ||
|
||
return ( | ||
<Button | ||
w="100%" | ||
justifyContent="start" | ||
isActive={isEmailCopied} | ||
onClick={handleCopyEmail} | ||
variant="secondary" | ||
rightIcon={<CopyIcon />} | ||
{...props} | ||
> | ||
<Box as="span" flexGrow={1} textAlign="left"> | ||
{email} | ||
</Box> | ||
</Button> | ||
) | ||
} |
101 changes: 101 additions & 0 deletions
101
src/pages/projectView/projectActivityPanel/components/CreatorEmailContentButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { CopyIcon } from '@chakra-ui/icons' | ||
import { HStack, StackProps, Text, VStack } from '@chakra-ui/react' | ||
import { useRef, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { useProjectContext } from '../../../../context' | ||
import { copyTextToClipboard } from '../../../../utils' | ||
|
||
export const CreatorEmailContentButton = ({ ...props }: StackProps) => { | ||
const { t } = useTranslation() | ||
const [isCopied, setCopied] = useState(false) | ||
|
||
const ref = useRef<HTMLDivElement>(null) | ||
|
||
const { | ||
project, | ||
fundingFlow: { fundingTx }, | ||
fundForm: { state }, | ||
} = useProjectContext() | ||
|
||
const handleCopyContent = () => { | ||
const content = ref.current?.innerText || '' | ||
copyTextToClipboard(content) | ||
|
||
if (content) { | ||
setCopied(true) | ||
setTimeout(() => { | ||
setCopied(false) | ||
}, 1000) | ||
} | ||
} | ||
|
||
const rewards = project ? project.rewards : [] | ||
|
||
const rewardEntries = state.rewardsByIDAndCount | ||
? Object.entries(state.rewardsByIDAndCount) | ||
: [] | ||
|
||
if (!fundingTx) { | ||
return null | ||
} | ||
|
||
return ( | ||
<HStack | ||
w="100%" | ||
ref={ref} | ||
px={2} | ||
py={4} | ||
justifyContent="start" | ||
alignItems="center" | ||
maxHeight="auto" | ||
height="auto" | ||
cursor="pointer" | ||
border="2px solid" | ||
borderRadius="8px" | ||
_hover={{ borderColor: 'primary.400' }} | ||
bg={isCopied ? 'primary.100' : 'neutral.0'} | ||
borderColor={isCopied ? 'primary.400' : 'neutral.200'} | ||
onClick={handleCopyContent} | ||
{...props} | ||
> | ||
<VStack flexGrow={1} textAlign="left" alignItems="start"> | ||
<Text display="block" variant="caption"> | ||
{t('Hi,\nI just purchased the following items on Geyser:')}{' '} | ||
<b> | ||
{rewardEntries.map(([key, value], index) => { | ||
const reward = rewards.find(({ id }) => id === key) | ||
if (reward) { | ||
return ( | ||
<span key={key}> | ||
{reward.name} x{value} | ||
{index < rewardEntries.length - 1 ? ', ' : ''} | ||
</span> | ||
) | ||
} | ||
})} | ||
</b> | ||
</Text> | ||
<Text display="block" variant="caption"> | ||
{t('This is my reference code:')} | ||
</Text> | ||
<Text display="block" variant="caption" fontWeight="bold"> | ||
{fundingTx.uuid} | ||
</Text> | ||
<Text display="block" variant="caption"> | ||
{t('I’d like it to be shipped to the following address:')} | ||
</Text> | ||
<Text display="block" variant="caption" fontWeight="bold"> | ||
{'<'} | ||
{t('ADD RECEIVING POSTAL ADDRESS')} | ||
{'>'} | ||
</Text> | ||
|
||
<Text display="block" variant="caption"> | ||
{t('Cheers,')} | ||
</Text> | ||
</VStack> | ||
<CopyIcon /> | ||
</HStack> | ||
) | ||
} |
67 changes: 67 additions & 0 deletions
67
src/pages/projectView/projectActivityPanel/components/FundingFormUserInfoSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { ArrowBackIcon } from '@chakra-ui/icons' | ||
import { Button, HStack, Input, VStack } from '@chakra-ui/react' | ||
import { MouseEventHandler } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { SectionTitle } from '../../../../components/ui' | ||
import { useProjectContext } from '../../../../context' | ||
import { FieldContainer } from '../../../../forms/components/FieldContainer' | ||
import { ProjectFundingFormCommentField } from '../../projectMainBody/components' | ||
|
||
type Props = { | ||
onBackClick: MouseEventHandler<HTMLButtonElement> | ||
} | ||
|
||
export const FundingFormUserInfoSection = ({ onBackClick }: Props) => { | ||
const { t } = useTranslation() | ||
const { | ||
fundForm: { | ||
setState, | ||
setTarget, | ||
needsShipping, | ||
state: { comment, email }, | ||
}, | ||
} = useProjectContext() | ||
return ( | ||
<VStack alignItems="start" width="100%" spacing={5}> | ||
<HStack> | ||
<Button onClick={onBackClick} variant="transparent"> | ||
<ArrowBackIcon /> | ||
</Button> | ||
<SectionTitle>{t('Final details')}</SectionTitle> | ||
</HStack> | ||
|
||
<FieldContainer title={t('Public comment')}> | ||
<ProjectFundingFormCommentField | ||
comment={comment} | ||
setTarget={setTarget} | ||
setFormState={setState} | ||
width="full" | ||
/> | ||
</FieldContainer> | ||
|
||
{needsShipping ? ( | ||
<> | ||
<FieldContainer | ||
title="Your email" | ||
subtitle="The seller may want to reach out." | ||
> | ||
<Input | ||
type="email" | ||
name="email" | ||
placeholder="funderemail@gmail.com" | ||
value={email} | ||
onChange={setTarget} | ||
/> | ||
</FieldContainer> | ||
<FieldContainer | ||
title={t('Shipping')} | ||
subtitle={t( | ||
"To receive the selected items, you will need to send your shipping details to the creator's email. Which will be revealed in the success screen.", | ||
)} | ||
/> | ||
</> | ||
) : null} | ||
</VStack> | ||
) | ||
} |
Oops, something went wrong.