maccounter
50 строк · 1.8 Кб
1import Button from '@components/Button/Button'
2import React from 'react'
3import { useAppDispatch, useAppSelector } from '@store/hooks'
4import clsx from 'clsx'
5import { showComponentIf } from '@utils/showIf'
6import { ReactComponent as CloseSvg } from '@icons/close.svg'
7import { setModalIsActive } from '@store/app-store/appReducer'
8import { space } from '@assets/symbols'
9import { phoneParser } from '@utils/stringParser'
10import classes from './Modal.module.scss'
11
12const Modal: React.FC = () => {
13const isActive = useAppSelector((state) => state.app.modal.isActive)
14const profile = useAppSelector((state) => state.profile)
15const dispatch = useAppDispatch()
16const close = () => {
17dispatch(setModalIsActive(false))
18}
19
20const mainComponent = (
21<div className={classes.container}>
22<div className={clsx(
23'component',
24classes.modal,
25)}
26>
27<header className={classes.header}>
28<div className={classes.title}>Profile</div>
29<div className={classes.close} onClick={close}><CloseSvg /></div>
30</header>
31<div className={classes.body}>
32<div className={classes.img}>img</div>
33<div className={classes.info}>
34<p>
35{profile.firstName}
36{space}
37{profile.secondName}
38</p>
39<p>{profile.email}</p>
40<p>{phoneParser(profile.phone)}</p>
41</div>
42</div>
43<Button>Edit</Button>
44</div>
45</div>
46)
47return showComponentIf(isActive, mainComponent)
48}
49
50export default Modal
51