import { createFileRoute } from "@tanstack/react-router";
import z from "zod";
import RequestResetPassword from "../-components/RequestResetPassword";
import ResetPasswordForm from "../-components/ResetPasswordForm";

export const Route = createFileRoute("/_app/(auth)/user/resetpassword")({
    // beforeLoad: ({ search }) => {
    //     return { token: search.token };
    // },
    validateSearch: z.object({
        token: z.string().optional(),
    }),
    component: RouteComponent,
});

function RouteComponent() {
    const { token } = Route.useSearch();
    return (
        <div className="ml-[25%] mt-[0.5%]">
            {token ? (
                <ResetPasswordForm token={token} />
            ) : (
                <RequestResetPassword />
            )}
        </div>
    );
}
