when you click on edit flows, the whole flow sjould be displayed with an

This commit is contained in:
Leon Serfaty G
2025-07-18 05:34:46 +00:00
parent 80aa0f32ba
commit 8e4af8e745
2 changed files with 135 additions and 32 deletions
+40 -32
View File
@@ -8,11 +8,12 @@ import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Textarea } from '@/components/ui/textarea';
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card';
import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter } from '@/components/ui/card';
import { useToast } from '@/hooks/use-toast';
import Link from 'next/link';
import { ChevronLeft } from 'lucide-react';
import { ChevronLeft, Plus } from 'lucide-react';
import { Skeleton } from '@/components/ui/skeleton';
import { FlowCanvas } from '@/components/admin/flow-canvas';
interface FlowFormPageProps {
params: { id: string };
@@ -93,7 +94,7 @@ export default function FlowFormPage({ params }: FlowFormPageProps) {
}
return (
<form action={formAction} className="space-y-8">
<div className="space-y-8">
<div className="flex items-center gap-4">
<Button variant="outline" size="icon" asChild>
<Link href="/admin/flows">
@@ -106,34 +107,41 @@ export default function FlowFormPage({ params }: FlowFormPageProps) {
</h1>
</div>
<Card>
<CardHeader>
<CardTitle>Flow Details</CardTitle>
<CardDescription>
{isNew ? 'Fill in the details for your new flow.' : 'Update the details for this flow.'}
</CardDescription>
</CardHeader>
<CardContent className="space-y-6">
<input type="hidden" name="id" value={flow?.id} />
<div className="space-y-2">
<Label htmlFor="name">Flow Name</Label>
<Input id="name" name="name" defaultValue={flow?.name} required />
{getError('name') && <p className="text-sm text-destructive">{getError('name')}</p>}
</div>
<div className="space-y-2">
<Label htmlFor="path">Path</Label>
<Input id="path" name="path" defaultValue={flow?.path} placeholder="/my-cool-flow" required />
{getError('path') && <p className="text-sm text-destructive">{getError('path')}</p>}
</div>
<div className="space-y-2">
<Label htmlFor="description">Description</Label>
<Textarea id="description" name="description" defaultValue={flow?.description || ''} placeholder="A brief description of what this flow does." />
{getError('description') && <p className="text-sm text-destructive">{getError('description')}</p>}
</div>
</CardContent>
</Card>
<SubmitButton isNew={isNew} />
</form>
<form action={formAction} className="space-y-8">
<Card>
<CardHeader>
<CardTitle>Flow Details</CardTitle>
<CardDescription>
{isNew ? 'Fill in the details for your new flow.' : 'Update the details for this flow.'}
</CardDescription>
</CardHeader>
<CardContent className="space-y-6">
<input type="hidden" name="id" value={flow?.id} />
<div className="space-y-2">
<Label htmlFor="name">Flow Name</Label>
<Input id="name" name="name" defaultValue={flow?.name} required />
{getError('name') && <p className="text-sm text-destructive">{getError('name')}</p>}
</div>
<div className="space-y-2">
<Label htmlFor="path">Path</Label>
<Input id="path" name="path" defaultValue={flow?.path} placeholder="/my-cool-flow" required />
{getError('path') && <p className="text-sm text-destructive">{getError('path')}</p>}
</div>
<div className="space-y-2">
<Label htmlFor="description">Description</Label>
<Textarea id="description" name="description" defaultValue={flow?.description || ''} placeholder="A brief description of what this flow does." />
{getError('description') && <p className="text-sm text-destructive">{getError('description')}</p>}
</div>
</CardContent>
<CardFooter>
<SubmitButton isNew={isNew} />
</CardFooter>
</Card>
</form>
{!isNew && (
<FlowCanvas />
)}
</div>
);
}