feat(frontend): add confirmation before force log out

This commit is contained in:
sam 2024-10-02 16:49:33 +02:00
parent e030342358
commit 40da4865bc
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
6 changed files with 65 additions and 24 deletions

View file

@ -1,6 +1,9 @@
import { ActionFunction, redirect } from "@remix-run/node";
import { fastRequest, getToken, writeCookie } from "~/lib/request.server";
import { tokenCookieName } from "~/lib/utils";
import { Button, Form } from "react-bootstrap";
import { useTranslation } from "react-i18next";
import { Form as RemixForm, Link } from "@remix-run/react";
export const action: ActionFunction = async ({ request }) => {
const token = getToken(request);
@ -17,3 +20,29 @@ export const action: ActionFunction = async ({ request }) => {
headers: { "Set-Cookie": writeCookie(tokenCookieName, "token", 0) },
});
};
export const loader = () => {
return null;
};
export default function ForceLogoutPage() {
const { t } = useTranslation();
return (
<>
<h4>{t("settings.general.log-out-everywhere")}</h4>
<p className="text-has-newline">{t("settings.general.log-out-everywhere-confirm")}</p>
<RemixForm method="POST">
<Form as="div">
<Button type="submit" variant="danger">
{t("yes")}
</Button>
{/* @ts-expect-error as=Link */}
<Button variant="link" as={Link} to="/settings">
{t("no")}
</Button>
</Form>
</RemixForm>
</>
);
}