From c75eb7d9d4cb1b477f6427ad0366ab58177ba496 Mon Sep 17 00:00:00 2001 From: kirill-k88 Date: Thu, 27 Jun 2024 11:33:08 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=83=20=D1=81=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=BE=D0=B9=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=B0=D1=80=D0=BE=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=B8=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BA=20API.=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D1=83=20=D0=B8=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D1=83=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=83=D1=87=D0=B5?= =?UTF-8?q?=D1=82=D0=BD=D1=8B=D1=85=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreProvider/config/StateSchema.ts | 2 + .../providers/StoreProvider/config/store.ts | 4 +- src/app/router/AppRouter/ui/AppRouter.tsx | 5 + .../model/functions/sideBarOptions.ts | 2 +- .../ChangePasswordPage.module.scss | 33 ++++ .../ChangePasswordPage/ChangePasswordPage.tsx | 61 +++++++ src/shared/api/types.ts | 3 +- src/shared/config/routerConfig/routes.ts | 3 +- .../ChangePassword/ChangePassword.module.scss | 88 ++++++++++ src/widgets/ChangePassword/ChangePassword.tsx | 162 ++++++++++++++++++ .../model/constants/constants.ts | 3 + .../model/functions/functions.ts | 50 ++++++ .../scheme/changePasswordFormSliceScheme.ts | 15 ++ .../model/slice/changePasswordtFormSlice.ts | 56 ++++++ .../validation/changePasswordFormScheme.ts | 9 + src/widgets/EditAccount/EditAccount.tsx | 12 +- .../model/slice/editAccountFormSlice.ts | 2 +- 17 files changed, 504 insertions(+), 6 deletions(-) create mode 100644 src/pages/ChangePasswordPage/ChangePasswordPage.module.scss create mode 100644 src/pages/ChangePasswordPage/ChangePasswordPage.tsx create mode 100644 src/widgets/ChangePassword/ChangePassword.module.scss create mode 100644 src/widgets/ChangePassword/ChangePassword.tsx create mode 100644 src/widgets/ChangePassword/model/constants/constants.ts create mode 100644 src/widgets/ChangePassword/model/functions/functions.ts create mode 100644 src/widgets/ChangePassword/model/scheme/changePasswordFormSliceScheme.ts create mode 100644 src/widgets/ChangePassword/model/slice/changePasswordtFormSlice.ts create mode 100644 src/widgets/ChangePassword/model/validation/changePasswordFormScheme.ts diff --git a/src/app/providers/StoreProvider/config/StateSchema.ts b/src/app/providers/StoreProvider/config/StateSchema.ts index e077bc21..bb641a58 100644 --- a/src/app/providers/StoreProvider/config/StateSchema.ts +++ b/src/app/providers/StoreProvider/config/StateSchema.ts @@ -20,6 +20,7 @@ import type { IFeedbackSchema } from '@/features/Reviews/model/types/types' import { IEditAccountFormSchema } from '@/widgets/EditAccount/model/scheme/editAccountFormSliceScheme' import type { TNumberOfPageSchema } from '@/widgets/Pagination/types/types' import { ICreateAccountSchema } from '@/widgets/CreateAccount/model/types/types' +import { IChangePasswordFormSchema } from '@/widgets/ChangePassword/model/scheme/changePasswordFormSliceScheme' export interface StateSchema { aboutUs: IAboutUsSchema @@ -46,6 +47,7 @@ export interface StateSchema { pagination: TNumberOfPageSchema editAccount: IEditAccountFormSchema createAccount: ICreateAccountSchema + changePassword: IChangePasswordFormSchema } export interface ThunkExtraArg { diff --git a/src/app/providers/StoreProvider/config/store.ts b/src/app/providers/StoreProvider/config/store.ts index e313f133..f5615c2f 100644 --- a/src/app/providers/StoreProvider/config/store.ts +++ b/src/app/providers/StoreProvider/config/store.ts @@ -25,6 +25,7 @@ import { feedbacksReducer } from '@/features/Reviews/model/slice/feedbacksSlice' import { editAccountFormReducer } from '@/widgets/EditAccount/model/slice/editAccountFormSlice' import { paginationSliceReducer } from '@/widgets/Pagination/slice/paginationSlice' import { createAccountReducer } from '@/widgets/CreateAccount/model/slice/loginSlice' +import { changePasswordFormReducer } from '@/widgets/ChangePassword/model/slice/changePasswordtFormSlice' export type RootState = StateSchema @@ -52,7 +53,8 @@ const rootReducer: ReducersMapObject = { categoryFilters: categoryFiltersSliceReducer, pagination: paginationSliceReducer, editAccount: editAccountFormReducer, - createAccount: createAccountReducer + createAccount: createAccountReducer, + changePassword: changePasswordFormReducer } export function createReduxStore(initialState: RootState) { diff --git a/src/app/router/AppRouter/ui/AppRouter.tsx b/src/app/router/AppRouter/ui/AppRouter.tsx index 9f9c990e..bb9dc2d6 100644 --- a/src/app/router/AppRouter/ui/AppRouter.tsx +++ b/src/app/router/AppRouter/ui/AppRouter.tsx @@ -5,6 +5,7 @@ import { AccountPage } from '@/pages/AccountPage/AccountPage' import BlogPage from '@/pages/BlogPage/BlogPage' import CartPage from '@/pages/CartPage/CartPage' import { CategoryPage } from '@/pages/CategoryPage/CategoryPage' +import { ChangePasswordPage } from '@/pages/ChangePasswordPage/ChangePasswordPage' import ComparePage from '@/pages/ComparePage/ComparePage' import ContactsPage from '@/pages/ContactsPage/ContactsPage' import CreateAccountPage from '@/pages/CreateAccountPage/CreateAccountPage' @@ -170,6 +171,10 @@ export const AppRouter = createBrowserRouter([ { path: Routes.SHOP_NEWS, element: + }, + { + path: Routes.CHANGE_PASSWORD, + element: } /* { diff --git a/src/entities/SideBarEntity/model/functions/sideBarOptions.ts b/src/entities/SideBarEntity/model/functions/sideBarOptions.ts index 0399fe6b..343e6e40 100644 --- a/src/entities/SideBarEntity/model/functions/sideBarOptions.ts +++ b/src/entities/SideBarEntity/model/functions/sideBarOptions.ts @@ -6,7 +6,7 @@ const user = [ routes: [ { subtitle: 'Личный Кабинет', route: Routes.ACCOUNT }, { subtitle: 'Изменить контактную информацию', route: Routes.EDIT_ACCOUNT }, - { subtitle: 'Изменить свой пароль', route: Routes.HOME }, // '/change-password' - данного роута пока нет + { subtitle: 'Изменить свой пароль', route: Routes.CHANGE_PASSWORD }, { subtitle: 'Изменить мои адреса', route: Routes.HOME }, // '/address-book' - данного роута пока нет { subtitle: 'Посмотреть закладки', route: Routes.FAVORITES } ] diff --git a/src/pages/ChangePasswordPage/ChangePasswordPage.module.scss b/src/pages/ChangePasswordPage/ChangePasswordPage.module.scss new file mode 100644 index 00000000..5c3eb1b3 --- /dev/null +++ b/src/pages/ChangePasswordPage/ChangePasswordPage.module.scss @@ -0,0 +1,33 @@ +@use '../../shared/styles/utils/mixins' as media; +@use '../../shared/styles/utils/variables' as color; + +.changePasswordPage { + width: 100%; + + &__pageDescriptor { + width: 100%; + display: flex; + flex-direction: column; + gap: 10px; + } + + &__container { + width: 100%; + display: flex; + justify-content: start; + align-items: start; + gap: 20px; + + @include media.respond-to('large') { + flex-direction: column; + gap: 10px; + } + } + + &__contentContainer { + width: 100%; + display: flex; + flex-direction: column; + gap: 50px; + } +} diff --git a/src/pages/ChangePasswordPage/ChangePasswordPage.tsx b/src/pages/ChangePasswordPage/ChangePasswordPage.tsx new file mode 100644 index 00000000..621b6cf8 --- /dev/null +++ b/src/pages/ChangePasswordPage/ChangePasswordPage.tsx @@ -0,0 +1,61 @@ +import { FC, Suspense, useState } from 'react' + +import SideBarMenuModal from '@/features/SideBarMenuModal' +import { Routes } from '@/shared/config/routerConfig/routes' +import { useResize } from '@/shared/libs/hooks/useResize' +import Breadcrumbs from '@/shared/ui/Breadcrumbs/Breadcrumbs' +import Heading from '@/shared/ui/Heading/Heading' +import Modal from '@/shared/ui/Modal/Modal' +import Spinner from '@/shared/ui/Spinner/Spinner' +import WrapperForMainContent from '@/shared/ui/WrapperForMainContent/WrapperForMainContent' +import { ChangePassword } from '@/widgets/ChangePassword/ChangePassword' +import { withAdaptiveSideBar } from '@/widgets/SideBarMenu' + +import styles from './ChangePasswordPage.module.scss' + +const links = [ + { heading: 'Главная', href: '/' }, + { heading: 'Личный Кабинет', href: Routes.ACCOUNT }, + { heading: 'Изменить пароль', href: '' } +] + +export const ChangePasswordPage: FC = () => { + const { isScreenLg } = useResize() + const [isModalOpen, setIsModalOpen] = useState(false) + const [isModalClosing, setIsModalClosing] = useState(false) + const AdaptiveSideBar = withAdaptiveSideBar(isScreenLg) + + const handleClick = () => { + setIsModalOpen(true) + } + + const changeModalState = () => { + setIsModalOpen(!isModalOpen) + } + + return ( + +
+ Изменить пароль + +
+
+ +
+ +
+
+ {isModalOpen && ( + + }> + + + + )} +
+ ) +} diff --git a/src/shared/api/types.ts b/src/shared/api/types.ts index f7114a08..da4544fa 100644 --- a/src/shared/api/types.ts +++ b/src/shared/api/types.ts @@ -19,7 +19,8 @@ export enum ApiRoutes { RENEW_PRODUCT_AMOUNT = 'cart/', USER = 'users/me', UPDATE_PROFILE = 'update-profile', - CREATE_ACCOUNT = 'users' + CREATE_ACCOUNT = 'users', + CHANGE_PASSWORD = 'users/set_password' } export enum ApiErrorTypes { diff --git a/src/shared/config/routerConfig/routes.ts b/src/shared/config/routerConfig/routes.ts index ae6f017b..7dc5fbda 100644 --- a/src/shared/config/routerConfig/routes.ts +++ b/src/shared/config/routerConfig/routes.ts @@ -34,5 +34,6 @@ export enum Routes { ERROR = '*', CREATE_ACCOUNT_SUCCESS = '/success', NEWSLETTER = '/newsletter', - SHOP_NEWS = '/shopnews' + SHOP_NEWS = '/shopnews', + CHANGE_PASSWORD = '/change-password' } diff --git a/src/widgets/ChangePassword/ChangePassword.module.scss b/src/widgets/ChangePassword/ChangePassword.module.scss new file mode 100644 index 00000000..e54a8975 --- /dev/null +++ b/src/widgets/ChangePassword/ChangePassword.module.scss @@ -0,0 +1,88 @@ +@use '../../shared/styles/utils/variables' as color; + +@mixin font($size) { + font-size: $size; + font-weight: 500; + line-height: 1.5; +} + +.changePasswordform { + width: 100%; + min-height: 400px; + padding: 30px; + display: flex; + flex-direction: column; + align-items: flex-start; + justify-content: flex-start; + gap: 20px; + background-color: color.$white; + border-radius: 5px; + + &__header { + font-size: 20px; + line-height: 1; + font-weight: 700; + } + + &__form { + width: 100%; + display: flex; + flex-direction: column; + align-items: flex-start; + justify-content: flex-start; + gap: 20px; + } + + &__label { + width: 100%; + display: flex; + flex-direction: column; + gap: 10px; + } + + &__fieldlabel { + @include font(14px); + } + + &__field { + width: 100%; + padding: 10px 16px; + border: none; + outline: none; + background-color: color.$body-bg; + border-radius: 5px; + box-shadow: none; + @include font(14px); + + transition: box-shadow 0.5s; + + &:focus { + box-shadow: 0 0 0 2px color.$theme-primary-color; + } + + &_textfield { + min-height: 100px; + } + } + + &__btnConteiner { + width: 50%; + display: flex; + gap: 10px; + } + + &__submitbtn { + width: 100%; + transition: opacity 0.5s; + + &:hover { + opacity: 0.8; + } + } + + &__msg { + font-size: 18px; + line-height: 25px; + font-weight: 400; + } +} diff --git a/src/widgets/ChangePassword/ChangePassword.tsx b/src/widgets/ChangePassword/ChangePassword.tsx new file mode 100644 index 00000000..a47d832e --- /dev/null +++ b/src/widgets/ChangePassword/ChangePassword.tsx @@ -0,0 +1,162 @@ +import { Field, Form, Formik, FormikHelpers } from 'formik' +import { useEffect, useState, type FC } from 'react' +import { useSelector } from 'react-redux' +import { useNavigate } from 'react-router' + +import { StateSchema } from '@/app/providers/StoreProvider' +import { RequiredFieldTitle } from '@/features/RequiredFieldTitle/RequiredFieldTitle' +import { Routes } from '@/shared/config/routerConfig/routes' +import { useAppDispatch } from '@/shared/libs/hooks/store' +import { Button, ButtonSize, ButtonTheme } from '@/shared/ui/Button/Button' +import { FormMsg } from '@/shared/ui/FormMsg/FormMsg' +import Heading from '@/shared/ui/Heading/Heading' + +import styles from './ChangePassword.module.scss' +import { SECCEED_SUBMIT_MESSAGE } from './model/constants/constants' +import { getErrorText, getQueryErrorText, hasErrors } from './model/functions/functions' +import { IChangePasswordForm } from './model/scheme/changePasswordFormSliceScheme' +import { changePasswordFormActions, postNewPassword } from './model/slice/changePasswordtFormSlice' +import { changePasswordFormScheme } from './model/validation/changePasswordFormScheme' + +export const ChangePassword: FC = () => { + const navigate = useNavigate() + const [showMsg, setShowMsg] = useState(false) + const [showApiErrorMsg, setShowApiErrorMsg] = useState(false) + const dispatch = useAppDispatch() + const changePasswordForm = useSelector((store: StateSchema) => store.changePassword) + + const onMsgClose = () => { + dispatch(changePasswordFormActions.reset()) + setShowMsg(false) + } + + const onErrorMsgClose = () => { + setShowApiErrorMsg(false) + } + + useEffect(() => { + if (changePasswordForm.isSuccess && !changePasswordForm.isLoading && changePasswordForm.error === null) { + setShowMsg(true) + } + + if (changePasswordForm.error) { + setShowApiErrorMsg(true) + } + }, [changePasswordForm.isLoading, changePasswordForm.error, changePasswordForm.isSuccess]) + + const onSubmit = async (values: IChangePasswordForm, formikHelpers: FormikHelpers) => { + const { current_password, new_password } = values + const result = await dispatch(postNewPassword({ current_password, new_password })) + if (result.meta.requestStatus === 'fulfilled') { + formikHelpers.setErrors({}) + setShowMsg(true) + } + } + + const backBtnClickHandle = () => { + navigate(Routes.ACCOUNT) + } + + return ( +
+ Пароль + + {({ errors, touched, isSubmitting }) => { + return ( +
+ + + + + + + {hasErrors(errors, touched) && ( + + )} + + {!isSubmitting && showApiErrorMsg && ( + + )} + + {!isSubmitting && showMsg && ( + + )} + +
+ + + +
+ + ) + }} +
+
+ ) +} diff --git a/src/widgets/ChangePassword/model/constants/constants.ts b/src/widgets/ChangePassword/model/constants/constants.ts new file mode 100644 index 00000000..e7a34ceb --- /dev/null +++ b/src/widgets/ChangePassword/model/constants/constants.ts @@ -0,0 +1,3 @@ +export const SECCEED_SUBMIT_MESSAGE = 'Ваш пароль был успешно обновлен!' + +export const UNSECCEED_SUBMIT_MESSAGE = 'Ошибка при отправке данных на сервер!' diff --git a/src/widgets/ChangePassword/model/functions/functions.ts b/src/widgets/ChangePassword/model/functions/functions.ts new file mode 100644 index 00000000..d4b2db3c --- /dev/null +++ b/src/widgets/ChangePassword/model/functions/functions.ts @@ -0,0 +1,50 @@ +import { FormikErrors } from 'formik' + +import type { ApiErrorTypes } from '@/shared/api/types' + +import { UNSECCEED_SUBMIT_MESSAGE } from '../constants/constants' +import { IChangePasswordForm } from '../scheme/changePasswordFormSliceScheme' + +/** + * Функция определяет есть ли в данный момент ошибка валидации полей формы + * + * @param {FormikErrors} errors ошибки валидации полей формы + * @param touched объект с состояниями полей, true если поле было тронуто пользователем + * @returns {boolean} true, если хоть одно поле с ошибкой и оно трогалось + */ +export const hasErrors = (errors: FormikErrors, touched: { [key: string]: boolean }) => { + return ( + (errors.current_password && touched.current_password) || + (errors.new_password && touched.new_password) || + (errors.new_passwordConfirmation && touched.new_passwordConfirmation) + ) +} + +/** + * Функция получения строки ошибки из объекта ошибок Formik + * + * @param {FormikErrors} errors ошибки валидации полей формы + * @param touched объект с состояниями полей, true если поле было тронуто пользователем + * @returns {string} строка с ошибкой валидации любого из полей формы + */ +export const getErrorText = ( + errors: FormikErrors, + touched: { [key: string]: boolean } +) => { + if (errors.current_password && touched.current_password) return errors.current_password + if (errors.new_password && touched.new_password) return errors.new_password + if (errors.new_passwordConfirmation && touched.new_passwordConfirmation) + return errors.new_passwordConfirmation + + return 'Ошибка' +} + +/** + * Функция получения текста ошибки при выполнении запроса + * + * @param {ApiErrorTypes | string[]} error Ошибка в формате ApiErrorTypes | string[] + * @returns {string} Ошибка в фромате string + */ +export const getQueryErrorText = (error: ApiErrorTypes | string[] | null): string => { + return Array.isArray(error) ? error.join('') : typeof error === 'string' ? error : UNSECCEED_SUBMIT_MESSAGE +} diff --git a/src/widgets/ChangePassword/model/scheme/changePasswordFormSliceScheme.ts b/src/widgets/ChangePassword/model/scheme/changePasswordFormSliceScheme.ts new file mode 100644 index 00000000..c55212f3 --- /dev/null +++ b/src/widgets/ChangePassword/model/scheme/changePasswordFormSliceScheme.ts @@ -0,0 +1,15 @@ +import type { ApiErrorTypes } from '@/shared/api/types' + +export interface IChangePasswordFormSchema { + isLoading: boolean + isSuccess: boolean + error: string[] | ApiErrorTypes | null +} + +export interface IChangePasswordForm { + current_password: string + new_password: string + new_passwordConfirmation: string +} + +export type IChangePassword = Omit diff --git a/src/widgets/ChangePassword/model/slice/changePasswordtFormSlice.ts b/src/widgets/ChangePassword/model/slice/changePasswordtFormSlice.ts new file mode 100644 index 00000000..a4e8bd5e --- /dev/null +++ b/src/widgets/ChangePassword/model/slice/changePasswordtFormSlice.ts @@ -0,0 +1,56 @@ +import { createAsyncThunk, createSlice } from '@reduxjs/toolkit' + +import { ThunkConfig } from '@/app/providers/StoreProvider/config/StateSchema' +import { apiErrorIdentify } from '@/shared/api/apiErrorIdentify' +import { rejectedPayloadHandle } from '@/shared/api/rejectedPayloadHandle' +import { ApiError, ApiErrorTypes, ApiRoutes } from '@/shared/api/types' + +import type { IChangePassword, IChangePasswordFormSchema } from '../scheme/changePasswordFormSliceScheme' + +export const postNewPassword = createAsyncThunk>( + 'changePasswordForm/postNewPassword', + async (setPasswordData, thunkAPI) => { + const { rejectWithValue, extra } = thunkAPI + try { + await extra.api.post(`api/${ApiRoutes.CHANGE_PASSWORD}/`, setPasswordData) + } catch (error) { + return rejectWithValue(apiErrorIdentify(error, ApiErrorTypes.DATA_EMPTY_ERROR)) + } + } +) + +const initialState: IChangePasswordFormSchema = { + isLoading: false, + isSuccess: false, + error: null +} + +export const changePasswordFormSlice = createSlice({ + name: 'changePasswordForm', + initialState, + reducers: { + reset: state => { + state.error = null + state.isSuccess = false + } + }, + extraReducers: builder => { + builder + .addCase(postNewPassword.pending, state => { + state.isLoading = true + state.error = null + state.isSuccess = false + }) + .addCase(postNewPassword.fulfilled, state => { + state.isLoading = false + state.isSuccess = true + }) + .addCase(postNewPassword.rejected, (state, { payload }) => { + state.isLoading = false + state.error = rejectedPayloadHandle(payload) + }) + } +}) + +export const { actions: changePasswordFormActions, reducer: changePasswordFormReducer } = + changePasswordFormSlice diff --git a/src/widgets/ChangePassword/model/validation/changePasswordFormScheme.ts b/src/widgets/ChangePassword/model/validation/changePasswordFormScheme.ts new file mode 100644 index 00000000..c9f3b30f --- /dev/null +++ b/src/widgets/ChangePassword/model/validation/changePasswordFormScheme.ts @@ -0,0 +1,9 @@ +import * as Yup from 'yup' + +export const changePasswordFormScheme = Yup.object().shape({ + current_password: Yup.string().required('Введите текущий пароль'), + new_password: Yup.string().required('Введите новый пароль'), + new_passwordConfirmation: Yup.string() + .required('Введите подтверждение нового пароля') + .oneOf([Yup.ref('new_password')], 'Пароли должны совпадать') +}) diff --git a/src/widgets/EditAccount/EditAccount.tsx b/src/widgets/EditAccount/EditAccount.tsx index b6af8410..55aeafd1 100644 --- a/src/widgets/EditAccount/EditAccount.tsx +++ b/src/widgets/EditAccount/EditAccount.tsx @@ -1,6 +1,6 @@ import classNames from 'classnames' import { Field, Form, Formik, FormikHelpers } from 'formik' -import { useState, type FC } from 'react' +import { useEffect, useState, type FC } from 'react' import { useSelector } from 'react-redux' import { useNavigate } from 'react-router' @@ -38,6 +38,16 @@ export const EditAccount: FC = () => { setShowApiErrorMsg(false) } + useEffect(() => { + if (editAccountForm.isSuccess && !editAccountForm.isLoading && editAccountForm.error === null) { + setShowMsg(true) + } + + if (editAccountForm.error) { + setShowApiErrorMsg(true) + } + }, [editAccountForm.isLoading, editAccountForm.error, editAccountForm.isSuccess]) + const onSubmit = async (values: IUserprofile, formikHelpers: FormikHelpers) => { const result = await dispatch(postAccount(values)) if (result.meta.requestStatus === 'fulfilled') { diff --git a/src/widgets/EditAccount/model/slice/editAccountFormSlice.ts b/src/widgets/EditAccount/model/slice/editAccountFormSlice.ts index 6da392d7..0757b9c1 100644 --- a/src/widgets/EditAccount/model/slice/editAccountFormSlice.ts +++ b/src/widgets/EditAccount/model/slice/editAccountFormSlice.ts @@ -13,7 +13,7 @@ export const postAccount = createAsyncThunk { const { rejectWithValue, extra, dispatch } = thunkAPI try { - await extra.api.put(`api/${ApiRoutes.UPDATE_PROFILE}/`, JSON.stringify(editedAccount)) + await extra.api.put(`api/${ApiRoutes.UPDATE_PROFILE}/`, editedAccount) dispatch(getCurrentUser()) } catch (error) { return rejectWithValue(apiErrorIdentify(error, ApiErrorTypes.DATA_EMPTY_ERROR))