-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PREVIEW] Better organise settings and create flow instances of the N…
…FT form and related components
- Loading branch information
1 parent
3621734
commit 2b5e79d
Showing
27 changed files
with
242 additions
and
162 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
27 changes: 27 additions & 0 deletions
27
src/components/Create/components/pages/NftRewards/NftRewardsPage.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,27 @@ | ||
import { AddNftCollectionForm } from 'components/NftRewards/AddNftCollectionForm' | ||
import { CREATE_FLOW } from 'constants/fathomEvents' | ||
import { trackFathomGoal } from 'lib/fathom' | ||
import { useContext } from 'react' | ||
import { useSetCreateFurthestPageReached } from 'redux/hooks/useEditingCreateFurthestPageReached' | ||
import { Wizard } from '../../Wizard' | ||
import { PageContext } from '../../Wizard/contexts/PageContext' | ||
import { useCreateFlowNftRewardsForm } from './hooks' | ||
|
||
export function NftRewardsPage() { | ||
const { goToNextPage } = useContext(PageContext) | ||
|
||
const { form, initialValues } = useCreateFlowNftRewardsForm() | ||
useSetCreateFurthestPageReached('nftRewards') | ||
|
||
return ( | ||
<AddNftCollectionForm | ||
form={form} | ||
initialValues={initialValues} | ||
okButton={<Wizard.Page.ButtonControl />} | ||
onFinish={() => { | ||
goToNextPage?.() | ||
trackFathomGoal(CREATE_FLOW.NFT_NEXT_CTA) | ||
}} | ||
/> | ||
) | ||
} |
2 changes: 1 addition & 1 deletion
2
src/components/Create/components/pages/NftRewards/hooks/index.ts
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 |
---|---|---|
@@ -1 +1 @@ | ||
export * from './useNftRewardsForm' | ||
export * from './useCreateFlowNftRewardsForm' |
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 |
---|---|---|
@@ -1 +1 @@ | ||
export * from './AddNftCollectionForm' | ||
export * from './NftRewardsPage' |
2 changes: 1 addition & 1 deletion
2
...omponents/Create/components/pages/ReviewDeploy/components/RewardsReview/RewardsReview.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
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.
File renamed without changes.
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 @@ | ||
export * from './AddNftCollectionForm' |
File renamed without changes.
File renamed without changes.
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...v3/V2V3Project/V2V3ProjectSettings/pages/EditNftsPage/hooks/useUpdateCurrentCollection.ts
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
47 changes: 43 additions & 4 deletions
47
...ct/V2V3ProjectSettings/pages/NewEditNftsPage/LaunchNftCollection/LaunchNftsCollection.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 |
---|---|---|
@@ -1,10 +1,49 @@ | ||
import { AddNftCollectionForm } from 'components/Create/components' | ||
import { Trans } from '@lingui/macro' | ||
import { AddNftCollectionForm } from 'components/NftRewards/AddNftCollectionForm' | ||
import TransactionModal from 'components/modals/TransactionModal' | ||
import { TransactionSuccessModal } from '../../../TransactionSuccessModal' | ||
import { UploadAndLaunchNftsButton } from './UploadAndLaunchNftsButton' | ||
import { useSettingsLaunchNftsForm } from './hooks/useSettingsLaunchNftsForm' | ||
|
||
export function LaunchNftsPage() { | ||
const { | ||
form, | ||
launchCollection, | ||
launchButtonLoading, | ||
launchTxPending, | ||
successModalOpen, | ||
setSuccessModalOpen, | ||
} = useSettingsLaunchNftsForm() | ||
return ( | ||
<AddNftCollectionForm | ||
okButton={<UploadAndLaunchNftsButton className="mt-10" />} | ||
/> | ||
<> | ||
<AddNftCollectionForm | ||
form={form} | ||
okButton={ | ||
<UploadAndLaunchNftsButton | ||
className="mt-10" | ||
onClick={() => launchCollection} | ||
loading={launchButtonLoading} | ||
/> | ||
} | ||
/> | ||
<TransactionModal transactionPending open={launchTxPending} /> | ||
<TransactionSuccessModal | ||
open={successModalOpen} | ||
onClose={() => setSuccessModalOpen(false)} | ||
content={ | ||
<> | ||
<div className="w-80 pt-1 text-2xl font-medium"> | ||
<Trans>Your new NFTs have been deployed</Trans> | ||
</div> | ||
<div className="text-secondary pb-6"> | ||
<Trans> | ||
New NFTs will be available in your next cycle as long as it | ||
starts after your edit deadline. | ||
</Trans> | ||
</div> | ||
</> | ||
} | ||
/> | ||
</> | ||
) | ||
} |
122 changes: 12 additions & 110 deletions
122
...V3ProjectSettings/pages/NewEditNftsPage/LaunchNftCollection/UploadAndLaunchNftsButton.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 |
---|---|---|
@@ -1,121 +1,23 @@ | ||
import { Trans } from '@lingui/macro' | ||
import { Button } from 'antd' | ||
import TransactionModal from 'components/modals/TransactionModal' | ||
import { useState } from 'react' | ||
import { useAppSelector } from 'redux/hooks/useAppSelector' | ||
import { pinNftCollectionMetadata, pinNftRewards } from 'utils/nftRewards' | ||
import { TransactionSuccessModal } from '../../../TransactionSuccessModal' | ||
import { | ||
EditingFundingCycleConfig, | ||
useEditingFundingCycleConfig, | ||
} from '../../ReconfigureFundingCycleSettingsPage/hooks/useEditingFundingCycleConfig' | ||
import { useReconfigureFundingCycle } from '../../ReconfigureFundingCycleSettingsPage/hooks/useReconfigureFundingCycle' | ||
|
||
export function UploadAndLaunchNftsButton({ | ||
className, | ||
onClick, | ||
loading, | ||
}: { | ||
className?: string | ||
onClick?: VoidFunction | ||
loading: boolean | ||
}) { | ||
const [ipfsUploading, setIpfsUploading] = useState<boolean>(false) | ||
const [successModalOpen, setSuccessModalOpen] = useState<boolean>(false) | ||
|
||
const { | ||
projectMetadata: { logoUri }, | ||
} = useAppSelector(state => state.editingV2Project) | ||
|
||
const editingFundingCycleConfig = useEditingFundingCycleConfig() | ||
const { reconfigureLoading, reconfigureFundingCycle, txPending } = | ||
useReconfigureFundingCycle({ | ||
editingFundingCycleConfig, | ||
memo: 'First NFT collection', | ||
launchedNewNfts: true, | ||
onComplete: () => setSuccessModalOpen(true), | ||
}) | ||
|
||
const buttonLoading = ipfsUploading || reconfigureLoading | ||
|
||
const { | ||
editingPayoutGroupedSplits, | ||
editingReservedTokensGroupedSplits, | ||
editingFundingCycleMetadata, | ||
editingFundingCycleData, | ||
editingFundAccessConstraints, | ||
editingNftRewards, | ||
editingMustStartAtOrAfter, | ||
} = editingFundingCycleConfig | ||
|
||
const uploadNftsToIpfs = async () => { | ||
setIpfsUploading(true) | ||
const newRewardTiers = | ||
editingFundingCycleConfig.editingNftRewards?.rewardTiers | ||
const collectionName = | ||
editingFundingCycleConfig.editingNftRewards?.collectionMetadata.name ?? '' | ||
const collectionDescription = | ||
editingFundingCycleConfig.editingNftRewards?.collectionMetadata | ||
.description ?? '' | ||
const collectionLogoUri = logoUri ?? '' | ||
const collectionInfoUri = | ||
editingFundingCycleConfig.editingNftRewards?.collectionMetadata.uri ?? '' | ||
|
||
const [rewardTiersCIDs, nftCollectionMetadataUri] = await Promise.all([ | ||
newRewardTiers ? pinNftRewards(newRewardTiers) : [], | ||
pinNftCollectionMetadata({ | ||
collectionName, | ||
collectionDescription, | ||
collectionLogoUri, | ||
collectionInfoUri, | ||
}), | ||
]) | ||
const latestEditingData: EditingFundingCycleConfig = { | ||
editingPayoutGroupedSplits, | ||
editingReservedTokensGroupedSplits, | ||
editingFundingCycleMetadata, | ||
editingFundingCycleData, | ||
editingFundAccessConstraints, | ||
editingNftRewards: editingNftRewards | ||
? { | ||
...editingNftRewards, | ||
collectionMetadata: { | ||
...editingNftRewards.collectionMetadata, | ||
uri: nftCollectionMetadataUri, | ||
}, | ||
CIDs: rewardTiersCIDs, | ||
} | ||
: undefined, | ||
editingMustStartAtOrAfter, | ||
} | ||
reconfigureFundingCycle(latestEditingData) | ||
setIpfsUploading(false) | ||
} | ||
|
||
return ( | ||
<> | ||
<Button | ||
type="primary" | ||
onClick={uploadNftsToIpfs} | ||
loading={buttonLoading} | ||
className={className} | ||
> | ||
<Trans>Deploy NFT collection</Trans> | ||
</Button> | ||
<TransactionModal transactionPending open={txPending} /> | ||
<TransactionSuccessModal | ||
open={successModalOpen} | ||
onClose={() => setSuccessModalOpen(false)} | ||
content={ | ||
<> | ||
<div className="w-80 pt-1 text-2xl font-medium"> | ||
<Trans>Your new NFTs have been deployed</Trans> | ||
</div> | ||
<div className="text-secondary pb-6"> | ||
<Trans> | ||
New NFTs will be available in your next cycle as long as it | ||
starts after your edit deadline. | ||
</Trans> | ||
</div> | ||
</> | ||
} | ||
/> | ||
</> | ||
<Button | ||
type="primary" | ||
onClick={onClick} | ||
loading={loading} | ||
className={className} | ||
> | ||
<Trans>Deploy NFT collection</Trans> | ||
</Button> | ||
) | ||
} |
Oops, something went wrong.