Skip to content

Commit 90c6f8b

Browse files
committed
bugfix(modeling-commons): Favor UInput[type='date'] over UInputDate
1 parent fffcbb9 commit 90c6f8b

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

apps/modeling-commons-frontend/app/composables/user/useProfileSettings.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,11 @@ function normalizeUserKind(value: string | undefined | null): NonNullable<UserKi
1919
return "other";
2020
}
2121

22-
function toDate(value: unknown): Date | null {
22+
function toDateString(value: unknown): string | null {
2323
if (!value) return null;
24-
if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : value;
25-
if (typeof value === "string" || typeof value === "number") {
26-
const d = new Date(value);
27-
return Number.isNaN(d.getTime()) ? null : d;
28-
}
29-
return null;
30-
}
31-
32-
function sameDay(a: Date | null, b: Date | null): boolean {
33-
if (!a && !b) return true;
34-
if (!a || !b) return false;
35-
return a.getTime() === b.getTime();
24+
const d = value instanceof Date ? value : new Date(String(value));
25+
if (isNaN(d.getTime())) return null;
26+
return d.toISOString().split("T")[0] ?? null;
3627
}
3728

3829
function sameSocialLinks(a: Array<SocialMediaLink>, b: Array<SocialMediaLink>): boolean {
@@ -51,7 +42,7 @@ export default function useProfileSettings() {
5142

5243
const nameField = useTrackedField(() => profile.value?.name ?? "");
5344
const bioField = useTrackedField(() => profile.value?.bio ?? "");
54-
const dobField = useTrackedField(() => toDate(profile.value?.dob), sameDay);
45+
const dobField = useTrackedField(() => toDateString(profile.value?.dob));
5546
const socialLinksField = useTrackedField(
5647
() => (Array.isArray(profile.value?.socialLinks) ? profile.value?.socialLinks : []),
5748
sameSocialLinks,

apps/modeling-commons-frontend/app/pages/profile/(edit)/settings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</UFormField>
4747

4848
<UFormField label="Date of Birth">
49-
<UInputDate v-model="dob" size="md" />
49+
<UInput v-model="dob" type="date" size="md" />
5050
</UFormField>
5151

5252
<UFormField label="Country">

0 commit comments

Comments
 (0)