@@ -4,6 +4,7 @@ import { Button } from "@/components/ui/button";
44import { Input } from "@/components/ui/input" ;
55import { calculateLevelProgress } from "@/lib/levelCalculation" ;
66import { Edit2 , Trash2 , Save , X , Star } from "lucide-react" ;
7+ import ConfirmDialog from "./ConfirmDialog" ;
78
89interface CharacteristicCardProps {
910 characteristic : Characteristic ;
@@ -12,6 +13,7 @@ interface CharacteristicCardProps {
1213const CharacteristicCard = ( { characteristic } : CharacteristicCardProps ) => {
1314 const { updateCharacteristic, deleteCharacteristic } = useCharacteristics ( ) ;
1415 const [ isEditing , setIsEditing ] = useState ( false ) ;
16+ const [ showDeleteDialog , setShowDeleteDialog ] = useState ( false ) ;
1517 const [ editName , setEditName ] = useState ( characteristic . name ) ;
1618 const [ editIcon , setEditIcon ] = useState ( characteristic . icon ) ;
1719 const [ editXP , setEditXP ] = useState ( characteristic . xp . toString ( ) ) ;
@@ -36,13 +38,17 @@ const CharacteristicCard = ({ characteristic }: CharacteristicCardProps) => {
3638 } ;
3739
3840 const handleDelete = ( ) => {
39- if ( window . confirm ( `Delete characteristic "${ characteristic . name } "?` ) ) {
40- deleteCharacteristic . mutate ( characteristic . id ) ;
41- }
41+ setShowDeleteDialog ( true ) ;
42+ } ;
43+
44+ const confirmDelete = ( ) => {
45+ deleteCharacteristic . mutate ( characteristic . id ) ;
46+ setShowDeleteDialog ( false ) ;
4247 } ;
4348
4449 return (
45- < div className = "system-panel p-4 space-y-3" >
50+ < >
51+ < div className = "system-panel p-4 space-y-3" >
4652 { /* Header */ }
4753 < div className = "flex items-start justify-between" >
4854 < div className = "flex items-center gap-3 flex-1" >
@@ -86,7 +92,7 @@ const CharacteristicCard = ({ characteristic }: CharacteristicCardProps) => {
8692 < Button
8793 variant = "ghost"
8894 size = "icon"
89- className = "h-8 w-8 text-green-600 hover:text-green-700 hover:bg-green-50 "
95+ className = "h-8 w-8 text-primary hover:text-primary/80 hover:bg-primary/10 "
9096 onClick = { handleSave }
9197 >
9298 < Save className = "w-4 h-4" />
@@ -153,6 +159,16 @@ const CharacteristicCard = ({ characteristic }: CharacteristicCardProps) => {
153159 </ div >
154160 </ div >
155161 </ div >
162+
163+ { /* Delete Confirmation Dialog */ }
164+ < ConfirmDialog
165+ open = { showDeleteDialog }
166+ onOpenChange = { setShowDeleteDialog }
167+ title = "Delete Characteristic"
168+ description = { `Are you sure you want to delete "${ characteristic . name } "? This action cannot be undone.` }
169+ onConfirm = { confirmDelete }
170+ />
171+ </ >
156172 ) ;
157173} ;
158174
0 commit comments