-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #438 from Studio-Yandex-Practicum/bug_436_registra…
…tion_page Bug 436 registration page
- Loading branch information
Showing
18 changed files
with
342 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 26 additions & 25 deletions
51
src/pages/CreateAccountPage/CreateAccountPage.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,41 @@ | ||
@use '@/shared/styles/utils/mixins' as media; | ||
|
||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 65px 0; | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 65px 0; | ||
} | ||
|
||
.wrapper { | ||
display: flex; | ||
align-items: center; | ||
justify-content:space-between; | ||
width: 45%; | ||
margin-bottom: 20px; | ||
@include media.respond-to('large') { | ||
width: 80%; | ||
} | ||
@include media.respond-to('middle') { | ||
width: 94%; | ||
} | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 45%; | ||
margin-bottom: 20px; | ||
@include media.respond-to('large') { | ||
width: 80%; | ||
} | ||
@include media.respond-to('middle') { | ||
width: 94%; | ||
} | ||
} | ||
|
||
.auth { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
column-gap: 10px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
column-gap: 10px; | ||
} | ||
|
||
.button { | ||
padding: 4px 14px; | ||
padding: 4px 14px; | ||
} | ||
|
||
.paragraph { | ||
@include media.respond-to('middle') { | ||
display: none; | ||
} | ||
} | ||
@include media.respond-to('middle') { | ||
display: none; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/pages/CreateAccountSuccess/CreateAccountSuccess.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@use '../../shared/styles/utils/mixins' as media; | ||
@use '../../shared/styles/utils/variables' as color; | ||
|
||
.createAccountPage { | ||
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; | ||
} | ||
|
||
&__button { | ||
width: 150px; | ||
transition: opacity 0.3s; | ||
|
||
&:hover { | ||
opacity: 0.8; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { FC, Suspense, useState } from 'react' | ||
import { useNavigate } from 'react-router' | ||
|
||
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 { Button, ButtonSize, ButtonTheme } from '@/shared/ui/Button/Button' | ||
import Heading from '@/shared/ui/Heading/Heading' | ||
import Modal from '@/shared/ui/Modal/Modal' | ||
import Paragraph from '@/shared/ui/Paragraph/Paragraph' | ||
import Spinner from '@/shared/ui/Spinner/Spinner' | ||
import WrapperForMainContent from '@/shared/ui/WrapperForMainContent/WrapperForMainContent' | ||
import { withAdaptiveSideBar } from '@/widgets/SideBarMenu' | ||
|
||
import styles from './CreateAccountSuccess.module.scss' | ||
|
||
const links = [ | ||
{ heading: 'Главная', href: '/' }, | ||
{ heading: 'Личный Кабинет', href: Routes.ACCOUNT }, | ||
{ heading: 'Успешно', href: '' } | ||
] | ||
|
||
/** | ||
* Страница успешной регистрации | ||
* | ||
*/ | ||
export const CreateAccountSuccess: FC = () => { | ||
const { isScreenLg } = useResize() | ||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false) | ||
const [isModalClosing, setIsModalClosing] = useState<boolean>(false) | ||
const AdaptiveSideBar = withAdaptiveSideBar(isScreenLg) | ||
const navigate = useNavigate() | ||
|
||
const handleClick = () => { | ||
setIsModalOpen(true) | ||
} | ||
|
||
const changeModalState = () => { | ||
setIsModalOpen(!isModalOpen) | ||
} | ||
|
||
const onGoOnHandle = () => { | ||
navigate(Routes.LOGIN) | ||
} | ||
|
||
return ( | ||
<WrapperForMainContent> | ||
<div className={styles.createAccountPage__pageDescriptor}> | ||
<Heading>Ваша учетная запись создана!</Heading> | ||
<Breadcrumbs links={links} /> | ||
</div> | ||
<div className={styles.createAccountPage__container}> | ||
<AdaptiveSideBar handleClick={handleClick} /> | ||
<div className={styles.createAccountPage__contentContainer}> | ||
<Paragraph> | ||
Поздравляем! Ваш Личный Кабинет был успешно создан. Для окончания регистарции перейдите по ссылке | ||
в письме! | ||
</Paragraph> | ||
<Paragraph> | ||
После завершения регистрации Вы сможете воспользоваться дополнительными возможностями: просмотр | ||
истории заказов, печать счета, изменение своей контактной информации и адресов доставки и многое | ||
другое. | ||
</Paragraph> | ||
<Paragraph>Если у Вас есть какие-либо вопросы, напишите нам.</Paragraph> | ||
<Button | ||
onClick={onGoOnHandle} | ||
size={ButtonSize.S} | ||
theme={ButtonTheme.PRIMARY} | ||
className={styles.createAccountPage__button}> | ||
Продолжить | ||
</Button> | ||
</div> | ||
</div> | ||
{isModalOpen && ( | ||
<Modal | ||
isModalOpen={isModalOpen} | ||
onClose={changeModalState} | ||
isModalClosing={isModalClosing} | ||
setIsModalClosing={setIsModalClosing}> | ||
<Suspense fallback={<Spinner />}> | ||
<SideBarMenuModal handleClose={changeModalState} /> | ||
</Suspense> | ||
</Modal> | ||
)} | ||
</WrapperForMainContent> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/widgets/CreateAccount/model/services/createAccount/createAccount.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { createAsyncThunk } from '@reduxjs/toolkit' | ||
|
||
import { ThunkConfig } from '@/app/providers/StoreProvider/config/StateSchema' | ||
import { apiErrorIdentify } from '@/shared/api/apiErrorIdentify' | ||
import { ApiError, ApiErrorTypes, ApiRoutes } from '@/shared/api/types' | ||
|
||
import type { ICreateAccountResult, TCreateAccountPayload } from '../../types/types' | ||
|
||
export const createAccount = createAsyncThunk< | ||
ICreateAccountResult, | ||
TCreateAccountPayload, | ||
ThunkConfig<ApiError> | ||
>('createAccount/createAccount', async (values, thunkAPI) => { | ||
const { rejectWithValue, extra } = thunkAPI | ||
try { | ||
const { data } = await extra.api.post(`api/${ApiRoutes.CREATE_ACCOUNT}/`, values) | ||
return data | ||
} catch (error) { | ||
return rejectWithValue(apiErrorIdentify(error, ApiErrorTypes.DATA_EMPTY_ERROR)) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { createSlice } from '@reduxjs/toolkit' | ||
|
||
import { rejectedPayloadHandle } from '@/shared/api/rejectedPayloadHandle' | ||
|
||
import { createAccount } from '../services/createAccount/createAccount' | ||
import { ICreateAccountSchema } from '../types/types' | ||
|
||
const initialState: ICreateAccountSchema = { | ||
isLoading: false, | ||
user: { | ||
id: null, | ||
email: null | ||
} | ||
} | ||
|
||
export const createAccountSlice = createSlice({ | ||
name: 'createAccount', | ||
initialState, | ||
reducers: { | ||
errorReset: state => { | ||
state.error = undefined | ||
} | ||
}, | ||
extraReducers: builder => { | ||
builder | ||
.addCase(createAccount.pending, state => { | ||
state.error = undefined | ||
state.isLoading = true | ||
}) | ||
.addCase(createAccount.fulfilled, state => { | ||
state.isLoading = false | ||
}) | ||
.addCase(createAccount.rejected, (state, { payload }) => { | ||
state.isLoading = false | ||
state.error = rejectedPayloadHandle(payload) | ||
}) | ||
} | ||
}) | ||
|
||
export const { actions: createAccountActions, reducer: createAccountReducer } = createAccountSlice |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.