-
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.
Добавил меню. Немного исправил стили для адаптива.
- Loading branch information
1 parent
d515e1e
commit aa09b13
Showing
7 changed files
with
143 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,97 @@ | ||
import { FC, KeyboardEvent, Suspense, useState } from 'react' | ||
|
||
import WrapperForMainContent from '@/components/WrapperForMainContent/WrapperForMainContent' | ||
import { useFavorite } from '@/entities/Favorite/model/hooks/useFavorite' | ||
import SideBarButton from '@/entities/SideBarButton' | ||
import SideBarMenuModal from '@/features/SideBarMenuModal' | ||
import { Routes } from '@/shared/config/routerConfig/routes' | ||
import { useResize } from '@/shared/libs/hooks/useResize' | ||
import { ECardView } from '@/shared/model/types/common' | ||
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 { ProductsList } from '@/widgets/ProductsList/ProductsList' | ||
import SideBarMenu from '@/widgets/SideBarMenu' | ||
|
||
import styles from './FavoritesPage.module.scss' | ||
|
||
const links = [ | ||
{ heading: 'Главная', href: '/' }, | ||
{ heading: 'Личный Кабинет', href: Routes.LOGIN }, | ||
{ heading: 'Избранные товары', href: '' } | ||
] | ||
|
||
/** | ||
* Страница с избранными товарами | ||
*/ | ||
const FavoritesPage = () => { | ||
export const FavoritesPage: FC = () => { | ||
const favoriteProducts = useFavorite() | ||
const { isScreenMd } = useResize() | ||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false) | ||
const [isModalClosing, setIsModalClosing] = useState<boolean>(false) | ||
const [user, setUser] = useState<string>('Elon Musk') // TODO получать пользователя из редакса | ||
|
||
const handleClick = () => { | ||
setIsModalOpen(true) | ||
} | ||
|
||
const changeModalState = () => { | ||
setIsModalOpen(!isModalOpen) | ||
} | ||
|
||
const links = [ | ||
{ heading: 'Главная', href: '/' }, | ||
{ heading: 'Избранные товары', href: '' } | ||
] | ||
const handleLogOut = () => { | ||
setUser('') | ||
} | ||
|
||
const handleKeyUp = (e: KeyboardEvent<HTMLDivElement>) => { | ||
if (e.code === 'Enter' || e.code === 'Space') { | ||
e.preventDefault() | ||
handleLogOut() | ||
} | ||
} | ||
|
||
return ( | ||
<WrapperForMainContent> | ||
<div className={styles.pageDescriptor}> | ||
<Heading>Избранные товары</Heading> | ||
<Breadcrumbs links={links} /> | ||
</div> | ||
<section className={styles.favoritePage_list}> | ||
<ProductsList | ||
items={{ | ||
category_name: '', | ||
count: favoriteProducts.length, | ||
next: '', | ||
previous: '', | ||
results: favoriteProducts | ||
}} | ||
cardView={ECardView.GRID} | ||
/> | ||
</section> | ||
<div className={styles.favoritePage__container}> | ||
{isScreenMd ? ( | ||
<SideBarMenu user={user} handleLogOut={handleLogOut} /> | ||
) : ( | ||
<SideBarButton onClick={handleClick} /> | ||
)} | ||
<section className={styles.favoritePage__list}> | ||
<ProductsList | ||
items={{ | ||
category_name: '', | ||
count: favoriteProducts.length, | ||
next: '', | ||
previous: '', | ||
results: favoriteProducts | ||
}} | ||
cardView={ECardView.GRID} | ||
/> | ||
</section> | ||
</div> | ||
{isModalOpen && ( | ||
<Modal | ||
isModalOpen={isModalOpen} | ||
onClose={changeModalState} | ||
isModalClosing={isModalClosing} | ||
setIsModalClosing={setIsModalClosing}> | ||
<Suspense fallback={<Spinner />}> | ||
<SideBarMenuModal | ||
handleClose={changeModalState} | ||
onKeyUp={handleKeyUp} | ||
handleLogOut={handleLogOut} | ||
user={user} | ||
/> | ||
</Suspense> | ||
</Modal> | ||
)} | ||
</WrapperForMainContent> | ||
) | ||
} | ||
|
||
export default FavoritesPage |
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