diff --git a/src/modules/project/funding/state/fundingFormAtom.ts b/src/modules/project/funding/state/fundingFormAtom.ts index b002f51da..719eddcee 100644 --- a/src/modules/project/funding/state/fundingFormAtom.ts +++ b/src/modules/project/funding/state/fundingFormAtom.ts @@ -37,6 +37,7 @@ export type FundFormType = { email: string media: string comment: string + privateComment: string rewardsByIDAndCount?: { [key: string]: number } | undefined rewardCurrency: RewardCurrency needsShipping: boolean @@ -51,6 +52,7 @@ const initialState: FundFormType = { shippingCost: 0, totalAmount: 0, comment: '', + privateComment: '', email: '', media: '', rewardsByIDAndCount: undefined, @@ -254,7 +256,6 @@ export const isFundingInputAmountValidAtom = atom((get) => { } } - console.log('checking totalAmount', totalAmount) if (!isException && walletLimits?.max && totalAmount >= walletLimits.max) { return { title: `Amount above the project wallet limit: ${commaFormatted(walletLimits.max)} sats.`, diff --git a/src/modules/project/pages1/projectFunding/views/fundingDetails/FundingDetails.tsx b/src/modules/project/pages1/projectFunding/views/fundingDetails/FundingDetails.tsx index c11c140b0..e0bac00a9 100644 --- a/src/modules/project/pages1/projectFunding/views/fundingDetails/FundingDetails.tsx +++ b/src/modules/project/pages1/projectFunding/views/fundingDetails/FundingDetails.tsx @@ -5,6 +5,7 @@ import { useFundingFormAtom } from '@/modules/project/funding/hooks/useFundingFo import { getPath } from '@/shared/constants' import { FundingLayout } from '../../layouts/FundingLayout' +import { FundingDetailsPrivateCommentPrompt } from './sections/FundingDetailsPrivateCommentPrompt' import { FundingDetailsBottomContent, FundingDetailsSideContent } from './sections/FundingDetailsSideContent' import { FundingDetailsUserComment } from './sections/FundingDetailsUserComment' import { FundingDetailsUserEmail } from './sections/FundingDetailsUserEmail' @@ -27,6 +28,7 @@ export const FundingDetails = () => { containerProps={{ spacing: 6 }} > + ) diff --git a/src/modules/project/pages1/projectFunding/views/fundingDetails/sections/FundingDetailsPrivateCommentPrompt.tsx b/src/modules/project/pages1/projectFunding/views/fundingDetails/sections/FundingDetailsPrivateCommentPrompt.tsx new file mode 100644 index 000000000..01390cfc9 --- /dev/null +++ b/src/modules/project/pages1/projectFunding/views/fundingDetails/sections/FundingDetailsPrivateCommentPrompt.tsx @@ -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.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 ( + +

+ {t('Private message')} +

+ + {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.', + )} + + {mergedPrivateCommentPrompts.length > 0 && ( + <> + + {t('The creator has requested the following information from you. Make sure you add in the message box:')} + + + + {mergedPrivateCommentPrompts.map((prompt) => ( + {privateCommentPromptMap[prompt]} + ))} + + + )} +