-
-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1/2] Improve launch NFT collection tx UI #4063
Changes from 2 commits
3621734
9602353
fd83cc8
bcf4ccd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,17 @@ import { Button, Modal } from 'antd' | |
import { ProjectMetadataContext } from 'contexts/shared/ProjectMetadataContext' | ||
import { V2V3ProjectContext } from 'contexts/v2v3/Project/V2V3ProjectContext' | ||
import Link from 'next/link' | ||
import { useContext } from 'react' | ||
import { ReactNode, useContext } from 'react' | ||
import { settingsPagePath, v2v3ProjectRoute } from 'utils/routes' | ||
|
||
export function EditCycleSuccessModal({ | ||
export function TransactionSuccessModal({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes this component reusable across edit cycle and nfts settings pages |
||
open, | ||
onClose, | ||
content, | ||
}: { | ||
open: boolean | ||
onClose: VoidFunction | ||
content: ReactNode | ||
}) { | ||
const { projectId } = useContext(ProjectMetadataContext) | ||
const { handle } = useContext(V2V3ProjectContext) | ||
|
@@ -35,15 +37,7 @@ export function EditCycleSuccessModal({ | |
> | ||
<div className="flex w-full flex-col items-center gap-4 pt-2 text-center"> | ||
{checkIconWithBackground} | ||
<div className="w-80 pt-1 text-2xl font-medium"> | ||
<Trans>Your updated cycle has been deployed</Trans> | ||
</div> | ||
<div className="text-secondary pb-6"> | ||
<Trans> | ||
Changes will take effect in your next cycle as long as it starts | ||
after your edit deadline. | ||
</Trans> | ||
</div> | ||
{content} | ||
<div className="flex gap-2.5"> | ||
<Link href={settingsPagePath(undefined, { projectId, handle })}> | ||
<Button type="ghost" className={buttonClasses}> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,6 @@ export function EnableNftsModal({ | |
setLoading(false) | ||
reloadWindow() | ||
}, | ||
onDone() { | ||
setLoading(false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Obv bug |
||
}, | ||
onError() { | ||
setLoading(false) | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
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, | ||
|
@@ -15,19 +17,23 @@ export function UploadAndLaunchNftsButton({ | |
className?: string | ||
}) { | ||
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 } = | ||
const { reconfigureLoading, reconfigureFundingCycle, txPending } = | ||
useReconfigureFundingCycle({ | ||
editingFundingCycleConfig, | ||
memo: 'First NFT collection', | ||
launchedNewNfts: true, | ||
onComplete: () => setSuccessModalOpen(true), | ||
}) | ||
|
||
const buttonLoading = ipfsUploading || reconfigureLoading | ||
|
||
const { | ||
editingPayoutGroupedSplits, | ||
editingReservedTokensGroupedSplits, | ||
|
@@ -83,13 +89,33 @@ export function UploadAndLaunchNftsButton({ | |
} | ||
|
||
return ( | ||
<Button | ||
type="primary" | ||
onClick={uploadNftsToIpfs} | ||
loading={ipfsUploading || reconfigureLoading} | ||
className={className} | ||
> | ||
<Trans>Deploy NFT collection</Trans> | ||
</Button> | ||
<> | ||
<Button | ||
type="primary" | ||
onClick={uploadNftsToIpfs} | ||
loading={buttonLoading} | ||
className={className} | ||
> | ||
<Trans>Deploy NFT collection</Trans> | ||
</Button> | ||
<TransactionModal transactionPending open={txPending} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adds pending and success modal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome, good attn to detail 🙏 |
||
<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> | ||
</> | ||
} | ||
/> | ||
</> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ export const useReconfigureFundingCycle = ({ | |
|
||
const [reconfigureTxLoading, setReconfigureTxLoading] = | ||
useState<boolean>(false) | ||
const [txPending, setTxPending] = useState<boolean>(false) | ||
|
||
const reconfigureV2V3FundingCycleTx = useReconfigureV2V3FundingCycleTx() | ||
const reconfigureV2V3FundingCycleWithNftsTx = | ||
|
@@ -120,6 +121,9 @@ export const useReconfigureFundingCycle = ({ | |
} | ||
|
||
const txOpts = { | ||
onDone() { | ||
setTxPending(true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capture tx pending state in reconfigure hook |
||
}, | ||
async onConfirmed() { | ||
if (projectId) { | ||
await revalidateProject({ | ||
|
@@ -128,14 +132,20 @@ export const useReconfigureFundingCycle = ({ | |
}) | ||
} | ||
setReconfigureTxLoading(false) | ||
setTxPending(false) | ||
if (onComplete) { | ||
onComplete() | ||
} else { | ||
reloadWindow() | ||
} | ||
}, | ||
onCancelled() { | ||
setTxPending(false) | ||
}, | ||
onError() { | ||
setTxPending(false) | ||
}, | ||
} | ||
|
||
let txSuccessful: boolean | ||
if (launchedNewNfts && editingNftRewards?.rewardTiers) { | ||
txSuccessful = await reconfigureV2V3FundingCycleWithNftsTx( | ||
|
@@ -154,6 +164,7 @@ export const useReconfigureFundingCycle = ({ | |
|
||
if (!txSuccessful) { | ||
setReconfigureTxLoading(false) | ||
setTxPending(false) | ||
} | ||
}, | ||
[ | ||
|
@@ -169,5 +180,9 @@ export const useReconfigureFundingCycle = ({ | |
], | ||
) | ||
|
||
return { reconfigureLoading: reconfigureTxLoading, reconfigureFundingCycle } | ||
return { | ||
reconfigureLoading: reconfigureTxLoading, | ||
reconfigureFundingCycle, | ||
txPending, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix weird i18n encoding thing