From 451f2297fdd251d9a68db58530f071c844f32428 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 28 Jan 2024 00:13:51 +0100 Subject: [PATCH] delete account --- public/locales/de/translation.json | 37 ++++++-- public/locales/en/translation.json | 37 ++++++-- src/Components/MyModal/index.js | 2 + src/Pages/Store/Calendar/index.js | 10 +-- src/Pages/UserProfile/index.js | 139 ++++++++++++++++++++++++++++- src/utils.js | 13 ++- 6 files changed, 212 insertions(+), 26 deletions(-) diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 6d2cb02..6760a2d 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -67,6 +67,10 @@ "failedInternetProblem": { "title": "Anfrage fehlgeschlagen", "description": "Bitte überprüfen Sie Ihre Internetverbindung und versuchen Sie es erneut." + }, + "passwordIncorrect": { + "title": "Passwort falsch", + "description": "Bitte überprüfen Sie Ihr Passwort und versuchen Sie es erneut." } } }, @@ -214,13 +218,7 @@ "title": "Google Kalender trennen", "description": "Aus Sicherheitsgründen müssen Sie Ihr Passwort eingeben, um die Verbindung zu Ihrem Google Kalender zu trennen.", "checkboxDeleteCalendars": "Kalender für Öffnungszeiten und Termine löschen (Alle Termine werden gelöscht und können nicht wiederhergestellt werden)", - "button": "Google Kalender trennen", - "request": { - "400": { - "title": "Passwort ungültig", - "description": "Bitte überprüfen Sie Ihr Passwort und versuchen Sie es erneut." - } - } + "button": "Google Kalender trennen" }, "calendarFrameCustomerView": "Terminkalenderansicht der Kunden" }, @@ -283,7 +281,30 @@ } }, "deleteAccount": { - "cardTitle": "Konto löschen" + "cardTitle": "Konto löschen", + "info": "Ihr Konto und alle Ihre Daten endgültig löschen.", + "button": "Konto löschen", + "modal": { + "title": "Konto löschen", + "info": "Ihr Konto wird sofort deaktiviert und nach {{days}} Tagen gelöscht. Während dieser Zeit können Sie Ihr Konto wiederherstellen, indem Sie sich erneut anmelden.", + "why": "Warum löschen Sie Ihr Konto?", + "whyRuleRequired": "Bitte wählen Sie einen Grund", + "radioOptions": { + "notNeeded": "Ich benötige es nicht mehr", + "notUseful": "Ich finde es nicht nützlich", + "other": "Sonstiges" + }, + "improveLabel": "Wie können wir das Produkt verbessern?", + "improveRequired": "Bitte geben Sie Ihr Feedback ein", + "improveMinLengthRequired": "Bitte geben Sie mindestens {{minLength}} Zeichen ein", + "button": "Konto löschen", + "request": { + "400": { + "title": "Passwort falsch", + "description": "Bitte überprüfen Sie Ihr Passwort und versuchen Sie es erneut." + } + } + } } } } diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 6a2b669..7456518 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -67,6 +67,10 @@ "failedInternetProblem": { "title": "Request failed", "description": "The request failed. Please check your internet connection and try again." + }, + "passwordIncorrect": { + "title": "Password incorrect", + "description": "Please check your password and try again." } } }, @@ -217,13 +221,7 @@ "title": "Unlink Google Calendar", "description": "For security reasons, you need to enter your password to unlink your Google Calendar.", "checkboxDeleteCalendars": "Delete calendar for opening hours and appointments (all appointments are deleted and cannot be restored)", - "button": "Unlink Google Calendar", - "request": { - "400": { - "title": "Password incorrect", - "description": "Please check your password and try again." - } - } + "button": "Unlink Google Calendar" }, "calendarFrameCustomerView": "Appointment diary view of customers" }, @@ -292,7 +290,30 @@ } }, "deleteAccount": { - "cardTitle": "Delete account" + "cardTitle": "Delete account", + "info": "Permanently delete your account and all your data.", + "button": "Delete account", + "modal": { + "title": "Delete account", + "info": "Your account will be deactivated immediately and deleted after {{days}} days. During this time, you can restore your account by logging in again.", + "why": "Why are you deleting your account?", + "whyRuleRequired": "Please select a reason", + "radioOptions": { + "notNeeded": "I don't need it anymore", + "notUseful": "I don't find it useful", + "other": "Other" + }, + "improveLabel": "How can we improve the product?", + "improveRequired": "Please enter your feedback", + "improveMinLengthRequired": "Please enter at least {{minLength}} characters", + "button": "Delete account", + "request": { + "400": { + "title": "Password incorrect", + "description": "Please check your password and try again." + } + } + } } } } diff --git a/src/Components/MyModal/index.js b/src/Components/MyModal/index.js index 7840153..e1f0343 100644 --- a/src/Components/MyModal/index.js +++ b/src/Components/MyModal/index.js @@ -108,6 +108,7 @@ export function MyModalCloseConfirmButtonFooter({ onCancel, onConfirm, isConfirmButtonLoading, + danger = false, }) { const { t } = useTranslation(); @@ -115,6 +116,7 @@ export function MyModalCloseConfirmButtonFooter({ <> + + + { + form + .validateFields() + .then((values) => { + setIsRequesting(true); + + myFetch({ + url: "/user/profile/delete", + method: "DELETE", + body: { + feedback: values.improve, + reason: values["deleteReason"], + password: EncodeStringToBase64(values.password), + }, + }) + .then(() => { + setIsRequesting(false); + + window.location.reload(); + }) + .catch((errStatus) => { + setIsRequesting(false); + + if (errStatus === 400) { + showPasswordIncorrectNotification(notificationApi, t); + } + }); + }) + .catch(() => setIsRequesting(false)); + }} + onCancel={handleModalClose} + /> + } + > +
+ + {t("userProfile.deleteAccount.modal.info", { + days: Constants.ACCOUNT_DELETED_AFTER_DAYS, + })} + + + + + + + {t("userProfile.deleteAccount.modal.radioOptions.notNeeded")} + + + {t("userProfile.deleteAccount.modal.radioOptions.notUseful")} + + + {t("userProfile.deleteAccount.modal.radioOptions.other")} + + + + + + + + + +
+ + ); } diff --git a/src/utils.js b/src/utils.js index df90e1b..597f11c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -68,10 +68,13 @@ export const Constants = { MAX_CALENDAR_FUTURE_BOOKING_DAYS: 365, MIN_CALENDAR_EARLIEST_BOOKING_TIME: 0, MAX_CALENDAR_EARLIEST_BOOKING_TIME: 60 * 24, // 24 hours in minutes + MIN_FEEDBACK_LENGTH: 10, + MAX_FEEDBACK_LENGTH: 1024, }, DELAY_ACCOUNT_NAME_CHECK: 250, CLARITY_PROJECT_ID: "kr0pale8uy", KK_JOBS_URL: "https://kk-innovation.eu/jobs/", + ACCOUNT_DELETED_AFTER_DAYS: 30, }; export const AppStyle = { @@ -247,8 +250,16 @@ export function showInputsInvalidNotification(notificationApi, t) { }); } +export function showPasswordIncorrectNotification(notificationApi, t) { + notificationApi["warning"]({ + message: t("common.request.passwordIncorrect.title"), + description: t("common.request.passwordIncorrect.description"), + }); +} + export function handleLogout({ setUserSession }) { - setUserSession(); + if (setUserSession !== undefined) setUserSession(); + window.location.href = "/"; }