From e75d6a332d8b5ed14a7efe2ab763cea99c746f9f Mon Sep 17 00:00:00 2001 From: miahro Date: Thu, 2 May 2024 12:56:31 +0300 Subject: [PATCH 1/2] add confirmation to tag deletion --- .../TagManagementPage/TagsDashboard.jsx | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/TagManagementPage/TagsDashboard.jsx b/frontend/src/components/TagManagementPage/TagsDashboard.jsx index 7e7a6a75..94787df6 100644 --- a/frontend/src/components/TagManagementPage/TagsDashboard.jsx +++ b/frontend/src/components/TagManagementPage/TagsDashboard.jsx @@ -2,17 +2,20 @@ import React, { useState, useEffect, useRef } from 'react' import Typography from '@material-ui/core/Typography' import TextField from '@material-ui/core/TextField' import Button from '@material-ui/core/Button' +import { DeleteOutlineRounded } from '@material-ui/icons' import tagService from '../../services/tags' import './TagsDashboard.css' import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' import * as notificationActions from '../../reducers/actions/notificationActions' - +import ConfirmationDialog from '../common/ConfirmationDialog' const TagsPage = (props) => { const [allTags, setAllTags] = useState([]) const [tagTitle, setTagTitle] = useState('') const isMounted = useRef(true) + const [confirmOpen, setConfirmOpen] = useState(false) + const [tagToDelete, setTagToDelete] = useState(null) useEffect(() => { const fetchTags = async () => { @@ -22,7 +25,7 @@ const TagsPage = (props) => { setAllTags(fetchedData) } } catch (error) { - console.error('Error fetching tags:', error.message, ' / ' , error.response.data.error) + console.error('Error fetching tags:', error.message, ' / ', error.response.data.error) if (error.response && error.response.data && error.response.data.error) { props.setError(error.response.data.error) } else { @@ -47,7 +50,7 @@ const TagsPage = (props) => { clearForm() props.setSuccess('Tag created successfully.') } catch (error) { - console.error('Error fetching tags:', error.message, ' / ' , error.response.data.error) + console.error('Error fetching tags:', error.message, ' / ', error.response.data.error) props.setError(error.response.data.error, 3000) } } @@ -62,7 +65,7 @@ const TagsPage = (props) => { setAllTags(updatedTags) props.setSuccess('Tag deleted successfully.') } catch (error) { - console.error('Error fetching tags:', error.message, ' / ' , error.response.data.error) + console.error('Error fetching tags:', error.message, ' / ', error.response.data.error) props.setError(error.response.data.error) } } @@ -113,8 +116,11 @@ const TagsPage = (props) => { {tag.title}