1
0
Fork 0

fix: optimise CSS

user-stream
Lea 2023-09-02 23:54:18 +02:00 committed by insert
parent 373c66a251
commit c54c690fe4
1 changed files with 72 additions and 70 deletions

View File

@ -56,77 +56,79 @@ export default function Classifications() {
<TableRow> <TableRow>
<TableHead>Domain</TableHead> <TableHead>Domain</TableHead>
<TableHead>Classification</TableHead> <TableHead>Classification</TableHead>
<TableHead>Action</TableHead> <TableHead className="flex flex-row items-center justify-between gap-2 pr-1">
<TableHead className="text-end pr-2"> <span>Action</span>
<AlertDialog> <div className="text-end pr-2">
<AlertDialogTrigger asChild> <AlertDialog>
<Button disabled={!loaded}>Add</Button> <AlertDialogTrigger asChild>
</AlertDialogTrigger> <Button disabled={!loaded}>Add</Button>
<AlertDialogContent> </AlertDialogTrigger>
<AlertDialogHeader> <AlertDialogContent>
<AlertDialogTitle>Create classification</AlertDialogTitle> <AlertDialogHeader>
<AlertDialogDescription className="flex flex-row gap-1"> <AlertDialogTitle>Create classification</AlertDialogTitle>
<Input <AlertDialogDescription className="flex flex-row gap-1">
value={domainDraft} <Input
onChange={(e) => setDomainDraft(e.currentTarget.value)} value={domainDraft}
placeholder="reddit.com" onChange={(e) => setDomainDraft(e.currentTarget.value)}
/> placeholder="reddit.com"
<Popover />
open={classificationOpen} <Popover
onOpenChange={setClassificationOpen} open={classificationOpen}
onOpenChange={setClassificationOpen}
>
<PopoverTrigger asChild>
<Button
variant="outline"
role="combobox"
aria-expanded={classificationOpen}
>
{classificationDraft || "Classification"}
</Button>
</PopoverTrigger>
<PopoverContent>
<Command>
{CLASSIFICATIONS.map((c) => (
<CommandItem key={c} onSelect={() => {
setClassificationDraft(c);
setClassificationOpen(false);
}}>
{c}
</CommandItem>
))}
</Command>
</PopoverContent>
</Popover>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
disabled={!domainDraft || !classificationDraft}
onClick={async () => {
try {
await createEmailClassification(domainDraft, classificationDraft);
setDomains([...domains, { _id: domainDraft, classification: classificationDraft }]);
setDomainDraft("");
setClassificationDraft("");
setClassificationOpen(false);
toast({
title: "Classification created",
});
} catch (e) {
toast({
title: "Failed to create classification",
description: String(e),
variant: "destructive",
});
}
}}
> >
<PopoverTrigger asChild> Create
<Button </AlertDialogAction>
variant="outline" </AlertDialogFooter>
role="combobox" </AlertDialogContent>
aria-expanded={classificationOpen} </AlertDialog>
> </div>
{classificationDraft || "Classification"}
</Button>
</PopoverTrigger>
<PopoverContent>
<Command>
{CLASSIFICATIONS.map((c) => (
<CommandItem key={c} onSelect={() => {
setClassificationDraft(c);
setClassificationOpen(false);
}}>
{c}
</CommandItem>
))}
</Command>
</PopoverContent>
</Popover>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
disabled={!domainDraft || !classificationDraft}
onClick={async () => {
try {
await createEmailClassification(domainDraft, classificationDraft);
setDomains([...domains, { _id: domainDraft, classification: classificationDraft }]);
setDomainDraft("");
setClassificationDraft("");
setClassificationOpen(false);
toast({
title: "Classification created",
});
} catch (e) {
toast({
title: "Failed to create classification",
description: String(e),
variant: "destructive",
});
}
}}
>
Create
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</TableHead> </TableHead>
</TableRow> </TableRow>
</TableHeader> </TableHeader>