From e1e02a6dbce361d310b1d40ea181f9fa16f21198 Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Thu, 19 Oct 2023 13:26:40 +0200 Subject: [PATCH] fix: being able to set birthday into the future --- packages/frontend/src/components/MkInput.vue | 2 +- .../frontend/src/pages/settings/profile.vue | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/components/MkInput.vue b/packages/frontend/src/components/MkInput.vue index a51a97efe..9918a3ff6 100644 --- a/packages/frontend/src/components/MkInput.vue +++ b/packages/frontend/src/components/MkInput.vue @@ -62,7 +62,7 @@ const props = defineProps<{ step?: any; datalist?: string[]; min?: number; - max?: number; + max?: number | string; inline?: boolean; debounce?: boolean; manualSave?: boolean; diff --git a/packages/frontend/src/pages/settings/profile.vue b/packages/frontend/src/pages/settings/profile.vue index 6d557aced..10705cfa0 100644 --- a/packages/frontend/src/pages/settings/profile.vue +++ b/packages/frontend/src/pages/settings/profile.vue @@ -28,7 +28,7 @@ SPDX-License-Identifier: AGPL-3.0-only - + @@ -134,6 +134,14 @@ const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.d const reactionAcceptance = computed(defaultStore.makeGetterSetter('reactionAcceptance')); +const now = new Date(); + +const setMaxBirthDate = () => { + const y = now.getFullYear(); + + return `${y}-12-31`; +}; + const profile = reactive({ name: $i.name, description: $i.description, @@ -178,6 +186,13 @@ function saveFields() { } function save() { + if (profile.birthday && profile.birthday > setMaxBirthDate()) { + os.alert({ + type: 'warning', + text: 'You can\'t set your birthday to the future', + }); + return undefined; + } os.apiWithDialog('i/update', { // 空文字列をnullにしたいので??は使うな // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing