PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | resources/js/components/trips/TripsTable.tsx +26 -13 3.0.8 → 3.0.16 View file →
@@ -3,9 +3,9 @@
3 3 * Modular table component for displaying trips
4 4 * Supports extensibility for Pro features
5 5 */
6 6
7 -import React from "react";
7 +import React, { useState } from "react";
8 8 import { __ } from "../../lib/i18n";
9 9 import { formatYatraMoney } from "../../lib/currency-display";
10 10 import { ConditionalRender } from "../ui/conditional-render";
11 11 import {
@@ -18,8 +18,9 @@
18 18 } from "../ui/table";
19 19 import { Button } from "../ui/button";
20 20 import { Badge } from "../ui/badge";
21 21 import { Edit, Trash2, Eye } from "lucide-react";
22 +import { ConfirmationDialog } from "../ui/confirmation-dialog";
22 23
23 24 interface Trip {
24 25 id: number;
25 26 title: string;
@@ -51,8 +52,12 @@
51 52 onDelete,
52 53 onView,
53 54 showProFeatures = false,
54 55 }) => {
56 + // Uses the shared ConfirmationDialog like the rest of the admin, instead of
57 + // the browser's native confirm() which ignores the admin theme.
58 + const [tripToDelete, setTripToDelete] = useState<any | null>(null);
59 +
55 60 const formatDate = (dateString: string) => {
56 61 return new Date(dateString).toLocaleDateString();
57 62 };
58 63
@@ -180,20 +185,9 @@
180 185 {onDelete && (
181 186 <Button
182 187 variant="ghost"
183 188 size="sm"
184 - onClick={() => {
185 - if (
186 - confirm(
187 - __(
188 - "Are you sure you want to delete this trip?",
189 - "yatra",
190 - ),
191 - )
192 - ) {
193 - onDelete(trip);
194 - }
195 - }}
189 + onClick={() => setTripToDelete(trip)}
196 190 aria-label={__("Delete trip", "yatra")}
197 191 >
198 192 <Trash2 className="w-4 h-4 text-red-500" />
199 193 </Button>
@@ -204,8 +198,27 @@
204 198 </TableRow>
205 199 ))}
206 200 </TableBody>
207 201 </Table>
202 +
203 + <ConfirmationDialog
204 + isOpen={tripToDelete !== null}
205 + onClose={() => setTripToDelete(null)}
206 + onConfirm={() => {
207 + if (tripToDelete && onDelete) {
208 + onDelete(tripToDelete);
209 + }
210 + setTripToDelete(null);
211 + }}
212 + title={__("Delete Trip", "yatra")}
213 + message={__(
214 + "Are you sure you want to delete this trip? This action cannot be undone.",
215 + "yatra",
216 + )}
217 + confirmText={__("Delete", "yatra")}
218 + cancelText={__("Cancel", "yatra")}
219 + variant="danger"
220 + />
208 221 </div>
209 222 );
210 223 };
211 224