From 0b3d809e3b0140ff6cdc4e4fe9ddd4f0e084cf22 Mon Sep 17 00:00:00 2001 From: Mateusz Tylka Date: Fri, 14 Jul 2023 14:57:11 +0200 Subject: [PATCH] refactor and style DeletePopUp --- src/components/generic/Table/Table.js | 38 +++------------- .../components/DeletePopUp/DeletePopUp.js | 45 +++++++++++++++++++ .../Table/components/DeletePopUp/index.js | 1 + 3 files changed, 53 insertions(+), 31 deletions(-) create mode 100644 src/components/generic/Table/components/DeletePopUp/DeletePopUp.js create mode 100644 src/components/generic/Table/components/DeletePopUp/index.js diff --git a/src/components/generic/Table/Table.js b/src/components/generic/Table/Table.js index 260796d..5defe4a 100644 --- a/src/components/generic/Table/Table.js +++ b/src/components/generic/Table/Table.js @@ -1,5 +1,4 @@ import React from 'react'; -import { createPortal } from 'react-dom'; import TableStyle from './styles/TableStyle'; import TableHeader from './components/TableHeader'; import TableRowItems from './components/TableRowItems'; @@ -7,9 +6,7 @@ import RowsBackgroundStyle from './styles/RowsBackgroundStyle'; import TableRowFooter from './components/TableRowFooter'; import deleteSubmission from '../../../api/deleteSubmission'; import theme from '../../../utils/theme'; -import PopUp from '../PopUp'; -import Button from '../Button'; -import { Medium, H3 } from '../../../utils/fonts'; +import DeletePopUp from './components/DeletePopUp/DeletePopUp'; const Table = ({ items, @@ -34,32 +31,6 @@ const Table = ({ ); }; - const renderDeletePopUp = (item) => { - if (deletePopUp) { - return createPortal( - setDeletePopUp(false)} - > -

Warning

- Are you sure to delete submission with id: {item.id}? - - -
, - document.body - ); - } - }; - return ( { return ( + setDeletePopUp(true)} @@ -77,7 +54,6 @@ const Table = ({ item={item} i={i} /> - {renderDeletePopUp(item)} ); diff --git a/src/components/generic/Table/components/DeletePopUp/DeletePopUp.js b/src/components/generic/Table/components/DeletePopUp/DeletePopUp.js new file mode 100644 index 0000000..9028cef --- /dev/null +++ b/src/components/generic/Table/components/DeletePopUp/DeletePopUp.js @@ -0,0 +1,45 @@ +import { createPortal } from 'react-dom'; +import PopUp from '../../../PopUp'; +import Button from '../../../Button'; +import { Medium, H3 } from '../../../../../utils/fonts'; +import { FlexColumn, FlexRow } from '../../../../../utils/containers'; +import theme from '../../../../../utils/theme'; + +const DeletePopUp = ({ deletePopUp, setDeletePopUp, deleteItem, item }) => { + if (deletePopUp) { + return createPortal( + setDeletePopUp(false)} + > + +

Warning

+ + Are you sure want to delete submission with id: {item.id}? + + + + + +
+
, + document.body + ); + } +}; + +export default DeletePopUp; diff --git a/src/components/generic/Table/components/DeletePopUp/index.js b/src/components/generic/Table/components/DeletePopUp/index.js new file mode 100644 index 0000000..6c15e19 --- /dev/null +++ b/src/components/generic/Table/components/DeletePopUp/index.js @@ -0,0 +1 @@ +export { default } from './DeletePopUp';