2023-02-16 22:39:57 +00:00
|
|
|
import type { GetServerSidePropsContext } from "next";
|
2022-05-17 16:52:45 +00:00
|
|
|
import { signOut, useSession } from "next-auth/react";
|
2022-01-20 09:32:24 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { useEffect } from "react";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2022-07-01 17:19:52 +00:00
|
|
|
import { WEBSITE_URL } from "@calcom/lib/constants";
|
2022-05-17 16:52:45 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-01-23 23:08:01 +00:00
|
|
|
import { Button } from "@calcom/ui";
|
2023-04-12 15:26:31 +00:00
|
|
|
import { Check } from "@calcom/ui/components/icon";
|
2022-03-16 23:36:43 +00:00
|
|
|
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
2021-10-14 14:24:21 +00:00
|
|
|
|
2022-11-01 13:29:01 +00:00
|
|
|
import AuthContainer from "@components/ui/AuthContainer";
|
2021-04-07 15:03:02 +00:00
|
|
|
|
2021-11-16 17:12:08 +00:00
|
|
|
import { ssrInit } from "@server/lib/ssr";
|
|
|
|
|
2022-01-20 09:32:24 +00:00
|
|
|
type Props = inferSSRProps<typeof getServerSideProps>;
|
|
|
|
|
2023-04-05 18:14:46 +00:00
|
|
|
export function Logout(props: Props) {
|
2022-05-17 16:52:45 +00:00
|
|
|
const { status } = useSession();
|
2022-03-28 20:06:41 +00:00
|
|
|
if (status === "authenticated") signOut({ redirect: false });
|
2022-01-20 09:32:24 +00:00
|
|
|
const router = useRouter();
|
|
|
|
useEffect(() => {
|
|
|
|
if (props.query?.survey === "true") {
|
2022-07-01 17:19:52 +00:00
|
|
|
router.push(`${WEBSITE_URL}/cancellation`);
|
2022-01-20 09:32:24 +00:00
|
|
|
}
|
2022-05-17 16:52:45 +00:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [props.query?.survey]);
|
2021-10-14 14:24:21 +00:00
|
|
|
const { t } = useLocale();
|
|
|
|
|
2021-07-20 18:18:26 +00:00
|
|
|
return (
|
2022-10-04 09:31:13 +00:00
|
|
|
<AuthContainer title={t("logged_out")} description={t("youve_been_logged_out")} showLogo>
|
2022-01-27 10:16:20 +00:00
|
|
|
<div className="mb-4">
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-success mx-auto flex h-12 w-12 items-center justify-center rounded-full">
|
2023-04-12 15:26:31 +00:00
|
|
|
<Check className="h-6 w-6 text-green-600" />
|
2022-01-27 10:16:20 +00:00
|
|
|
</div>
|
|
|
|
<div className="mt-3 text-center sm:mt-5">
|
2023-04-05 18:14:46 +00:00
|
|
|
<h3 className="text-emphasis text-lg font-medium leading-6" id="modal-title">
|
2022-01-27 10:16:20 +00:00
|
|
|
{t("youve_been_logged_out")}
|
|
|
|
</h3>
|
|
|
|
<div className="mt-2">
|
2023-04-05 18:14:46 +00:00
|
|
|
<p className="text-subtle text-sm">{t("hope_to_see_you_soon")}</p>
|
2021-07-20 18:18:26 +00:00
|
|
|
</div>
|
2021-04-07 15:03:02 +00:00
|
|
|
</div>
|
2021-07-20 18:18:26 +00:00
|
|
|
</div>
|
2023-03-16 15:12:45 +00:00
|
|
|
<Button href="/auth/login" className="flex w-full justify-center">
|
2022-10-04 09:31:13 +00:00
|
|
|
{t("go_back_login")}
|
|
|
|
</Button>
|
2022-01-27 10:16:20 +00:00
|
|
|
</AuthContainer>
|
2021-07-20 18:18:26 +00:00
|
|
|
);
|
2021-07-19 15:56:58 +00:00
|
|
|
}
|
2021-11-16 17:12:08 +00:00
|
|
|
|
2023-04-05 18:14:46 +00:00
|
|
|
Logout.isThemeSupported = false;
|
|
|
|
|
|
|
|
export default Logout;
|
|
|
|
|
2021-11-16 17:12:08 +00:00
|
|
|
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
|
|
|
const ssr = await ssrInit(context);
|
2022-04-26 15:12:08 +00:00
|
|
|
// Deleting old cookie manually, remove this code after all existing cookies have expired
|
|
|
|
context.res.setHeader(
|
|
|
|
"Set-Cookie",
|
|
|
|
"next-auth.session-token=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"
|
|
|
|
);
|
2021-11-16 17:12:08 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
trpcState: ssr.dehydrate(),
|
2022-01-20 09:32:24 +00:00
|
|
|
query: context.query,
|
2021-11-16 17:12:08 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|