'use client'; //=========================================== // THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template //=========================================== import { KnownErrors } from "@hexclave/shared"; import { throwErr } from "@hexclave/shared/dist/utils/errors"; import React from "react"; import { useStackApp, useUser } from ".."; import { MessageCard } from "../components/message-cards/message-card"; import { useTranslation } from "../lib/translations"; export function EmailVerification(props: { searchParams?: Record, fullPage?: boolean, }) { const { t } = useTranslation(); const hexclaveApp = useStackApp(); const user = useUser(); const [result, setResult] = React.useState> | null>(null); const invalidJsx = (

{t("Please check if you have the correct link. If you continue to have issues, please contact support.")}

); const expiredJsx = (

{t("Your email verification link has expired. Please request a new verification link from your account settings.")}

); if (!props.searchParams?.code) { return invalidJsx; } if (!result) { return { const result = await hexclaveApp.verifyEmail(props.searchParams?.code || throwErr("No verification code provided")); setResult(result); }} secondaryButtonText={t("Cancel")} secondaryAction={async () => { await hexclaveApp.redirectToHome(); }} />; } else { if (result.status === 'error') { if (KnownErrors.VerificationCodeNotFound.isInstance(result.error)) { return invalidJsx; } else if (KnownErrors.VerificationCodeExpired.isInstance(result.error)) { return expiredJsx; } else if (KnownErrors.VerificationCodeAlreadyUsed.isInstance(result.error)) { // everything fine, continue } else { throw result.error; } } return { await hexclaveApp.redirectToHome(); }} />; } }