import type { GetServerSidePropsContext } from "next"; import { getCsrfToken } from "next-auth/react"; import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import Link from "next/link"; import type { CSSProperties } from "react"; import { useForm } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import prisma from "@calcom/prisma"; import { Button, PasswordField, Form } from "@calcom/ui"; import PageWrapper from "@components/PageWrapper"; import AuthContainer from "@components/ui/AuthContainer"; type Props = { requestId: string; isRequestExpired: boolean; csrfToken: string; }; export default function Page({ requestId, isRequestExpired, csrfToken }: Props) { const { t } = useLocale(); const formMethods = useForm<{ new_password: string }>(); const success = formMethods.formState.isSubmitSuccessful; const loading = formMethods.formState.isSubmitting; const passwordValue = formMethods.watch("new_password"); const isEmpty = passwordValue?.length === 0; const submitChangePassword = async ({ password, requestId }: { password: string; requestId: string }) => { const res = await fetch("/api/auth/reset-password", { method: "POST", body: JSON.stringify({ requestId, password }), headers: { "Content-Type": "application/json", }, }); const json = await res.json(); if (!res.ok) return formMethods.setError("new_password", { type: "server", message: json.message }); }; const Success = () => { return ( <>
{t("request_is_expired_instructions")}