From fdcdd9fd13bfdfe63f5aea2a44cc9bc0d51ff4a2 Mon Sep 17 00:00:00 2001 From: estifanos Date: Sat, 8 Aug 2026 07:55:07 +0000 Subject: [PATCH] Enhance AddressFormContent with additional ID types and update ProfilePage to optimize user profile update handling --- .../features/profile/components/AddressFormContent.tsx | 7 +++++-- .../src/app/features/profile/pages/ProfilePage.tsx | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/portal/src/app/features/profile/components/AddressFormContent.tsx b/apps/portal/src/app/features/profile/components/AddressFormContent.tsx index a07c8aa49..33f5cd4ff 100644 --- a/apps/portal/src/app/features/profile/components/AddressFormContent.tsx +++ b/apps/portal/src/app/features/profile/components/AddressFormContent.tsx @@ -31,10 +31,13 @@ export const addressSchema = z.object({ export type AddressValues = z.infer; +// Backend rejects anything outside this set: +// "idType must be one of the following values: NID, VITAL, PASSPORT, DRIVERS_LICENSE" export const ID_TYPES = [ - { value: 'KEBELE_ID', label: 'Kebele Id' }, - { value: 'PASSPORT', label: 'Passport' }, { value: 'NID', label: 'National Id' }, + { value: 'VITAL', label: 'Vital ID' }, + { value: 'PASSPORT', label: 'Passport' }, + { value: 'DRIVERS_LICENSE', label: "Driver's License" }, ] as const; /** diff --git a/apps/portal/src/app/features/profile/pages/ProfilePage.tsx b/apps/portal/src/app/features/profile/pages/ProfilePage.tsx index 2ac740812..fa4373973 100644 --- a/apps/portal/src/app/features/profile/pages/ProfilePage.tsx +++ b/apps/portal/src/app/features/profile/pages/ProfilePage.tsx @@ -271,7 +271,11 @@ export function ProfilePage() { const onSavePersonal = async (values: PersonalValues) => { setIsSavingProfile(true); try { - await updateTrigger({ + // The PATCH already returns the updated user — trusting it instead of + // an immediate follow-up GET avoids a read-after-write race where the + // GET can return pre-edit data and silently undo `setUser` below, + // which is why the change used to only show up after a re-login. + const updated = await updateTrigger({ url: '/auth/update-profile', method: 'PATCH', body: { @@ -282,9 +286,7 @@ export function ProfilePage() { }, }).unwrap(); - const me = await meTrigger({ url: '/auth/me', method: 'GET' }).unwrap(); - dispatch(setUser(me)); - + dispatch(setUser(updated)); notify.success(t('profile.profileUpdated')); } catch (e) { handleError(e);