Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

replace delete account page with modal

daniel31x13f813324959d1
diff --git a/apps/web/components/ModalContent/DeleteOwnAccountModal.tsx b/apps/web/components/ModalContent/DeleteOwnAccountModal.tsx
index 55201a8a..2eac25b8 100644
--- a/apps/web/components/ModalContent/DeleteOwnAccountModal.tsx
+++ b/apps/web/components/ModalContent/DeleteOwnAccountModal.tsx
@@ -68,6 +68,26 @@ export default function DeleteOwnAccountModal({ onClose }: Props) {
<div className="flex flex-col gap-3">
<p>{t("delete_warning")}</p>
+ {user?.subscription?.active &&
+ user.subscription.provider === "APPLE" && (
+ <p>
+ {t("delete_account_apple_subscription_notice")}{" "}
+ <a
+ className="underline text-primary"
+ href="https://apps.apple.com/account/subscriptions"
+ target="_blank"
+ rel="noreferrer"
+ >
+ https://apps.apple.com/account/subscriptions
+ </a>
+ </p>
+ )}
+
+ {user?.subscription?.active &&
+ user.subscription.provider === "GOOGLE" && (
+ <p>{t("delete_account_google_subscription_notice")}</p>
+ )}
+
{user?.hasPassword ? (
<div>
<p className="mb-2 font-semibold">{t("confirm_password")}</p>
diff --git a/apps/web/pages/settings/account.tsx b/apps/web/pages/settings/account.tsx
index 6c40beb8..fa27c507 100644
--- a/apps/web/pages/settings/account.tsx
+++ b/apps/web/pages/settings/account.tsx
@@ -8,6 +8,7 @@ import ProfilePhoto from "@/components/ProfilePhoto";
import React from "react";
import Link from "next/link";
import EmailChangeVerificationModal from "@/components/ModalContent/EmailChangeVerificationModal";
+import DeleteOwnAccountModal from "@/components/ModalContent/DeleteOwnAccountModal";
import { Button } from "@/components/ui/button";
import { i18n } from "next-i18next.config";
import { useTranslation } from "next-i18next";
@@ -29,6 +30,7 @@ import { NextPageWithLayout } from "../_app";
const Page: NextPageWithLayout = () => {
const [emailChangeVerificationModal, setEmailChangeVerificationModal] =
useState(false);
+ const [deleteAccountModal, setDeleteAccountModal] = useState(false);
const [submitLoader, setSubmitLoader] = useState(false);
const { data: account } = useUser();
const updateUser = useUpdateUser();
@@ -341,11 +343,20 @@ const Page: NextPageWithLayout = () => {
</p>
</div>
- <Link href="/settings/delete" className="underline">
- {t("account_deletion_page")}
- </Link>
+ <Button
+ onClick={() => setDeleteAccountModal(true)}
+ variant="destructive"
+ size="sm"
+ className="w-fit"
+ >
+ {t("delete_account")}
+ </Button>
</div>
+ {deleteAccountModal && (
+ <DeleteOwnAccountModal onClose={() => setDeleteAccountModal(false)} />
+ )}
+
{emailChangeVerificationModal && (
<EmailChangeVerificationModal
onClose={() => setEmailChangeVerificationModal(false)}
diff --git a/apps/web/pages/settings/delete.tsx b/apps/web/pages/settings/delete.tsx
deleted file mode 100644
index f330ef8f..00000000
--- a/apps/web/pages/settings/delete.tsx
+++ /dev/null
@@ -1,166 +0,0 @@
-import React, { useState } from "react";
-import { toast } from "react-hot-toast";
-import TextInput from "@/components/TextInput";
-import CenteredForm from "@/components/CenteredForm";
-import { signOut, useSession } from "next-auth/react";
-import Link from "next/link";
-import { Button } from "@/components/ui/button";
-import { useTranslation } from "next-i18next";
-import getServerSideProps from "@/lib/client/getServerSideProps";
-import { useUser } from "@linkwarden/router/user";
-
-export default function Delete() {
- const [password, setPassword] = useState("");
- const [comment, setComment] = useState<string>();
- const [feedback, setFeedback] = useState<string>();
- const [submitLoader, setSubmitLoader] = useState(false);
- const { data } = useSession();
- const { t } = useTranslation();
- const { data: user } = useUser();
-
- const submit = async () => {
- const body = {
- password,
- cancellation_details: {
- comment,
- feedback,
- },
- };
-
- if (password === "") {
- return toast.error(t("fill_required_fields"));
- }
-
- setSubmitLoader(true);
- const load = toast.loading(t("deleting_message"));
-
- const response = await fetch(`/api/v1/users/${data?.user.id}`, {
- method: "DELETE",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(body),
- });
-
- const message = (await response.json()).response;
-
- toast.dismiss(load);
-
- if (response.ok) {
- signOut();
- } else {
- toast.error(message);
- }
-
- setSubmitLoader(false);
- };
-
- return (
- <CenteredForm>
- <div className="mx-auto flex flex-col gap-3 justify-between max-w-[30rem] min-w-80">
- <div className="flex items-center gap-2 w-full rounded-md h-8 relative">
- <Button
- asChild
- variant="ghost"
- size="icon"
- className="absolute top-0 left-0"
- >
- <Link href="/settings/account">
- <i className="bi-chevron-left text-neutral text-xl"></i>
- </Link>
- </Button>
- <p className="text-red-500 dark:text-red-500 truncate w-full text-2xl text-center">
- {t("delete_account")}
- </p>
- </div>
-
- <p>{t("delete_warning")}</p>
-
- {user?.subscription?.active &&
- user.subscription.provider === "APPLE" && (
- <p className="text-sm border border-primary rounded-md p-2">
- {t("delete_account_apple_subscription_notice")}{" "}
- <a
- className="underline"
- href="https://apps.apple.com/account/subscriptions"
- target="_blank"
- rel="noreferrer"
- >
- {t("manage_subscriptions")}
- </a>
- </p>
- )}
-
- {user?.subscription?.active &&
- user.subscription.provider === "GOOGLE" && (
- <p className="text-sm border border-primary rounded-md p-2">
- {t("delete_account_google_subscription_notice")}
- </p>
- )}
-
- <div>
- <TextInput
- value={password}
- onChange={(e) => setPassword(e.target.value)}
- placeholder={t("confirm_password")}
- className="bg-base-100"
- type="password"
- />
- </div>
-
- {process.env.NEXT_PUBLIC_STRIPE && !user?.parentSubscriptionId && (
- <fieldset className="border rounded-md p-2 border-primary">
- <legend className="px-3 py-1 text-sm sm:text-base border rounded-md border-primary">
- <b>{t("optional")}</b> <i>{t("feedback_help")}</i>
- </legend>
- <label className="w-full flex min-[430px]:items-center items-start gap-2 mb-3 min-[430px]:flex-row flex-col">
- <p className="text-sm">{t("reason_for_cancellation")}:</p>
- <select
- className="rounded-md p-1 outline-none"
- value={feedback}
- onChange={(e) => setFeedback(e.target.value)}
- >
- <option value={undefined}>{t("please_specify")}</option>
- <option value="customer_service">
- {t("customer_service")}
- </option>
- <option value="low_quality">{t("low_quality")}</option>
- <option value="missing_features">
- {t("missing_features")}
- </option>
- <option value="switched_service">
- {t("switched_service")}
- </option>
- <option value="too_complex">{t("too_complex")}</option>
- <option value="too_expensive">{t("too_expensive")}</option>
- <option value="unused">{t("unused")}</option>
- <option value="other">{t("other")}</option>
- </select>
- </label>
- <div>
- <p className="text-sm mb-2">{t("more_information")}</p>
-
- <textarea
- value={comment}
- onChange={(e) => setComment(e.target.value)}
- placeholder={t("feedback_placeholder")}
- className="resize-none w-full rounded-md p-2 border-neutral-content bg-base-100 focus:border-sky-300 dark:focus:border-sky-600 border-solid border outline-none duration-100"
- />
- </div>
- </fieldset>
- )}
-
- <Button
- className="mx-auto"
- variant="destructive"
- disabled={submitLoader}
- onClick={submit}
- >
- <p className="text-center w-full">{t("delete_your_account")}</p>
- </Button>
- </div>
- </CenteredForm>
- );
-}
-
-export { getServerSideProps };
diff --git a/apps/web/public/locales/en/common.json b/apps/web/public/locales/en/common.json
index 88bb9198..91407bd9 100644
--- a/apps/web/public/locales/en/common.json
+++ b/apps/web/public/locales/en/common.json
@@ -133,9 +133,8 @@
"fill_required_fields": "Please fill the required fields.",
"deleting_message": "Deleting everything, please wait...",
"delete_warning": "This will permanently delete all the Links, Collections, Tags, and archived data you own. It will also log you out. This action is irreversible!",
- "delete_account_apple_subscription_notice": "Deleting your account won't cancel your App Store subscription. To stop future charges, cancel it from your Apple ID's subscription settings.",
+ "delete_account_apple_subscription_notice": "Note: Deleting your account will not cancel your App Store subscription. To avoid future charges, cancel the subscription in your Apple ID settings or use the following link.",
"delete_account_google_subscription_notice": "Your Google Play subscription's auto-renewal will be cancelled automatically when your account is deleted.",
- "manage_subscriptions": "Manage subscriptions",
"optional": "Optional",
"feedback_help": "(but it really helps us improve!)",
"reason_for_cancellation": "Reason for cancellation",