feat: add account type synchronization to operations form based on selected license types

This commit is contained in:
estifanos
2026-08-18 11:23:30 +00:00
parent 581eac7466
commit 2257989821
3 changed files with 57 additions and 3 deletions

View File

@@ -37,6 +37,7 @@ export {
useGetMyProfileQuery,
useUpdateMyProfileMutation,
useUpdateMyAddressMutation,
useUpdateMyAccountTypeMutation,
PROFILE_FIELDS,
PROFILE_FIELD_SECTION,
} from "./lib/hooks/useCurrentProfile";

View File

@@ -119,6 +119,22 @@ const profileApi = baseApi
query: ({ id, body }) => ({ url: `/profiles/${id}`, method: 'PUT', body }),
invalidatesTags: ['CurrentProfile'],
}),
/**
* The portal role — seafarer, vessel owner or logistics operator.
*
* Sidebar and route permissions are computed from this server-side
* (`profiles.type`), not from the declared modes of operation, so the
* Operations tab writes it here too. Invalidates the profile so the
* shell repermissions itself without a reload.
*/
updateMyAccountType: builder.mutation<unknown, { type: string }>({
query: (body) => ({
url: '/profiles/me/account-type',
method: 'PUT',
body,
}),
invalidatesTags: (_result, error) => (error ? [] : ['CurrentProfile']),
}),
updateMyAddress: builder.mutation<
unknown,
{ id: string; body: Record<string, unknown> }
@@ -134,6 +150,7 @@ export const {
useGetMyProfileQuery,
useUpdateMyProfileMutation,
useUpdateMyAddressMutation,
useUpdateMyAccountTypeMutation,
} = profileApi;
export const currentProfileApi = profileApi;