diff options
author | Hailey <me@haileyok.com> | 2024-09-07 11:54:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-07 11:54:39 -0700 |
commit | 2842f661db8aeb0154dd362a6b61b3edb808bef9 (patch) | |
tree | 6de50442adac91debfba0fd89dcbef44488dd43a /src/components/intents/IntentDialogs.tsx | |
parent | 45a719b256173f98b20457cc80b4288e84f1c33f (diff) | |
download | voidsky-2842f661db8aeb0154dd362a6b61b3edb808bef9.tar.zst |
Add intent for verifying email (#5120)
Diffstat (limited to 'src/components/intents/IntentDialogs.tsx')
-rw-r--r-- | src/components/intents/IntentDialogs.tsx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/components/intents/IntentDialogs.tsx b/src/components/intents/IntentDialogs.tsx new file mode 100644 index 000000000..244850370 --- /dev/null +++ b/src/components/intents/IntentDialogs.tsx @@ -0,0 +1,37 @@ +import React from 'react' + +import * as Dialog from '#/components/Dialog' +import {DialogControlProps} from '#/components/Dialog' +import {VerifyEmailIntentDialog} from '#/components/intents/VerifyEmailIntentDialog' + +interface Context { + verifyEmailDialogControl: DialogControlProps + verifyEmailState: {code: string} | undefined + setVerifyEmailState: (state: {code: string} | undefined) => void +} + +const Context = React.createContext({} as Context) +export const useIntentDialogs = () => React.useContext(Context) + +export function Provider({children}: {children: React.ReactNode}) { + const verifyEmailDialogControl = Dialog.useDialogControl() + const [verifyEmailState, setVerifyEmailState] = React.useState< + {code: string} | undefined + >() + + const value = React.useMemo( + () => ({ + verifyEmailDialogControl, + verifyEmailState, + setVerifyEmailState, + }), + [verifyEmailDialogControl, verifyEmailState, setVerifyEmailState], + ) + + return ( + <Context.Provider value={value}> + {children} + <VerifyEmailIntentDialog /> + </Context.Provider> + ) +} |