Skip to content

Commit

Permalink
Сделал страницу смены E-mail и подключил к API
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-k88 committed Jun 28, 2024
1 parent f8968a5 commit 29d771d
Show file tree
Hide file tree
Showing 15 changed files with 467 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/app/providers/StoreProvider/config/StateSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type { TNumberOfPageSchema } from '@/widgets/Pagination/types/types'
import { INewsItem } from '@/pages/NewsItemPage/types/types'
import { ICreateAccountSchema } from '@/widgets/CreateAccount/model/types/types'
import { IChangePasswordFormSchema } from '@/widgets/ChangePassword/model/scheme/changePasswordFormSliceScheme'
import { IChangeEmailFormSchema } from '@/widgets/ChangeEmail/model/scheme/changeEmailFormSliceScheme'

export interface StateSchema {
aboutUs: IAboutUsSchema
Expand Down Expand Up @@ -50,6 +51,7 @@ export interface StateSchema {
createAccount: ICreateAccountSchema
newsItem: INewsItem
changePassword: IChangePasswordFormSchema
changeEmail: IChangeEmailFormSchema
}

export interface ThunkExtraArg {
Expand Down
4 changes: 3 additions & 1 deletion src/app/providers/StoreProvider/config/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { paginationSliceReducer } from '@/widgets/Pagination/slice/paginationSli
import { newsItemReducer } from '@/pages/NewsItemPage/slice/newsItemSlice'
import { createAccountReducer } from '@/widgets/CreateAccount/model/slice/loginSlice'
import { changePasswordFormReducer } from '@/widgets/ChangePassword/model/slice/changePasswordtFormSlice'
import { changeEmailFormReducer } from '@/widgets/ChangeEmail/model/slice/changeEmailFormSlice'

export type RootState = StateSchema

Expand Down Expand Up @@ -56,7 +57,8 @@ const rootReducer: ReducersMapObject<RootState> = {
newsItem: newsItemReducer,
editAccount: editAccountFormReducer,
createAccount: createAccountReducer,
changePassword: changePasswordFormReducer
changePassword: changePasswordFormReducer,
changeEmail: changeEmailFormReducer
}

export function createReduxStore(initialState: RootState) {
Expand Down
5 changes: 5 additions & 0 deletions src/app/router/AppRouter/ui/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 { ChangeEmailPage } from '@/pages/ChangeEmailPage/ChangeEmailPage'
import { ChangePasswordPage } from '@/pages/ChangePasswordPage/ChangePasswordPage'
import ComparePage from '@/pages/ComparePage/ComparePage'
import ContactsPage from '@/pages/ContactsPage/ContactsPage'
Expand Down Expand Up @@ -176,6 +177,10 @@ export const AppRouter = createBrowserRouter([
{
path: Routes.CHANGE_PASSWORD,
element: <ProtectedRoute element={ChangePasswordPage} />
},
{
path: Routes.CHANGE_EMAIL,
element: <ProtectedRoute element={ChangeEmailPage} />
}

/* {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const user = [
{ subtitle: 'Личный Кабинет', route: Routes.ACCOUNT },
{ subtitle: 'Изменить контактную информацию', route: Routes.EDIT_ACCOUNT },
{ subtitle: 'Изменить свой пароль', route: Routes.CHANGE_PASSWORD },
{ subtitle: 'Изменить свой E-Mail', route: Routes.CHANGE_EMAIL },
{ subtitle: 'Изменить мои адреса', route: Routes.HOME }, // '/address-book' - данного роута пока нет
{ subtitle: 'Посмотреть закладки', route: Routes.FAVORITES }
]
Expand Down
33 changes: 33 additions & 0 deletions src/pages/ChangeEmailPage/ChangeEmailPage.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@use '../../shared/styles/utils/mixins' as media;
@use '../../shared/styles/utils/variables' as color;

.changeEmailPage {
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;
}
}
61 changes: 61 additions & 0 deletions src/pages/ChangeEmailPage/ChangeEmailPage.tsx
Original file line number Diff line number Diff line change
@@ -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 { ChangeEmail } from '@/widgets/ChangeEmail/ChangeEmail'
import { withAdaptiveSideBar } from '@/widgets/SideBarMenu'

import styles from './ChangeEmailPage.module.scss'

const links = [
{ heading: 'Главная', href: '/' },
{ heading: 'Личный Кабинет', href: Routes.ACCOUNT },
{ heading: 'Изменить E-Mail', href: '' }
]

export const ChangeEmailPage: FC = () => {
const { isScreenLg } = useResize()
const [isModalOpen, setIsModalOpen] = useState<boolean>(false)
const [isModalClosing, setIsModalClosing] = useState<boolean>(false)
const AdaptiveSideBar = withAdaptiveSideBar(isScreenLg)

const handleClick = () => {
setIsModalOpen(true)
}

const changeModalState = () => {
setIsModalOpen(!isModalOpen)
}

return (
<WrapperForMainContent>
<div className={styles.changeEmailPage__pageDescriptor}>
<Heading>Изменить E-Mail</Heading>
<Breadcrumbs links={links} />
</div>
<div className={styles.changeEmailPage__container}>
<AdaptiveSideBar handleClick={handleClick} />
<div className={styles.changeEmailPage__contentContainer}>
<ChangeEmail />
</div>
</div>
{isModalOpen && (
<Modal
isModalOpen={isModalOpen}
onClose={changeModalState}
isModalClosing={isModalClosing}
setIsModalClosing={setIsModalClosing}>
<Suspense fallback={<Spinner />}>
<SideBarMenuModal handleClose={changeModalState} />
</Suspense>
</Modal>
)}
</WrapperForMainContent>
)
}
3 changes: 2 additions & 1 deletion src/shared/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export enum ApiRoutes {
USER = 'users/me',
UPDATE_PROFILE = 'update-profile',
CREATE_ACCOUNT = 'users',
CHANGE_PASSWORD = 'users/set_password'
CHANGE_PASSWORD = 'users/set_password',
CHANGE_EMAIL = 'users/set_email'
}

export enum ApiErrorTypes {
Expand Down
3 changes: 2 additions & 1 deletion src/shared/config/routerConfig/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ export enum Routes {
CREATE_ACCOUNT_SUCCESS = '/success',
NEWSLETTER = '/newsletter',
SHOP_NEWS = '/shopnews',
CHANGE_PASSWORD = '/change-password'
CHANGE_PASSWORD = '/change-password',
CHANGE_EMAIL = '/change-email'
}
88 changes: 88 additions & 0 deletions src/widgets/ChangeEmail/ChangeEmail.module.scss
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading

0 comments on commit 29d771d

Please sign in to comment.