| @@ -17,8 +17,9 @@ | ||
| 17 | 17 | CheckCircle, |
| 18 | 18 | XCircle, |
| 19 | 19 | } from "lucide-react"; |
| 20 | 20 | import { __ } from "../lib/i18n"; |
| 21 | +import { toDateValue } from "../lib/dateFormat"; | |
| 21 | 22 | import { Button } from "../components/ui/button"; |
| 22 | 23 | import { Input } from "../components/ui/input"; |
| 23 | 24 | import { Select } from "../components/ui/select"; |
| 24 | 25 | import { PageHeader } from "../components/common/PageHeader"; |
| @@ -64,8 +65,10 @@ | ||
| 64 | 65 | ? parseInt(urlParams.get("trip_id")!) |
| 65 | 66 | : null; |
| 66 | 67 | |
| 67 | 68 | // Filters and search |
| 69 | + const [bulkDeleteConfirm, setBulkDeleteConfirm] = useState(false); | |
| 70 | + | |
| 68 | 71 | const [searchTerm, setSearchTerm] = useState(""); |
| 69 | 72 | const [statusFilter, setStatusFilter] = useState("all"); |
| 70 | 73 | const [page, setPage] = useState(1); |
| 71 | 74 | |
| @@ -197,18 +200,11 @@ | ||
| 197 | 200 | if (!bulkAction || selectedIds.length === 0) return; |
| 198 | 201 | |
| 199 | 202 | switch (bulkAction) { |
| 200 | 203 | case "delete": |
| 201 | - if ( | |
| 202 | - confirm( | |
| 203 | - __( | |
| 204 | - "Are you sure you want to delete {count} rule(s)?", | |
| 205 | - "yatra", | |
| 206 | - ).replace("{count}", selectedIds.length.toString()), | |
| 207 | - ) | |
| 208 | - ) { | |
| 209 | - bulkDeleteMutation.mutate(selectedIds); | |
| 210 | - } | |
| 204 | + // Confirmed through the shared dialog, matching the single-rule delete | |
| 205 | + // already used on this page. | |
| 206 | + setBulkDeleteConfirm(true); | |
| 211 | 207 | break; |
| 212 | 208 | } |
| 213 | 209 | |
| 214 | 210 | setBulkAction(""); |
| @@ -230,9 +226,9 @@ | ||
| 230 | 226 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 231 | 227 | const formatDate = (dateString: string | null | undefined): string => { |
| 232 | 228 | if (!dateString) return "--"; |
| 233 | 229 | try { |
| 234 | - const date = new Date(dateString); | |
| 230 | + const date = toDateValue(dateString); | |
| 235 | 231 | return date.toLocaleDateString("en-US", { |
| 236 | 232 | year: "numeric", |
| 237 | 233 | month: "short", |
| 238 | 234 | day: "numeric", |
| @@ -642,8 +638,26 @@ | ||
| 642 | 638 | </CardContent> |
| 643 | 639 | </Card> |
| 644 | 640 | </> |
| 645 | 641 | )} |
| 642 | + | |
| 643 | + <ConfirmationDialog | |
| 644 | + isOpen={bulkDeleteConfirm} | |
| 645 | + onClose={() => setBulkDeleteConfirm(false)} | |
| 646 | + onConfirm={() => { | |
| 647 | + bulkDeleteMutation.mutate(selectedIds); | |
| 648 | + setBulkDeleteConfirm(false); | |
| 649 | + }} | |
| 650 | + title={__("Delete Rules", "yatra")} | |
| 651 | + message={__( | |
| 652 | + "Are you sure you want to delete {count} rule(s)? This action cannot be undone.", | |
| 653 | + "yatra", | |
| 654 | + ).replace("{count}", selectedIds.length.toString())} | |
| 655 | + confirmText={__("Delete", "yatra")} | |
| 656 | + cancelText={__("Cancel", "yatra")} | |
| 657 | + variant="danger" | |
| 658 | + isLoading={bulkDeleteMutation.isPending} | |
| 659 | + /> | |
| 646 | 660 | </div> |
| 647 | 661 | ); |
| 648 | 662 | }; |
| 649 | 663 | |