"use client"; import { AlertDialog, AlertDialogAction, AlertDialogContent, AlertDialogFooter, AlertDialogHeader, AlertDialogTrigger, AlertDialogCancel, AlertDialogDescription, } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { Command, CommandItem } from "@/components/ui/command"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { TableCell, TableRow } from "@/components/ui/table"; import { toast } from "@/components/ui/use-toast"; import { deleteEmailClassification, updateEmailClassification } from "@/lib/actions"; import { cn } from "@/lib/utils"; import { Check } from "lucide-react"; import { useState } from "react"; export const CLASSIFICATIONS = [ "DISPOSABLE", "GAYSEX", "HOMOSEXUAL", "FDGIUHDIFUIOFZH", ]; export default function EmailClassificationRow({ domain, ...props }: { domain: string; classification: string; }) { const [classification, setClassification] = useState(props.classification); const [selectClassification, setSelectClassification] = useState(false); const [deleted, setDeleted] = useState(false); return deleted ? null : ( {domain} {CLASSIFICATIONS.map((c) => ( { try { await updateEmailClassification(domain, c); setSelectClassification(false); setClassification(c); toast({ title: "Classification updated", description: `${domain} is now classified as ${c}`, }); } catch (e) { toast({ title: "Failed to update classification", description: String(e), variant: "destructive", }); } }} > {c} ))} Delete classification for {domain}? Cancel { try { await deleteEmailClassification(domain); setDeleted(true); toast({ title: "Classification deleted", }); } catch(e) { toast({ title: "Failed to delete classification", description: String(e), variant: "destructive", }); } }} > Remove ); }