Skip to content

Commit

Permalink
add reset app data on sign out
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanlundberg committed Oct 30, 2024
1 parent 417f25d commit 629a261
Show file tree
Hide file tree
Showing 28 changed files with 156 additions and 33 deletions.
5 changes: 4 additions & 1 deletion messages/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "এটি পূর্বে সংরক্ষিত ডেটা ওভাররাইট করবে।",
"source": "উৎস",
"title": "সেটিংস",
"tos": "পরিষেবার শর্তাবলী"
"tos": "পরিষেবার শর্তাবলী",
"unlink-account": "অ্যাকাউন্ট আনলিঙ্ক করুন",
"unlink-account-para1": "আপনি কি নিশ্চিত যে আপনি অ্যাকাউন্ট থেকে লিঙ্কমুক্ত করতে চান৷",
"unlink-account-para2": "লিঙ্কমুক্ত করা হলে এই ডিভাইস থেকে সমস্ত ডেটা মুছে যাবে।"
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Tím se přepíší dříve uložená data.",
"source": "Zdroj",
"title": "Nastavení",
"tos": "Podmínky služby"
"tos": "Podmínky služby",
"unlink-account": "Odpojit účet",
"unlink-account-para1": "Opravdu se chcete odpojit od účtu?",
"unlink-account-para2": "Odpojením smažete všechna data z tohoto zařízení."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Dadurch werden zuvor gespeicherte Daten überschrieben.",
"source": "Quelle",
"title": "Einstellungen",
"tos": "Nutzungsbedingungen"
"tos": "Nutzungsbedingungen",
"unlink-account": "Kontoverknüpfung aufheben",
"unlink-account-para1": "Sind Sie sicher, dass Sie die Verknüpfung mit dem Konto aufheben möchten?",
"unlink-account-para2": "Durch das Aufheben der Verknüpfung werden alle Daten von diesem Gerät gelöscht."
}
},
"Metadata": {
Expand Down
3 changes: 3 additions & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@
"title": "Settings",
"not-authenticated": "Authenticate to grant access",
"fetching-last-backup": "Fetching information from server wait a moment...",
"unlink-account": "Unlink account",
"unlink-account-para1": "Are you sure you want to unlink from the account",
"unlink-account-para2": "Unlinking will delete all data from this device.",
"options": "Options",
"help": "Help",
"account": "Account",
Expand Down
5 changes: 4 additions & 1 deletion messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"tos": "Términos de servicio",
"not-authenticated": "Autenticarse para otorgar acceso",
"options": "Opciones",
"privacy-policy": "política de privacidad"
"privacy-policy": "política de privacidad",
"unlink-account": "Desvincular cuenta",
"unlink-account-para1": "¿Estás seguro de que quieres desvincularte de la cuenta?",
"unlink-account-para2": "Al desvincularse se eliminarán todos los datos de este dispositivo."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "See kirjutab üle varem salvestatud andmed.",
"source": "Allikas",
"title": "Seaded",
"tos": "Kasutustingimused"
"tos": "Kasutustingimused",
"unlink-account": "Tühistage konto linkimine",
"unlink-account-para1": "Kas olete kindel, et soovite konto linkimise tühistada?",
"unlink-account-para2": "Linkimise tühistamisel kustutatakse sellest seadmest kõik andmed."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Tämä korvaa aiemmin tallennetut tiedot.",
"source": "Lähde",
"title": "Asetukset",
"tos": "Palveluehdot"
"tos": "Palveluehdot",
"unlink-account": "Poista tilin linkitys",
"unlink-account-para1": "Haluatko varmasti poistaa linkityksen tilistä",
"unlink-account-para2": "Linkityksen poistaminen poistaa kaikki tiedot tältä laitteelta."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Cela écrasera les données précédemment enregistrées.",
"source": "Source",
"title": "Paramètres",
"tos": "Conditions d'utilisation"
"tos": "Conditions d'utilisation",
"unlink-account": "Dissocier le compte",
"unlink-account-para1": "Etes-vous sûr de vouloir vous dissocier du compte",
"unlink-account-para2": "La dissociation supprimera toutes les données de cet appareil."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "यह पहले से सहेजे गए डेटा को अधिलेखित कर देगा.",
"source": "स्रोत",
"title": "सेटिंग्स",
"tos": "सेवा की शर्तें"
"tos": "सेवा की शर्तें",
"unlink-account": "खाता अनलिंक करें",
"unlink-account-para1": "क्या आप वाकई खाते से अनलिंक करना चाहते हैं?",
"unlink-account-para2": "अनलिंक करने से इस डिवाइस से सारा डेटा हट जाएगा."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Ez felülírja a korábban elmentett adatokat.",
"source": "Forrás",
"title": "Beállítások elemre",
"tos": "Szolgáltatási feltételek"
"tos": "Szolgáltatási feltételek",
"unlink-account": "Fiók leválasztása",
"unlink-account-para1": "Biztosan le szeretné választani a kapcsolatot a fiókkal?",
"unlink-account-para2": "A leválasztással törli az összes adatot erről az eszközről."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Ini akan menimpa data yang disimpan sebelumnya.",
"source": "Sumber",
"title": "Pengaturan",
"tos": "Ketentuan Layanan"
"tos": "Ketentuan Layanan",
"unlink-account": "Putuskan tautan akun",
"unlink-account-para1": "Apakah Anda yakin ingin membatalkan tautan dari akun tersebut",
"unlink-account-para2": "Membatalkan tautan akan menghapus semua data dari perangkat ini."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Ciò sovrascriverà i dati salvati in precedenza.",
"source": "Fonte",
"title": "Impostazioni",
"tos": "Termini di servizio"
"tos": "Termini di servizio",
"unlink-account": "Scollega account",
"unlink-account-para1": "Sei sicuro di volerti scollegare dall'account?",
"unlink-account-para2": "Lo scollegamento eliminerà tutti i dati da questo dispositivo."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "これにより、以前に保存されたデータが上書きされます。",
"source": "ソース",
"title": "設定",
"tos": "利用規約"
"tos": "利用規約",
"unlink-account": "アカウントのリンクを解除する",
"unlink-account-para1": "アカウントからのリンクを解除してもよろしいですか",
"unlink-account-para2": "リンクを解除すると、このデバイスからすべてのデータが削除されます。"
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "이전에 저장된 데이터를 덮어쓰게 됩니다.",
"source": "원천",
"title": "설정",
"tos": "서비스 약관"
"tos": "서비스 약관",
"unlink-account": "계정 연결 해제",
"unlink-account-para1": "정말로 계정에서 연결을 해제하시겠습니까?",
"unlink-account-para2": "연결을 해제하면 이 기기의 모든 데이터가 삭제됩니다."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/ms.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Ini akan menimpa data yang disimpan sebelum ini.",
"source": "Sumber",
"title": "tetapan",
"tos": "Syarat Perkhidmatan"
"tos": "Syarat Perkhidmatan",
"unlink-account": "Nyahpaut akaun",
"unlink-account-para1": "Adakah anda pasti mahu menyahpaut daripada akaun",
"unlink-account-para2": "Menyahpaut akan memadamkan semua data daripada peranti ini."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Hierdoor worden eerder opgeslagen gegevens overschreven.",
"source": "Bron",
"title": "Instellingen",
"tos": "Servicevoorwaarden"
"tos": "Servicevoorwaarden",
"unlink-account": "Account ontkoppelen",
"unlink-account-para1": "Weet u zeker dat u de account wilt ontkoppelen?",
"unlink-account-para2": "Als u de koppeling ontkoppelt, worden alle gegevens van dit apparaat verwijderd."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Dette vil overskrive tidligere lagrede data.",
"source": "Kilde",
"title": "Innstillinger",
"tos": "Vilkår for bruk"
"tos": "Vilkår for bruk",
"unlink-account": "Fjern tilknytningen til kontoen",
"unlink-account-para1": "Er du sikker på at du vil koble fra kontoen",
"unlink-account-para2": "Hvis du fjerner tilknytningen, slettes alle data fra denne enheten."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Spowoduje to zastąpienie wcześniej zapisanych danych.",
"source": "Źródło",
"title": "Ustawienia",
"tos": "Warunki świadczenia usług"
"tos": "Warunki świadczenia usług",
"unlink-account": "Odłącz konto",
"unlink-account-para1": "Czy na pewno chcesz odłączyć się od konta?",
"unlink-account-para2": "Odłączenie spowoduje usunięcie wszystkich danych z tego urządzenia."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Isso substituirá os dados salvos anteriormente.",
"source": "Fonte",
"title": "Configurações",
"tos": "Termos de Serviço"
"tos": "Termos de Serviço",
"unlink-account": "Desvincular conta",
"unlink-account-para1": "Tem certeza de que deseja desvincular a conta",
"unlink-account-para2": "A desvinculação excluirá todos os dados deste dispositivo."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Aceasta va suprascrie datele salvate anterior.",
"source": "Sursă",
"title": "Setări",
"tos": "Termeni și condiții"
"tos": "Termeni și condiții",
"unlink-account": "Deconectați contul",
"unlink-account-para1": "Sigur doriți să vă deconectați de la cont",
"unlink-account-para2": "Deconectarea va șterge toate datele de pe acest dispozitiv."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Это приведет к перезаписи ранее сохраненных данных.",
"source": "Источник",
"title": "Настройки",
"tos": "Условия использования"
"tos": "Условия использования",
"unlink-account": "Отсоединить аккаунт",
"unlink-account-para1": "Вы уверены, что хотите отменить связь с аккаунтом?",
"unlink-account-para2": "Отмена привязки приведет к удалению всех данных с этого устройства."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Tým sa prepíšu predtým uložené údaje.",
"source": "Zdroj",
"title": "Nastavenia",
"tos": "Zmluvné podmienky"
"tos": "Zmluvné podmienky",
"unlink-account": "Odpojiť účet",
"unlink-account-para1": "Naozaj chcete zrušiť prepojenie s účtom?",
"unlink-account-para2": "Odpojením sa odstránia všetky údaje z tohto zariadenia."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Detta kommer att skriva över tidigare sparad data.",
"source": "Källa",
"title": "Inställningar",
"tos": "Användarvillkor"
"tos": "Användarvillkor",
"unlink-account": "Ta bort länken till kontot",
"unlink-account-para1": "Är du säker på att du vill ta bort länken från kontot",
"unlink-account-para2": "Om du tar bort länken raderas all data från den här enheten."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Bu, daha önce kaydedilen verilerin üzerine yazacaktır.",
"source": "Kaynak",
"title": "Ayarlar",
"tos": "Hizmet Şartları"
"tos": "Hizmet Şartları",
"unlink-account": "Hesabın bağlantısını kaldır",
"unlink-account-para1": "Hesapla bağlantıyı kaldırmak istediğinizden emin misiniz?",
"unlink-account-para2": "Bağlantının kaldırılması bu cihazdaki tüm verilerin silinmesine neden olacaktır."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Це призведе до перезапису раніше збережених даних.",
"source": "Джерело",
"title": "Налаштування",
"tos": "Умови обслуговування"
"tos": "Умови обслуговування",
"unlink-account": "Від’єднати обліковий запис",
"unlink-account-para1": "Ви впевнені, що хочете від’єднати обліковий запис?",
"unlink-account-para2": "Від’єднання видалить усі дані з цього пристрою."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "Điều này sẽ ghi đè lên dữ liệu đã lưu trước đó.",
"source": "Nguồn",
"title": "Cài đặt",
"tos": "Điều khoản dịch vụ"
"tos": "Điều khoản dịch vụ",
"unlink-account": "Hủy liên kết tài khoản",
"unlink-account-para1": "Bạn có chắc chắn muốn hủy liên kết khỏi tài khoản",
"unlink-account-para2": "Việc hủy liên kết sẽ xóa tất cả dữ liệu khỏi thiết bị này."
}
},
"Metadata": {
Expand Down
5 changes: 4 additions & 1 deletion messages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
"save-data-warning": "这将覆盖以前保存的数据。",
"source": "来源",
"title": "设置",
"tos": "服务条款"
"tos": "服务条款",
"unlink-account": "取消账户关联",
"unlink-account-para1": "您确定要取消与帐户的关联吗",
"unlink-account-para2": "取消链接将删除该设备上的所有数据。"
}
},
"Metadata": {
Expand Down
56 changes: 49 additions & 7 deletions src/app/settings/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ import Link from "next/link";
import AccountNotAuth from "@/components/account/account-not-auth/account-not-auth";
import AccountLastBackup from "@/components/account/account-last-backup/account-last-backup";
import { useTranslations } from "next-intl";
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { deleteCubeById, getAllCubes } from "@/db/dbOperations";

export default function Page() {
const { data: session } = useSession();
Expand All @@ -15,6 +26,15 @@ export default function Page() {
return <AccountNotAuth />;
}

const handleResetDeviceData = async () => {
const cubes = await getAllCubes();
if (cubes) {
cubes.map(async (cube) => await deleteCubeById(cube.id));
}

signOut({ redirectTo: "/" });
};

return (
<>
<AccountHeader back="/settings" label={t("SettingsPage.account")} />
Expand All @@ -40,13 +60,35 @@ export default function Page() {
</Button>
</Link>

<Button
className="w-full"
variant={"destructive"}
onClick={() => signOut({ redirectTo: "/" })}
>
{t("SettingsPage.logout")}
</Button>
<Dialog>
<DialogTrigger className="w-full" asChild>
<Button className="w-full" variant={"destructive"}>
{t("SettingsPage.unlink-account")}
</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>{t("SettingsPage.unlink-account")}</DialogTitle>
<DialogDescription>
{t("SettingsPage.unlink-account-para1")}{" "}
<span className="text-primary">{session.user?.name}</span>
</DialogDescription>
<DialogDescription className="text-yellow-600">
{t("SettingsPage.unlink-account-para2")}
</DialogDescription>
</DialogHeader>
<DialogFooter className="flex flex-col gap-2">
<DialogClose className="w-full">
<Button variant={"secondary"} className="w-full">
{t("Inputs.cancel")}
</Button>
</DialogClose>
<Button className="w-full" onClick={handleResetDeviceData}>
{t("Inputs.continue")}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>

<AccountLastBackup session={session} />
</div>
Expand Down

0 comments on commit 629a261

Please sign in to comment.