Skip to content

Commit

Permalink
fix: update auth user permissions after project group deleted gf-585
Browse files Browse the repository at this point in the history
  • Loading branch information
GvoFor committed Sep 28, 2024
1 parent 2c82f82 commit 020e7ad
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/frontend/src/modules/project-groups/slices/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
type AsyncThunkConfig,
type PaginationQueryParameters,
} from "~/libs/types/types.js";
import { actions as authActions } from "~/modules/auth/auth.js";
import {
type UserGetAllQueryParameters,
type UserGetAllResponseDto,
Expand Down Expand Up @@ -40,7 +41,7 @@ const loadAllByProjectId = createAsyncThunk<

const deleteById = createAsyncThunk<boolean, { id: number }, AsyncThunkConfig>(
`${sliceName}/delete-by-id`,
async ({ id }, { extra }) => {
async ({ id }, { dispatch, extra }) => {
const { projectGroupApi, toastNotifier } = extra;

const isDeleted = await projectGroupApi.deleteById(id);
Expand All @@ -49,6 +50,7 @@ const deleteById = createAsyncThunk<boolean, { id: number }, AsyncThunkConfig>(
toastNotifier.showSuccess(
NotificationMessage.PROJECT_GROUP_DELETE_SUCCESS,
);
void dispatch(authActions.getAuthenticatedUser());
}

return isDeleted;
Expand All @@ -59,12 +61,13 @@ const create = createAsyncThunk<
ProjectGroupGetAllItemResponseDto,
ProjectGroupCreateRequestDto,
AsyncThunkConfig
>(`${sliceName}/create`, async (payload, { extra }) => {
>(`${sliceName}/create`, async (payload, { dispatch, extra }) => {
const { projectGroupApi, toastNotifier } = extra;

const response = await projectGroupApi.create(payload);

toastNotifier.showSuccess(NotificationMessage.PROJECT_GROUP_CREATE_SUCCESS);
void dispatch(authActions.getAuthenticatedUser());

return response;
});
Expand All @@ -73,12 +76,13 @@ const patch = createAsyncThunk<
ProjectGroupGetAllItemResponseDto,
{ id: number; payload: ProjectGroupPatchRequestDto },
AsyncThunkConfig
>(`${sliceName}/update`, async ({ id, payload }, { extra }) => {
>(`${sliceName}/update`, async ({ id, payload }, { dispatch, extra }) => {
const { projectGroupApi, toastNotifier } = extra;

const response = await projectGroupApi.patch(id, payload);

toastNotifier.showSuccess(NotificationMessage.PROJECT_GROUP_UPDATE_SUCCESS);
void dispatch(authActions.getAuthenticatedUser());

return response;
});
Expand Down

0 comments on commit 020e7ad

Please sign in to comment.