Skip to content

Commit ad3171a

Browse files
committed
feat(register): support for birthday
1 parent 4bc9c64 commit ad3171a

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

.changes/birthday.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"algohub": patch:feat
3+
---
4+
5+
Support for Birthday datetime picker in the register page.

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/views/signup.vue

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,16 @@ const sexOptions = [
153153
{ name: 'Female', value: false },
154154
]
155155
156-
interface UpdateProfileForm<T, S> {
156+
interface UpdateProfileForm<T, S, D> {
157157
nickname?: T;
158158
signature?: T;
159159
sex?: S;
160-
birthday?: T;
160+
birthday?: D;
161161
avatar?: T;
162162
}
163163
164-
const updateProfileResolver = ({ values }: { values: UpdateProfileForm<string, boolean> }) => {
165-
const errors: UpdateProfileForm<{ message: string }[], { message: string }[]> = {};
164+
const updateProfileResolver = ({ values }: { values: UpdateProfileForm<string, boolean, Date> }) => {
165+
const errors: UpdateProfileForm<{ message: string }[], { message: string }[], { message: string }[]> = {};
166166
167167
if (values.nickname && values.nickname.length > 16) {
168168
errors.nickname = [{ message: "Nickname is too long (16 characters max)." }]
@@ -174,7 +174,7 @@ const updateProfileResolver = ({ values }: { values: UpdateProfileForm<string, b
174174
175175
const onUpdateProfile = async ({ valid, states }: {
176176
valid: boolean,
177-
states: UpdateProfileForm<Ref<string>, Ref<boolean>>
177+
states: UpdateProfileForm<Ref<string>, Ref<boolean>, Ref<Date>>
178178
}) => {
179179
if (!valid) return;
180180
@@ -186,21 +186,22 @@ const onUpdateProfile = async ({ valid, states }: {
186186
nickname: states.nickname!.value,
187187
signature: states.signature!.value,
188188
sex: states.sex!.value,
189-
// birthday: states.birthday!.value,
189+
birthday: states.birthday!.value.toISOString().replace('Z', ''),
190190
avatar: accountStore.account!.avatar,
191191
}
192192
})
193193
if (!res.success) {
194-
toast.add({ severity: "error", summary: "Update failed", detail: res.message });
195-
} else {
196-
toast.add({ severity: "success", summary: "Profile updated", detail: "Your profile has been updated.", life: 3000 });
197-
accountStore.mergeProfile({
198-
nickname: states.nickname!.value,
199-
signature: states.signature!.value,
200-
sex: states.sex!.value,
201-
// birthday: states.birthday!.value,
202-
})
194+
inProgress.value = false;
195+
return toast.add({ severity: "error", summary: "Update failed", detail: res.message });
203196
}
197+
toast.add({ severity: "success", summary: "Profile updated", detail: "Your profile has been updated.", life: 3000 });
198+
accountStore.mergeProfile({
199+
nickname: states.nickname!.value,
200+
signature: states.signature!.value,
201+
sex: states.sex!.value,
202+
birthday: states.birthday!.value.toISOString().replace('Z', ''),
203+
})
204+
204205
inProgress.value = false;
205206
206207
activeStep.value = "3";
@@ -394,7 +395,7 @@ const path = [
394395
$form.sex.error.message }}</Message>
395396
</div>
396397
<div class="flex flex-col gap-1 w-full">
397-
<InputText name="birthday" type="text" placeholder="Birthday" fluid :disabled="true" />
398+
<DatePicker name="birthday" placeholder="Birthday" fluid />
398399
<Message v-if="$form.birthday?.invalid" severity="error" size="small" variant="simple">{{
399400
$form.birthday.error.message }}</Message>
400401
</div>

0 commit comments

Comments
 (0)