|
|
|
@@ -1,69 +1,82 @@
|
|
|
|
|
"use client";
|
|
|
|
|
'use client'
|
|
|
|
|
|
|
|
|
|
import { ArrowLeft, HardHat, Loader2, Package, Pencil, Plus, Save, Trash2 } from "lucide-react";
|
|
|
|
|
import Link from "next/link";
|
|
|
|
|
import { useEffect, useRef, useState } from "react";
|
|
|
|
|
import { createBcItem, deleteBcItem, updateBcItem, updateBcPage } from "@/actions/catalog-bc";
|
|
|
|
|
import { Badge } from "@/components/ui/badge";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
|
|
|
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
|
|
|
|
import { Input } from "@/components/ui/input";
|
|
|
|
|
import { Label } from "@/components/ui/label";
|
|
|
|
|
import { Switch } from "@/components/ui/switch";
|
|
|
|
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
|
|
|
|
import { Textarea } from "@/components/ui/textarea";
|
|
|
|
|
import { useServerAction } from "@/hooks/use-server-action";
|
|
|
|
|
import { ArrowLeft, HardHat, Loader2, Package, Pencil, Plus, Save, Trash2 } from 'lucide-react'
|
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
import { useEffect, useRef, useState } from 'react'
|
|
|
|
|
import { createBcItem, deleteBcItem, updateBcItem, updateBcPage } from '@/actions/catalog-bc'
|
|
|
|
|
import { Badge } from '@/components/ui/badge'
|
|
|
|
|
import { Button } from '@/components/ui/button'
|
|
|
|
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
|
|
|
|
import {
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogContent,
|
|
|
|
|
DialogFooter,
|
|
|
|
|
DialogHeader,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
} from '@/components/ui/dialog'
|
|
|
|
|
import { Input } from '@/components/ui/input'
|
|
|
|
|
import { Label } from '@/components/ui/label'
|
|
|
|
|
import { Switch } from '@/components/ui/switch'
|
|
|
|
|
import {
|
|
|
|
|
Table,
|
|
|
|
|
TableBody,
|
|
|
|
|
TableCell,
|
|
|
|
|
TableHead,
|
|
|
|
|
TableHeader,
|
|
|
|
|
TableRow,
|
|
|
|
|
} from '@/components/ui/table'
|
|
|
|
|
import { Textarea } from '@/components/ui/textarea'
|
|
|
|
|
import { useServerAction } from '@/hooks/use-server-action'
|
|
|
|
|
|
|
|
|
|
// ── Types ────────────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
export interface BcPageData {
|
|
|
|
|
id: number;
|
|
|
|
|
parentId: number;
|
|
|
|
|
caption: string;
|
|
|
|
|
pageLayout: string;
|
|
|
|
|
iconColor: number;
|
|
|
|
|
iconImage: number;
|
|
|
|
|
orderNum: number;
|
|
|
|
|
visible: string;
|
|
|
|
|
enabled: string;
|
|
|
|
|
pageHeadline: string;
|
|
|
|
|
pageTeaser: string;
|
|
|
|
|
pageSpecial: string;
|
|
|
|
|
pageText1: string;
|
|
|
|
|
pageText2: string;
|
|
|
|
|
pageTextDetails: string;
|
|
|
|
|
pageTextTeaser: string;
|
|
|
|
|
id: number
|
|
|
|
|
parentId: number
|
|
|
|
|
caption: string
|
|
|
|
|
pageLayout: string
|
|
|
|
|
iconColor: number
|
|
|
|
|
iconImage: number
|
|
|
|
|
orderNum: number
|
|
|
|
|
visible: string
|
|
|
|
|
enabled: string
|
|
|
|
|
pageHeadline: string
|
|
|
|
|
pageTeaser: string
|
|
|
|
|
pageSpecial: string
|
|
|
|
|
pageText1: string
|
|
|
|
|
pageText2: string
|
|
|
|
|
pageTextDetails: string
|
|
|
|
|
pageTextTeaser: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface BcItemData {
|
|
|
|
|
id: number;
|
|
|
|
|
pageId: number;
|
|
|
|
|
itemIds: string;
|
|
|
|
|
catalogName: string;
|
|
|
|
|
orderNumber: number;
|
|
|
|
|
extradata: string;
|
|
|
|
|
id: number
|
|
|
|
|
pageId: number
|
|
|
|
|
itemIds: string
|
|
|
|
|
catalogName: string
|
|
|
|
|
orderNumber: number
|
|
|
|
|
extradata: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface BcPageDetailProps {
|
|
|
|
|
page: BcPageData;
|
|
|
|
|
items: BcItemData[];
|
|
|
|
|
canEdit: boolean;
|
|
|
|
|
page: BcPageData
|
|
|
|
|
items: BcItemData[]
|
|
|
|
|
canEdit: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ── Main Component ───────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
const { isPending, run } = useServerAction();
|
|
|
|
|
const formRef = useRef<HTMLFormElement>(null);
|
|
|
|
|
const [editingItem, setEditingItem] = useState<BcItemData | null>(null);
|
|
|
|
|
const [addingItem, setAddingItem] = useState(false);
|
|
|
|
|
const { isPending, run } = useServerAction()
|
|
|
|
|
const formRef = useRef<HTMLFormElement>(null)
|
|
|
|
|
const [editingItem, setEditingItem] = useState<BcItemData | null>(null)
|
|
|
|
|
const [addingItem, setAddingItem] = useState(false)
|
|
|
|
|
|
|
|
|
|
const [form, setForm] = useState({
|
|
|
|
|
caption: page.caption,
|
|
|
|
|
orderNum: page.orderNum,
|
|
|
|
|
enabled: page.enabled as "0" | "1",
|
|
|
|
|
visible: page.visible as "0" | "1",
|
|
|
|
|
enabled: page.enabled as '0' | '1',
|
|
|
|
|
visible: page.visible as '0' | '1',
|
|
|
|
|
pageHeadline: page.pageHeadline,
|
|
|
|
|
pageTeaser: page.pageTeaser,
|
|
|
|
|
pageSpecial: page.pageSpecial,
|
|
|
|
@@ -71,31 +84,31 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
pageText2: page.pageText2,
|
|
|
|
|
pageTextDetails: page.pageTextDetails,
|
|
|
|
|
pageTextTeaser: page.pageTextTeaser,
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Ctrl+S / Cmd+S to save
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!canEdit) return;
|
|
|
|
|
if (!canEdit) return
|
|
|
|
|
function onKeyDown(e: KeyboardEvent) {
|
|
|
|
|
if ((e.metaKey || e.ctrlKey) && e.key === "s") {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
formRef.current?.requestSubmit();
|
|
|
|
|
if ((e.metaKey || e.ctrlKey) && e.key === 's') {
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
formRef.current?.requestSubmit()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
document.addEventListener("keydown", onKeyDown);
|
|
|
|
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
|
|
|
}, [canEdit]);
|
|
|
|
|
document.addEventListener('keydown', onKeyDown)
|
|
|
|
|
return () => document.removeEventListener('keydown', onKeyDown)
|
|
|
|
|
}, [canEdit])
|
|
|
|
|
|
|
|
|
|
function update<K extends keyof typeof form>(key: K, value: (typeof form)[K]) {
|
|
|
|
|
setForm((prev) => ({ ...prev, [key]: value }));
|
|
|
|
|
setForm((prev) => ({ ...prev, [key]: value }))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleSubmit(e: React.FormEvent) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
run(() => updateBcPage({ id: page.id, ...form }), {
|
|
|
|
|
successMessage: "BC page updated and catalog synced.",
|
|
|
|
|
errorMessage: "Failed to update.",
|
|
|
|
|
});
|
|
|
|
|
successMessage: 'BC page updated and catalog synced.',
|
|
|
|
|
errorMessage: 'Failed to update.',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
@@ -137,7 +150,7 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
<Input
|
|
|
|
|
id="caption"
|
|
|
|
|
value={form.caption}
|
|
|
|
|
onChange={(e) => update("caption", e.target.value)}
|
|
|
|
|
onChange={(e) => update('caption', e.target.value)}
|
|
|
|
|
disabled={!canEdit}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
@@ -147,7 +160,7 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
id="orderNum"
|
|
|
|
|
type="number"
|
|
|
|
|
value={form.orderNum}
|
|
|
|
|
onChange={(e) => update("orderNum", parseInt(e.target.value, 10) || 0)}
|
|
|
|
|
onChange={(e) => update('orderNum', parseInt(e.target.value, 10) || 0)}
|
|
|
|
|
disabled={!canEdit}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
@@ -157,7 +170,7 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
<Label>Headline</Label>
|
|
|
|
|
<Input
|
|
|
|
|
value={form.pageHeadline}
|
|
|
|
|
onChange={(e) => update("pageHeadline", e.target.value)}
|
|
|
|
|
onChange={(e) => update('pageHeadline', e.target.value)}
|
|
|
|
|
disabled={!canEdit}
|
|
|
|
|
placeholder="Headline image path"
|
|
|
|
|
/>
|
|
|
|
@@ -166,7 +179,7 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
<Label>Teaser</Label>
|
|
|
|
|
<Input
|
|
|
|
|
value={form.pageTeaser}
|
|
|
|
|
onChange={(e) => update("pageTeaser", e.target.value)}
|
|
|
|
|
onChange={(e) => update('pageTeaser', e.target.value)}
|
|
|
|
|
disabled={!canEdit}
|
|
|
|
|
placeholder="Teaser image path"
|
|
|
|
|
/>
|
|
|
|
@@ -177,7 +190,7 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
<Label>Text 1</Label>
|
|
|
|
|
<Textarea
|
|
|
|
|
value={form.pageText1}
|
|
|
|
|
onChange={(e) => update("pageText1", e.target.value)}
|
|
|
|
|
onChange={(e) => update('pageText1', e.target.value)}
|
|
|
|
|
disabled={!canEdit}
|
|
|
|
|
rows={3}
|
|
|
|
|
/>
|
|
|
|
@@ -186,7 +199,7 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
<Label>Text 2</Label>
|
|
|
|
|
<Textarea
|
|
|
|
|
value={form.pageText2}
|
|
|
|
|
onChange={(e) => update("pageText2", e.target.value)}
|
|
|
|
|
onChange={(e) => update('pageText2', e.target.value)}
|
|
|
|
|
disabled={!canEdit}
|
|
|
|
|
rows={3}
|
|
|
|
|
/>
|
|
|
|
@@ -198,7 +211,7 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
<Label>Details</Label>
|
|
|
|
|
<Textarea
|
|
|
|
|
value={form.pageTextDetails}
|
|
|
|
|
onChange={(e) => update("pageTextDetails", e.target.value)}
|
|
|
|
|
onChange={(e) => update('pageTextDetails', e.target.value)}
|
|
|
|
|
disabled={!canEdit}
|
|
|
|
|
rows={3}
|
|
|
|
|
/>
|
|
|
|
@@ -207,7 +220,7 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
<Label>Text Teaser</Label>
|
|
|
|
|
<Textarea
|
|
|
|
|
value={form.pageTextTeaser}
|
|
|
|
|
onChange={(e) => update("pageTextTeaser", e.target.value)}
|
|
|
|
|
onChange={(e) => update('pageTextTeaser', e.target.value)}
|
|
|
|
|
disabled={!canEdit}
|
|
|
|
|
rows={3}
|
|
|
|
|
/>
|
|
|
|
@@ -218,7 +231,7 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
<Label>Special</Label>
|
|
|
|
|
<Textarea
|
|
|
|
|
value={form.pageSpecial}
|
|
|
|
|
onChange={(e) => update("pageSpecial", e.target.value)}
|
|
|
|
|
onChange={(e) => update('pageSpecial', e.target.value)}
|
|
|
|
|
disabled={!canEdit}
|
|
|
|
|
rows={2}
|
|
|
|
|
/>
|
|
|
|
@@ -250,7 +263,9 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
{items.length === 0 ? (
|
|
|
|
|
<p className="text-sm text-muted-foreground text-center py-4">No items in this page.</p>
|
|
|
|
|
<p className="text-sm text-muted-foreground text-center py-4">
|
|
|
|
|
No items in this page.
|
|
|
|
|
</p>
|
|
|
|
|
) : (
|
|
|
|
|
<Table>
|
|
|
|
|
<TableHeader>
|
|
|
|
@@ -273,7 +288,7 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell className="text-xs">{item.orderNumber}</TableCell>
|
|
|
|
|
<TableCell className="text-xs text-muted-foreground max-w-32 truncate">
|
|
|
|
|
{item.extradata || "\u2014"}
|
|
|
|
|
{item.extradata || '\u2014'}
|
|
|
|
|
</TableCell>
|
|
|
|
|
{canEdit && (
|
|
|
|
|
<TableCell>
|
|
|
|
@@ -293,10 +308,10 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
size="sm"
|
|
|
|
|
className="h-6 w-6 p-0 text-[var(--admin-error)] hover:text-[var(--admin-error)]"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
if (!confirm(`Delete item "${item.catalogName}"?`)) return;
|
|
|
|
|
if (!confirm(`Delete item "${item.catalogName}"?`)) return
|
|
|
|
|
run(() => deleteBcItem({ id: item.id }), {
|
|
|
|
|
successMessage: "Item deleted.",
|
|
|
|
|
});
|
|
|
|
|
successMessage: 'Item deleted.',
|
|
|
|
|
})
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Trash2 className="h-3 w-3" />
|
|
|
|
@@ -325,16 +340,16 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
id="tg-enabled"
|
|
|
|
|
label="Enabled"
|
|
|
|
|
description="Active in the BC catalog"
|
|
|
|
|
checked={form.enabled === "1"}
|
|
|
|
|
onChange={(v) => update("enabled", v ? "1" : "0")}
|
|
|
|
|
checked={form.enabled === '1'}
|
|
|
|
|
onChange={(v) => update('enabled', v ? '1' : '0')}
|
|
|
|
|
disabled={!canEdit}
|
|
|
|
|
/>
|
|
|
|
|
<ToggleRow
|
|
|
|
|
id="tg-visible"
|
|
|
|
|
label="Visible"
|
|
|
|
|
description="Shown in BC navigation"
|
|
|
|
|
checked={form.visible === "1"}
|
|
|
|
|
onChange={(v) => update("visible", v ? "1" : "0")}
|
|
|
|
|
checked={form.visible === '1'}
|
|
|
|
|
onChange={(v) => update('visible', v ? '1' : '0')}
|
|
|
|
|
disabled={!canEdit}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
@@ -345,8 +360,10 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
Layout: <span className="font-mono">{page.pageLayout}</span>
|
|
|
|
|
</span>
|
|
|
|
|
<span>
|
|
|
|
|
Parent:{" "}
|
|
|
|
|
<span className="font-mono">{page.parentId <= 0 ? "Root" : `#${page.parentId}`}</span>
|
|
|
|
|
Parent:{' '}
|
|
|
|
|
<span className="font-mono">
|
|
|
|
|
{page.parentId <= 0 ? 'Root' : `#${page.parentId}`}
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
@@ -381,9 +398,9 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
onClose={() => setEditingItem(null)}
|
|
|
|
|
onSubmit={(data) => {
|
|
|
|
|
run(() => updateBcItem({ id: editingItem.id, ...data }), {
|
|
|
|
|
successMessage: "Item updated.",
|
|
|
|
|
successMessage: 'Item updated.',
|
|
|
|
|
onSuccess: () => setEditingItem(null),
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
@@ -394,24 +411,24 @@ export function BcPageDetail({ page, items, canEdit }: BcPageDetailProps) {
|
|
|
|
|
item={{
|
|
|
|
|
id: 0,
|
|
|
|
|
pageId: page.id,
|
|
|
|
|
itemIds: "",
|
|
|
|
|
catalogName: "",
|
|
|
|
|
itemIds: '',
|
|
|
|
|
catalogName: '',
|
|
|
|
|
orderNumber: 1,
|
|
|
|
|
extradata: "",
|
|
|
|
|
extradata: '',
|
|
|
|
|
}}
|
|
|
|
|
mode="add"
|
|
|
|
|
isPending={isPending}
|
|
|
|
|
onClose={() => setAddingItem(false)}
|
|
|
|
|
onSubmit={(data) => {
|
|
|
|
|
run(() => createBcItem({ pageId: page.id, ...data }), {
|
|
|
|
|
successMessage: "Item created.",
|
|
|
|
|
successMessage: 'Item created.',
|
|
|
|
|
onSuccess: () => setAddingItem(false),
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ── Toggle row ───────────────────────────────────────────────────────
|
|
|
|
@@ -424,12 +441,12 @@ function ToggleRow({
|
|
|
|
|
onChange,
|
|
|
|
|
disabled,
|
|
|
|
|
}: {
|
|
|
|
|
id: string;
|
|
|
|
|
label: string;
|
|
|
|
|
description: string;
|
|
|
|
|
checked: boolean;
|
|
|
|
|
onChange: (v: boolean) => void;
|
|
|
|
|
disabled?: boolean;
|
|
|
|
|
id: string
|
|
|
|
|
label: string
|
|
|
|
|
description: string
|
|
|
|
|
checked: boolean
|
|
|
|
|
onChange: (v: boolean) => void
|
|
|
|
|
disabled?: boolean
|
|
|
|
|
}) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-start justify-between gap-3">
|
|
|
|
@@ -441,7 +458,7 @@ function ToggleRow({
|
|
|
|
|
</div>
|
|
|
|
|
<Switch id={id} checked={checked} onCheckedChange={onChange} disabled={disabled} />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ── Item Dialog ──────────────────────────────────────────────────────
|
|
|
|
@@ -453,24 +470,29 @@ function ItemDialog({
|
|
|
|
|
onClose,
|
|
|
|
|
onSubmit,
|
|
|
|
|
}: {
|
|
|
|
|
item: BcItemData;
|
|
|
|
|
mode: "add" | "edit";
|
|
|
|
|
isPending: boolean;
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
onSubmit: (data: { itemIds: string; catalogName: string; orderNumber: number; extradata: string }) => void;
|
|
|
|
|
item: BcItemData
|
|
|
|
|
mode: 'add' | 'edit'
|
|
|
|
|
isPending: boolean
|
|
|
|
|
onClose: () => void
|
|
|
|
|
onSubmit: (data: {
|
|
|
|
|
itemIds: string
|
|
|
|
|
catalogName: string
|
|
|
|
|
orderNumber: number
|
|
|
|
|
extradata: string
|
|
|
|
|
}) => void
|
|
|
|
|
}) {
|
|
|
|
|
const [form, setForm] = useState({
|
|
|
|
|
itemIds: item.itemIds,
|
|
|
|
|
catalogName: item.catalogName,
|
|
|
|
|
orderNumber: item.orderNumber,
|
|
|
|
|
extradata: item.extradata,
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Dialog open onOpenChange={(open) => !open && onClose()}>
|
|
|
|
|
<DialogContent>
|
|
|
|
|
<DialogHeader>
|
|
|
|
|
<DialogTitle>{mode === "add" ? "Add BC Item" : `Edit Item #${item.id}`}</DialogTitle>
|
|
|
|
|
<DialogTitle>{mode === 'add' ? 'Add BC Item' : `Edit Item #${item.id}`}</DialogTitle>
|
|
|
|
|
</DialogHeader>
|
|
|
|
|
<div className="space-y-4 py-2">
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
@@ -493,7 +515,9 @@ function ItemDialog({
|
|
|
|
|
<Input
|
|
|
|
|
type="number"
|
|
|
|
|
value={form.orderNumber}
|
|
|
|
|
onChange={(e) => setForm((f) => ({ ...f, orderNumber: parseInt(e.target.value, 10) || 0 }))}
|
|
|
|
|
onChange={(e) =>
|
|
|
|
|
setForm((f) => ({ ...f, orderNumber: parseInt(e.target.value, 10) || 0 }))
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
@@ -510,12 +534,15 @@ function ItemDialog({
|
|
|
|
|
<Button variant="outline" onClick={onClose} disabled={isPending}>
|
|
|
|
|
Cancel
|
|
|
|
|
</Button>
|
|
|
|
|
<Button onClick={() => onSubmit(form)} disabled={isPending || !form.catalogName || !form.itemIds}>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => onSubmit(form)}
|
|
|
|
|
disabled={isPending || !form.catalogName || !form.itemIds}
|
|
|
|
|
>
|
|
|
|
|
{isPending && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
|
|
|
{mode === "add" ? "Add Item" : "Save"}
|
|
|
|
|
{mode === 'add' ? 'Add Item' : 'Save'}
|
|
|
|
|
</Button>
|
|
|
|
|
</DialogFooter>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
);
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|