From c0b21882ce103b5d8580e3d969f20df927ee131a Mon Sep 17 00:00:00 2001 From: Max Nikitin <61289736+Maxxnikitin@users.noreply.github.com> Date: Thu, 28 Jan 2021 11:45:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8?= =?UTF-8?q?=D1=8F=20/=20=D0=B7=D0=B0=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BC=D0=BE=D0=B4=D0=B0=D0=BB=D0=BA=D0=B8=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B7=D0=B0=D0=B4=D0=B0?= =?UTF-8?q?=D1=87=D0=B8=20(#78)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Добавить открытие\закрытие модалки создания задачи #63 написал каркас функции и рендеринга, настроил открытие и закрытие модалки --- .eslintrc.json | 1 + src/app/components/both-menu/BothMenu.tsx | 49 ++++++------------- .../create-task-modal/CreateTaskModal.tsx | 20 +++++--- src/app/components/page/Page.tsx | 6 +-- .../popup-list-item/PopupListItem.tsx | 26 ++++++++++ src/app/components/popup-list-item/index.ts | 1 + src/app/components/popup-list/PopupList.tsx | 15 ++---- src/app/components/popup-list/index.ts | 1 + src/app/consts.ts | 27 +++++++++- src/app/enums.ts | 8 +++ 10 files changed, 98 insertions(+), 56 deletions(-) create mode 100644 src/app/components/popup-list-item/PopupListItem.tsx create mode 100644 src/app/components/popup-list-item/index.ts diff --git a/.eslintrc.json b/.eslintrc.json index c38f6d5..2e19d6b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -97,6 +97,7 @@ "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/no-unused-vars": "warn", "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/ban-types": "off", "array-bracket-spacing": ["warn", "never"], "block-spacing": ["warn", "never"], "brace-style": ["warn", "1tbs", {"allowSingleLine": true}], diff --git a/src/app/components/both-menu/BothMenu.tsx b/src/app/components/both-menu/BothMenu.tsx index 59440a8..d1d8a14 100644 --- a/src/app/components/both-menu/BothMenu.tsx +++ b/src/app/components/both-menu/BothMenu.tsx @@ -10,19 +10,19 @@ import {NavLink} from 'react-router-dom'; import {ROUTES} from '_consts/common'; import ToggleMenu from '../toggle-menu'; import {BOTH_MENU_LINKS} from '../../consts'; -import PopupList from '../popup-list/PopupList'; +import PopupList from '../popup-list'; const useStyles = makeStyles((theme: Theme) => createStyles({ iconRight: { - marginRight: theme.spacing(2), + marginRight: theme.spacing(2) }, appBar: { top: 'auto', - bottom: 0, + bottom: 0 }, grow: { - flexGrow: 1, + flexGrow: 1 }, fabButton: { position: 'absolute', @@ -30,9 +30,9 @@ const useStyles = makeStyles((theme: Theme) => top: -30, left: 0, right: 0, - margin: '0 auto', - }, - }), + margin: '0 auto' + } + }) ); type Props = { @@ -44,58 +44,37 @@ const BothMenu: React.FC = ({trigger}) => { return ( - + - + - + - +
- + - + - + ); }; diff --git a/src/app/components/create-task-modal/CreateTaskModal.tsx b/src/app/components/create-task-modal/CreateTaskModal.tsx index d9b7bbc..a8fd0e3 100644 --- a/src/app/components/create-task-modal/CreateTaskModal.tsx +++ b/src/app/components/create-task-modal/CreateTaskModal.tsx @@ -1,4 +1,5 @@ -import React, {FC, memo} from 'react'; +import React, {FC, memo, useCallback} from 'react'; +import {useHistory} from 'react-router-dom'; import {format} from 'date-fns'; import {useFormik} from 'formik'; import Dialog from '@material-ui/core/Dialog'; @@ -7,6 +8,8 @@ import DialogContent from '@material-ui/core/DialogContent'; import DialogTitle from '@material-ui/core/DialogTitle'; import {Task} from '_types/common'; import {VIEW_DATE_TIME} from '_consts/common'; +import {buildPath} from '_utils/buildPath'; +import {PageType} from '_enums/common'; import {Button, TextField} from '@material-ui/core'; import {LABELS} from '../../consts'; @@ -17,18 +20,23 @@ type Props = { const now = format(new Date(), VIEW_DATE_TIME); const CreateTaskModal: FC = ({isOpen}) => { + const history = useHistory(); const form = useFormik>({ initialValues: { title: '', body: '', start_at: now, - end_at: '', + end_at: '' }, onSubmit: () => { // В аргументах приходят values. Ждем задачи со сторами для формы - }, + } }); + const handleClose = useCallback(() => { + history.push(buildPath({pageType: PageType.Main})); + }, [history]); + return (
@@ -61,7 +69,7 @@ const CreateTaskModal: FC = ({isOpen}) => { onChange={form.handleChange} margin="dense" InputLabelProps={{ - shrink: true, + shrink: true }} fullWidth /> @@ -73,13 +81,13 @@ const CreateTaskModal: FC = ({isOpen}) => { onChange={form.handleChange} margin="dense" InputLabelProps={{ - shrink: true, + shrink: true }} fullWidth /> -