Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

chore(DeleteAccount):restore-the-account-feedback-requirement

Aswin Asok2f523488201a
diff --git a/web/apps/photos/src/components/DeleteAccount.tsx b/web/apps/photos/src/components/DeleteAccount.tsx
index 1e918d360f..dc6b70ab38 100644
--- a/web/apps/photos/src/components/DeleteAccount.tsx
+++ b/web/apps/photos/src/components/DeleteAccount.tsx
@@ -116,7 +116,18 @@ const DeleteAccountDialogContents: React.FC<
const formik = useFormik<{ reason: DeleteReason | ""; feedback: string }>({
initialValues: { reason: "", feedback: "" },
- validate: ({ reason }) => (reason ? {} : { reason: t("required") }),
+ validate: ({ reason, feedback }) => {
+ if (!reason) return { reason: t("required") };
+ if (!feedback.trim().length) {
+ return {
+ feedback:
+ reason == "found_another_service"
+ ? t("feedback_required_found_another_service")
+ : t("feedback_required"),
+ };
+ }
+ return {};
+ },
onSubmit: async ({ reason, feedback }) => {
if (step == "reason") {
setStep("confirmation");
@@ -344,10 +355,23 @@ const DeleteAccountDialogContents: React.FC<
)}
</Stack>
<Stack sx={{ gap: "8px" }}>
- <Typography variant="small" sx={bodyFont}>
+ <Typography
+ variant="small"
+ sx={{
+ ...bodyFont,
+ display: "flex",
+ gap: "2px",
+ }}
+ >
{t(
"delete_account_additional_feedback_label",
)}
+ <Box
+ component="span"
+ sx={{ color: "critical.main" }}
+ >
+ {"*"}
+ </Box>
</Typography>
<TextField
variant="standard"
@@ -385,6 +409,19 @@ const DeleteAccountDialogContents: React.FC<
},
})}
/>
+ {formik.touched.feedback &&
+ formik.errors.feedback && (
+ <Typography
+ variant="small"
+ sx={{
+ ...bodyFont,
+ px: 1,
+ color: "critical.main",
+ }}
+ >
+ {formik.errors.feedback}
+ </Typography>
+ )}
</Stack>
</Stack>
) : (
diff --git a/web/packages/new/photos/services/user.ts b/web/packages/new/photos/services/user.ts
index 28aff9f4d6..6492a30cde 100644
--- a/web/packages/new/photos/services/user.ts
+++ b/web/packages/new/photos/services/user.ts
@@ -47,21 +47,26 @@ const DeleteChallengeResponse = z.object({
encryptedChallenge: z.string().nullish().transform(nullToUndefined),
});
+export interface AccountDeletionSummary {
+ photosAndVideosCount: number;
+ authenticatorCodesCount: number;
+ lockerRecordsCount: number;
+}
+
const AccountDeletionSummary = z.object({
photosAndVideosCount: z.number().int(),
authenticatorCodesCount: z.number().int(),
lockerRecordsCount: z.number().int(),
});
-export type AccountDeletionSummary = z.infer<typeof AccountDeletionSummary>;
-
-export const getAccountDeletionSummary = async () => {
- const res = await fetch(await apiURL("/users/deletion-summary"), {
- headers: await authenticatedRequestHeaders(),
- });
- ensureOk(res);
- return AccountDeletionSummary.parse(await res.json());
-};
+export const getAccountDeletionSummary =
+ async (): Promise<AccountDeletionSummary> => {
+ const res = await fetch(await apiURL("/users/deletion-summary"), {
+ headers: await authenticatedRequestHeaders(),
+ });
+ ensureOk(res);
+ return AccountDeletionSummary.parse(await res.json());
+ };
export const getAccountDeleteChallenge = async () => {
const res = await fetch(await apiURL("/users/delete-challenge"), {