File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed
frontend/src/features/task-management/components Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ import React , { FC } from "react" ;
2+ import { useToast } from "@chakra-ui/react" ;
3+ import PopupModal from "../../../components/common/PopupModal" ;
4+ import TaskTemplateAPIClient from "../../../APIClients/TaskTemplateAPIClient" ;
5+
6+ interface DeleteTaskTemplateModalProps {
7+ taskTemplateId : number ;
8+ isOpen : boolean ;
9+ onClose : ( ) => void ;
10+ onDeleteSuccess ?: ( ) => void ;
11+ }
12+
13+ const DeleteTaskTemplateModal : FC < DeleteTaskTemplateModalProps > = ( {
14+ taskTemplateId,
15+ isOpen,
16+ onClose,
17+ onDeleteSuccess,
18+ } ) => {
19+ const toast = useToast ( ) ;
20+
21+ const handlePrimaryButtonClick = async ( ) => {
22+ try {
23+ await TaskTemplateAPIClient . deleteTaskTemplate ( taskTemplateId ) ;
24+ toast ( {
25+ title : "Success" ,
26+ description : "Task template deleted successfully." ,
27+ status : "success" ,
28+ duration : 3000 ,
29+ isClosable : true ,
30+ } ) ;
31+ onDeleteSuccess ?.( ) ;
32+ onClose ( ) ;
33+ } catch ( error ) {
34+ toast ( {
35+ title : "Error" ,
36+ description : "Failed to delete task template. Please try again later." ,
37+ status : "error" ,
38+ duration : 3000 ,
39+ isClosable : true ,
40+ } ) ;
41+ }
42+ } ;
43+
44+ return (
45+ < PopupModal
46+ open = { isOpen }
47+ title = "Delete Template?"
48+ message = "Are you sure you want to delete this template? Tasks can no longer be created with this template. This process cannot be undone."
49+ primaryButtonText = "Delete"
50+ onPrimaryClick = { handlePrimaryButtonClick }
51+ primaryButtonColor = "red"
52+ secondaryButtonText = "Cancel"
53+ onSecondaryClick = { onClose }
54+ />
55+ ) ;
56+ } ;
57+
58+ export default DeleteTaskTemplateModal ;
You can’t perform that action at this time.
0 commit comments