Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): User name is not updated after changing it in profile bb-375 #383

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions apps/frontend/src/modules/auth/slices/auth.slice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createSlice } from "@reduxjs/toolkit";
import { createSlice, type PayloadAction } from "@reduxjs/toolkit";

import { DataStatus } from "~/libs/enums/enums.js";
import { type ValueOf } from "~/libs/types/types.js";
Expand Down Expand Up @@ -84,7 +84,11 @@ const { actions, name, reducer } = createSlice({
},
initialState,
name: "auth",
reducers: {},
reducers: {
udpateAuthUser(state, action: PayloadAction<UserDto>) {
state.user = action.payload;
},
},
});

export { actions, name, reducer };
4 changes: 3 additions & 1 deletion apps/frontend/src/modules/users/slices/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createAsyncThunk } from "@reduxjs/toolkit";

import { NotificationMessage } from "~/libs/enums/enums.js";
import { type AsyncThunkConfig } from "~/libs/types/types.js";
import { actions as authActions } from "~/modules/auth/auth.js";
import {
type UserDto,
type UserGetParametersDto,
Expand Down Expand Up @@ -34,11 +35,12 @@ const saveNotificationAnswers = createAsyncThunk<

const update = createAsyncThunk<UserDto, UserUpdatePayload, AsyncThunkConfig>(
`${sliceName}/update`,
async (payload, { extra }) => {
async (payload, { dispatch, extra }) => {
const { notification, usersApi } = extra;
const { data, id } = payload;

const response = await usersApi.update(id, data);
dispatch(authActions.udpateAuthUser(response));
notification.success(NotificationMessage.PROFILE_UPDATED);

return response;
Expand Down
Loading