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 {InlineLinkText} from '#/components/Link'
import {Loader} from '#/components/Loader' import {Loader} from '#/components/Loader'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import {ChangeEmailDialog} from './ChangeEmailDialog'
export function VerifyEmailDialog({ export function VerifyEmailDialog({
control, control,
@@ -26,13 +27,20 @@ export function VerifyEmailDialog({
onCloseWithoutVerifying?: () => void onCloseWithoutVerifying?: () => void
onCloseAfterVerifying?: () => void onCloseAfterVerifying?: () => void
reasonText?: string 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 agent = useAgent()
const fallbackChangeEmailControl = Dialog.useDialogControl()
const [didVerify, setDidVerify] = React.useState(false) const [didVerify, setDidVerify] = React.useState(false)
return ( return (
<>
<Dialog.Outer <Dialog.Outer
control={control} control={control}
onClose={async () => { onClose={async () => {
@@ -53,9 +61,16 @@ export function VerifyEmailDialog({
<Inner <Inner
setDidVerify={setDidVerify} setDidVerify={setDidVerify}
reasonText={reasonText} reasonText={reasonText}
changeEmailControl={changeEmailControl} changeEmailControl={changeEmailControl ?? fallbackChangeEmailControl}
/> />
</Dialog.Outer> </Dialog.Outer>
{!changeEmailControl && (
<ChangeEmailDialog
control={fallbackChangeEmailControl}
verifyEmailControl={control}
/>
)}
</>
) )
} }