mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
Enhance AddressFormContent with additional ID types and update ProfilePage to optimize user profile update handling
This commit is contained in:
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user