-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make mint flow bottom sheet generic, powered by sanity
- Loading branch information
Showing
9 changed files
with
237 additions
and
92 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
40 changes: 35 additions & 5 deletions
40
apps/mobile/src/components/Mint/MintCampaign/MintCampaignBottomSheet.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,18 +1,48 @@ | ||
import { MCHX_CLAIM_CODE_KEY } from 'src/constants/storageKeys'; | ||
import { useMemo } from 'react'; | ||
import usePersistedState from 'src/hooks/usePersistedState'; | ||
|
||
import { useSanityDataContext } from '~/contexts/SanityDataContext'; | ||
|
||
import MintCampaignPostTransaction from './MintCampaignPostTransaction'; | ||
import MintCampaignPreTransaction from './MintCampaignPreTransaction'; | ||
|
||
export default function MintCampaignBottomSheet({ onClose }: { onClose: () => void }) { | ||
type Props = { | ||
onClose?: () => void; | ||
projectInternalId?: string; | ||
}; | ||
|
||
export default function MintCampaignBottomSheet({ onClose, projectInternalId }: Props) { | ||
// claimCode is the identifer used to poll for the status of the mint | ||
// Once we kick off the mint, the backend returns a claim code from Highlight that we can use to check the status of the mint | ||
|
||
const [claimCode, setClaimCode] = usePersistedState(MCHX_CLAIM_CODE_KEY, ''); | ||
const [claimCode, setClaimCode] = usePersistedState(`${projectInternalId}_claim_code`, ''); | ||
|
||
const { data } = useSanityDataContext(); | ||
const projectData = useMemo(() => { | ||
return data?.mintProjects.find((document) => document.internalId === projectInternalId); | ||
}, [data, projectInternalId]); | ||
console.log({ projectData }); | ||
|
||
if (!projectData) { | ||
// TODO decide best way to handle missing data | ||
return null; | ||
} | ||
|
||
if (claimCode) { | ||
return <MintCampaignPostTransaction claimCode={claimCode} onClose={onClose} />; | ||
return ( | ||
<MintCampaignPostTransaction | ||
claimCode={claimCode} | ||
onClose={onClose} | ||
projectData={projectData} | ||
/> | ||
); | ||
} | ||
|
||
return <MintCampaignPreTransaction setClaimCode={setClaimCode} />; | ||
return ( | ||
<MintCampaignPreTransaction | ||
setClaimCode={setClaimCode} | ||
projectInternalId={projectInternalId} | ||
projectData={projectData} | ||
/> | ||
); | ||
} |
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
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
Oops, something went wrong.