Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 63 additions & 5 deletions client/src/components/settings/TicketSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1182,6 +1182,64 @@ const TicketSettings = ({
</AlertDialogContent>
</AlertDialog>

{/* AI Punishment Edit Dialog */}
{selectedAIPunishmentType && (
<Dialog open={Boolean(selectedAIPunishmentType)} onOpenChange={() => setSelectedAIPunishmentType(null)}>
<DialogContent className="max-w-lg">
<DialogHeader>
<DialogTitle>Edit AI Punishment Configuration</DialogTitle>
<DialogDescription>
Update the AI description for "{selectedAIPunishmentType.name}".
</DialogDescription>
</DialogHeader>

<div className="space-y-4">
<div className="space-y-2">
<Label htmlFor="edit-ai-punishment-desc">AI Description</Label>
<textarea
id="edit-ai-punishment-desc"
className="w-full rounded-md border border-border bg-background px-3 py-2 text-sm min-h-[100px]"
value={newAIPunishmentDescription}
onChange={(e) => setNewAIPunishmentDescription(e.target.value)}
/>
<p className="text-xs text-muted-foreground">
This description helps the AI understand when to suggest this punishment type.
</p>
</div>
</div>

<DialogFooter>
<Button
variant="outline"
onClick={() => setSelectedAIPunishmentType(null)}
>
Cancel
</Button>
<Button
onClick={() => {
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
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)}

{/* Quick Response Action Dialog */}
<Dialog open={showActionDialog} onOpenChange={setShowActionDialog}>
<DialogContent className="max-w-2xl">
Expand Down