Skip to content

Commit

Permalink
Edit NFTs [1/2]: Redo /settings/nfts to account for all project NFT…
Browse files Browse the repository at this point in the history
… states (#4051)
  • Loading branch information
johnnyd-eth authored Sep 9, 2023
1 parent 1a77385 commit b6c93e7
Show file tree
Hide file tree
Showing 28 changed files with 602 additions and 343 deletions.
Binary file added public/assets/images/settings/no-nfts.webp
Binary file not shown.
4 changes: 2 additions & 2 deletions src/components/Create/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { NetworkName } from 'models/networkName'
import Link from 'next/link'
import { useRouter } from 'next/router'
import {
AddNftCollectionForm,
FundingCyclesPage,
NftRewardsPage,
ProjectDetailsPage,
ProjectTokenPage,
ReconfigurationRulesPage,
Expand Down Expand Up @@ -124,7 +124,7 @@ export function Create() {
<Trans>Reward your supporters with custom NFTs.</Trans>
}
>
<NftRewardsPage />
<AddNftCollectionForm />
</Wizard.Page>
<Wizard.Page
name="reconfigurationRules"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,11 @@ export const AddEditRewardModal = ({
rules={[inputMustExistRule({ label: t`Minimum Contribution` })]}
>
<FormattedNumberInput
className="w-1/2"
accessory={<InputAccessoryButton content="ETH" />}
/>
</Form.Item>
<Form.Item>
<div className="flex flex-col gap-2">
<div className="mt-2 flex flex-col gap-2">
<JuiceSwitch
value={limitedSupply}
onChange={setLimitedSupply}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
import { EyeOutlined, RightOutlined } from '@ant-design/icons'
import { RightOutlined } from '@ant-design/icons'
import { Trans, t } from '@lingui/macro'
import { Form, Radio } from 'antd'
import { useLockPageRulesWrapper } from 'components/Create/hooks/useLockPageRulesWrapper'
import ExternalLink from 'components/ExternalLink'
import { NftPostPayModal } from 'components/NftRewards/NftPostPayModal'
import TooltipLabel from 'components/TooltipLabel'
import { CreateButton } from 'components/buttons/CreateButton'
import { JuiceSwitch } from 'components/inputs/JuiceSwitch'
import { JuiceTextArea } from 'components/inputs/JuiceTextArea'
import { JuiceInput } from 'components/inputs/JuiceTextInput'
import { RadioItem } from 'components/inputs/RadioItem'
import {
PREVENT_OVERSPENDING_EXPLANATION,
USE_DATASOURCE_FOR_REDEEM_EXPLANATION,
} from 'components/strings'
import { CREATE_FLOW } from 'constants/fathomEvents'
import { useModal } from 'hooks/useModal'
import { trackFathomGoal } from 'lib/fathom'
import { JB721GovernanceType } from 'models/nftRewards'
import { useContext } from 'react'
import { useAppSelector } from 'redux/hooks/useAppSelector'
import { useSetCreateFurthestPageReached } from 'redux/hooks/useEditingCreateFurthestPageReached'
import { inputMustExistRule } from 'utils/antdRules'
import { helpPagePath } from 'utils/routes'
Expand All @@ -29,19 +19,20 @@ import { OptionalHeader } from '../../OptionalHeader'
import { RewardsList } from '../../RewardsList'
import { Wizard } from '../../Wizard'
import { PageContext } from '../../Wizard/contexts/PageContext'
import { NftAdvancedFormItems } from './NftAdvancedFormItems'
import { NftPaymentSuccessFormItems } from './NftPaymentSuccessFormItems'
import { useNftRewardsForm } from './hooks'

export const NftRewardsPage = () => {
export const AddNftCollectionForm = ({
okButton,
}: {
okButton?: React.ReactNode
}) => {
useSetCreateFurthestPageReached('nftRewards')
const { form, initialValues } = useNftRewardsForm()
const lockPageRulesWrapper = useLockPageRulesWrapper()
const { goToNextPage } = useContext(PageContext)

const postPayModal = useModal()
const postPayModalData = useAppSelector(
state => state.editingV2Project.nftRewards.postPayModal,
)

const hasNfts = !!Form.useWatch('rewards', form)?.length

return (
Expand Down Expand Up @@ -166,99 +157,21 @@ export const NftRewardsPage = () => {
header={<OptionalHeader header={t`Payment Success Pop-up`} />}
hideDivider
>
<div className="flex flex-col gap-4 pt-3 pb-2">
<p>
<Trans>
Show your supporters a pop-up with a message and a link
after they receive an NFT. You can use this to direct
supporters to your project's website, a Discord server,
or somewhere else.
</Trans>
</p>
<Form.Item
name="postPayMessage"
label={
<TooltipLabel
label={t`Message`}
tip={
<Trans>
The message that will be shown to supporters after
they receive an NFT.
</Trans>
}
/>
}
>
<JuiceTextArea autoSize={{ minRows: 4, maxRows: 6 }} />
</Form.Item>
<Form.Item
name="postPayButtonText"
label={
<TooltipLabel
label={t`Button label`}
tip={
<Trans>
The text on the button at the bottom of the
pop-up. You can preview this below.
</Trans>
}
/>
}
>
<JuiceInput />
</Form.Item>
<Form.Item
name="postPayButtonLink"
label={
<TooltipLabel
label={t`Button link`}
tip={
<Trans>
Supporters will be sent to this page if they click
the button on your pop-up. You can preview this
below.
</Trans>
}
/>
}
extra={t`If you leave this blank, the button will close the pop-up.`}
>
<JuiceInput prefix={'https://'} />
</Form.Item>
<CreateButton
className="max-w-fit border"
disabled={!postPayModalData}
icon={<EyeOutlined />}
onClick={postPayModal.open}
>
Preview
</CreateButton>
</div>
<NftPaymentSuccessFormItems />
</CreateCollapse.Panel>

<CreateCollapse.Panel
key={3}
header={<OptionalHeader header={t`Advanced options`} />}
hideDivider
>
<Form.Item
name="useDataSourceForRedeem"
extra={USE_DATASOURCE_FOR_REDEEM_EXPLANATION}
>
<JuiceSwitch label={t`Use NFTs for redemptions`} />
</Form.Item>
<Form.Item
name="preventOverspending"
extra={PREVENT_OVERSPENDING_EXPLANATION}
>
<JuiceSwitch label={t`Prevent NFT overspending`} />
</Form.Item>
<NftAdvancedFormItems />
</CreateCollapse.Panel>
</CreateCollapse>
</div>
)}
</div>
<Wizard.Page.ButtonControl />
{okButton ?? <Wizard.Page.ButtonControl />}
</Form>

<div className="mt-8 text-center">
Expand All @@ -273,14 +186,6 @@ export const NftRewardsPage = () => {
</ExternalLink>
</div>
</div>

{postPayModalData && (
<NftPostPayModal
open={postPayModal.visible}
config={postPayModalData}
onClose={postPayModal.close}
/>
)}
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { t } from '@lingui/macro'
import { Form } from 'antd'
import { JuiceSwitch } from 'components/inputs/JuiceSwitch'
import {
PREVENT_OVERSPENDING_EXPLANATION,
USE_DATASOURCE_FOR_REDEEM_EXPLANATION,
} from 'components/strings'

export function NftAdvancedFormItems() {
return (
<>
<Form.Item
name="useDataSourceForRedeem"
extra={USE_DATASOURCE_FOR_REDEEM_EXPLANATION}
>
<JuiceSwitch label={t`Use NFTs for redemptions`} />
</Form.Item>
<Form.Item
name="preventOverspending"
extra={PREVENT_OVERSPENDING_EXPLANATION}
>
<JuiceSwitch label={t`Prevent NFT overspending`} />
</Form.Item>
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { EyeOutlined } from '@ant-design/icons'
import { Trans, t } from '@lingui/macro'
import { Form } from 'antd'
import { NftPostPayModal } from 'components/NftRewards/NftPostPayModal'
import TooltipLabel from 'components/TooltipLabel'
import { CreateButton } from 'components/buttons/CreateButton'
import { JuiceTextArea } from 'components/inputs/JuiceTextArea'
import { JuiceInput } from 'components/inputs/JuiceTextInput'
import { useModal } from 'hooks/useModal'
import { useAppSelector } from 'redux/hooks/useAppSelector'

export function NftPaymentSuccessFormItems({
hidePreview,
}: {
hidePreview?: boolean
}) {
const postPayModal = useModal()
const postPayModalData = useAppSelector(
state => state.editingV2Project.nftRewards.postPayModal,
)
return (
<>
<div className="flex flex-col gap-4 pt-3 pb-2">
<p>
<Trans>
Show your supporters a pop-up with a message and a link after they
receive an NFT. You can use this to direct supporters to your
project's website, a Discord server, or somewhere else.
</Trans>
</p>
<Form.Item
name="postPayMessage"
label={
<TooltipLabel
label={t`Message`}
tip={
<Trans>
The message that will be shown to supporters after they
receive an NFT.
</Trans>
}
/>
}
>
<JuiceTextArea autoSize={{ minRows: 4, maxRows: 6 }} />
</Form.Item>
<Form.Item
name="postPayButtonText"
label={
<TooltipLabel
label={t`Button label`}
tip={
<Trans>
The text on the button at the bottom of the pop-up. You can
preview this below.
</Trans>
}
/>
}
>
<JuiceInput />
</Form.Item>
<Form.Item
name="postPayButtonLink"
label={
<TooltipLabel
label={t`Button link`}
tip={
<Trans>
Supporters will be sent to this page if they click the button
on your pop-up. You can preview this below.
</Trans>
}
/>
}
extra={t`If you leave this blank, the button will close the pop-up.`}
>
<JuiceInput prefix={'https://'} />
</Form.Item>
{hidePreview ? null : (
<CreateButton
className="max-w-fit border"
disabled={!postPayModalData}
icon={<EyeOutlined />}
onClick={postPayModal.open}
>
Preview
</CreateButton>
)}
</div>
{postPayModalData && (
<NftPostPayModal
open={postPayModal.visible}
config={postPayModalData}
onClose={postPayModal.close}
/>
)}
</>
)
}
2 changes: 1 addition & 1 deletion src/components/Create/components/pages/NftRewards/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './NftRewardsPage'
export * from './AddNftCollectionForm'
Loading

1 comment on commit b6c93e7

@vercel
Copy link

@vercel vercel bot commented on b6c93e7 Sep 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.