From e16234d0b73acadf333477c9884a1b32236b6195 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Mon, 15 Jun 2020 17:01:39 +0300 Subject: [PATCH] deleted trash page --- client/src/App.js | 2 - .../Dialogs/Category/DeleteCategoryDialog.js | 1 - .../Todo/DeleteTodoСompletelyDialog.js | 43 ------------------ .../Dialogs/Todo/RestoreTodoDialog.js | 44 ------------------- .../components/Nav/NavContent/NavContent.js | 9 ---- client/src/components/Todos/Todos.js | 42 +++--------------- .../TrashContainer/TrashContainer.js | 19 -------- 7 files changed, 6 insertions(+), 154 deletions(-) delete mode 100644 client/src/components/Dialogs/Todo/DeleteTodoСompletelyDialog.js delete mode 100644 client/src/components/Dialogs/Todo/RestoreTodoDialog.js delete mode 100644 client/src/containers/TrashContainer/TrashContainer.js diff --git a/client/src/App.js b/client/src/App.js index 598cca1..d290994 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -3,7 +3,6 @@ import { Route, Switch, Redirect, withRouter } from "react-router-dom" import Layout from './components/Layout/Layout' import TodosContainer from './containers/TodosContainer/TodosContainer' import CategoryContainer from './containers/CategoryContainer/CategoryContainer' -import TrashContainer from './containers/TrashContainer/TrashContainer' import NotFoundContainer from './containers/NotFoundContainer/NotFoundContainer' import CssBaseLine from '@material-ui/core/CssBaseline' @@ -23,7 +22,6 @@ const App = ({ history }) => { - diff --git a/client/src/components/Dialogs/Category/DeleteCategoryDialog.js b/client/src/components/Dialogs/Category/DeleteCategoryDialog.js index 5bdb3a3..54c6b91 100644 --- a/client/src/components/Dialogs/Category/DeleteCategoryDialog.js +++ b/client/src/components/Dialogs/Category/DeleteCategoryDialog.js @@ -17,7 +17,6 @@ const DeleteCategoryDialog = ({ isOpenDialog, handleCloseDialog }) => { const [deleteCategory] = useMutation(DELETE_CATEGORY, { update(cache, { data: { deleteCategory } }) { const { categories } = cache.readQuery({ query: GET_CATEGORIES }) - console.log(categories, deleteCategory) cache.writeQuery({ query: GET_CATEGORIES, data: { categories: categories.filter(category => category.id !== deleteCategory.id) } diff --git a/client/src/components/Dialogs/Todo/DeleteTodoСompletelyDialog.js b/client/src/components/Dialogs/Todo/DeleteTodoСompletelyDialog.js deleted file mode 100644 index 54f46b1..0000000 --- a/client/src/components/Dialogs/Todo/DeleteTodoСompletelyDialog.js +++ /dev/null @@ -1,43 +0,0 @@ -import React from 'react'; -import useStyles from '../styles' -import WarningIcon from '@material-ui/icons/Warning'; -import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@material-ui/core' - -const DeleteTodoСompletelyDialog = ({ isOpenDialog, handleCloseDialog, selectedTodo }) => { - const classes = useStyles() - const handleClickDelete = () => { - console.log('Request on delete completely todo:', selectedTodo.id, selectedTodo.title) - handleCloseDialog() - } - - return ( - <> - - - - Удалить запись навсегда? - - - - Запись будет удалена навсегда, вы не сможете её восстановить. - - - - - - - - - ) -} - -export default DeleteTodoСompletelyDialog \ No newline at end of file diff --git a/client/src/components/Dialogs/Todo/RestoreTodoDialog.js b/client/src/components/Dialogs/Todo/RestoreTodoDialog.js deleted file mode 100644 index 1af8ee7..0000000 --- a/client/src/components/Dialogs/Todo/RestoreTodoDialog.js +++ /dev/null @@ -1,44 +0,0 @@ -import React from 'react'; -import useStyles from '../styles' -import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@material-ui/core' - -import RestoreIcon from '@material-ui/icons/Restore'; - -const DeleteTodoDialog = ({ isOpenDialog, handleCloseDialog, selectedTodo }) => { - const classes = useStyles() - const handleClickDelete = () => { - console.log('Request on restore todo:', selectedTodo.id, selectedTodo.title) - handleCloseDialog() - } - - return ( - <> - - - - Восстановить запись? - - - - Запись будет восстановлена в прежнее состояние. - - - - - - - - - ) -} - -export default DeleteTodoDialog \ No newline at end of file diff --git a/client/src/components/Nav/NavContent/NavContent.js b/client/src/components/Nav/NavContent/NavContent.js index b72943b..96f6a29 100644 --- a/client/src/components/Nav/NavContent/NavContent.js +++ b/client/src/components/Nav/NavContent/NavContent.js @@ -8,7 +8,6 @@ import MuiLink from '@material-ui/core/Link'; import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted'; import CategoryIcon from '@material-ui/icons/Category'; import AddIcon from '@material-ui/icons/Add'; -import DeleteIcon from '@material-ui/icons/Delete'; import GitHubIcon from '@material-ui/icons/GitHub'; import ExpandLess from '@material-ui/icons/ExpandLess' import ExpandMore from '@material-ui/icons/ExpandMore' @@ -69,14 +68,6 @@ const NavContent = ({ history, handleOpenModal }) => { - - - - - - - - ) diff --git a/client/src/components/Todos/Todos.js b/client/src/components/Todos/Todos.js index 2a71e2c..82c845e 100644 --- a/client/src/components/Todos/Todos.js +++ b/client/src/components/Todos/Todos.js @@ -2,16 +2,13 @@ import React from 'react'; import useStyles from './styles' import UpdateTodoModal from '../Modals/Todo/UpdateTodoModal' import DeleteTodoDialog from '../Dialogs/Todo/DeleteTodoDialog' -import DeleteTodoСompletelyDialog from '../Dialogs/Todo/DeleteTodoСompletelyDialog' -import RestoreTodoDialog from '../Dialogs/Todo/RestoreTodoDialog' import { Card, CardActions, CardContent, Typography, Grid, IconButton } from '@material-ui/core' -import RestoreIcon from '@material-ui/icons/Restore'; import DeleteIcon from '@material-ui/icons/Delete' import AlarmIcon from '@material-ui/icons/Alarm'; import EditIcon from '@material-ui/icons/Edit'; -const Todos = ({ data, fromTrashContainer }) => { +const Todos = ({ data }) => { const classes = useStyles() const [selectedTodo, setSelectedTodo] = React.useState({ title: '', @@ -21,7 +18,6 @@ const Todos = ({ data, fromTrashContainer }) => { }) const [isModalOpen, setIsModalOpen] = React.useState(false) const [isOpenDialog, setIsOpenDialog] = React.useState(false); - const [isOpenRestoreDialog, setIsOpenRestoreDialog] = React.useState(false) const handleOpenModal = todo => { const selectedTodo = { @@ -49,31 +45,10 @@ const Todos = ({ data, fromTrashContainer }) => { } const handleCloseDialog = () => setIsOpenDialog(false) - const handleOpenRestoreDialog = todo => { - setSelectedTodo({ - id: todo.id, - title: todo.title, - description: todo.description, - category: todo.category, - deadline: todo.deadline - }) - setIsOpenRestoreDialog(true) - } - - const handleCloseRestoreDialog = () => setIsOpenRestoreDialog(false) - return ( <> - {!fromTrashContainer - ? <> - - - - : <> - - - - } + + {data.map((todo, i) => @@ -93,14 +68,9 @@ const Todos = ({ data, fromTrashContainer }) => { - {!fromTrashContainer - ? handleOpenModal(todo)} aria-label="update"> - - - : handleOpenRestoreDialog(todo)} aria-label="restore"> - - - } + handleOpenModal(todo)} aria-label="update"> + + handleOpenDialog(todo)} aria-label="delete" color='secondary'> diff --git a/client/src/containers/TrashContainer/TrashContainer.js b/client/src/containers/TrashContainer/TrashContainer.js deleted file mode 100644 index e6231ef..0000000 --- a/client/src/containers/TrashContainer/TrashContainer.js +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; -import Todos from '../../components/Todos/Todos' -import { Grid, Typography } from '@material-ui/core' - -const Trash = () => { - return ( - - - - Здесь находятся ваши недавно удаленные записи, вы можете их легко восстановить. - - - {/* Здесь также выполняем нужный запрос на удаленные записи в БД !!!!!!!! */} - {/* */} - - ) -} - -export default Trash \ No newline at end of file