import type {MetaFunction} from "@remix-run/node"; import {useSearchParams} from "@remix-run/react"; import {Button} from "~/components/ui/button.js"; import logoPng from "~/images/lume-logo.png?url"; import lumeBgPng from "~/images/lume-bg-image.png?url"; import {Authenticated, HttpError, useGetIdentity, useGo, useNotification} from "@refinedev/core"; import {useEffect} from "react"; import {useMutation, useQuery} from "@tanstack/react-query"; import {useSdk} from "~/components/lib/sdk-context.js"; import {Identity} from "~/data/auth-provider.js"; export const meta: MetaFunction = () => { return [{ title: "Verify Email" }]; }; export default function Verify() { return ( ); } function VerifyAuthenticated() { const go = useGo(); const {open} = useNotification(); const [searchParams] = useSearchParams(); const token = searchParams.get("token"); const sdk = useSdk(); const user = useGetIdentity(); const exchangeToken = useQuery({ queryKey: ["exchange-token", token], retry: false, queryFn: async () => { const ret= await sdk.account!().verifyEmail({ email: user.data?.email as string, token: token!, }) if (ret instanceof Error) { return Promise.reject(ret) } return ret }, }); const verifyAgain = useMutation({ mutationFn: () => { return sdk.account!().requestEmailVerification() }, onMutate() { open?.({ type: "success", message: "Email sent", description: "Please check your email inbox and click the link", }) } }); useEffect(() => { if (exchangeToken.isSuccess) { go({ to: "/dashboard" }); } }, [go, exchangeToken.isSuccess]); return (
Lume logo

{exchangeToken.isLoading ? "Verifying your email." : null} {exchangeToken.isSuccess && !exchangeToken.isLoading ? "Your email has been verified" : null} {exchangeToken.isError && !exchangeToken.isLoading ? "Something went wrong, please try again" : null}

{exchangeToken.isError ? (

{exchangeToken.error.message}

) : null} {exchangeToken.isSuccess ?

Redirecting to your dashboard

: null}
Lume background
) }