Enhance AddressFormContent with additional ID types and update ProfilePage to optimize user profile update handling

This commit is contained in:
estifanos
2026-08-08 07:55:07 +00:00
parent 56de3727fa
commit fdcdd9fd13
2 changed files with 11 additions and 6 deletions

View File

@@ -31,10 +31,13 @@ export const addressSchema = z.object({
export type AddressValues = z.infer<typeof addressSchema>;
// 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;
/**

View File

@@ -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);