diff --git a/src/components/admin/admin-feature-selection.tsx b/src/components/admin/admin-feature-selection.tsx index 931625b..440ac0b 100644 --- a/src/components/admin/admin-feature-selection.tsx +++ b/src/components/admin/admin-feature-selection.tsx @@ -3,6 +3,7 @@ import { useState, useEffect } from 'react' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' +import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Badge } from '@/components/ui/badge' import { Input } from '@/components/ui/input' import { Checkbox } from '@/components/ui/checkbox' @@ -84,6 +85,7 @@ export function AdminFeatureSelection({ template, onBack }: AdminFeatureSelectio }) const [selectedIds, setSelectedIds] = useState>(new Set()) const [showAIModal, setShowAIModal] = useState(false) + const [editingFeature, setEditingFeature] = useState(null) const load = async () => { try { @@ -169,6 +171,7 @@ export function AdminFeatureSelection({ template, onBack }: AdminFeatureSelectio try { await updateFeature(template.id, f.id, updates) await load() + setEditingFeature(null) } catch (err) { console.error('Error updating feature:', err) const message = err instanceof Error ? err.message : 'Failed to update feature' @@ -178,6 +181,7 @@ export function AdminFeatureSelection({ template, onBack }: AdminFeatureSelectio const handleDelete = async (f: TemplateFeature) => { try { + if (!confirm(`Delete feature "${f.name}"? This cannot be undone.`)) return await deleteFeature(template.id, f.id) setSelectedIds((prev) => { const next = new Set(prev) @@ -230,26 +234,24 @@ export function AdminFeatureSelection({ template, onBack }: AdminFeatureSelectio /> {f.name} - {f.feature_type === 'custom' && ( -
- - -
- )} +
+ + +
@@ -289,6 +291,27 @@ export function AdminFeatureSelection({ template, onBack }: AdminFeatureSelectio {section('Your Custom Features', customFeatures)} + {/* Edit Feature Modal reusing AI-Powered Feature Creator */} + {editingFeature && ( + { + await handleUpdate(editingFeature, { + name: payload.name, + description: payload.description, + complexity: payload.complexity, + // Map AI form structure to backend fields + business_rules: payload.business_rules, + // Flatten logic rules to store if backend supports it on update + logic_rules: payload.logic_rules, + } as any) + setEditingFeature(null) + }} + onClose={() => setEditingFeature(null)} + /> + )} + {showAIModal && ( { const [descExpanded, setDescExpanded] = useState(false) @@ -335,14 +335,14 @@ export function AdminTemplatesList({ onTemplateSelect }: AdminTemplatesListProps onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); handleManageFeatures(template) } }} > -
-
+
+
- {truncatedTitle} + {truncatedTitle} -
+
{template.type} @@ -351,7 +351,7 @@ export function AdminTemplatesList({ onTemplateSelect }: AdminTemplatesListProps
-
e.stopPropagation()}> +
e.stopPropagation()}>
{fullDesc && ( -
+
{shownDesc} {needsClamp && (