Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: validate max date when creating reminder (#9937)

01zulfi5ddf1eddf555
diff --git a/apps/web/src/dialogs/add-reminder-dialog.tsx b/apps/web/src/dialogs/add-reminder-dialog.tsx
index b90d52486..26fe0205a 100644
--- a/apps/web/src/dialogs/add-reminder-dialog.tsx
+++ b/apps/web/src/dialogs/add-reminder-dialog.tsx
@@ -48,6 +48,8 @@ import Skeleton from "react-loading-skeleton";
dayjs.extend(customParseFormat);
+const MAX_DATE = dayjs().add(99, "year").endOf("year").toDate();
+
export type AddReminderDialogProps = BaseDialogProps<boolean> & {
reminder?: Reminder;
note?: Note;
@@ -200,6 +202,14 @@ export const AddReminderDialog = DialogManager.register(
return;
}
+ if (mode !== Modes.REPEAT && date.isAfter(MAX_DATE)) {
+ showToast(
+ "error",
+ strings.maximumReminderDate(getFormattedDate(MAX_DATE, "date"))
+ );
+ return;
+ }
+
const id = await db.reminders.add({
id: reminder?.id,
recurringMode,
@@ -431,7 +441,7 @@ export const AddReminderDialog = DialogManager.register(
}}
selected={dayjs(date).toDate()}
minDate={new Date()}
- maxDate={new Date(new Date().getFullYear() + 99, 11, 31)}
+ maxDate={MAX_DATE}
onSelect={(day) => {
if (!day) return;
const date = getFormattedDate(day, "date");
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 21d9a834a..842f61e8a 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -3946,6 +3946,10 @@ msgstr "Math & formulas"
msgid "Maximize"
msgstr "Maximize"
+#: src/strings.ts:2698
+msgid "Maximum reminder date is {maxDate}"
+msgstr "Maximum reminder date is {maxDate}"
+
#: src/strings.ts:2080
msgid "Meet other privacy-minded people & talk to us directly about your concerns, issues and suggestions."
msgstr "Meet other privacy-minded people & talk to us directly about your concerns, issues and suggestions."
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index 5d6a9f43a..103ffefb4 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -3926,6 +3926,10 @@ msgstr ""
msgid "Maximize"
msgstr ""
+#: src/strings.ts:2698
+msgid "Maximum reminder date is {maxDate}"
+msgstr ""
+
#: src/strings.ts:2080
msgid "Meet other privacy-minded people & talk to us directly about your concerns, issues and suggestions."
msgstr ""
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index c247d490b..79024af1b 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -2693,5 +2693,7 @@ Continue without attachments?`,
expiryDateSet: () => t`Expiry date set`,
creationDateCannotBeAfterLastEditedDate: () =>
t`Creation date cannot be after last edited date`,
- noteDuplicated: () => t`Note duplicated`
+ noteDuplicated: () => t`Note duplicated`,
+ maximumReminderDate: (maxDate: string) =>
+ t`Maximum reminder date is ${maxDate}`
};