diff --git a/client/src/components/settings/TicketSettings.tsx b/client/src/components/settings/TicketSettings.tsx index a40ca12..41745b5 100644 --- a/client/src/components/settings/TicketSettings.tsx +++ b/client/src/components/settings/TicketSettings.tsx @@ -805,8 +805,8 @@ const TicketSettings = ({ }, [quickResponsesState, setQuickResponsesState]); // AI Moderation computed values - const availablePunishmentTypes = punishmentTypesState?.filter(pt => - pt.isCustomizable && (!aiModerationSettings.aiPunishmentConfigs?.[pt.id] || !aiModerationSettings.aiPunishmentConfigs[pt.id].enabled) + const availablePunishmentTypes = punishmentTypesState?.filter(pt => + pt.isCustomizable && (!aiModerationSettings.aiPunishmentConfigs?.[pt.ordinal] || !aiModerationSettings.aiPunishmentConfigs[pt.ordinal].enabled) ) || []; // Clear form when dialog opens for new field (not editing) @@ -1034,13 +1034,13 @@ const TicketSettings = ({ if (selectedPunishmentTypeId && newAIPunishmentDescription.trim()) { const selectedType = punishmentTypesState.find(t => t.id === selectedPunishmentTypeId); if (selectedType) { - const newId = Date.now().toString(); + const configKey = selectedType.ordinal.toString(); setAiModerationSettings((prev: any) => ({ ...prev, aiPunishmentConfigs: { ...prev.aiPunishmentConfigs, - [newId]: { - id: newId, + [configKey]: { + id: configKey, name: selectedType.name, aiDescription: newAIPunishmentDescription.trim(), enabled: true @@ -1182,6 +1182,64 @@ const TicketSettings = ({ + {/* AI Punishment Edit Dialog */} + {selectedAIPunishmentType && ( + setSelectedAIPunishmentType(null)}> + + + Edit AI Punishment Configuration + + Update the AI description for "{selectedAIPunishmentType.name}". + + + + + + AI Description + setNewAIPunishmentDescription(e.target.value)} + /> + + This description helps the AI understand when to suggest this punishment type. + + + + + + setSelectedAIPunishmentType(null)} + > + Cancel + + { + if (selectedAIPunishmentType && newAIPunishmentDescription.trim()) { + setAiModerationSettings((prev: any) => ({ + ...prev, + aiPunishmentConfigs: { + ...prev.aiPunishmentConfigs, + [selectedAIPunishmentType.id]: { + ...prev.aiPunishmentConfigs[selectedAIPunishmentType.id], + aiDescription: newAIPunishmentDescription.trim() + } + } + })); + setSelectedAIPunishmentType(null); + } + }} + disabled={!newAIPunishmentDescription.trim()} + > + Save Changes + + + + + )} + {/* Quick Response Action Dialog */}
+ This description helps the AI understand when to suggest this punishment type. +