Fallback change email dialog

This commit is contained in:
Samuel Newman
2025-04-04 15:29:59 +03:00
parent 5665958dd9
commit 28ee1ca4a1
+17 -2
View File
@@ -14,6 +14,7 @@ import * as TextField from '#/components/forms/TextField'
import {InlineLinkText} from '#/components/Link'
import {Loader} from '#/components/Loader'
import {Text} from '#/components/Typography'
import {ChangeEmailDialog} from './ChangeEmailDialog'
export function VerifyEmailDialog({
control,
@@ -26,13 +27,20 @@ export function VerifyEmailDialog({
onCloseWithoutVerifying?: () => void
onCloseAfterVerifying?: () => void
reasonText?: string
changeEmailControl: Dialog.DialogControlProps
/**
* if a changeEmailControl for a ChangeEmailDialog is not provided,
* this component will create one for you. Using this prop
* helps reduce duplication, since these dialogs are often used together.
*/
changeEmailControl?: Dialog.DialogControlProps
}) {
const agent = useAgent()
const fallbackChangeEmailControl = Dialog.useDialogControl()
const [didVerify, setDidVerify] = React.useState(false)
return (
<>
<Dialog.Outer
control={control}
onClose={async () => {
@@ -53,9 +61,16 @@ export function VerifyEmailDialog({
<Inner
setDidVerify={setDidVerify}
reasonText={reasonText}
changeEmailControl={changeEmailControl}
changeEmailControl={changeEmailControl ?? fallbackChangeEmailControl}
/>
</Dialog.Outer>
{!changeEmailControl && (
<ChangeEmailDialog
control={fallbackChangeEmailControl}
verifyEmailControl={control}
/>
)}
</>
)
}