mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-30 07:38:12 +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>;
|
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 = [
|
export const ID_TYPES = [
|
||||||
{ value: 'KEBELE_ID', label: 'Kebele Id' },
|
|
||||||
{ value: 'PASSPORT', label: 'Passport' },
|
|
||||||
{ value: 'NID', label: 'National Id' },
|
{ value: 'NID', label: 'National Id' },
|
||||||
|
{ value: 'VITAL', label: 'Vital ID' },
|
||||||
|
{ value: 'PASSPORT', label: 'Passport' },
|
||||||
|
{ value: 'DRIVERS_LICENSE', label: "Driver's License" },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -271,7 +271,11 @@ export function ProfilePage() {
|
|||||||
const onSavePersonal = async (values: PersonalValues) => {
|
const onSavePersonal = async (values: PersonalValues) => {
|
||||||
setIsSavingProfile(true);
|
setIsSavingProfile(true);
|
||||||
try {
|
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',
|
url: '/auth/update-profile',
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
body: {
|
body: {
|
||||||
@@ -282,9 +286,7 @@ export function ProfilePage() {
|
|||||||
},
|
},
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
|
|
||||||
const me = await meTrigger({ url: '/auth/me', method: 'GET' }).unwrap();
|
dispatch(setUser(updated));
|
||||||
dispatch(setUser(me));
|
|
||||||
|
|
||||||
notify.success(t('profile.profileUpdated'));
|
notify.success(t('profile.profileUpdated'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError(e);
|
handleError(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user