-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: prompting private message on checkout
- Loading branch information
1 parent
0cadb01
commit 5510407
Showing
4 changed files
with
74 additions
and
10 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
69 changes: 69 additions & 0 deletions
69
...ages1/projectFunding/views/fundingDetails/sections/FundingDetailsPrivateCommentPrompt.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,69 @@ | ||
import { ListItem, UnorderedList } from '@chakra-ui/react' | ||
import { t } from 'i18next' | ||
|
||
import { TextArea } from '@/components/ui' | ||
import { useFundingFormAtom } from '@/modules/project/funding/hooks/useFundingFormAtom' | ||
import { useRewardsAtom } from '@/modules/project/hooks/useProjectAtom' | ||
import { CardLayout } from '@/shared/components/layouts' | ||
import { Body, H1 } from '@/shared/components/typography' | ||
import { PrivateCommentPrompt } from '@/types' | ||
|
||
const privateCommentPromptMap: Record<PrivateCommentPrompt, string> = { | ||
[PrivateCommentPrompt.NostrNpub]: t('Provide your Nostr public address (npub)'), | ||
[PrivateCommentPrompt.ProjectRewardSpecs]: t( | ||
'Specify your desired options for each reward, as mentioned on the rewards page.', | ||
), | ||
} | ||
|
||
export const FundingDetailsPrivateCommentPrompt = () => { | ||
const { rewards } = useRewardsAtom() | ||
|
||
const { | ||
formState: { privateComment, rewardsByIDAndCount }, | ||
setTarget, | ||
} = useFundingFormAtom() | ||
|
||
const selectedRewards = rewards.filter((reward) => rewardsByIDAndCount && rewardsByIDAndCount[reward.id]) | ||
|
||
const mergedPrivateCommentPrompts = Array.from( | ||
new Set(selectedRewards.flatMap((reward) => reward.privateCommentPrompts || [])), | ||
) | ||
|
||
return ( | ||
<CardLayout width="100%" mobileDense> | ||
<H1 size="2xl" bold> | ||
{t('Private message')} | ||
</H1> | ||
<Body size="md" light> | ||
{t( | ||
'Send a private message to the creator with a thank you note, feedback, or special requests. Sometimes, if you don’t provide these creator won’t be able to send you your reward.', | ||
)} | ||
</Body> | ||
{mergedPrivateCommentPrompts.length > 0 && ( | ||
<> | ||
<Body size="md"> | ||
{t('The creator has requested the following information from you. Make sure you add in the message box:')} | ||
</Body> | ||
|
||
<UnorderedList> | ||
{mergedPrivateCommentPrompts.map((prompt) => ( | ||
<ListItem key={prompt}>{privateCommentPromptMap[prompt]}</ListItem> | ||
))} | ||
</UnorderedList> | ||
</> | ||
)} | ||
<TextArea | ||
data-testid="funding-private-comment-input" | ||
placeholder={t('Enter your message here...')} | ||
fontSize="14px" | ||
resize="none" | ||
value={privateComment} | ||
maxLength={280} | ||
minHeight="128px" | ||
name="privateComment" | ||
backgroundColor={'utils.pbg'} | ||
onChange={setTarget} | ||
/> | ||
</CardLayout> | ||
) | ||
} |
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