2023-02-16 22:39:57 +00:00
|
|
|
import type { GetStaticPropsContext } from "next";
|
2021-08-02 20:51:57 +00:00
|
|
|
import Link from "next/link";
|
2021-09-22 19:52:38 +00:00
|
|
|
import { useRouter } from "next/router";
|
2022-09-08 00:38:37 +00:00
|
|
|
import z from "zod";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2022-08-16 23:38:26 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-01-23 23:08:01 +00:00
|
|
|
import { Button, SkeletonText } from "@calcom/ui";
|
|
|
|
import { FiX } from "@calcom/ui/components/icon";
|
2022-03-16 23:36:43 +00:00
|
|
|
|
2022-02-04 20:30:36 +00:00
|
|
|
import AuthContainer from "@components/ui/AuthContainer";
|
2021-03-29 21:01:12 +00:00
|
|
|
|
2022-08-16 23:38:26 +00:00
|
|
|
import { ssgInit } from "@server/lib/ssg";
|
2021-11-16 17:12:08 +00:00
|
|
|
|
2022-09-08 00:38:37 +00:00
|
|
|
const querySchema = z.object({
|
|
|
|
error: z.string().optional(),
|
|
|
|
});
|
|
|
|
|
2021-03-29 21:01:12 +00:00
|
|
|
export default function Error() {
|
2021-10-14 14:24:21 +00:00
|
|
|
const { t } = useLocale();
|
2021-08-02 20:51:57 +00:00
|
|
|
const router = useRouter();
|
2022-09-08 00:38:37 +00:00
|
|
|
const { error } = querySchema.parse(router.query);
|
|
|
|
const isTokenVerificationError = error?.toLowerCase() === "verification";
|
|
|
|
let errorMsg = <SkeletonText />;
|
|
|
|
if (router.isReady) {
|
|
|
|
errorMsg = isTokenVerificationError ? t("token_invalid_expired") : t("error_during_login");
|
|
|
|
}
|
2021-03-29 21:01:12 +00:00
|
|
|
|
2021-08-02 20:51:57 +00:00
|
|
|
return (
|
2022-02-04 20:30:36 +00:00
|
|
|
<AuthContainer title="" description="">
|
|
|
|
<div>
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-red-100">
|
2023-01-23 23:08:01 +00:00
|
|
|
<FiX className="h-6 w-6 text-red-600" />
|
2022-02-04 20:30:36 +00:00
|
|
|
</div>
|
|
|
|
<div className="mt-3 text-center sm:mt-5">
|
2022-02-09 00:05:13 +00:00
|
|
|
<h3 className="text-lg font-medium leading-6 text-gray-900" id="modal-title">
|
2022-02-04 20:30:36 +00:00
|
|
|
{error}
|
|
|
|
</h3>
|
|
|
|
<div className="mt-2">
|
2022-09-08 00:38:37 +00:00
|
|
|
<p className="text-sm text-gray-500">{errorMsg}</p>
|
2021-08-02 20:51:57 +00:00
|
|
|
</div>
|
2021-03-29 21:01:12 +00:00
|
|
|
</div>
|
2021-08-02 20:51:57 +00:00
|
|
|
</div>
|
2022-02-04 20:30:36 +00:00
|
|
|
<div className="mt-5 sm:mt-6">
|
2023-01-06 12:13:56 +00:00
|
|
|
<Link href="/auth/login" passHref legacyBehavior>
|
2022-02-09 00:05:13 +00:00
|
|
|
<Button className="flex w-full justify-center">{t("go_back_login")}</Button>
|
2022-02-04 20:30:36 +00:00
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
</AuthContainer>
|
2021-08-02 20:51:57 +00:00
|
|
|
);
|
2021-07-30 23:05:38 +00:00
|
|
|
}
|
2021-11-16 17:12:08 +00:00
|
|
|
|
2022-08-16 23:38:26 +00:00
|
|
|
export const getStaticProps = async (context: GetStaticPropsContext) => {
|
|
|
|
const ssr = await ssgInit(context);
|
2021-11-16 17:12:08 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
trpcState: ssr.dehydrate(),
|
|
|
|
},
|
|
|
|
};
|
2022-08-16 23:38:26 +00:00
|
|
|
};
|