"use client"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { MoreHorizontal } from "lucide-react"; import type IShortcode from "@/interfaces/IShortcode"; import ShortcodeDialog from "@/components/shortcode-dialogue"; import { useState } from "react"; interface ShortcodeTableProps { shortcodes: IShortcode[]; onUpdate: (shortcode: IShortcode) => void; onDelete: (id: string) => void; onAdd: (shortcode: Omit) => void; } export function ShortcodeTable({ shortcodes, onUpdate, onDelete, onAdd, }: ShortcodeTableProps) { const [shortcodeSelected, setUpdateDialog] = useState( null, ); const [addDialog, setAddDialog] = useState(false); return (
setAddDialog(false)} />
ID Code Type Valeur Media ID Actions {shortcodes.map((shortcode) => ( {shortcode.id} {shortcode.code} {shortcode.type} {shortcode.value || "N/A"} {shortcode.media_id || "N/A"} setUpdateDialog(shortcode) } > Mettre à jour onDelete(shortcode.code) } > Supprimer ))}
{shortcodeSelected && ( setUpdateDialog(null)} /> )}
); }