mirror of
https://github.com/sussy-code/smov.git
synced 2026-04-21 08:31:57 +00:00
add logout all accounts button
very well coded 👌
This commit is contained in:
parent
3584abac59
commit
a9d7fe2561
4 changed files with 46 additions and 3 deletions
|
|
@ -535,7 +535,12 @@
|
||||||
"text": "This action is irreversible. All data will be deleted and nothing can be recovered.",
|
"text": "This action is irreversible. All data will be deleted and nothing can be recovered.",
|
||||||
"title": "Delete account"
|
"title": "Delete account"
|
||||||
},
|
},
|
||||||
"title": "Actions"
|
"title": "Actions",
|
||||||
|
"logoutAllDevices": {
|
||||||
|
"title": "End All Sessions",
|
||||||
|
"text": "This will sign you out from all devices linked to your account.",
|
||||||
|
"button": "Log Out of All Devices"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"devices": {
|
"devices": {
|
||||||
"deviceNameLabel": "Device name",
|
"deviceNameLabel": "Device name",
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import { useAuthData } from "@/hooks/auth/useAuthData";
|
||||||
import { useBackendUrl } from "@/hooks/auth/useBackendUrl";
|
import { useBackendUrl } from "@/hooks/auth/useBackendUrl";
|
||||||
import { useAuthStore } from "@/stores/auth";
|
import { useAuthStore } from "@/stores/auth";
|
||||||
|
|
||||||
|
import { signOutAllDevices } from "./DeviceListPart";
|
||||||
|
|
||||||
export function AccountActionsPart() {
|
export function AccountActionsPart() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const url = useBackendUrl();
|
const url = useBackendUrl();
|
||||||
|
|
@ -29,6 +31,29 @@ export function AccountActionsPart() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Heading2 border>{t("settings.account.actions.title")}</Heading2>
|
<Heading2 border>{t("settings.account.actions.title")}</Heading2>
|
||||||
|
|
||||||
|
{/* Logout All Devices Section */}
|
||||||
|
<SolidSettingsCard
|
||||||
|
paddingClass="px-6 py-12 mb-10"
|
||||||
|
className="grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-12"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<Heading3>
|
||||||
|
{" "}
|
||||||
|
{t("settings.account.actions.logoutAllDevices.title")}
|
||||||
|
</Heading3>
|
||||||
|
<p className="text-type-text">
|
||||||
|
{t("settings.account.actions.logoutAllDevices.text")}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-start lg:justify-end items-center">
|
||||||
|
<Button theme="danger" onClick={signOutAllDevices}>
|
||||||
|
{t("settings.account.actions.logoutAllDevices.button")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</SolidSettingsCard>
|
||||||
|
|
||||||
|
{/* Delete Account Section */}
|
||||||
<SolidSettingsCard
|
<SolidSettingsCard
|
||||||
paddingClass="px-6 py-12"
|
paddingClass="px-6 py-12"
|
||||||
className="grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-12"
|
className="grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-12"
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ export function AccountEditPart(props: {
|
||||||
onChange={(value) => props.setDeviceName(value)}
|
onChange={(value) => props.setDeviceName(value)}
|
||||||
/>
|
/>
|
||||||
<div className="flex space-x-3">
|
<div className="flex space-x-3">
|
||||||
<Button theme="danger" onClick={logout}>
|
<Button className="logout-button" theme="danger" onClick={logout}>
|
||||||
{t("settings.account.accountDetails.logoutButton")}
|
{t("settings.account.accountDetails.logoutButton")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,14 @@ import { Heading2 } from "@/components/utils/Text";
|
||||||
import { useBackendUrl } from "@/hooks/auth/useBackendUrl";
|
import { useBackendUrl } from "@/hooks/auth/useBackendUrl";
|
||||||
import { useAuthStore } from "@/stores/auth";
|
import { useAuthStore } from "@/stores/auth";
|
||||||
|
|
||||||
|
export const signOutAllDevices = () => {
|
||||||
|
const buttons = document.querySelectorAll(".logout-button");
|
||||||
|
|
||||||
|
buttons.forEach((button) => {
|
||||||
|
(button as HTMLElement).click();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export function Device(props: {
|
export function Device(props: {
|
||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -41,7 +49,12 @@ export function Device(props: {
|
||||||
<p className="text-white">{props.name}</p>
|
<p className="text-white">{props.name}</p>
|
||||||
</div>
|
</div>
|
||||||
{!props.isCurrent ? (
|
{!props.isCurrent ? (
|
||||||
<Button theme="danger" loading={result.loading} onClick={exec}>
|
<Button
|
||||||
|
theme="danger"
|
||||||
|
className="logout-button"
|
||||||
|
loading={result.loading}
|
||||||
|
onClick={exec}
|
||||||
|
>
|
||||||
{t("settings.account.devices.removeDevice")}
|
{t("settings.account.devices.removeDevice")}
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue