Bluesky app fork with some witchin' additions 馃挮
at main 38 lines 1.1 kB view raw
1import React from 'react' 2 3import * as Dialog from '#/components/Dialog' 4import {type DialogControlProps} from '#/components/Dialog' 5import {VerifyEmailIntentDialog} from '#/components/intents/VerifyEmailIntentDialog' 6 7interface Context { 8 verifyEmailDialogControl: DialogControlProps 9 verifyEmailState: {code: string} | undefined 10 setVerifyEmailState: (state: {code: string} | undefined) => void 11} 12 13const Context = React.createContext({} as Context) 14Context.displayName = 'IntentDialogsContext' 15export const useIntentDialogs = () => React.useContext(Context) 16 17export function Provider({children}: {children: React.ReactNode}) { 18 const verifyEmailDialogControl = Dialog.useDialogControl() 19 const [verifyEmailState, setVerifyEmailState] = React.useState< 20 {code: string} | undefined 21 >() 22 23 const value = React.useMemo( 24 () => ({ 25 verifyEmailDialogControl, 26 verifyEmailState, 27 setVerifyEmailState, 28 }), 29 [verifyEmailDialogControl, verifyEmailState, setVerifyEmailState], 30 ) 31 32 return ( 33 <Context.Provider value={value}> 34 {children} 35 <VerifyEmailIntentDialog /> 36 </Context.Provider> 37 ) 38}