Skip to content

Commit f908763

Browse files
committed
feat: save filters
1 parent 333591b commit f908763

File tree

6 files changed

+1502
-45
lines changed

6 files changed

+1502
-45
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
'use client';
2+
3+
import { TrashIcon, WarningIcon } from '@phosphor-icons/react';
4+
import { Button } from '@/components/ui/button';
5+
import {
6+
Dialog,
7+
DialogContent,
8+
DialogDescription,
9+
DialogHeader,
10+
DialogTitle,
11+
} from '@/components/ui/dialog';
12+
13+
interface DeleteAllDialogProps {
14+
isOpen: boolean;
15+
onClose: () => void;
16+
onConfirm: () => void;
17+
filterCount: number;
18+
isDeleting?: boolean;
19+
}
20+
21+
export function DeleteAllDialog({
22+
isOpen,
23+
onClose,
24+
onConfirm,
25+
filterCount,
26+
isDeleting = false,
27+
}: DeleteAllDialogProps) {
28+
const handleConfirm = () => {
29+
onConfirm();
30+
onClose();
31+
};
32+
33+
return (
34+
<Dialog onOpenChange={onClose} open={isOpen}>
35+
<DialogContent className="max-w-md">
36+
<DialogHeader className="space-y-3">
37+
<DialogTitle className="flex items-center gap-3 text-destructive">
38+
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-destructive/10">
39+
<WarningIcon
40+
className="h-4 w-4 text-destructive"
41+
weight="duotone"
42+
/>
43+
</div>
44+
<span className="font-semibold">Delete All Saved Filters</span>
45+
</DialogTitle>
46+
<DialogDescription className="text-muted-foreground">
47+
Are you sure you want to delete all{' '}
48+
<span className="font-medium text-foreground">{filterCount}</span>{' '}
49+
saved filter
50+
{filterCount === 1 ? '' : 's'}? This will permanently remove all
51+
your saved filter configurations and cannot be undone.
52+
</DialogDescription>
53+
</DialogHeader>
54+
55+
<div className="flex justify-end gap-3 pt-6">
56+
<Button
57+
className="h-10"
58+
disabled={isDeleting}
59+
onClick={onClose}
60+
variant="outline"
61+
>
62+
Cancel
63+
</Button>
64+
<Button
65+
className="h-10 gap-2"
66+
disabled={isDeleting}
67+
onClick={handleConfirm}
68+
variant="destructive"
69+
>
70+
{isDeleting ? (
71+
'Deleting...'
72+
) : (
73+
<>
74+
<TrashIcon className="h-4 w-4" />
75+
<span>Delete All</span>
76+
</>
77+
)}
78+
</Button>
79+
</div>
80+
</DialogContent>
81+
</Dialog>
82+
);
83+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
'use client';
2+
3+
import { TrashIcon, WarningIcon } from '@phosphor-icons/react';
4+
import { Button } from '@/components/ui/button';
5+
import {
6+
Dialog,
7+
DialogContent,
8+
DialogDescription,
9+
DialogHeader,
10+
DialogTitle,
11+
} from '@/components/ui/dialog';
12+
13+
interface DeleteFilterDialogProps {
14+
isOpen: boolean;
15+
onClose: () => void;
16+
onConfirm: () => void;
17+
filterName: string;
18+
isDeleting?: boolean;
19+
}
20+
21+
export function DeleteFilterDialog({
22+
isOpen,
23+
onClose,
24+
onConfirm,
25+
filterName,
26+
isDeleting = false,
27+
}: DeleteFilterDialogProps) {
28+
const handleConfirm = () => {
29+
onConfirm();
30+
onClose();
31+
};
32+
33+
return (
34+
<Dialog onOpenChange={onClose} open={isOpen}>
35+
<DialogContent className="max-w-md">
36+
<DialogHeader className="space-y-3">
37+
<DialogTitle className="flex items-center gap-3 text-destructive">
38+
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-destructive/10">
39+
<WarningIcon
40+
className="h-4 w-4 text-destructive"
41+
weight="duotone"
42+
/>
43+
</div>
44+
<span className="font-semibold">Delete Saved Filter</span>
45+
</DialogTitle>
46+
<DialogDescription className="text-muted-foreground">
47+
Are you sure you want to delete{' '}
48+
<span className="font-medium text-foreground">"{filterName}"</span>?
49+
This action cannot be undone and the filter configuration will be
50+
permanently removed.
51+
</DialogDescription>
52+
</DialogHeader>
53+
54+
<div className="flex justify-end gap-3 pt-6">
55+
<Button
56+
className="h-10"
57+
disabled={isDeleting}
58+
onClick={onClose}
59+
variant="outline"
60+
>
61+
Cancel
62+
</Button>
63+
<Button
64+
className="h-10 gap-2"
65+
disabled={isDeleting}
66+
onClick={handleConfirm}
67+
variant="destructive"
68+
>
69+
{isDeleting ? (
70+
'Deleting...'
71+
) : (
72+
<>
73+
<TrashIcon className="h-4 w-4" />
74+
<span>Delete</span>
75+
</>
76+
)}
77+
</Button>
78+
</div>
79+
</DialogContent>
80+
</Dialog>
81+
);
82+
}

0 commit comments

Comments
 (0)