PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.9
Yatra – Travel Booking & Tour Operator Software v3.0.2.9
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
yatra / assets / dist / js / account-page.js

account-page.js in Yatra – Travel Booking & Tour Operator Software 3.0.2.9, at assets/dist/js/account-page.js

3,361 lines 187.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { j as jsxRuntimeExports, i as Calendar, h as FileText, l as Plane, ak as ArrowRight, M as MapPin, U as User, v as ChevronRight, b2 as Sparkles, P as Package, k as CreditCard, bS as LifeBuoy, bB as Bell, b5 as AlertCircle, bh as CheckCircle2, ai as Clock, av as ExternalLink, ah as Users, o as Mail, bj as Phone, aI as Download, r as reactExports, u as useQuery, am as CheckCircle, aj as DollarSign, w as React, aZ as Eye, ax as PenSquare, b6 as XCircle, bT as ShieldCheck, aJ as Heart, L as LayoutDashboard, bU as LogOut, bP as QueryClient, bQ as client, bR as QueryClientProvider } from "./react-vendor-lSVLenth.js";
2 import { _ as __, g as getCurrencySymbol, c as getCurrency, a as apiClient, A as API_ENDPOINTS, u as useToast, T as ToastProvider } from "./index-Ar4TZ2Se.js";
3 const formatDate = (value) => {
4 if (!value) {
5 return __("N/A", "yatra");
6 }
7 try {
8 const date = new Date(value);
9 if (isNaN(date.getTime())) {
10 return __("Invalid date", "yatra");
11 }
12 return date.toLocaleDateString(void 0, {
13 year: "numeric",
14 month: "long",
15 day: "numeric"
16 });
17 } catch (error) {
18 return __("Invalid date", "yatra");
19 }
20 };
21 const getBadge = (status) => {
22 const base = "px-2.5 py-0.5 rounded-full text-xs font-medium";
23 if (!status || typeof status !== "string") {
24 return `${base} bg-gray-100 text-gray-800 dark:bg-gray-900/30 dark:text-gray-300`;
25 }
26 switch (status.toLowerCase()) {
27 case "paid":
28 case "confirmed":
29 case "resolved":
30 return `${base} bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300`;
31 case "pending":
32 case "partial":
33 case "awaiting_response":
34 return `${base} bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300`;
35 case "failed":
36 case "cancelled":
37 return `${base} bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300`;
38 default:
39 return `${base} bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300`;
40 }
41 };
42 function readPriceConfig() {
43 if (typeof window === "undefined") {
44 return {
45 globalCurrency: "USD",
46 currencyPosition: "before",
47 decimalPlaces: 2,
48 thousandSeparator: ",",
49 decimalSeparator: "."
50 };
51 }
52 const w = window;
53 const a = w.yatraAdmin || {};
54 const p = w.yatraAccountPage || {};
55 return {
56 globalCurrency: a.currency || p.currency || "USD",
57 currencyPosition: a.currencyPosition || p.currencyPosition || "before",
58 decimalPlaces: Number(a.decimalPlaces ?? p.decimalPlaces ?? 2) || 2,
59 thousandSeparator: a.thousandSeparator || p.thousandSeparator || ",",
60 decimalSeparator: a.decimalSeparator || p.decimalSeparator || "."
61 };
62 }
63 const formatPrice = (price) => {
64 const {
65 globalCurrency,
66 currencyPosition,
67 decimalPlaces,
68 thousandSeparator,
69 decimalSeparator
70 } = readPriceConfig();
71 if (!price || price === 0) {
72 return __("Contact for pricing", "yatra");
73 }
74 const formattedAmount = new Intl.NumberFormat(void 0, {
75 minimumFractionDigits: decimalPlaces,
76 maximumFractionDigits: decimalPlaces
77 }).format(price).replace(/,/g, "TEMP_THOUSAND").replace(/\./g, decimalSeparator).replace(/TEMP_THOUSAND/g, thousandSeparator);
78 const currencySymbol = new Intl.NumberFormat(void 0, {
79 style: "currency",
80 currency: globalCurrency
81 }).format(0).replace(/[\d\s.,]/g, "").trim();
82 if (currencyPosition === "right" || currencyPosition === "after") {
83 return `${formattedAmount}${currencySymbol}`;
84 }
85 return `${currencySymbol}${formattedAmount}`;
86 };
87 const formatPriceForBooking = (price, currency2) => {
88 const cfg = readPriceConfig();
89 const globalCurrency = currency2 || cfg.globalCurrency;
90 const {
91 currencyPosition,
92 decimalPlaces,
93 thousandSeparator,
94 decimalSeparator
95 } = cfg;
96 const currencyToUse = globalCurrency;
97 const numPrice = Number(price) || 0;
98 const formattedAmount = new Intl.NumberFormat(void 0, {
99 minimumFractionDigits: decimalPlaces,
100 maximumFractionDigits: decimalPlaces
101 }).format(numPrice).replace(/,/g, "TEMP_THOUSAND").replace(/\./g, decimalSeparator).replace(/TEMP_THOUSAND/g, thousandSeparator);
102 const currencySymbol = new Intl.NumberFormat(void 0, {
103 style: "currency",
104 currency: currencyToUse
105 }).format(0).replace(/[\d\s.,]/g, "").trim();
106 if (currencyPosition === "right" || currencyPosition === "after") {
107 return `${formattedAmount}${currencySymbol}`;
108 }
109 return `${currencySymbol}${formattedAmount}`;
110 };
111 const currency = (value, currencyCode = "USD") => {
112 const symbol = getCurrencySymbol(currencyCode);
113 const currencyData = getCurrency(currencyCode);
114 const decimals = (currencyData == null ? void 0 : currencyData.decimalDigits) ?? 2;
115 const formatted = new Intl.NumberFormat(void 0, {
116 minimumFractionDigits: decimals,
117 maximumFractionDigits: decimals
118 }).format(value);
119 return `${symbol}${formatted}`;
120 };
121 function getYatraAccountPageGlobals() {
122 if (typeof window === "undefined") {
123 return {
124 logoutUrl: "",
125 companyPhone: "",
126 companyName: "",
127 companyEmail: ""
128 };
129 }
130 const p = window.yatraAccountPage;
131 const raw = p || {};
132 return {
133 logoutUrl: String(raw.logoutUrl || "").trim(),
134 companyPhone: String(raw.companyPhone || "").trim(),
135 companyName: String(raw.companyName || "").trim(),
136 companyEmail: String(raw.companyEmail || "").trim()
137 };
138 }
139 function phoneToTelHref(phone) {
140 const t = String(phone).trim();
141 if (!t) {
142 return "";
143 }
144 const compact = t.replace(/[^\d+]/g, "");
145 return compact ? `tel:${compact}` : `tel:${encodeURIComponent(t)}`;
146 }
147 const Dashboard = ({
148 bookings,
149 payments,
150 displayProfile,
151 stats,
152 notifications,
153 conciergePhone = "",
154 conciergeEmail = "",
155 onSectionChange
156 }) => {
157 var _a;
158 const conciergeTel = phoneToTelHref(conciergePhone);
159 const conciergeMail = String(conciergeEmail || "").trim();
160 const upcomingBookings = bookings.filter((b) => new Date(b.travel_date) > /* @__PURE__ */ new Date()).length > 0 ? bookings.filter((b) => new Date(b.travel_date) > /* @__PURE__ */ new Date()).slice(0, 3) : bookings.filter((b) => new Date(b.travel_date) > /* @__PURE__ */ new Date()).slice(0, 3);
161 const recentBookings = bookings.length > 0 ? bookings.slice(0, 2) : [];
162 const pendingPayments = payments.filter((p) => p.status === "pending").length > 0 ? payments.filter((p) => p.status === "pending").slice(0, 2) : [];
163 const displayNotifications = notifications;
164 const enhancedStats = [
165 {
166 ...stats[0],
167 gradient: "from-blue-500 to-blue-600",
168 bgColor: "bg-blue-50 dark:bg-blue-900/20",
169 iconColor: "text-blue-600 dark:text-blue-400"
170 },
171 {
172 ...stats[1],
173 gradient: "from-emerald-500 to-emerald-600",
174 bgColor: "bg-emerald-50 dark:bg-emerald-900/20",
175 iconColor: "text-emerald-600 dark:text-emerald-400"
176 },
177 {
178 ...stats[2],
179 gradient: "from-amber-500 to-amber-600",
180 bgColor: "bg-amber-50 dark:bg-amber-900/20",
181 iconColor: "text-amber-600 dark:text-amber-400"
182 },
183 {
184 ...stats[3],
185 gradient: "from-purple-500 to-purple-600",
186 bgColor: "bg-purple-50 dark:bg-purple-900/20",
187 iconColor: "text-purple-600 dark:text-purple-400"
188 }
189 ];
190 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
191 /* @__PURE__ */ jsxRuntimeExports.jsxs(
192 "div",
193 {
194 className: "yatra-dashboard-welcome relative overflow-hidden rounded-2xl p-8 shadow-xl",
195 style: {
196 background: "linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #4f46e5 100%)",
197 color: "#ffffff"
198 },
199 children: [
200 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative z-10", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between", children: [
201 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
202 /* @__PURE__ */ jsxRuntimeExports.jsxs(
203 "h2",
204 {
205 className: "text-lg font-bold mb-2",
206 style: { color: "#ffffff" },
207 children: [
208 __("Welcome back,", "yatra"),
209 " ",
210 ((_a = displayProfile == null ? void 0 : displayProfile.name) == null ? void 0 : _a.split(" ")[0]) || __("Traveler", "yatra"),
211 "! 👋"
212 ]
213 }
214 ),
215 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm mb-4", style: { color: "#e0e7ff" }, children: [
216 __("You have", "yatra"),
217 " ",
218 upcomingBookings.length,
219 " ",
220 upcomingBookings.length === 1 ? __("upcoming adventure", "yatra") : __("upcoming adventures", "yatra"),
221 " ",
222 __("coming up", "yatra")
223 ] }),
224 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap gap-3 mt-4", children: [
225 /* @__PURE__ */ jsxRuntimeExports.jsxs(
226 "div",
227 {
228 role: "button",
229 tabIndex: 0,
230 onClick: () => onSectionChange("bookings"),
231 className: "px-4 py-2 rounded-lg text-sm font-medium transition-all flex items-center gap-2 hover:opacity-90 cursor-pointer",
232 style: {
233 backgroundColor: "rgba(255, 255, 255, 0.2)",
234 color: "#ffffff",
235 backdropFilter: "blur(8px)"
236 },
237 children: [
238 /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-4 h-4", style: { color: "#ffffff" } }),
239 __("View Calendar", "yatra")
240 ]
241 }
242 ),
243 /* @__PURE__ */ jsxRuntimeExports.jsxs(
244 "div",
245 {
246 role: "button",
247 tabIndex: 0,
248 onClick: () => onSectionChange("documents"),
249 className: "px-4 py-2 rounded-lg text-sm font-medium transition-all flex items-center gap-2 hover:opacity-90 cursor-pointer",
250 style: {
251 backgroundColor: "rgba(255, 255, 255, 0.2)",
252 color: "#ffffff",
253 backdropFilter: "blur(8px)"
254 },
255 children: [
256 /* @__PURE__ */ jsxRuntimeExports.jsx(FileText, { className: "w-4 h-4", style: { color: "#ffffff" } }),
257 __("My Documents", "yatra")
258 ]
259 }
260 )
261 ] })
262 ] }),
263 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hidden md:block", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
264 "div",
265 {
266 className: "w-24 h-24 rounded-full flex items-center justify-center",
267 style: {
268 backgroundColor: "rgba(255, 255, 255, 0.1)",
269 backdropFilter: "blur(8px)"
270 },
271 children: /* @__PURE__ */ jsxRuntimeExports.jsx(Plane, { className: "w-12 h-12", style: { color: "#ffffff" } })
272 }
273 ) })
274 ] }) }),
275 /* @__PURE__ */ jsxRuntimeExports.jsx(
276 "div",
277 {
278 className: "absolute top-0 right-0 w-64 h-64 rounded-full -mr-32 -mt-32",
279 style: { backgroundColor: "rgba(255, 255, 255, 0.05)" }
280 }
281 ),
282 /* @__PURE__ */ jsxRuntimeExports.jsx(
283 "div",
284 {
285 className: "absolute bottom-0 left-0 w-48 h-48 rounded-full -ml-24 -mb-24",
286 style: { backgroundColor: "rgba(255, 255, 255, 0.05)" }
287 }
288 )
289 ]
290 }
291 ),
292 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-dashboard-stats grid gap-4 sm:grid-cols-2 lg:grid-cols-4", children: enhancedStats.map((stat) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
293 "div",
294 {
295 className: `yatra-stat-card yatra-stat-card-${stat.label.toLowerCase().replace(/\s+/g, "-")} group relative bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm hover:shadow-md transition-all overflow-hidden`,
296 children: [
297 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-6", children: [
298 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between mb-4", children: [
299 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-3 rounded-lg ${stat.bgColor}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(stat.icon, { className: `w-6 h-6 ${stat.iconColor}` }) }),
300 stat.badge && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex text-xs px-2 py-1 rounded-full bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-200 font-medium", children: stat.badge })
301 ] }),
302 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
303 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mb-1", children: stat.label }),
304 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-gray-900 dark:text-white", children: stat.value })
305 ] })
306 ] }),
307 /* @__PURE__ */ jsxRuntimeExports.jsx(
308 "div",
309 {
310 className: `absolute bottom-0 left-0 right-0 h-1 bg-gradient-to-r ${stat.gradient} opacity-0 group-hover:opacity-100 transition-opacity`
311 }
312 )
313 ]
314 },
315 stat.label
316 )) }),
317 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid gap-6 lg:grid-cols-3", children: [
318 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-dashboard-upcoming-trips lg:col-span-2 bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm overflow-hidden", children: [
319 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-dashboard-upcoming-trips-header p-6 border-b border-gray-100 dark:border-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
320 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
321 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-emerald-50 dark:bg-emerald-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-5 h-5 text-emerald-600 dark:text-emerald-400" }) }),
322 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
323 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-base font-semibold text-gray-900 dark:text-white", children: __("Upcoming Trips", "yatra") }),
324 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: __("Your next adventures", "yatra") })
325 ] })
326 ] }),
327 upcomingBookings.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(
328 "div",
329 {
330 role: "button",
331 tabIndex: 0,
332 onClick: () => onSectionChange("bookings"),
333 className: "text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium flex items-center gap-1 transition-colors cursor-pointer",
334 children: [
335 __("View all", "yatra"),
336 /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowRight, { className: "w-4 h-4" })
337 ]
338 }
339 )
340 ] }) }),
341 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6", children: upcomingBookings.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: upcomingBookings.map((booking) => /* @__PURE__ */ jsxRuntimeExports.jsx(
342 "div",
343 {
344 className: "yatra-booking-card yatra-booking-card-upcoming group relative border border-gray-200 dark:border-gray-700 rounded-xl p-5 hover:border-blue-300 dark:hover:border-blue-600 hover:shadow-md transition-all cursor-pointer bg-gradient-to-r from-white to-gray-50/50 dark:from-gray-800 dark:to-gray-800/50",
345 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-4", children: [
346 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-12 h-12 bg-gradient-to-br from-blue-500 to-indigo-600 rounded-lg flex items-center justify-center shadow-sm", children: /* @__PURE__ */ jsxRuntimeExports.jsx(MapPin, { className: "w-6 h-6 text-white" }) }) }),
347 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
348 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-2 mb-2", children: [
349 /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white group-hover:text-blue-600 dark:group-hover:text-blue-400 transition-colors", children: booking.trip_title }),
350 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: getBadge(booking.booking_status), children: __(booking.booking_status, booking.booking_status) })
351 ] }),
352 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm text-gray-600 dark:text-gray-400 mb-2 flex items-center gap-2", children: [
353 /* @__PURE__ */ jsxRuntimeExports.jsx(MapPin, { className: "w-4 h-4" }),
354 booking.destination || __("Multiple destinations", "yatra")
355 ] }),
356 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4 text-xs text-gray-500 dark:text-gray-400", children: [
357 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-1", children: [
358 /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-3.5 h-3.5" }),
359 formatDate(booking.travel_date)
360 ] }),
361 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-1", children: [
362 /* @__PURE__ */ jsxRuntimeExports.jsx(User, { className: "w-3.5 h-3.5" }),
363 booking.travelers,
364 " ",
365 booking.travelers === 1 ? __("Traveler", "yatra") : __("Travelers", "yatra")
366 ] })
367 ] })
368 ] }),
369 /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "w-5 h-5 text-gray-400 group-hover:text-blue-600 dark:group-hover:text-blue-400 transition-colors flex-shrink-0" })
370 ] })
371 },
372 booking.id
373 )) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center py-12", children: [
374 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-16 h-16 bg-gray-100 dark:bg-gray-700 rounded-full flex items-center justify-center mx-auto mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-8 h-8 text-gray-400" }) }),
375 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-gray-500 dark:text-gray-400 font-medium mb-1", children: __("No upcoming trips", "yatra") }),
376 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-400 dark:text-gray-500", children: __("Start planning your next adventure!", "yatra") })
377 ] }) })
378 ] }),
379 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
380 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-dashboard-quick-actions bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm overflow-hidden", children: [
381 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-dashboard-quick-actions-header p-6 border-b border-gray-100 dark:border-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
382 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-purple-50 dark:bg-purple-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Sparkles, { className: "w-5 h-5 text-purple-600 dark:text-purple-400" }) }),
383 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-base font-semibold text-gray-900 dark:text-white", children: __("Quick Actions", "yatra") })
384 ] }) }),
385 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-6 space-y-3", children: [
386 /* @__PURE__ */ jsxRuntimeExports.jsxs(
387 "div",
388 {
389 role: "button",
390 tabIndex: 0,
391 onClick: () => onSectionChange("bookings"),
392 className: "w-full flex items-center justify-between p-4 border border-gray-200 dark:border-gray-700 rounded-lg hover:border-blue-300 dark:hover:border-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/10 transition-all group cursor-pointer text-sm",
393 children: [
394 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
395 /* @__PURE__ */ jsxRuntimeExports.jsx(Package, { className: "w-5 h-5 text-gray-400 group-hover:text-blue-600 dark:group-hover:text-blue-400" }),
396 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-gray-700 dark:text-gray-300 group-hover:text-blue-600 dark:group-hover:text-blue-400", children: __("View Bookings", "yatra") })
397 ] }),
398 /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "w-4 h-4 text-gray-400 group-hover:text-blue-600 dark:group-hover:text-blue-400" })
399 ]
400 }
401 ),
402 /* @__PURE__ */ jsxRuntimeExports.jsxs(
403 "div",
404 {
405 role: "button",
406 tabIndex: 0,
407 onClick: () => onSectionChange("payments"),
408 className: "w-full flex items-center justify-between p-4 border border-gray-200 dark:border-gray-700 rounded-lg hover:border-blue-300 dark:hover:border-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/10 transition-all group cursor-pointer text-sm",
409 children: [
410 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
411 /* @__PURE__ */ jsxRuntimeExports.jsx(CreditCard, { className: "w-5 h-5 text-gray-400 group-hover:text-blue-600 dark:group-hover:text-blue-400" }),
412 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-gray-700 dark:text-gray-300 group-hover:text-blue-600 dark:group-hover:text-blue-400", children: __("Make Payment", "yatra") })
413 ] }),
414 /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "w-4 h-4 text-gray-400 group-hover:text-blue-600 dark:group-hover:text-blue-400" })
415 ]
416 }
417 ),
418 /* @__PURE__ */ jsxRuntimeExports.jsxs(
419 "div",
420 {
421 role: "button",
422 tabIndex: 0,
423 onClick: () => onSectionChange("documents"),
424 className: "w-full flex items-center justify-between p-4 border border-gray-200 dark:border-gray-700 rounded-lg hover:border-blue-300 dark:hover:border-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/10 transition-all group cursor-pointer text-sm",
425 children: [
426 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
427 /* @__PURE__ */ jsxRuntimeExports.jsx(FileText, { className: "w-5 h-5 text-gray-400 group-hover:text-blue-600 dark:group-hover:text-blue-400" }),
428 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-gray-700 dark:text-gray-300 group-hover:text-blue-600 dark:group-hover:text-blue-400", children: __("My Documents", "yatra") })
429 ] }),
430 /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "w-4 h-4 text-gray-400 group-hover:text-blue-600 dark:group-hover:text-blue-400" })
431 ]
432 }
433 ),
434 conciergeTel ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
435 "a",
436 {
437 href: conciergeTel,
438 className: "w-full flex items-center justify-between p-4 border border-gray-200 dark:border-gray-700 rounded-lg hover:border-blue-300 dark:hover:border-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/10 transition-all group cursor-pointer text-sm no-underline text-inherit",
439 children: [
440 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
441 /* @__PURE__ */ jsxRuntimeExports.jsx(LifeBuoy, { className: "w-5 h-5 text-gray-400 group-hover:text-blue-600 dark:group-hover:text-blue-400" }),
442 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-gray-700 dark:text-gray-300 group-hover:text-blue-600 dark:group-hover:text-blue-400", children: __("Call us", "yatra") })
443 ] }),
444 /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "w-4 h-4 text-gray-400 group-hover:text-blue-600 dark:group-hover:text-blue-400" })
445 ]
446 }
447 ) : conciergeMail ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
448 "a",
449 {
450 href: `mailto:${encodeURIComponent(conciergeMail)}`,
451 className: "w-full flex items-center justify-between p-4 border border-gray-200 dark:border-gray-700 rounded-lg hover:border-blue-300 dark:hover:border-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/10 transition-all group cursor-pointer text-sm no-underline text-inherit",
452 children: [
453 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
454 /* @__PURE__ */ jsxRuntimeExports.jsx(LifeBuoy, { className: "w-5 h-5 text-gray-400 group-hover:text-blue-600 dark:group-hover:text-blue-400" }),
455 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-gray-700 dark:text-gray-300 group-hover:text-blue-600 dark:group-hover:text-blue-400", children: __("Email us", "yatra") })
456 ] }),
457 /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "w-4 h-4 text-gray-400 group-hover:text-blue-600 dark:group-hover:text-blue-400" })
458 ]
459 }
460 ) : null
461 ] })
462 ] }),
463 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-dashboard-notifications bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm overflow-hidden", children: [
464 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-dashboard-notifications-header p-6 border-b border-gray-100 dark:border-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
465 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-amber-50 dark:bg-amber-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Bell, { className: "w-5 h-5 text-amber-600 dark:text-amber-400" }) }),
466 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
467 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-base font-semibold text-gray-900 dark:text-white", children: __("Notifications", "yatra") }),
468 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: __("Updates & reminders", "yatra") })
469 ] })
470 ] }) }),
471 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6 space-y-3", children: displayNotifications.length > 0 ? displayNotifications.map((notif) => /* @__PURE__ */ jsxRuntimeExports.jsx(
472 "div",
473 {
474 className: `p-4 rounded-lg border ${notif.type === "warning" ? "bg-amber-50 dark:bg-amber-900/10 border-amber-200 dark:border-amber-800" : "bg-blue-50 dark:bg-blue-900/10 border-blue-200 dark:border-blue-800"}`,
475 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-3", children: [
476 notif.type === "warning" ? /* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle2, { className: "w-5 h-5 text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5" }),
477 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
478 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-semibold text-sm text-gray-900 dark:text-white mb-1", children: notif.title }),
479 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-600 dark:text-gray-400 leading-relaxed", children: notif.message })
480 ] })
481 ] })
482 },
483 notif.id
484 )) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center py-6", children: [
485 /* @__PURE__ */ jsxRuntimeExports.jsx(Bell, { className: "w-8 h-8 text-gray-300 dark:text-gray-600 mx-auto mb-2" }),
486 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-400 dark:text-gray-500", children: __("No new notifications", "yatra") })
487 ] }) })
488 ] })
489 ] })
490 ] }),
491 (recentBookings.length > 0 || pendingPayments.length > 0) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-dashboard-recent-activity bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm overflow-hidden", children: [
492 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-dashboard-recent-activity-header p-6 border-b border-gray-100 dark:border-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
493 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-indigo-50 dark:bg-indigo-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Clock, { className: "w-5 h-5 text-indigo-600 dark:text-indigo-400" }) }),
494 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
495 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-base font-semibold text-gray-900 dark:text-white", children: __("Recent Activity", "yatra") }),
496 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: __("Your latest updates", "yatra") })
497 ] })
498 ] }) }),
499 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
500 recentBookings.map((booking) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
501 "div",
502 {
503 className: "flex items-center gap-4 pb-4 border-b border-gray-100 dark:border-gray-700 last:border-0 last:pb-0",
504 children: [
505 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle2, { className: "w-5 h-5 text-blue-600 dark:text-blue-400" }) }),
506 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
507 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: [
508 __("Booking confirmed:", "yatra"),
509 " ",
510 booking.trip_title
511 ] }),
512 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: formatDate(booking.booking_date || booking.created_at) })
513 ] }),
514 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: getBadge(booking.booking_status), children: __(booking.booking_status, booking.booking_status) })
515 ]
516 },
517 booking.id
518 )),
519 pendingPayments.map((payment) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
520 "div",
521 {
522 className: "flex items-center gap-4 pb-4 border-b border-gray-100 dark:border-gray-700 last:border-0 last:pb-0",
523 children: [
524 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-10 h-10 bg-amber-100 dark:bg-amber-900/30 rounded-full flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Clock, { className: "w-5 h-5 text-amber-600 dark:text-amber-400" }) }),
525 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
526 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: [
527 __("Payment pending:", "yatra"),
528 " ",
529 currency(payment.amount)
530 ] }),
531 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: formatDate(payment.date) })
532 ] }),
533 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: getBadge(payment.status), children: __(payment.status, payment.status) })
534 ]
535 },
536 payment.id
537 ))
538 ] }) })
539 ] })
540 ] });
541 };
542 function getAccountRestConfig() {
543 var _a, _b, _c, _d;
544 if (typeof window === "undefined") {
545 return { base: "/wp-json/yatra/v1", nonce: "" };
546 }
547 const w = window;
548 const raw = ((_a = w.yatraAccountPage) == null ? void 0 : _a.apiUrl) || ((_b = w.yatraAdmin) == null ? void 0 : _b.apiUrl) || "/wp-json/yatra/v1";
549 const base = String(raw).replace(/\/$/, "");
550 const nonce = ((_c = w.yatraAccountPage) == null ? void 0 : _c.nonce) || ((_d = w.yatraAdmin) == null ? void 0 : _d.nonce) || "";
551 return { base, nonce };
552 }
553 function parseYatraRestSubpath(href) {
554 const origin = typeof window !== "undefined" ? window.location.origin : "http://localhost";
555 try {
556 const u = new URL(href, origin);
557 const rr = u.searchParams.get("rest_route");
558 if (rr) {
559 const decoded = decodeURIComponent(rr.replace(/\+/g, " "));
560 const idx = decoded.indexOf("/yatra/v1");
561 if (idx !== -1) {
562 return decoded.slice(idx + "/yatra/v1".length) || decoded;
563 }
564 return decoded;
565 }
566 const path = u.pathname || "";
567 const marker = "/yatra/v1";
568 const pos = path.indexOf(marker);
569 if (pos !== -1) {
570 return path.slice(pos + marker.length);
571 }
572 } catch {
573 }
574 return "";
575 }
576 function parsePaymentIdFromHref(href) {
577 const sub = parseYatraRestSubpath(href);
578 const m = sub.match(/^\/payment\/(\d+)\/invoice(?:\/?|$)/i);
579 return m ? parseInt(m[1], 10) : null;
580 }
581 function parseBookingDocFromHref(href, kind) {
582 const sub = parseYatraRestSubpath(href);
583 const re = new RegExp(`^/bookings/(\\d+)/${kind}(?:/?|$)`, "i");
584 const m = sub.match(re);
585 return m ? parseInt(m[1], 10) : null;
586 }
587 function buildBookingDocumentUrl(baseRaw, bookingId, kind, mode = "download") {
588 const suffix = `/bookings/${bookingId}/${kind}`;
589 const origin = typeof window !== "undefined" ? window.location.origin : "http://localhost";
590 let u;
591 try {
592 u = new URL(String(baseRaw).trim(), origin);
593 } catch {
594 const b = String(baseRaw).replace(/\/$/, "");
595 const q = mode === "download" ? "?download=1" : "?preview=1";
596 return `${b}${suffix}${q}`;
597 }
598 if (u.searchParams.has("rest_route")) {
599 const route = (u.searchParams.get("rest_route") || "").replace(/\/$/, "");
600 u.searchParams.set("rest_route", `${route}${suffix}`);
601 if (mode === "download") {
602 u.searchParams.set("download", "1");
603 u.searchParams.delete("preview");
604 } else {
605 u.searchParams.set("preview", "1");
606 u.searchParams.delete("download");
607 }
608 return u.toString();
609 }
610 u.pathname = (u.pathname || "").replace(/\/$/, "") + suffix;
611 if (mode === "download") {
612 u.searchParams.set("download", "1");
613 u.searchParams.delete("preview");
614 } else {
615 u.searchParams.set("preview", "1");
616 u.searchParams.delete("download");
617 }
618 return u.toString();
619 }
620 function buildPaymentInvoiceUrl(baseRaw, paymentId, mode) {
621 const suffix = `/payment/${paymentId}/invoice`;
622 const origin = typeof window !== "undefined" ? window.location.origin : "http://localhost";
623 let u;
624 try {
625 u = new URL(String(baseRaw).trim(), origin);
626 } catch {
627 const b = String(baseRaw).replace(/\/$/, "");
628 const q = mode === "download" ? "?download=1" : "?preview=1";
629 return `${b}${suffix}${q}`;
630 }
631 if (u.searchParams.has("rest_route")) {
632 const route = (u.searchParams.get("rest_route") || "").replace(/\/$/, "");
633 u.searchParams.set("rest_route", `${route}${suffix}`);
634 if (mode === "download") {
635 u.searchParams.set("download", "1");
636 u.searchParams.delete("preview");
637 } else {
638 u.searchParams.set("preview", "1");
639 u.searchParams.delete("download");
640 }
641 return u.toString();
642 }
643 u.pathname = (u.pathname || "").replace(/\/$/, "") + suffix;
644 if (mode === "download") {
645 u.searchParams.set("download", "1");
646 u.searchParams.delete("preview");
647 } else {
648 u.searchParams.set("preview", "1");
649 u.searchParams.delete("download");
650 }
651 return u.toString();
652 }
653 async function readFetchErrorMessage(res) {
654 let msg = res.statusText || "Request failed";
655 try {
656 const j = await res.json();
657 if (j == null ? void 0 : j.message) {
658 msg = typeof j.message === "string" ? j.message : msg;
659 }
660 } catch {
661 const t = await res.text().catch(() => "");
662 if (t && t.length < 200) {
663 msg = t;
664 }
665 }
666 return msg;
667 }
668 async function fetchPreviewPdf(url) {
669 const { nonce } = getAccountRestConfig();
670 if (!nonce) {
671 throw new Error("Missing REST nonce; reload the account page.");
672 }
673 const res = await fetch(url, {
674 method: "GET",
675 credentials: "include",
676 headers: {
677 "X-WP-Nonce": nonce,
678 Accept: "application/json"
679 }
680 });
681 if (!res.ok) {
682 throw new Error(await readFetchErrorMessage(res));
683 }
684 const data = await res.json();
685 if (!(data == null ? void 0 : data.pdf_data) || typeof data.pdf_data !== "string") {
686 throw new Error("Invalid preview response from server.");
687 }
688 const binary = atob(data.pdf_data);
689 const bytes = new Uint8Array(binary.length);
690 for (let i = 0; i < binary.length; i++) {
691 bytes[i] = binary.charCodeAt(i);
692 }
693 return new Blob([bytes], { type: "application/pdf" });
694 }
695 function openPdfInNewTab(blob) {
696 const objectUrl = URL.createObjectURL(blob);
697 const win = window.open(objectUrl, "_blank", "noopener,noreferrer");
698 if (!win) {
699 URL.revokeObjectURL(objectUrl);
700 throw new Error(
701 "Popup blocked. Allow popups for this site to preview the PDF."
702 );
703 }
704 window.setTimeout(() => URL.revokeObjectURL(objectUrl), 6e4);
705 }
706 async function downloadBookingBinary(bookingId, kind) {
707 const { base, nonce } = getAccountRestConfig();
708 if (!nonce) {
709 throw new Error("Missing REST nonce; reload the account page.");
710 }
711 const url = buildBookingDocumentUrl(base, bookingId, kind, "download");
712 const res = await fetch(url, {
713 method: "GET",
714 credentials: "include",
715 headers: {
716 "X-WP-Nonce": nonce,
717 Accept: "application/pdf, application/octet-stream, */*"
718 }
719 });
720 if (!res.ok) {
721 throw new Error(await readFetchErrorMessage(res));
722 }
723 const blob = await res.blob();
724 const dispo = res.headers.get("Content-Disposition");
725 let filename = `${kind}-${bookingId}.pdf`;
726 if (dispo) {
727 const m = /filename\*?=(?:UTF-8'')?["']?([^";\n]+)/i.exec(dispo);
728 if (m == null ? void 0 : m[1]) {
729 try {
730 filename = decodeURIComponent(m[1].replace(/['"]/g, "").trim());
731 } catch {
732 filename = m[1].replace(/['"]/g, "").trim();
733 }
734 }
735 }
736 const objectUrl = URL.createObjectURL(blob);
737 const link = document.createElement("a");
738 link.href = objectUrl;
739 link.download = filename;
740 document.body.appendChild(link);
741 link.click();
742 document.body.removeChild(link);
743 URL.revokeObjectURL(objectUrl);
744 }
745 async function downloadPaymentInvoiceBinary(paymentId) {
746 const { base, nonce } = getAccountRestConfig();
747 if (!nonce) {
748 throw new Error("Missing REST nonce; reload the account page.");
749 }
750 const url = buildPaymentInvoiceUrl(base, paymentId, "download");
751 const res = await fetch(url, {
752 method: "GET",
753 credentials: "include",
754 headers: {
755 "X-WP-Nonce": nonce,
756 Accept: "application/pdf, application/octet-stream, */*"
757 }
758 });
759 if (!res.ok) {
760 throw new Error(await readFetchErrorMessage(res));
761 }
762 const blob = await res.blob();
763 const dispo = res.headers.get("Content-Disposition");
764 let filename = `invoice-${paymentId}.pdf`;
765 if (dispo) {
766 const m = /filename\*?=(?:UTF-8'')?["']?([^";\n]+)/i.exec(dispo);
767 if (m == null ? void 0 : m[1]) {
768 try {
769 filename = decodeURIComponent(m[1].replace(/['"]/g, "").trim());
770 } catch {
771 filename = m[1].replace(/['"]/g, "").trim();
772 }
773 }
774 }
775 const objectUrl = URL.createObjectURL(blob);
776 const link = document.createElement("a");
777 link.href = objectUrl;
778 link.download = filename;
779 document.body.appendChild(link);
780 link.click();
781 document.body.removeChild(link);
782 URL.revokeObjectURL(objectUrl);
783 }
784 const downloadDocument = async (options) => {
785 if (options.documentType === "downloads" && options.fallbackUrl) {
786 window.open(options.fallbackUrl, "_blank", "noopener,noreferrer");
787 return;
788 }
789 if (options.documentType === "invoice") {
790 const pid = options.paymentId ?? parsePaymentIdFromHref(options.fallbackUrl || "");
791 if (pid) {
792 await downloadPaymentInvoiceBinary(pid);
793 return;
794 }
795 }
796 if (options.documentType === "voucher" || options.documentType === "itinerary") {
797 const kind = options.documentType === "voucher" ? "voucher" : "itinerary";
798 const bid = options.bookingId ?? parseBookingDocFromHref(options.fallbackUrl || "", kind);
799 if (bid) {
800 await downloadBookingBinary(bid, kind);
801 return;
802 }
803 }
804 if (options.bookingId && options.documentType === "all") {
805 await downloadBookingBinary(options.bookingId, "voucher");
806 return;
807 }
808 console.error(`No handler for document type: ${options.documentType}`);
809 };
810 const downloadVoucher = (bookingId) => downloadBookingBinary(bookingId, "voucher");
811 const downloadInvoice = (paymentId) => downloadPaymentInvoiceBinary(paymentId);
812 const previewPaymentInvoice = async (paymentId) => {
813 const { base, nonce } = getAccountRestConfig();
814 if (!nonce) {
815 throw new Error("Missing REST nonce; reload the account page.");
816 }
817 const url = buildPaymentInvoiceUrl(base, paymentId, "preview");
818 const blob = await fetchPreviewPdf(url);
819 openPdfInNewTab(blob);
820 };
821 async function previewTravelDocument(doc) {
822 const { base, nonce } = getAccountRestConfig();
823 if (!nonce) {
824 throw new Error("Missing REST nonce; reload the account page.");
825 }
826 if (doc.category === "invoice") {
827 const pid = doc.payment_id ?? parsePaymentIdFromHref(doc.url);
828 if (!pid) {
829 throw new Error("Could not resolve invoice link.");
830 }
831 const url = buildPaymentInvoiceUrl(base, pid, "preview");
832 const blob = await fetchPreviewPdf(url);
833 openPdfInNewTab(blob);
834 return;
835 }
836 if (doc.category === "voucher" || doc.category === "itinerary") {
837 const kind = doc.category === "voucher" ? "voucher" : "itinerary";
838 const bid = doc.booking_id ?? parseBookingDocFromHref(doc.url, kind);
839 if (!bid) {
840 throw new Error("Could not resolve document link.");
841 }
842 const url = buildBookingDocumentUrl(base, bid, kind, "preview");
843 const blob = await fetchPreviewPdf(url);
844 openPdfInNewTab(blob);
845 return;
846 }
847 window.open(doc.url, "_blank", "noopener,noreferrer");
848 }
849 const COUNTRY_NAMES = {
850 AF: "Afghanistan",
851 AL: "Albania",
852 DZ: "Algeria",
853 AD: "Andorra",
854 AO: "Angola",
855 AG: "Antigua and Barbuda",
856 AR: "Argentina",
857 AM: "Armenia",
858 AU: "Australia",
859 AT: "Austria",
860 AZ: "Azerbaijan",
861 BS: "Bahamas",
862 BH: "Bahrain",
863 BD: "Bangladesh",
864 BB: "Barbados",
865 BY: "Belarus",
866 BE: "Belgium",
867 BZ: "Belize",
868 BJ: "Benin",
869 BT: "Bhutan",
870 BO: "Bolivia",
871 BA: "Bosnia and Herzegovina",
872 BW: "Botswana",
873 BR: "Brazil",
874 BN: "Brunei",
875 BG: "Bulgaria",
876 BF: "Burkina Faso",
877 BI: "Burundi",
878 KH: "Cambodia",
879 CM: "Cameroon",
880 CA: "Canada",
881 CV: "Cape Verde",
882 CF: "Central African Republic",
883 TD: "Chad",
884 CL: "Chile",
885 CN: "China",
886 CO: "Colombia",
887 KM: "Comoros",
888 CG: "Congo",
889 CD: "DR Congo",
890 CR: "Costa Rica",
891 CI: "Ivory Coast",
892 HR: "Croatia",
893 CU: "Cuba",
894 CY: "Cyprus",
895 CZ: "Czech Republic",
896 DK: "Denmark",
897 DJ: "Djibouti",
898 DM: "Dominica",
899 DO: "Dominican Republic",
900 EC: "Ecuador",
901 EG: "Egypt",
902 SV: "El Salvador",
903 GQ: "Equatorial Guinea",
904 ER: "Eritrea",
905 EE: "Estonia",
906 SZ: "Eswatini",
907 ET: "Ethiopia",
908 FJ: "Fiji",
909 FI: "Finland",
910 FR: "France",
911 GA: "Gabon",
912 GM: "Gambia",
913 GE: "Georgia",
914 DE: "Germany",
915 GH: "Ghana",
916 GR: "Greece",
917 GD: "Grenada",
918 GT: "Guatemala",
919 GN: "Guinea",
920 GW: "Guinea-Bissau",
921 GY: "Guyana",
922 HT: "Haiti",
923 HN: "Honduras",
924 HU: "Hungary",
925 IS: "Iceland",
926 IN: "India",
927 ID: "Indonesia",
928 IR: "Iran",
929 IQ: "Iraq",
930 IE: "Ireland",
931 IL: "Israel",
932 IT: "Italy",
933 JM: "Jamaica",
934 JP: "Japan",
935 JO: "Jordan",
936 KZ: "Kazakhstan",
937 KE: "Kenya",
938 KI: "Kiribati",
939 KP: "North Korea",
940 KR: "South Korea",
941 KW: "Kuwait",
942 KG: "Kyrgyzstan",
943 LA: "Laos",
944 LV: "Latvia",
945 LB: "Lebanon",
946 LS: "Lesotho",
947 LR: "Liberia",
948 LY: "Libya",
949 LI: "Liechtenstein",
950 LT: "Lithuania",
951 LU: "Luxembourg",
952 MG: "Madagascar",
953 MW: "Malawi",
954 MY: "Malaysia",
955 MV: "Maldives",
956 ML: "Mali",
957 MT: "Malta",
958 MH: "Marshall Islands",
959 MR: "Mauritania",
960 MU: "Mauritius",
961 MX: "Mexico",
962 FM: "Micronesia",
963 MD: "Moldova",
964 MC: "Monaco",
965 MN: "Mongolia",
966 ME: "Montenegro",
967 MA: "Morocco",
968 MZ: "Mozambique",
969 MM: "Myanmar",
970 NA: "Namibia",
971 NR: "Nauru",
972 NP: "Nepal",
973 NL: "Netherlands",
974 NZ: "New Zealand",
975 NI: "Nicaragua",
976 NE: "Niger",
977 NG: "Nigeria",
978 MK: "North Macedonia",
979 NO: "Norway",
980 OM: "Oman",
981 PK: "Pakistan",
982 PW: "Palau",
983 PS: "Palestine",
984 PA: "Panama",
985 PG: "Papua New Guinea",
986 PY: "Paraguay",
987 PE: "Peru",
988 PH: "Philippines",
989 PL: "Poland",
990 PT: "Portugal",
991 QA: "Qatar",
992 RO: "Romania",
993 RU: "Russia",
994 RW: "Rwanda",
995 KN: "Saint Kitts and Nevis",
996 LC: "Saint Lucia",
997 VC: "Saint Vincent and the Grenadines",
998 WS: "Samoa",
999 SM: "San Marino",
1000 ST: "Sao Tome and Principe",
1001 SA: "Saudi Arabia",
1002 SN: "Senegal",
1003 RS: "Serbia",
1004 SC: "Seychelles",
1005 SL: "Sierra Leone",
1006 SG: "Singapore",
1007 SK: "Slovakia",
1008 SI: "Slovenia",
1009 SB: "Solomon Islands",
1010 SO: "Somalia",
1011 ZA: "South Africa",
1012 SS: "South Sudan",
1013 ES: "Spain",
1014 LK: "Sri Lanka",
1015 SD: "Sudan",
1016 SR: "Suriname",
1017 SE: "Sweden",
1018 CH: "Switzerland",
1019 SY: "Syria",
1020 TW: "Taiwan",
1021 TJ: "Tajikistan",
1022 TZ: "Tanzania",
1023 TH: "Thailand",
1024 TL: "Timor-Leste",
1025 TG: "Togo",
1026 TO: "Tonga",
1027 TT: "Trinidad and Tobago",
1028 TN: "Tunisia",
1029 TR: "Turkey",
1030 TM: "Turkmenistan",
1031 TV: "Tuvalu",
1032 UG: "Uganda",
1033 UA: "Ukraine",
1034 AE: "United Arab Emirates",
1035 GB: "United Kingdom",
1036 US: "United States",
1037 UY: "Uruguay",
1038 UZ: "Uzbekistan",
1039 VU: "Vanuatu",
1040 VA: "Vatican City",
1041 VE: "Venezuela",
1042 VN: "Vietnam",
1043 YE: "Yemen",
1044 ZM: "Zambia",
1045 ZW: "Zimbabwe"
1046 };
1047 const getCountryName = (code) => {
1048 if (!code) return "";
1049 const upperCode = code.toUpperCase();
1050 return COUNTRY_NAMES[upperCode] || code;
1051 };
1052 const BookingDetails = ({
1053 booking,
1054 isLoading,
1055 onBack
1056 }) => {
1057 var _a;
1058 if (isLoading) {
1059 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
1060 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1061 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white", children: __("Booking Details", "yatra") }) }),
1062 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1063 "div",
1064 {
1065 role: "button",
1066 tabIndex: 0,
1067 onClick: onBack,
1068 className: "inline-flex items-center gap-2 px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer",
1069 children: [
1070 /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowRight, { className: "w-4 h-4 rotate-180" }),
1071 __("Back to Bookings", "yatra")
1072 ]
1073 }
1074 )
1075 ] }),
1076 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "animate-pulse space-y-4", children: [
1077 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4" }),
1078 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/2" }),
1079 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-2/3" })
1080 ] }) })
1081 ] });
1082 }
1083 if (!booking) {
1084 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
1085 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1086 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white", children: __("Booking Details", "yatra") }) }),
1087 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1088 "div",
1089 {
1090 role: "button",
1091 tabIndex: 0,
1092 onClick: onBack,
1093 className: "inline-flex items-center gap-2 px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer",
1094 children: [
1095 /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowRight, { className: "w-4 h-4 rotate-180" }),
1096 __("Back to Bookings", "yatra")
1097 ]
1098 }
1099 )
1100 ] }),
1101 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6 text-center text-red-500", children: __("Booking not found or error loading booking", "yatra") })
1102 ] });
1103 }
1104 const normalizeRecord = (value) => {
1105 if (!value) return null;
1106 if (typeof value === "string") {
1107 try {
1108 const parsed = JSON.parse(value);
1109 if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
1110 return parsed;
1111 } catch {
1112 return null;
1113 }
1114 return null;
1115 }
1116 if (typeof value === "object" && !Array.isArray(value)) {
1117 return value;
1118 }
1119 return null;
1120 };
1121 const emergencyContact = normalizeRecord(booking.emergency_contact);
1122 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
1123 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1124 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1125 /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white", children: __("Booking Details", "yatra") }),
1126 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mt-1", children: __("Complete booking information", "yatra") })
1127 ] }),
1128 /* @__PURE__ */ jsxRuntimeExports.jsxs(
1129 "div",
1130 {
1131 role: "button",
1132 tabIndex: 0,
1133 onClick: onBack,
1134 className: "inline-flex items-center gap-2 px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer",
1135 children: [
1136 /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowRight, { className: "w-4 h-4 rotate-180" }),
1137 __("Back to Bookings", "yatra")
1138 ]
1139 }
1140 )
1141 ] }),
1142 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-3 gap-6", children: [
1143 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "lg:col-span-2 space-y-6", children: [
1144 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: [
1145 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-4", children: [
1146 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: __("Booking Overview", "yatra") }),
1147 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
1148 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: getBadge(booking.booking_status), children: __(
1149 booking.booking_status || "pending",
1150 booking.booking_status || "pending"
1151 ) }),
1152 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: getBadge(booking.payment_status), children: __(
1153 booking.payment_status || "pending",
1154 booking.payment_status || "pending"
1155 ) })
1156 ] })
1157 ] }),
1158 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
1159 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1160 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Booking Number", "yatra") }),
1161 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: booking.booking_number || `#${booking.id}` })
1162 ] }),
1163 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1164 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Trip", "yatra") }),
1165 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: booking.trip_title }),
1166 booking.trip_url ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
1167 "a",
1168 {
1169 href: booking.trip_url,
1170 className: "mt-2 inline-flex items-center gap-2 text-sm text-blue-600 dark:text-blue-400 hover:underline",
1171 children: [
1172 /* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-4 h-4" }),
1173 __("View Trip", "yatra")
1174 ]
1175 }
1176 ) : null
1177 ] }),
1178 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1179 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1 flex items-center gap-1", children: [
1180 /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-3 h-3" }),
1181 __("Booking Date", "yatra")
1182 ] }),
1183 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: formatDate(booking.booking_date || booking.created_at) })
1184 ] }),
1185 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1186 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1 flex items-center gap-1", children: [
1187 /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-3 h-3" }),
1188 __("Travel Date", "yatra")
1189 ] }),
1190 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: formatDate(booking.travel_date) })
1191 ] }),
1192 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1193 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1 flex items-center gap-1", children: [
1194 /* @__PURE__ */ jsxRuntimeExports.jsx(Users, { className: "w-3 h-3" }),
1195 __("Number of Travelers", "yatra")
1196 ] }),
1197 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm text-gray-900 dark:text-white", children: [
1198 booking.travelers,
1199 " ",
1200 booking.travelers === 1 ? __("Traveler", "yatra") : __("Travelers", "yatra")
1201 ] })
1202 ] })
1203 ] }),
1204 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 pt-4 border-t border-gray-200 dark:border-gray-700", children: [
1205 /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-3", children: __("Payment Summary", "yatra") }),
1206 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
1207 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-sm", children: [
1208 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600 dark:text-gray-400", children: __("Gross Total", "yatra") }),
1209 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: formatPriceForBooking(
1210 booking.subtotal || booking.total_amount,
1211 booking.currency
1212 ) })
1213 ] }),
1214 typeof booking.taxable_amount === "number" && booking.taxable_amount > 0 && (booking.tax_amount > 0 || ((_a = booking.tax_breakdown) == null ? void 0 : _a.length) > 0) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-sm font-medium", children: [
1215 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600 dark:text-gray-400", children: __("Subtotal (Taxable Amount)", "yatra") }),
1216 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: formatPriceForBooking(
1217 booking.taxable_amount,
1218 booking.currency
1219 ) })
1220 ] }),
1221 booking.discount_amount && booking.discount_amount > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-sm", children: [
1222 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600 dark:text-gray-400", children: __("Discount", "yatra") }),
1223 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-green-600 dark:text-green-400", children: [
1224 "-",
1225 formatPriceForBooking(
1226 booking.discount_amount,
1227 booking.currency
1228 )
1229 ] })
1230 ] }),
1231 booking.itinerary_costs && booking.itinerary_costs.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1232 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex justify-between text-sm", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600 dark:text-gray-400 font-medium", children: __("Itinerary Costs", "yatra") }) }),
1233 booking.itinerary_costs.map((cost, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
1234 "div",
1235 {
1236 className: "flex justify-between text-sm ml-4",
1237 children: [
1238 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-gray-600 dark:text-gray-400", children: [
1239 cost.name,
1240 cost.price_per === "person" && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-gray-500 dark:text-gray-500 ml-1", children: [
1241 "(",
1242 __("per person", "yatra"),
1243 ")"
1244 ] }),
1245 cost.price_per === "group" && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-gray-500 dark:text-gray-500 ml-1", children: [
1246 "(",
1247 __("per booking", "yatra"),
1248 ")"
1249 ] })
1250 ] }),
1251 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: formatPriceForBooking(
1252 cost.total_cost,
1253 booking.currency
1254 ) })
1255 ]
1256 },
1257 index
1258 ))
1259 ] }),
1260 booking.tax_amount > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: (() => {
1261 const taxBreakdown = booking.tax_breakdown;
1262 if (Array.isArray(taxBreakdown) && taxBreakdown.length > 0) {
1263 return taxBreakdown.map((tax, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
1264 "div",
1265 {
1266 className: "flex justify-between text-sm",
1267 children: [
1268 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-gray-600 dark:text-gray-400", children: [
1269 tax.name,
1270 " (",
1271 tax.rate,
1272 "%)"
1273 ] }),
1274 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: formatPriceForBooking(
1275 tax.amount,
1276 booking.currency
1277 ) })
1278 ]
1279 },
1280 index
1281 ));
1282 }
1283 const taxDetails = booking.tax_details;
1284 if (taxDetails) {
1285 try {
1286 const taxes = typeof taxDetails === "string" ? JSON.parse(taxDetails) : taxDetails;
1287 if (Array.isArray(taxes) && taxes.length > 0) {
1288 return taxes.map((tax, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
1289 "div",
1290 {
1291 className: "flex justify-between text-sm",
1292 children: [
1293 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-gray-600 dark:text-gray-400", children: [
1294 tax.name,
1295 " (",
1296 tax.rate,
1297 "%)"
1298 ] }),
1299 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: formatPriceForBooking(
1300 tax.amount,
1301 booking.currency
1302 ) })
1303 ]
1304 },
1305 index
1306 ));
1307 }
1308 } catch (e) {
1309 console.error("Failed to parse tax_details:", e);
1310 }
1311 }
1312 if (booking.tax_amount > 0) {
1313 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-sm", children: [
1314 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-gray-600 dark:text-gray-400", children: [
1315 __("Tax", "yatra"),
1316 " (",
1317 booking.tax_rate,
1318 "%)"
1319 ] }),
1320 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: formatPriceForBooking(
1321 booking.tax_amount,
1322 booking.currency
1323 ) })
1324 ] });
1325 }
1326 return null;
1327 })() }),
1328 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-base font-semibold pt-2 border-t border-gray-200 dark:border-gray-700", children: [
1329 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: __("Net Amount", "yatra") }),
1330 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: formatPriceForBooking(
1331 booking.total_amount,
1332 booking.currency
1333 ) })
1334 ] })
1335 ] })
1336 ] })
1337 ] }),
1338 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: [
1339 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: __("Customer Information", "yatra") }),
1340 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1341 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-medium text-gray-900 dark:text-white mb-1", children: booking.customer_name }),
1342 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400", children: [
1343 booking.customer_email && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5", children: [
1344 /* @__PURE__ */ jsxRuntimeExports.jsx(Mail, { className: "w-4 h-4" }),
1345 booking.customer_email
1346 ] }),
1347 booking.customer_phone && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5", children: [
1348 /* @__PURE__ */ jsxRuntimeExports.jsx(Phone, { className: "w-4 h-4" }),
1349 booking.customer_phone
1350 ] })
1351 ] })
1352 ] }) })
1353 ] }),
1354 booking.travelers_data && booking.travelers_data.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: [
1355 /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2", children: [
1356 /* @__PURE__ */ jsxRuntimeExports.jsx(Users, { className: "w-5 h-5" }),
1357 __("Travelers Information", "yatra"),
1358 /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-sm font-normal text-gray-500 dark:text-gray-400", children: [
1359 "(",
1360 booking.travelers_data.length,
1361 " ",
1362 booking.travelers_data.length === 1 ? __("traveler", "yatra") : __("travelers", "yatra"),
1363 ")"
1364 ] })
1365 ] }),
1366 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: booking.travelers_data.map((traveler, index) => {
1367 const travelerFieldsData = traveler.fields || traveler;
1368 const systemFields = [
1369 "id",
1370 "booking_id",
1371 "traveller_index",
1372 "is_lead",
1373 "created_at",
1374 "updated_at",
1375 "fields"
1376 ];
1377 const travelerEntries = Object.entries(
1378 travelerFieldsData
1379 ).filter(([key, value]) => {
1380 if (systemFields.includes(key)) return false;
1381 if (!value || typeof value === "string" && value.trim() === "")
1382 return false;
1383 if (typeof value === "object" && !Array.isArray(value))
1384 return false;
1385 return true;
1386 });
1387 const firstName = travelerFieldsData.first_name || traveler.first_name || "";
1388 const lastName = travelerFieldsData.last_name || traveler.last_name || "";
1389 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
1390 "div",
1391 {
1392 className: `p-4 rounded-lg ${index === 0 ? "bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800" : "bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700"}`,
1393 children: [
1394 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-3", children: [
1395 /* @__PURE__ */ jsxRuntimeExports.jsxs("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: [
1396 index === 0 ? __("Lead Traveler", "yatra") : `${__("Traveler", "yatra")} ${index + 1}`,
1397 (firstName || lastName) && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-normal text-gray-500 dark:text-gray-400 ml-2", children: [
1398 "-",
1399 " ",
1400 [firstName, lastName].filter(Boolean).join(" ")
1401 ] })
1402 ] }),
1403 index === 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300 px-2 py-0.5 rounded", children: __("Primary Contact", "yatra") })
1404 ] }),
1405 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 gap-3", children: travelerEntries.map(([fieldId, fieldValue]) => {
1406 if (fieldId === "first_name" || fieldId === "last_name")
1407 return null;
1408 const label = fieldId.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
1409 let displayValue = String(fieldValue);
1410 if (fieldId.includes("date") || fieldId.includes("expiry")) {
1411 try {
1412 displayValue = formatDate(fieldValue);
1413 } catch {
1414 displayValue = String(fieldValue);
1415 }
1416 }
1417 if ((fieldId === "nationality" || fieldId === "country") && fieldValue && typeof fieldValue === "string" && fieldValue.length === 2) {
1418 displayValue = getCountryName(fieldValue);
1419 }
1420 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1421 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 mb-0.5", children: label }),
1422 /* @__PURE__ */ jsxRuntimeExports.jsx(
1423 "div",
1424 {
1425 className: `text-sm text-gray-900 dark:text-white ${fieldId === "passport" ? "font-mono" : ""}`,
1426 children: displayValue
1427 }
1428 )
1429 ] }, fieldId);
1430 }) })
1431 ]
1432 },
1433 index
1434 );
1435 }) })
1436 ] }),
1437 emergencyContact && Object.values(emergencyContact).some(
1438 (v) => v && String(v).trim() !== ""
1439 ) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: [
1440 /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2", children: [
1441 /* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "w-5 h-5" }),
1442 __("Emergency Contact", "yatra")
1443 ] }),
1444 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-3", children: Object.entries(emergencyContact).filter(
1445 ([_, value]) => value && String(value).trim() !== ""
1446 ).map(([fieldId, fieldValue]) => {
1447 const label = fieldId.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
1448 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1449 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 mb-0.5", children: label }),
1450 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-medium text-gray-900 dark:text-white", children: String(fieldValue) })
1451 ] }, fieldId);
1452 }) })
1453 ] }),
1454 booking.notes && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: [
1455 /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2", children: [
1456 /* @__PURE__ */ jsxRuntimeExports.jsx(FileText, { className: "w-5 h-5" }),
1457 __("Special Requests", "yatra")
1458 ] }),
1459 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap", children: booking.notes })
1460 ] }),
1461 Array.isArray(booking.downloads) && booking.downloads.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: [
1462 /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2", children: [
1463 /* @__PURE__ */ jsxRuntimeExports.jsx(Download, { className: "w-5 h-5" }),
1464 __("Downloads", "yatra")
1465 ] }),
1466 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-3", children: booking.downloads.map((d) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
1467 "div",
1468 {
1469 className: "flex items-center justify-between gap-3 p-3 rounded-lg border border-gray-200 dark:border-gray-700",
1470 children: [
1471 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
1472 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-medium text-gray-900 dark:text-white truncate", children: d.title }),
1473 d.access_label ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: d.access_label }) : null,
1474 d.locked && d.locked_reason ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-amber-700 dark:text-amber-300 mt-1", children: d.locked_reason }) : null
1475 ] }),
1476 d.locked || !d.url ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300 text-sm font-medium cursor-not-allowed", children: [
1477 /* @__PURE__ */ jsxRuntimeExports.jsx(Download, { className: "w-4 h-4" }),
1478 __("Not Available", "yatra")
1479 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
1480 "a",
1481 {
1482 href: d.url,
1483 target: "_blank",
1484 rel: "noreferrer",
1485 className: "inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-colors text-sm font-medium",
1486 children: [
1487 /* @__PURE__ */ jsxRuntimeExports.jsx(Download, { className: "w-4 h-4" }),
1488 __("Download", "yatra")
1489 ]
1490 }
1491 )
1492 ]
1493 },
1494 d.id
1495 )) })
1496 ] })
1497 ] }),
1498 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
1499 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: [
1500 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: __("Payment Information", "yatra") }),
1501 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [
1502 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1503 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Payment Status", "yatra") }),
1504 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: getBadge(booking.payment_status), children: __(
1505 booking.payment_status || "pending",
1506 booking.payment_status || "pending"
1507 ) }) })
1508 ] }),
1509 booking.payment_method && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1510 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1 flex items-center gap-1", children: [
1511 /* @__PURE__ */ jsxRuntimeExports.jsx(CreditCard, { className: "w-3 h-3" }),
1512 __("Payment Method", "yatra")
1513 ] }),
1514 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: booking.payment_method })
1515 ] }),
1516 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1517 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Total Amount", "yatra") }),
1518 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: formatPriceForBooking(
1519 booking.total_amount,
1520 booking.currency
1521 ) })
1522 ] }),
1523 booking.amount_paid > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1524 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Amount Paid", "yatra") }),
1525 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: formatPriceForBooking(
1526 booking.amount_paid,
1527 booking.currency
1528 ) })
1529 ] }),
1530 booking.amount_due > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1531 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Amount Due", "yatra") }),
1532 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-semibold text-amber-600 dark:text-amber-400", children: formatPriceForBooking(
1533 booking.amount_due,
1534 booking.currency
1535 ) })
1536 ] })
1537 ] })
1538 ] }),
1539 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: [
1540 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: __("Timeline", "yatra") }),
1541 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [
1542 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1543 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Created", "yatra") }),
1544 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: formatDate(booking.created_at || booking.booking_date) })
1545 ] }),
1546 booking.updated_at && booking.updated_at !== booking.created_at && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1547 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Last Updated", "yatra") }),
1548 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: formatDate(booking.updated_at) })
1549 ] })
1550 ] })
1551 ] })
1552 ] })
1553 ] })
1554 ] });
1555 };
1556 const Bookings = ({
1557 bookings,
1558 conciergePhone = "",
1559 conciergeEmail = "",
1560 onSectionChange
1561 }) => {
1562 const conciergeTel = phoneToTelHref(conciergePhone);
1563 const conciergeMail = String(conciergeEmail || "").trim();
1564 const [searchTerm, setSearchTerm] = reactExports.useState("");
1565 const [bookingFilter, setBookingFilter] = reactExports.useState("all");
1566 const [selectedBookingId, setSelectedBookingId] = reactExports.useState(
1567 null
1568 );
1569 const [payLoading, setPayLoading] = reactExports.useState(null);
1570 const {
1571 data: bookingDetailsData,
1572 isPending: isBookingDetailLoading,
1573 isError: isBookingDetailError
1574 } = useQuery({
1575 queryKey: ["booking-details", selectedBookingId],
1576 queryFn: async () => {
1577 if (!selectedBookingId) return null;
1578 const response = await apiClient.get(
1579 API_ENDPOINTS.CUSTOMER_MY_BOOKING(selectedBookingId)
1580 );
1581 const inner = response && typeof response === "object" && "data" in response && response.data && typeof response.data === "object" ? response.data : response;
1582 return inner;
1583 },
1584 enabled: !!selectedBookingId
1585 });
1586 const handleBookingSelect = (bookingId) => {
1587 setSelectedBookingId(bookingId);
1588 };
1589 const handleBackToList = () => {
1590 setSelectedBookingId(null);
1591 };
1592 const handleDownloadClick = async (bookingId) => {
1593 try {
1594 await downloadVoucher(bookingId);
1595 } catch (e) {
1596 const msg = e instanceof Error ? e.message : __("Download failed.", "yatra");
1597 window.alert(msg);
1598 }
1599 };
1600 const startRemainingPaymentSession = async (bookingId) => {
1601 setPayLoading(bookingId);
1602 try {
1603 const response = await apiClient.post(
1604 API_ENDPOINTS.PAYMENT_REMAINING_SESSION,
1605 { booking_id: bookingId }
1606 );
1607 const payload = response && typeof response === "object" && "data" in response && response.data && typeof response.data === "object" ? response.data : response;
1608 const checkoutUrl = payload && typeof payload === "object" && "checkout_url" in payload && typeof payload.checkout_url === "string" ? payload.checkout_url : "";
1609 if (checkoutUrl) {
1610 window.location.href = checkoutUrl;
1611 } else {
1612 window.alert(__("Could not start payment. Please try again.", "yatra"));
1613 }
1614 } catch (error) {
1615 console.error("Error initiating payment:", error);
1616 const msg = error instanceof Error && error.message ? error.message : __("Could not start payment.", "yatra");
1617 window.alert(msg);
1618 } finally {
1619 setPayLoading(null);
1620 }
1621 };
1622 if (selectedBookingId) {
1623 return /* @__PURE__ */ jsxRuntimeExports.jsx(
1624 BookingDetails,
1625 {
1626 booking: isBookingDetailLoading || isBookingDetailError ? null : bookingDetailsData,
1627 isLoading: isBookingDetailLoading,
1628 onBack: handleBackToList
1629 }
1630 );
1631 }
1632 const displayBookings = bookings;
1633 let filteredDisplayBookings = displayBookings;
1634 if (bookingFilter === "upcoming") {
1635 const today = /* @__PURE__ */ new Date();
1636 today.setHours(0, 0, 0, 0);
1637 filteredDisplayBookings = filteredDisplayBookings.filter((b) => {
1638 const travelDate = new Date(b.travel_date);
1639 return travelDate >= today;
1640 });
1641 } else if (bookingFilter === "pending") {
1642 filteredDisplayBookings = filteredDisplayBookings.filter(
1643 (b) => b.payment_status === "pending" || b.booking_status === "pending"
1644 );
1645 } else if (bookingFilter === "completed") {
1646 filteredDisplayBookings = filteredDisplayBookings.filter(
1647 (b) => b.booking_status === "completed"
1648 );
1649 }
1650 if (searchTerm.trim()) {
1651 const searchLower = searchTerm.toLowerCase().trim();
1652 filteredDisplayBookings = filteredDisplayBookings.filter(
1653 (b) => b.trip_title && b.trip_title.toLowerCase().includes(searchLower) || b.booking_number && b.booking_number.toLowerCase().includes(searchLower) || b.destination && b.destination.toLowerCase().includes(searchLower) || b.payment_status && b.payment_status.toLowerCase().includes(searchLower) || b.booking_status && b.booking_status.toLowerCase().includes(searchLower)
1654 );
1655 }
1656 const bookingStats = {
1657 total: displayBookings.length,
1658 upcoming: displayBookings.filter(
1659 (b) => new Date(b.travel_date) >= /* @__PURE__ */ new Date()
1660 ).length,
1661 pending: displayBookings.filter(
1662 (b) => b.payment_status === "pending" || b.booking_status === "pending"
1663 ).length,
1664 completed: displayBookings.filter((b) => b.booking_status === "completed").length,
1665 totalSpent: displayBookings.reduce((sum, b) => sum + b.total_amount, 0)
1666 };
1667 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-bookings-page space-y-6", children: [
1668 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-bookings-header bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between", children: [
1669 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1670 /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-lg font-bold text-gray-900 dark:text-white", children: __("Bookings", "yatra") }),
1671 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mt-2", children: __("Manage and view all your travel bookings", "yatra") })
1672 ] }),
1673 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3 lg:flex-row lg:items-center lg:gap-4", children: [
1674 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1675 "input",
1676 {
1677 placeholder: __("Search bookings...", "yatra"),
1678 value: searchTerm,
1679 onChange: (e) => setSearchTerm(e.target.value),
1680 className: "w-full lg:w-64 pl-4 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
1681 }
1682 ) }),
1683 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1684 "select",
1685 {
1686 value: bookingFilter,
1687 onChange: (e) => setBookingFilter(
1688 e.target.value
1689 ),
1690 className: "appearance-none bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg px-4 py-2 pr-4 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent cursor-pointer",
1691 children: [
1692 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "all", children: __("All Bookings", "yatra") }),
1693 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "upcoming", children: __("Upcoming", "yatra") }),
1694 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "pending", children: __("Pending", "yatra") }),
1695 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "completed", children: __("Completed", "yatra") })
1696 ]
1697 }
1698 ) })
1699 ] })
1700 ] }) }),
1701 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-nowrap gap-6 overflow-x-auto", children: [
1702 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 bg-white dark:bg-gray-800 rounded-xl p-6 border border-gray-100 dark:border-gray-700 min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1703 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1704 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Total Bookings", "yatra") }),
1705 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-gray-900 dark:text-white", children: bookingStats.total })
1706 ] }),
1707 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-blue-50 dark:bg-blue-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Package, { className: "w-5 h-5 text-blue-600 dark:text-blue-400" }) })
1708 ] }) }),
1709 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 bg-white dark:bg-gray-800 rounded-xl p-6 border border-gray-100 dark:border-gray-700 min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1710 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1711 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Upcoming", "yatra") }),
1712 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-emerald-600 dark:text-emerald-400", children: bookingStats.upcoming })
1713 ] }),
1714 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-emerald-50 dark:bg-emerald-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-5 h-5 text-emerald-600 dark:text-emerald-400" }) })
1715 ] }) }),
1716 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 bg-white dark:bg-gray-800 rounded-xl p-6 border border-gray-100 dark:border-gray-700 min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1717 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1718 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Pending", "yatra") }),
1719 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-amber-600 dark:text-amber-400", children: bookingStats.pending })
1720 ] }),
1721 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-amber-50 dark:bg-amber-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Clock, { className: "w-5 h-5 text-amber-600 dark:text-amber-400" }) })
1722 ] }) }),
1723 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 bg-white dark:bg-gray-800 rounded-xl p-6 border border-gray-100 dark:border-gray-700 min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1724 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1725 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Completed", "yatra") }),
1726 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-gray-600 dark:text-gray-400", children: bookingStats.completed })
1727 ] }),
1728 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-gray-50 dark:bg-gray-700 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-5 h-5 text-gray-600 dark:text-gray-400" }) })
1729 ] }) }),
1730 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 bg-white dark:bg-gray-800 rounded-xl p-6 border border-gray-100 dark:border-gray-700 min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1731 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1732 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Total Spent", "yatra") }),
1733 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-gray-900 dark:text-white", children: currency(bookingStats.totalSpent) })
1734 ] }),
1735 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-purple-50 dark:bg-purple-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DollarSign, { className: "w-5 h-5 text-purple-600 dark:text-purple-400" }) })
1736 ] }) })
1737 ] }),
1738 filteredDisplayBookings.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl p-12 text-center", children: [
1739 /* @__PURE__ */ jsxRuntimeExports.jsx(Package, { className: "w-16 h-16 text-gray-300 dark:text-gray-600 mx-auto mb-4" }),
1740 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-gray-500 dark:text-gray-400 font-medium mb-1", children: __("No bookings found", "yatra") }),
1741 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-400 dark:text-gray-500", children: __("Try adjusting your filters or check back later.", "yatra") })
1742 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: filteredDisplayBookings.map((booking) => {
1743 const bookingId = Number(booking.id);
1744 const isUpcoming = new Date(booking.travel_date) > /* @__PURE__ */ new Date();
1745 const isCompleted = booking.booking_status === "completed";
1746 const paidNumeric = typeof booking.amount_paid === "number" ? booking.amount_paid : parseFloat(booking.amount_paid || "0");
1747 const totalNumeric = typeof booking.total_amount === "number" ? booking.total_amount : parseFloat(booking.total_amount || "0");
1748 const totalPaid = paidNumeric;
1749 const amountDue = totalNumeric - totalPaid;
1750 const canPayRemaining = amountDue > 0 && booking.payment_status !== "paid";
1751 return /* @__PURE__ */ jsxRuntimeExports.jsx(
1752 "div",
1753 {
1754 className: "group bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm hover:shadow-md transition-all overflow-hidden",
1755 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-6", children: [
1756 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col lg:flex-row lg:items-start lg:justify-between gap-4 mb-4", children: [
1757 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 mb-2", children: [
1758 /* @__PURE__ */ jsxRuntimeExports.jsx(
1759 "div",
1760 {
1761 className: `p-2 rounded-lg ${isUpcoming ? "bg-emerald-50 dark:bg-emerald-900/20" : isCompleted ? "bg-gray-50 dark:bg-gray-700" : "bg-amber-50 dark:bg-amber-900/20"}`,
1762 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1763 MapPin,
1764 {
1765 className: `w-5 h-5 ${isUpcoming ? "text-emerald-600 dark:text-emerald-400" : isCompleted ? "text-gray-400" : "text-amber-600 dark:text-amber-400"}`
1766 }
1767 )
1768 }
1769 ),
1770 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
1771 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs uppercase tracking-wider text-gray-500 dark:text-gray-400 font-medium mb-1", children: booking.booking_number }),
1772 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-base font-bold text-gray-900 dark:text-white mb-1", children: booking.trip_title }),
1773 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm text-gray-600 dark:text-gray-400 flex items-center gap-1", children: [
1774 /* @__PURE__ */ jsxRuntimeExports.jsx(MapPin, { className: "w-4 h-4 text-gray-600 dark:text-gray-400" }),
1775 booking.destination || __("Multiple destinations", "yatra")
1776 ] })
1777 ] })
1778 ] }) }),
1779 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap gap-2 items-start", children: [
1780 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: getBadge(booking.booking_status), children: __(booking.booking_status, booking.booking_status) }),
1781 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: getBadge(booking.payment_status), children: __(booking.payment_status, booking.payment_status) })
1782 ] })
1783 ] }),
1784 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-booking-details grid grid-cols-2 md:grid-cols-5 gap-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg mb-4", children: [
1785 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1786 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Travel Date", "yatra") }),
1787 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: formatDate(booking.travel_date) })
1788 ] }),
1789 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1790 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Travelers", "yatra") }),
1791 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: booking.travelers })
1792 ] }),
1793 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1794 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Total Amount", "yatra") }),
1795 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: currency(booking.total_amount) })
1796 ] }),
1797 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1798 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Paid / Due", "yatra") }),
1799 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: [
1800 currency(totalPaid ?? 0),
1801 amountDue !== null && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs font-normal text-gray-500 dark:text-gray-400 ml-1", children: [
1802 __("Due:", "yatra"),
1803 " ",
1804 currency(amountDue)
1805 ] })
1806 ] })
1807 ] }),
1808 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1809 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Booked On", "yatra") }),
1810 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: formatDate(booking.booking_date || booking.created_at) })
1811 ] })
1812 ] }),
1813 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-booking-actions flex flex-wrap gap-3", children: [
1814 /* @__PURE__ */ jsxRuntimeExports.jsx(
1815 "div",
1816 {
1817 role: "button",
1818 tabIndex: 0,
1819 onClick: () => handleBookingSelect(bookingId),
1820 className: "yatra-booking-action yatra-booking-action-view inline-flex items-center px-4 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-colors text-sm font-medium cursor-pointer",
1821 children: __("View Details", "yatra")
1822 }
1823 ),
1824 /* @__PURE__ */ jsxRuntimeExports.jsx(
1825 "div",
1826 {
1827 role: "button",
1828 tabIndex: 0,
1829 onClick: () => handleDownloadClick(bookingId),
1830 className: "yatra-booking-action yatra-booking-action-download inline-flex items-center px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-sm font-medium cursor-pointer",
1831 children: __("Download Voucher", "yatra")
1832 }
1833 ),
1834 /* @__PURE__ */ jsxRuntimeExports.jsx(
1835 "div",
1836 {
1837 role: "button",
1838 tabIndex: 0,
1839 onClick: () => onSectionChange("payments"),
1840 className: "yatra-booking-action yatra-booking-action-payment inline-flex items-center px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-sm font-medium cursor-pointer",
1841 children: __("Payment", "yatra")
1842 }
1843 ),
1844 canPayRemaining && /* @__PURE__ */ jsxRuntimeExports.jsxs(
1845 "button",
1846 {
1847 type: "button",
1848 onClick: () => bookingId && startRemainingPaymentSession(bookingId),
1849 disabled: payLoading === bookingId,
1850 className: "yatra-booking-action inline-flex items-center px-4 py-2 rounded-lg bg-emerald-600 text-white hover:bg-emerald-700 transition-colors text-sm font-medium disabled:opacity-50",
1851 children: [
1852 payLoading === bookingId ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
1853 "svg",
1854 {
1855 className: "w-4 h-4 animate-spin",
1856 viewBox: "0 0 24 24",
1857 fill: "none",
1858 stroke: "currentColor",
1859 strokeWidth: "2",
1860 children: [
1861 /* @__PURE__ */ jsxRuntimeExports.jsx(
1862 "circle",
1863 {
1864 cx: "12",
1865 cy: "12",
1866 r: "10",
1867 strokeOpacity: "0.25"
1868 }
1869 ),
1870 /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M4 12a8 8 0 0 1 8-8" })
1871 ]
1872 }
1873 ) : null,
1874 __("Pay Remaining Balance", "yatra")
1875 ]
1876 }
1877 ),
1878 conciergeTel ? /* @__PURE__ */ jsxRuntimeExports.jsx(
1879 "a",
1880 {
1881 href: conciergeTel,
1882 className: "yatra-booking-action yatra-booking-action-support inline-flex items-center px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-sm font-medium no-underline",
1883 children: __("Call us", "yatra")
1884 }
1885 ) : conciergeMail ? /* @__PURE__ */ jsxRuntimeExports.jsx(
1886 "a",
1887 {
1888 href: `mailto:${encodeURIComponent(conciergeMail)}`,
1889 className: "yatra-booking-action yatra-booking-action-support inline-flex items-center px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-sm font-medium no-underline",
1890 children: __("Email us", "yatra")
1891 }
1892 ) : null
1893 ] })
1894 ] })
1895 },
1896 booking.id
1897 );
1898 }) })
1899 ] });
1900 };
1901 const Payments = ({ payments, onSectionChange }) => {
1902 const displayPayments = payments;
1903 const bookingSummaries = React.useMemo(() => {
1904 const map = /* @__PURE__ */ new Map();
1905 displayPayments.forEach((payment) => {
1906 if (typeof payment.booking_id !== "number") {
1907 return;
1908 }
1909 const total = typeof payment.booking_total_amount === "number" ? payment.booking_total_amount : null;
1910 const dueValue = typeof payment.booking_amount_due === "number" ? payment.booking_amount_due : null;
1911 const paidValue = typeof payment.booking_amount_paid === "number" ? payment.booking_amount_paid : null;
1912 const paid = paidValue ?? (total !== null && dueValue !== null ? total - dueValue : null);
1913 const due = dueValue ?? (total !== null && paid !== null ? total - paid : null);
1914 const existing = map.get(payment.booking_id);
1915 const summary = {
1916 total: total ?? (existing == null ? void 0 : existing.total) ?? 0,
1917 paid: paid ?? (existing == null ? void 0 : existing.paid) ?? 0,
1918 due: due ?? (existing == null ? void 0 : existing.due) ?? 0
1919 };
1920 if (!existing || summary.due < existing.due) {
1921 map.set(payment.booking_id, summary);
1922 }
1923 });
1924 return Array.from(map.values());
1925 }, [displayPayments]);
1926 const paymentStats = React.useMemo(() => {
1927 const totals = bookingSummaries.reduce(
1928 (acc, summary) => {
1929 acc.totalAmount += summary.total;
1930 acc.paidAmount += summary.total - summary.due;
1931 acc.outstanding += summary.due;
1932 if (summary.due > 0) {
1933 acc.pendingBookings += 1;
1934 } else {
1935 acc.paidBookings += 1;
1936 }
1937 return acc;
1938 },
1939 {
1940 totalAmount: 0,
1941 paidAmount: 0,
1942 outstanding: 0,
1943 pendingBookings: 0,
1944 paidBookings: 0
1945 }
1946 );
1947 return {
1948 total: displayPayments.length,
1949 paid: totals.paidBookings,
1950 pending: totals.pendingBookings,
1951 totalPaidAmount: totals.paidAmount,
1952 outstandingAmount: totals.outstanding
1953 };
1954 }, [displayPayments, bookingSummaries]);
1955 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-payments-page space-y-6", children: [
1956 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-payments-header bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1957 /* @__PURE__ */ jsxRuntimeExports.jsxs("h2", { className: "text-lg font-bold text-gray-900 dark:text-white flex items-center gap-3", children: [
1958 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-emerald-50 dark:bg-emerald-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CreditCard, { className: "w-6 h-6 text-emerald-600 dark:text-emerald-400" }) }),
1959 __("Payments & Invoices", "yatra")
1960 ] }),
1961 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mt-2", children: __(
1962 "Track deposits, balances, and installment schedules with secure payment links.",
1963 "yatra"
1964 ) })
1965 ] }) }) }),
1966 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-payments-stats grid gap-4 sm:grid-cols-2 lg:grid-cols-4", children: [
1967 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-payment-stat-card bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1968 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1969 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Total Payments", "yatra") }),
1970 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-gray-900 dark:text-white", children: paymentStats.total })
1971 ] }),
1972 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-blue-50 dark:bg-blue-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CreditCard, { className: "w-5 h-5 text-blue-600 dark:text-blue-400" }) })
1973 ] }) }),
1974 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-payment-stat-card bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1975 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1976 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Paid", "yatra") }),
1977 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-emerald-600 dark:text-emerald-400", children: paymentStats.paid }),
1978 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-400 dark:text-gray-500", children: currency(paymentStats.totalPaidAmount) })
1979 ] }),
1980 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-emerald-50 dark:bg-emerald-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-5 h-5 text-emerald-600 dark:text-emerald-400" }) })
1981 ] }) }),
1982 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-payment-stat-card bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1983 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1984 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Pending", "yatra") }),
1985 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-amber-600 dark:text-amber-400", children: paymentStats.pending })
1986 ] }),
1987 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-amber-50 dark:bg-amber-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Clock, { className: "w-5 h-5 text-amber-600 dark:text-amber-400" }) })
1988 ] }) }),
1989 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-payment-stat-card bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
1990 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1991 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Outstanding", "yatra") }),
1992 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-gray-900 dark:text-white", children: currency(paymentStats.outstandingAmount) })
1993 ] }),
1994 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-purple-50 dark:bg-purple-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DollarSign, { className: "w-5 h-5 text-purple-600 dark:text-purple-400" }) })
1995 ] }) })
1996 ] }),
1997 displayPayments.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl p-12 text-center", children: [
1998 /* @__PURE__ */ jsxRuntimeExports.jsx(CreditCard, { className: "w-16 h-16 text-gray-300 dark:text-gray-600 mx-auto mb-4" }),
1999 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-gray-500 dark:text-gray-400 font-medium mb-1", children: __("No payments found", "yatra") }),
2000 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-400 dark:text-gray-500", children: __(
2001 "Payment history will appear here once you make a booking.",
2002 "yatra"
2003 ) })
2004 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: displayPayments.map((payment) => {
2005 const bookingTotal = typeof payment.booking_total_amount === "number" ? payment.booking_total_amount : null;
2006 const bookingPaid = typeof payment.booking_amount_paid === "number" ? payment.booking_amount_paid : null;
2007 const bookingDue = typeof payment.booking_amount_due === "number" ? payment.booking_amount_due : null;
2008 const total = bookingTotal ?? payment.amount;
2009 const paid = bookingPaid ?? (bookingDue !== null && bookingTotal !== null ? bookingTotal - bookingDue : payment.amount);
2010 const dueRaw = bookingDue ?? (bookingTotal !== null ? bookingTotal - paid : total - paid);
2011 const due = Math.max(0, dueRaw || 0);
2012 const canPayRemaining = typeof payment.booking_id === "number" && due > 0.01;
2013 const isPaid = payment.status === "paid" || payment.status === "completed";
2014 const isPending = payment.status === "pending";
2015 return /* @__PURE__ */ jsxRuntimeExports.jsx(
2016 "div",
2017 {
2018 className: "group bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm hover:shadow-md transition-all overflow-hidden",
2019 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-6", children: [
2020 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col lg:flex-row lg:items-start lg:justify-between gap-4 mb-4", children: [
2021 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 mb-2", children: [
2022 /* @__PURE__ */ jsxRuntimeExports.jsx(
2023 "div",
2024 {
2025 className: `p-2 rounded-lg ${payment.status === "paid" ? "bg-emerald-50 dark:bg-emerald-900/20" : payment.status === "pending" ? "bg-amber-50 dark:bg-amber-900/20" : "bg-gray-50 dark:bg-gray-700"}`,
2026 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2027 CreditCard,
2028 {
2029 className: `w-5 h-5 ${payment.status === "paid" ? "text-emerald-600 dark:text-emerald-400" : payment.status === "pending" ? "text-amber-600 dark:text-amber-400" : "text-gray-400"}`
2030 }
2031 )
2032 }
2033 ),
2034 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [
2035 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs uppercase tracking-wider text-gray-500 dark:text-gray-400 font-medium mb-1", children: payment.reference }),
2036 /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-base font-bold text-gray-900 dark:text-white mb-1", children: [
2037 __("Booking", "yatra"),
2038 ": ",
2039 payment.booking_number
2040 ] }),
2041 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm text-gray-600 dark:text-gray-400 flex items-center gap-1", children: [
2042 /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-4 h-4" }),
2043 formatDate(payment.date)
2044 ] })
2045 ] })
2046 ] }) }),
2047 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap gap-2 items-start", children: [
2048 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: getBadge(payment.status), children: __(payment.status, payment.status) }),
2049 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "px-3 py-1 rounded-lg text-xs font-medium bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300 capitalize", children: payment.type })
2050 ] })
2051 ] }),
2052 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-payment-details grid grid-cols-2 md:grid-cols-3 gap-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg mb-4", children: [
2053 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2054 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1 flex items-center gap-1", children: [
2055 /* @__PURE__ */ jsxRuntimeExports.jsx(DollarSign, { className: "w-3.5 h-3.5" }),
2056 __("Amount", "yatra")
2057 ] }),
2058 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: currency(payment.amount) })
2059 ] }),
2060 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2061 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1 flex items-center gap-1", children: [
2062 /* @__PURE__ */ jsxRuntimeExports.jsx(CreditCard, { className: "w-3.5 h-3.5" }),
2063 __("Payment Method", "yatra")
2064 ] }),
2065 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: payment.method })
2066 ] }),
2067 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2068 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1 flex items-center gap-1", children: [
2069 /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-3.5 h-3.5" }),
2070 __("Payment Date", "yatra")
2071 ] }),
2072 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: formatDate(payment.date) })
2073 ] })
2074 ] }),
2075 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-payment-actions flex flex-wrap gap-3", children: [
2076 isPaid && /* @__PURE__ */ jsxRuntimeExports.jsxs(
2077 "button",
2078 {
2079 type: "button",
2080 onClick: async () => {
2081 try {
2082 await downloadInvoice(payment.id);
2083 } catch (err) {
2084 alert(
2085 err instanceof Error ? err.message : __("Download failed.", "yatra")
2086 );
2087 }
2088 },
2089 className: "yatra-payment-action yatra-payment-action-invoice inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium",
2090 style: { backgroundColor: "#059669", color: "#ffffff" },
2091 children: [
2092 /* @__PURE__ */ jsxRuntimeExports.jsx(Download, { className: "w-4 h-4" }),
2093 __("Download Invoice", "yatra")
2094 ]
2095 }
2096 ),
2097 isPaid && /* @__PURE__ */ jsxRuntimeExports.jsxs(
2098 "button",
2099 {
2100 type: "button",
2101 onClick: async () => {
2102 try {
2103 await previewPaymentInvoice(payment.id);
2104 } catch (err) {
2105 alert(
2106 err instanceof Error ? err.message : __("Could not open receipt.", "yatra")
2107 );
2108 }
2109 },
2110 className: "yatra-payment-action yatra-payment-action-receipt inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium",
2111 style: { backgroundColor: "#2563eb", color: "#ffffff" },
2112 children: [
2113 /* @__PURE__ */ jsxRuntimeExports.jsx(FileText, { className: "w-4 h-4" }),
2114 __("View Receipt", "yatra")
2115 ]
2116 }
2117 ),
2118 isPending && !canPayRemaining && /* @__PURE__ */ jsxRuntimeExports.jsxs(
2119 "button",
2120 {
2121 type: "button",
2122 className: "yatra-payment-action inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-amber-600 text-white text-sm font-medium",
2123 children: [
2124 /* @__PURE__ */ jsxRuntimeExports.jsx(Clock, { className: "w-4 h-4" }),
2125 __("Pending approval", "yatra")
2126 ]
2127 }
2128 ),
2129 /* @__PURE__ */ jsxRuntimeExports.jsxs(
2130 "button",
2131 {
2132 type: "button",
2133 onClick: () => onSectionChange("bookings"),
2134 className: "yatra-payment-action yatra-payment-action-booking inline-flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-sm font-medium",
2135 children: [
2136 /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "w-4 h-4" }),
2137 __("View Booking Details", "yatra")
2138 ]
2139 }
2140 )
2141 ] })
2142 ] })
2143 },
2144 payment.id
2145 );
2146 }) })
2147 ] });
2148 };
2149 const Documents = ({ documents }) => {
2150 const [searchTerm, setSearchTerm] = reactExports.useState("");
2151 const [selectedCategory, setSelectedCategory] = reactExports.useState("all");
2152 const displayDocuments = documents;
2153 let filteredDocuments = [...displayDocuments];
2154 if (selectedCategory !== "all") {
2155 filteredDocuments = filteredDocuments.filter(
2156 (d) => d.category === selectedCategory
2157 );
2158 }
2159 if (searchTerm.trim()) {
2160 const searchLower = searchTerm.toLowerCase().trim();
2161 filteredDocuments = filteredDocuments.filter((d) => {
2162 const name = d.name || "";
2163 const tripTitle = d.trip_title || "";
2164 const category = d.category || "";
2165 return name.toLowerCase().includes(searchLower) || tripTitle.toLowerCase().includes(searchLower) || category.toLowerCase().includes(searchLower);
2166 });
2167 }
2168 const documentsByCategory = {
2169 itinerary: filteredDocuments.filter((d) => d.category === "itinerary"),
2170 voucher: filteredDocuments.filter((d) => d.category === "voucher"),
2171 invoice: filteredDocuments.filter((d) => d.category === "invoice"),
2172 downloads: filteredDocuments.filter((d) => d.category === "downloads")
2173 };
2174 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-documents-page space-y-6", children: [
2175 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-documents-header bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between", children: [
2176 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2177 /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-lg font-bold text-gray-900 dark:text-white", children: __("Travel Documents", "yatra") }),
2178 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mt-2", children: __(
2179 "Download itineraries, vouchers, invoices, and other documents for each trip.",
2180 "yatra"
2181 ) })
2182 ] }),
2183 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3 lg:flex-row lg:items-center lg:gap-4", children: [
2184 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2185 "input",
2186 {
2187 type: "text",
2188 placeholder: __("Search documents...", "yatra"),
2189 value: searchTerm,
2190 onChange: (e) => setSearchTerm(e.target.value),
2191 className: "w-full lg:w-64 pl-4 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent"
2192 }
2193 ) }),
2194 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
2195 "select",
2196 {
2197 value: selectedCategory,
2198 onChange: (e) => setSelectedCategory(
2199 e.target.value
2200 ),
2201 className: "appearance-none bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg px-4 py-2 pr-4 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent cursor-pointer",
2202 children: [
2203 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "all", children: __("All Documents", "yatra") }),
2204 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "itinerary", children: __("Itineraries", "yatra") }),
2205 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "voucher", children: __("Vouchers", "yatra") }),
2206 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "invoice", children: __("Invoices", "yatra") }),
2207 /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "downloads", children: __("Downloads", "yatra") })
2208 ]
2209 }
2210 ) })
2211 ] })
2212 ] }) }),
2213 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-documents-stats flex flex-nowrap gap-6 overflow-x-auto", children: [
2214 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 yatra-document-stat-card bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl p-6 min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2215 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Itinerary", "yatra") }),
2216 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-blue-600 dark:text-blue-400", children: documentsByCategory.itinerary.length })
2217 ] }) }),
2218 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 yatra-document-stat-card bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl p-6 min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2219 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Voucher", "yatra") }),
2220 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-emerald-600 dark:text-emerald-400", children: documentsByCategory.voucher.length })
2221 ] }) }),
2222 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 yatra-document-stat-card bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl p-6 min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2223 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Invoice", "yatra") }),
2224 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-purple-600 dark:text-purple-400", children: documentsByCategory.invoice.length })
2225 ] }) }),
2226 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 yatra-document-stat-card bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl p-6 min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2227 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: __("Downloads", "yatra") }),
2228 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xl font-bold text-amber-600 dark:text-amber-400", children: documentsByCategory.downloads.length })
2229 ] }) })
2230 ] }),
2231 filteredDocuments.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl p-12 text-center", children: [
2232 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-16 h-16 bg-gray-200 dark:bg-gray-700 rounded-full mx-auto mb-4" }),
2233 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-gray-500 dark:text-gray-400 font-medium mb-1", children: __("No documents found", "yatra") }),
2234 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-400 dark:text-gray-500", children: __(
2235 "No documents are available yet. Please check back later.",
2236 "yatra"
2237 ) })
2238 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: filteredDocuments.map((doc) => /* @__PURE__ */ jsxRuntimeExports.jsx(
2239 "div",
2240 {
2241 className: "group bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm hover:shadow-md transition-all overflow-hidden",
2242 children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-start gap-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
2243 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-4 mb-2", children: [
2244 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
2245 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1", children: doc.trip_title }),
2246 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-base font-bold text-gray-900 dark:text-white mb-1 truncate", children: doc.name }),
2247 /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: [
2248 __("Updated", "yatra"),
2249 ": ",
2250 formatDate(doc.updated_at)
2251 ] }),
2252 doc.category === "downloads" && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-2", children: [
2253 __("Access", "yatra"),
2254 ":",
2255 " ",
2256 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-gray-700 dark:text-gray-300", children: doc.access_label || doc.access || "-" }),
2257 doc.locked && doc.locked_reason ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-2 text-amber-700 dark:text-amber-300", children: [
2258 "(",
2259 doc.locked_reason,
2260 ")"
2261 ] }) : null
2262 ] })
2263 ] }),
2264 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 flex-shrink-0", children: [
2265 doc.category === "downloads" && doc.access_label && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "px-3 py-1 rounded-lg text-xs font-medium bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300 border border-amber-200 dark:border-amber-800", children: doc.access_label }),
2266 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "px-3 py-1 rounded-lg text-xs font-medium bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 capitalize", children: doc.category })
2267 ] })
2268 ] }),
2269 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-document-actions flex flex-wrap gap-3 mt-4", children: [
2270 doc.locked || !doc.url ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2271 "div",
2272 {
2273 className: "inline-flex items-center px-4 py-2 rounded-lg bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors text-sm font-medium cursor-not-allowed",
2274 title: doc.locked_reason || __("Not available", "yatra"),
2275 children: __("Not Available", "yatra")
2276 }
2277 ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
2278 "button",
2279 {
2280 type: "button",
2281 onClick: async () => {
2282 try {
2283 await downloadDocument({
2284 bookingId: doc.booking_id,
2285 paymentId: doc.payment_id,
2286 documentType: doc.category,
2287 fallbackUrl: doc.url
2288 });
2289 } catch (err) {
2290 alert(
2291 err instanceof Error ? err.message : __("Download failed.", "yatra")
2292 );
2293 }
2294 },
2295 className: "yatra-document-action yatra-document-action-download inline-flex items-center px-4 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-colors text-sm font-medium",
2296 children: __("Download", "yatra")
2297 }
2298 ),
2299 doc.url ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2300 "button",
2301 {
2302 type: "button",
2303 onClick: async () => {
2304 try {
2305 await previewTravelDocument(doc);
2306 } catch (err) {
2307 alert(
2308 err instanceof Error ? err.message : __("Preview failed.", "yatra")
2309 );
2310 }
2311 },
2312 className: "yatra-document-action yatra-document-action-preview inline-flex items-center px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-sm font-medium",
2313 children: __("Preview", "yatra")
2314 }
2315 ) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "inline-flex items-center px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-700 text-gray-500 dark:text-gray-500 text-sm font-medium cursor-not-allowed", children: __("Preview", "yatra") })
2316 ] })
2317 ] }) }) })
2318 },
2319 doc.id
2320 )) })
2321 ] });
2322 };
2323 const Profile = ({
2324 profile,
2325 savedTrips,
2326 wishlistEnabled = false
2327 }) => {
2328 const [isEditing, setIsEditing] = reactExports.useState(false);
2329 const [formData, setFormData] = reactExports.useState({
2330 name: "",
2331 email: "",
2332 phone: "",
2333 address: "",
2334 city: "",
2335 country: ""
2336 });
2337 const [isChangingPassword, setIsChangingPassword] = reactExports.useState(false);
2338 const [passwordData, setPasswordData] = reactExports.useState({
2339 currentPassword: "",
2340 newPassword: "",
2341 confirmPassword: ""
2342 });
2343 reactExports.useEffect(() => {
2344 if (profile && !isEditing) {
2345 setFormData({
2346 name: profile.name || "",
2347 email: profile.email || "",
2348 phone: profile.phone || "",
2349 address: profile.address || "",
2350 city: profile.city || "",
2351 country: profile.country || ""
2352 });
2353 }
2354 }, [profile, isEditing]);
2355 const handleInputChange = (field, value) => {
2356 setFormData((prev) => ({ ...prev, [field]: value }));
2357 };
2358 const handleSave = () => {
2359 setIsEditing(false);
2360 };
2361 const handleCancel = () => {
2362 setIsEditing(false);
2363 if (profile) {
2364 setFormData({
2365 name: profile.name || "",
2366 email: profile.email || "",
2367 phone: profile.phone || "",
2368 address: profile.address || "",
2369 city: profile.city || "",
2370 country: profile.country || ""
2371 });
2372 }
2373 };
2374 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-page space-y-6", children: [
2375 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-profile-header bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between", children: [
2376 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2377 /* @__PURE__ */ jsxRuntimeExports.jsxs("h2", { className: "text-lg font-bold text-gray-900 dark:text-white flex items-center gap-3", children: [
2378 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 bg-indigo-50 dark:bg-indigo-900/20 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(User, { className: "w-6 h-6 text-indigo-600 dark:text-indigo-400" }) }),
2379 __("Profile", "yatra")
2380 ] }),
2381 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mt-2", children: __(
2382 "Update your contact details, address, and communication preferences.",
2383 "yatra"
2384 ) })
2385 ] }),
2386 !isEditing && /* @__PURE__ */ jsxRuntimeExports.jsxs(
2387 "div",
2388 {
2389 role: "button",
2390 tabIndex: 0,
2391 onClick: () => setIsEditing(true),
2392 className: "yatra-profile-edit-btn inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-colors text-sm font-medium cursor-pointer",
2393 children: [
2394 /* @__PURE__ */ jsxRuntimeExports.jsx(PenSquare, { className: "w-4 h-4" }),
2395 " ",
2396 __("Edit Profile", "yatra")
2397 ]
2398 }
2399 )
2400 ] }) }),
2401 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-profile-card bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-fields space-y-6", children: [
2402 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
2403 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-field", children: [
2404 /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2", children: [
2405 __("Full Name", "yatra"),
2406 " ",
2407 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" })
2408 ] }),
2409 isEditing ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2410 "input",
2411 {
2412 type: "text",
2413 value: formData.name,
2414 onChange: (e) => handleInputChange("name", e.target.value),
2415 className: "w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent",
2416 placeholder: __("Enter your full name", "yatra")
2417 }
2418 ) : /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white py-2", children: formData.name || __("Not set", "yatra") })
2419 ] }),
2420 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-field", children: [
2421 /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2", children: [
2422 __("Email Address", "yatra"),
2423 " ",
2424 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" })
2425 ] }),
2426 isEditing ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2427 "input",
2428 {
2429 type: "email",
2430 value: formData.email,
2431 onChange: (e) => handleInputChange("email", e.target.value),
2432 className: "w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent",
2433 placeholder: __("Enter your email address", "yatra")
2434 }
2435 ) : /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white py-2", children: formData.email || __("Not set", "yatra") })
2436 ] }),
2437 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-field", children: [
2438 /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2", children: __("Phone Number", "yatra") }),
2439 isEditing ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2440 "input",
2441 {
2442 type: "tel",
2443 value: formData.phone,
2444 onChange: (e) => handleInputChange("phone", e.target.value),
2445 className: "w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent",
2446 placeholder: __("Enter your phone number", "yatra")
2447 }
2448 ) : /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white py-2", children: formData.phone || __("Not set", "yatra") })
2449 ] }),
2450 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-field", children: [
2451 /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2", children: __("City", "yatra") }),
2452 isEditing ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2453 "input",
2454 {
2455 type: "text",
2456 value: formData.city,
2457 onChange: (e) => handleInputChange("city", e.target.value),
2458 className: "w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent",
2459 placeholder: __("Enter your city", "yatra")
2460 }
2461 ) : /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white py-2", children: formData.city || __("Not set", "yatra") })
2462 ] }),
2463 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-field md:col-span-2", children: [
2464 /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2", children: __("Address", "yatra") }),
2465 isEditing ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2466 "textarea",
2467 {
2468 value: formData.address,
2469 onChange: (e) => handleInputChange("address", e.target.value),
2470 rows: 3,
2471 className: "w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent",
2472 placeholder: __("Enter your address", "yatra")
2473 }
2474 ) : /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white py-2", children: formData.address || __("Not set", "yatra") })
2475 ] }),
2476 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-field", children: [
2477 /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2", children: __("Country", "yatra") }),
2478 isEditing ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2479 "input",
2480 {
2481 type: "text",
2482 value: formData.country,
2483 onChange: (e) => handleInputChange("country", e.target.value),
2484 className: "w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent",
2485 placeholder: __("Enter your country", "yatra")
2486 }
2487 ) : /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white py-2", children: formData.country || __("Not set", "yatra") })
2488 ] })
2489 ] }),
2490 isEditing && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-actions flex flex-wrap gap-3 pt-4 border-t border-gray-200 dark:border-gray-700", children: [
2491 /* @__PURE__ */ jsxRuntimeExports.jsxs(
2492 "button",
2493 {
2494 type: "button",
2495 onClick: handleSave,
2496 className: "inline-flex items-center gap-2 px-6 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-colors text-sm font-medium",
2497 children: [
2498 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }),
2499 __("Save Changes", "yatra")
2500 ]
2501 }
2502 ),
2503 /* @__PURE__ */ jsxRuntimeExports.jsxs(
2504 "div",
2505 {
2506 role: "button",
2507 tabIndex: 0,
2508 onClick: handleCancel,
2509 className: "inline-flex items-center gap-2 px-6 py-2 rounded-lg border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-sm font-medium cursor-pointer",
2510 children: [
2511 /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-4 h-4" }),
2512 __("Cancel", "yatra")
2513 ]
2514 }
2515 )
2516 ] })
2517 ] }) }),
2518 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-password bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: [
2519 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-6", children: [
2520 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2521 /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-base font-semibold text-gray-900 dark:text-white flex items-center gap-2", children: [
2522 /* @__PURE__ */ jsxRuntimeExports.jsx(ShieldCheck, { className: "w-5 h-5 text-blue-600 dark:text-blue-400" }),
2523 __("Change Password", "yatra")
2524 ] }),
2525 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mt-1", children: __("Update your password to keep your account secure.", "yatra") })
2526 ] }),
2527 !isChangingPassword && /* @__PURE__ */ jsxRuntimeExports.jsxs(
2528 "div",
2529 {
2530 role: "button",
2531 tabIndex: 0,
2532 onClick: () => setIsChangingPassword(true),
2533 className: "inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-colors text-sm font-medium cursor-pointer",
2534 children: [
2535 /* @__PURE__ */ jsxRuntimeExports.jsx(ShieldCheck, { className: "w-4 h-4" }),
2536 __("Change Password", "yatra")
2537 ]
2538 }
2539 )
2540 ] }),
2541 isChangingPassword && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
2542 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-password-field", children: [
2543 /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2", children: [
2544 __("Current Password", "yatra"),
2545 " ",
2546 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" })
2547 ] }),
2548 /* @__PURE__ */ jsxRuntimeExports.jsx(
2549 "input",
2550 {
2551 type: "password",
2552 value: passwordData.currentPassword,
2553 onChange: (e) => setPasswordData((prev) => ({
2554 ...prev,
2555 currentPassword: e.target.value
2556 })),
2557 className: "w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent",
2558 placeholder: __("Enter your current password", "yatra")
2559 }
2560 )
2561 ] }),
2562 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-password-field", children: [
2563 /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2", children: [
2564 __("New Password", "yatra"),
2565 " ",
2566 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" })
2567 ] }),
2568 /* @__PURE__ */ jsxRuntimeExports.jsx(
2569 "input",
2570 {
2571 type: "password",
2572 value: passwordData.newPassword,
2573 onChange: (e) => setPasswordData((prev) => ({
2574 ...prev,
2575 newPassword: e.target.value
2576 })),
2577 className: "w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent",
2578 placeholder: __("Enter new password", "yatra")
2579 }
2580 )
2581 ] }),
2582 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-password-field", children: [
2583 /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2", children: [
2584 __("Confirm New Password", "yatra"),
2585 " ",
2586 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" })
2587 ] }),
2588 /* @__PURE__ */ jsxRuntimeExports.jsx(
2589 "input",
2590 {
2591 type: "password",
2592 value: passwordData.confirmPassword,
2593 onChange: (e) => setPasswordData((prev) => ({
2594 ...prev,
2595 confirmPassword: e.target.value
2596 })),
2597 className: "w-full rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent",
2598 placeholder: __("Confirm your new password", "yatra")
2599 }
2600 ),
2601 passwordData.newPassword && passwordData.confirmPassword && passwordData.newPassword !== passwordData.confirmPassword && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-red-500 mt-1", children: __("Passwords do not match", "yatra") })
2602 ] }),
2603 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-password-actions flex flex-wrap gap-3 pt-4 border-t border-gray-200 dark:border-gray-700", children: [
2604 /* @__PURE__ */ jsxRuntimeExports.jsxs(
2605 "button",
2606 {
2607 type: "button",
2608 onClick: () => {
2609 if (passwordData.newPassword !== passwordData.confirmPassword) {
2610 return;
2611 }
2612 setIsChangingPassword(false);
2613 setPasswordData({
2614 currentPassword: "",
2615 newPassword: "",
2616 confirmPassword: ""
2617 });
2618 },
2619 disabled: !passwordData.currentPassword || !passwordData.newPassword || !passwordData.confirmPassword || passwordData.newPassword !== passwordData.confirmPassword,
2620 className: "inline-flex items-center gap-2 px-6 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-colors text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",
2621 children: [
2622 /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }),
2623 __("Update Password", "yatra")
2624 ]
2625 }
2626 ),
2627 /* @__PURE__ */ jsxRuntimeExports.jsxs(
2628 "div",
2629 {
2630 role: "button",
2631 tabIndex: 0,
2632 onClick: () => {
2633 setIsChangingPassword(false);
2634 setPasswordData({
2635 currentPassword: "",
2636 newPassword: "",
2637 confirmPassword: ""
2638 });
2639 },
2640 className: "inline-flex items-center gap-2 px-6 py-2 rounded-lg border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-sm font-medium cursor-pointer",
2641 children: [
2642 /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-4 h-4" }),
2643 __("Cancel", "yatra")
2644 ]
2645 }
2646 )
2647 ] })
2648 ] })
2649 ] }),
2650 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-sections grid gap-6 lg:grid-cols-2", children: [
2651 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-communication bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: [
2652 /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-base font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2", children: [
2653 /* @__PURE__ */ jsxRuntimeExports.jsx(Mail, { className: "w-5 h-5 text-blue-600 dark:text-blue-400" }),
2654 __("Communication Preferences", "yatra")
2655 ] }),
2656 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-preferences space-y-3 text-sm", children: [
2657 /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-3 cursor-pointer", children: [
2658 /* @__PURE__ */ jsxRuntimeExports.jsx(
2659 "input",
2660 {
2661 type: "checkbox",
2662 defaultChecked: true,
2663 className: "w-4 h-4 rounded text-blue-600 focus:ring-blue-500"
2664 }
2665 ),
2666 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-700 dark:text-gray-300", children: __("Booking reminders", "yatra") })
2667 ] }),
2668 /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-3 cursor-pointer", children: [
2669 /* @__PURE__ */ jsxRuntimeExports.jsx(
2670 "input",
2671 {
2672 type: "checkbox",
2673 defaultChecked: true,
2674 className: "w-4 h-4 rounded text-blue-600 focus:ring-blue-500"
2675 }
2676 ),
2677 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-700 dark:text-gray-300", children: __("Payment notifications", "yatra") })
2678 ] }),
2679 /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-3 cursor-pointer", children: [
2680 /* @__PURE__ */ jsxRuntimeExports.jsx(
2681 "input",
2682 {
2683 type: "checkbox",
2684 className: "w-4 h-4 rounded text-blue-600 focus:ring-blue-500"
2685 }
2686 ),
2687 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-700 dark:text-gray-300", children: __("Promotional offers", "yatra") })
2688 ] }),
2689 /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-3 cursor-pointer", children: [
2690 /* @__PURE__ */ jsxRuntimeExports.jsx(
2691 "input",
2692 {
2693 type: "checkbox",
2694 defaultChecked: true,
2695 className: "w-4 h-4 rounded text-blue-600 focus:ring-blue-500"
2696 }
2697 ),
2698 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-700 dark:text-gray-300", children: __("Trip updates", "yatra") })
2699 ] })
2700 ] })
2701 ] }),
2702 wishlistEnabled && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-profile-saved-trips bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: [
2703 /* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-base font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2", children: [
2704 /* @__PURE__ */ jsxRuntimeExports.jsx(Heart, { className: "w-5 h-5 text-red-600 dark:text-red-400" }),
2705 __("Saved Trips", "yatra")
2706 ] }),
2707 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-saved-trips-list space-y-3", children: savedTrips.length > 0 ? savedTrips.map((trip) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
2708 "div",
2709 {
2710 className: "yatra-saved-trip-item flex items-center justify-between border border-gray-100 dark:border-gray-700 rounded-lg p-4 hover:bg-gray-50 dark:hover:bg-gray-900/40 transition-colors",
2711 children: [
2712 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
2713 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white truncate", children: trip.trip_title || trip.title }),
2714 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: formatDate(trip.next_departure) })
2715 ] }),
2716 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-right ml-4 flex-shrink-0", children: [
2717 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: __("From", "yatra") }),
2718 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: currency(trip.price_from || trip.price || 0) })
2719 ] })
2720 ]
2721 },
2722 trip.id || trip.trip_id
2723 )) : /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 text-center py-4", children: __("No saved trips yet", "yatra") }) })
2724 ] })
2725 ] })
2726 ] });
2727 };
2728 const SavedTrips = ({ savedTrips, isLoading }) => {
2729 const { showToast } = useToast();
2730 const handleRemoveTrip = async (tripId) => {
2731 try {
2732 await apiClient.delete(`/saved-trips/${tripId}`);
2733 window.location.reload();
2734 } catch (error) {
2735 console.error("Error removing trip:", error);
2736 showToast(__("Failed to remove trip from wishlist.", "yatra"), "error");
2737 }
2738 };
2739 return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
2740 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2741 /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white", children: __("Saved Trips", "yatra") }),
2742 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mt-1", children: __("Your wishlist of favorite trips", "yatra") })
2743 ] }) }),
2744 isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-trip-grid grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-trip-card", children: [
2745 /* @__PURE__ */ jsxRuntimeExports.jsx(
2746 "div",
2747 {
2748 className: "yatra-trip-image",
2749 style: { backgroundColor: "#f3f4f6", minHeight: "200px" },
2750 children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "animate-pulse bg-gray-200 dark:bg-gray-700 w-full h-full" })
2751 }
2752 ),
2753 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-trip-content p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "animate-pulse space-y-3", children: [
2754 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4" }),
2755 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/2" }),
2756 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-2/3" })
2757 ] }) })
2758 ] }, i)) }) : savedTrips.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center py-12", children: [
2759 /* @__PURE__ */ jsxRuntimeExports.jsx(Heart, { className: "w-16 h-16 text-gray-300 dark:text-gray-600 mx-auto mb-4" }),
2760 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-2", children: __("No saved trips yet", "yatra") }),
2761 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-gray-500 dark:text-gray-400 mb-6", children: __(
2762 "Start exploring and save your favorite trips to your wishlist!",
2763 "yatra"
2764 ) }),
2765 /* @__PURE__ */ jsxRuntimeExports.jsxs(
2766 "a",
2767 {
2768 href: "/trip/",
2769 className: "inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",
2770 children: [
2771 /* @__PURE__ */ jsxRuntimeExports.jsx(MapPin, { className: "w-4 h-4" }),
2772 __("Browse Trips", "yatra")
2773 ]
2774 }
2775 )
2776 ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-trip-grid grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6", children: savedTrips.map((trip) => {
2777 var _a, _b;
2778 const tripUrl = trip.permalink || `/trip/${trip.trip_slug || trip.trip_id}`;
2779 const siteBase = typeof window !== "undefined" && (((_a = window.yatraAdmin) == null ? void 0 : _a.siteUrl) || ((_b = window.yatraAccountPage) == null ? void 0 : _b.siteUrl)) || (typeof window !== "undefined" ? window.location.origin : "");
2780 const imageUrl = trip.trip_image || `${siteBase}/wp-content/plugins/yatra/assets/images/trip-placeholder.svg`;
2781 const hasDiscount = trip.discount_percent && trip.discount_percent > 0;
2782 const displayPrice = trip.price !== void 0 && trip.price !== null ? trip.price : trip.sale_price !== void 0 && trip.sale_price !== null && trip.sale_price > 0 ? trip.sale_price : trip.original_price !== void 0 && trip.original_price !== null && trip.original_price > 0 ? trip.original_price : 0;
2783 const originalPrice = trip.original_price;
2784 const avgRating = trip.rating !== void 0 && trip.rating !== null ? trip.rating : trip.average_rating !== void 0 && trip.average_rating !== null ? trip.average_rating : 0;
2785 const reviewCount = trip.reviews !== void 0 && trip.reviews !== null ? trip.reviews : trip.review_count || trip.reviews_count || 0;
2786 return /* @__PURE__ */ jsxRuntimeExports.jsxs(
2787 "div",
2788 {
2789 className: "yatra-trip-card flex h-full flex-col overflow-hidden rounded-xl border border-gray-100 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",
2790 "data-price": displayPrice,
2791 "data-rating": avgRating,
2792 "data-duration": trip.duration_days || 0,
2793 children: [
2794 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-trip-image", children: [
2795 /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: imageUrl, alt: trip.trip_title }),
2796 hasDiscount && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-discount-badge", children: [
2797 trip.discount_percent,
2798 "% ",
2799 __("OFF", "yatra")
2800 ] }),
2801 /* @__PURE__ */ jsxRuntimeExports.jsx(
2802 "button",
2803 {
2804 className: "yatra-favorite-btn saved is-saved",
2805 title: __("Remove from favorites", "yatra"),
2806 onClick: () => handleRemoveTrip(trip.trip_id),
2807 style: { color: "#ef4444" },
2808 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2809 "svg",
2810 {
2811 width: "20",
2812 height: "20",
2813 fill: "currentColor",
2814 stroke: "currentColor",
2815 viewBox: "0 0 24 24",
2816 children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2817 "path",
2818 {
2819 strokeLinecap: "round",
2820 strokeLinejoin: "round",
2821 strokeWidth: "2",
2822 d: "M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"
2823 }
2824 )
2825 }
2826 )
2827 }
2828 )
2829 ] }),
2830 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-trip-content flex flex-1 flex-col p-4", children: [
2831 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-trip-meta", children: [
2832 trip.location && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2833 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "yatra-trip-location", children: trip.location }),
2834 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "yatra-trip-separator", children: "•" })
2835 ] }),
2836 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "yatra-trip-duration", children: trip.duration || __("Flexible", "yatra") }),
2837 trip.difficulty && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2838 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "yatra-trip-separator", children: "•" }),
2839 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "yatra-trip-difficulty", children: trip.difficulty })
2840 ] })
2841 ] }),
2842 /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "yatra-trip-title mb-2 text-lg font-semibold leading-snug text-gray-900 dark:text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2843 "a",
2844 {
2845 href: tripUrl,
2846 className: "text-blue-700 hover:text-blue-800 hover:underline dark:text-blue-400 dark:hover:text-blue-300 focus-visible:outline focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 rounded-sm",
2847 children: trip.trip_title
2848 }
2849 ) }),
2850 trip.highlights && trip.highlights.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-trip-highlights", children: trip.highlights.map((highlight, idx) => {
2851 const highlightText = typeof highlight === "string" ? highlight : highlight.text || highlight;
2852 const highlightLink = typeof highlight === "object" && highlight.link ? highlight.link : null;
2853 if (highlightLink) {
2854 return /* @__PURE__ */ jsxRuntimeExports.jsx(
2855 "a",
2856 {
2857 href: highlightLink,
2858 className: "yatra-highlight-badge yatra-highlight-link",
2859 children: highlightText
2860 },
2861 idx
2862 );
2863 }
2864 return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "yatra-highlight-badge", children: highlightText }, idx);
2865 }) }),
2866 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-trip-rating", children: [
2867 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-rating-stars", children: [
2868 /* @__PURE__ */ jsxRuntimeExports.jsx(
2869 "svg",
2870 {
2871 width: "16",
2872 height: "16",
2873 fill: "#fbbf24",
2874 viewBox: "0 0 24 24",
2875 children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" })
2876 }
2877 ),
2878 /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "yatra-rating-value", children: avgRating > 0 ? avgRating.toFixed(1) : "0.0" })
2879 ] }),
2880 reviewCount > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "yatra-reviews-count", children: [
2881 "(",
2882 reviewCount,
2883 " ",
2884 __("reviews", "yatra"),
2885 ")"
2886 ] })
2887 ] }),
2888 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-trip-footer mt-auto flex flex-row items-center justify-between gap-4 border-t border-gray-100 pt-4 dark:border-gray-700", children: [
2889 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "yatra-trip-price flex min-w-0 flex-col items-start gap-1 text-left", children: [
2890 hasDiscount && originalPrice && originalPrice > displayPrice && !trip.is_traveler_based && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-original-price text-sm text-gray-500 line-through", children: formatPrice(originalPrice) }),
2891 trip.is_traveler_based ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "yatra-starting-from text-xs font-normal leading-tight text-gray-500 dark:text-gray-400", children: __("Starting from", "yatra") }) : null,
2892 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-current-price text-xl font-bold leading-none text-blue-600 tabular-nums dark:text-blue-400", children: formatPrice(displayPrice) }),
2893 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-price-note text-xs leading-tight text-gray-400 dark:text-gray-500", children: __("Per person", "yatra") })
2894 ] }),
2895 /* @__PURE__ */ jsxRuntimeExports.jsx(
2896 "a",
2897 {
2898 href: tripUrl,
2899 className: "yatra-card-view-btn inline-flex shrink-0 items-center justify-center self-center rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white no-underline transition-colors hover:bg-blue-700",
2900 children: __("View Details", "yatra")
2901 }
2902 )
2903 ] })
2904 ] })
2905 ]
2906 },
2907 trip.id || trip.trip_id
2908 );
2909 }) })
2910 ] });
2911 };
2912 const navigation = [
2913 { id: "dashboard", label: __("Dashboard", "yatra"), icon: LayoutDashboard },
2914 { id: "bookings", label: __("Bookings", "yatra"), icon: Calendar },
2915 { id: "payments", label: __("Payments", "yatra"), icon: CreditCard },
2916 { id: "documents", label: __("Documents", "yatra"), icon: FileText },
2917 { id: "saved-trips", label: __("Saved Trips", "yatra"), icon: Heart },
2918 { id: "profile", label: __("Profile", "yatra"), icon: User }
2919 ];
2920 const AccountPage = () => {
2921 var _a;
2922 const accountShell = reactExports.useMemo(() => getYatraAccountPageGlobals(), []);
2923 const accountNavigation = React.useMemo(() => {
2924 var _a2;
2925 const wl = typeof window !== "undefined" && !!((_a2 = window.yatraAccountPage) == null ? void 0 : _a2.wishlistEnabled);
2926 return navigation.filter((n) => n.id !== "saved-trips" || wl);
2927 }, []);
2928 const [urlKey, setUrlKey] = reactExports.useState(0);
2929 React.useEffect(() => {
2930 const handleLocationChange = () => {
2931 setUrlKey((prev) => prev + 1);
2932 };
2933 window.addEventListener("popstate", handleLocationChange);
2934 const interval = setInterval(() => {
2935 const currentSearch = window.location.search;
2936 if (currentSearch !== window.__lastAccountSearch) {
2937 window.__lastAccountSearch = currentSearch;
2938 handleLocationChange();
2939 }
2940 }, 100);
2941 return () => {
2942 window.removeEventListener("popstate", handleLocationChange);
2943 clearInterval(interval);
2944 };
2945 }, []);
2946 const getSectionFromUrl = () => {
2947 var _a2, _b;
2948 if (typeof window !== "undefined") {
2949 const wl = !!((_a2 = window.yatraAccountPage) == null ? void 0 : _a2.wishlistEnabled);
2950 const params = new URLSearchParams(window.location.search);
2951 const tab = params.get("tab");
2952 if (tab === "saved-trips" && !wl) {
2953 return "dashboard";
2954 }
2955 if (tab && [
2956 "dashboard",
2957 "bookings",
2958 "payments",
2959 "documents",
2960 "profile",
2961 "saved-trips"
2962 ].includes(tab)) {
2963 return tab;
2964 }
2965 const saved = localStorage.getItem("yatra-account-active-section");
2966 const wlSaved = !!((_b = window.yatraAccountPage) == null ? void 0 : _b.wishlistEnabled);
2967 if (saved === "saved-trips" && !wlSaved) {
2968 return "dashboard";
2969 }
2970 if (saved && [
2971 "dashboard",
2972 "bookings",
2973 "payments",
2974 "documents",
2975 "profile",
2976 "saved-trips"
2977 ].includes(saved)) {
2978 return saved;
2979 }
2980 }
2981 return "dashboard";
2982 };
2983 const [section, setSection] = reactExports.useState(getSectionFromUrl);
2984 React.useEffect(() => {
2985 const newSection = getSectionFromUrl();
2986 setSection(newSection);
2987 }, [urlKey]);
2988 const handleSectionChange = (newSection) => {
2989 setSection(newSection);
2990 if (typeof window !== "undefined") {
2991 const urlParams = new URLSearchParams(window.location.search);
2992 urlParams.set("tab", newSection);
2993 const newUrl = `${window.location.pathname}?${urlParams.toString()}`;
2994 window.history.pushState({}, "", newUrl);
2995 localStorage.setItem("yatra-account-active-section", newSection);
2996 window.dispatchEvent(new PopStateEvent("popstate"));
2997 }
2998 };
2999 const unwrapArrayResponse = (response) => {
3000 if (!response) return [];
3001 if (typeof response === "object" && response.success === true && Array.isArray(response.data)) {
3002 return response.data;
3003 }
3004 if (typeof response === "object" && response.data && typeof response.data === "object") {
3005 const inner = response.data;
3006 if (inner.success === true && Array.isArray(inner.data)) {
3007 return inner.data;
3008 }
3009 if (Array.isArray(inner)) {
3010 return inner;
3011 }
3012 }
3013 if (Array.isArray(response)) {
3014 return response;
3015 }
3016 if (typeof response === "object" && Array.isArray(response.data)) {
3017 return response.data;
3018 }
3019 return [];
3020 };
3021 const { data: profile, isLoading: isLoadingProfile } = useQuery({
3022 queryKey: ["account-profile"],
3023 queryFn: async () => {
3024 try {
3025 const response = await apiClient.get(API_ENDPOINTS.CUSTOMER_ME);
3026 const raw = response && typeof response === "object" && "data" in response && response.data && typeof response.data === "object" ? response.data : response;
3027 if (!raw || typeof raw !== "object" || !("id" in raw) && !("user_id" in raw) && !("email" in raw)) {
3028 return null;
3029 }
3030 const row = raw;
3031 const fromParts = [row.first_name, row.last_name].filter(Boolean).join(" ").trim();
3032 const name = typeof row.name === "string" && row.name.trim() || fromParts || (typeof row.email === "string" ? row.email.split("@")[0] || "" : "") || "";
3033 return {
3034 ...row,
3035 name,
3036 registered_at: row.registered_at || row.created_at || ""
3037 };
3038 } catch (error) {
3039 console.error("Error fetching profile:", error);
3040 return null;
3041 }
3042 },
3043 refetchOnMount: "always"
3044 });
3045 const displayProfile = profile;
3046 const { data: bookings = [] } = useQuery({
3047 queryKey: ["account-bookings"],
3048 queryFn: async () => {
3049 try {
3050 const response = await apiClient.get(
3051 API_ENDPOINTS.CUSTOMER_MY_BOOKINGS
3052 );
3053 return unwrapArrayResponse(response);
3054 } catch (error) {
3055 console.error("Error fetching bookings:", error);
3056 return [];
3057 }
3058 },
3059 refetchOnMount: "always"
3060 });
3061 const { data: payments = [] } = useQuery({
3062 queryKey: ["account-payments"],
3063 queryFn: async () => {
3064 try {
3065 const response = await apiClient.get(
3066 API_ENDPOINTS.CUSTOMER_MY_PAYMENTS
3067 );
3068 return unwrapArrayResponse(response);
3069 } catch (error) {
3070 console.error("Error fetching payments:", error);
3071 return [];
3072 }
3073 },
3074 refetchOnMount: "always"
3075 });
3076 const { data: documents = [] } = useQuery({
3077 queryKey: ["account-documents"],
3078 queryFn: async () => {
3079 try {
3080 const response = await apiClient.get(
3081 API_ENDPOINTS.CUSTOMER_MY_DOCUMENTS
3082 );
3083 return unwrapArrayResponse(response);
3084 } catch (error) {
3085 console.error("Error fetching documents:", error);
3086 return [];
3087 }
3088 },
3089 refetchOnMount: "always"
3090 });
3091 const notifications = [];
3092 const wishlistEnabled = typeof window !== "undefined" && !!((_a = window.yatraAccountPage) == null ? void 0 : _a.wishlistEnabled);
3093 const { data: savedTripsData, isLoading: isLoadingSavedTrips } = useQuery({
3094 queryKey: ["account-saved-trips"],
3095 enabled: wishlistEnabled,
3096 queryFn: async () => {
3097 try {
3098 const response = await apiClient.get(API_ENDPOINTS.SAVED_TRIPS);
3099 let trips = [];
3100 if (response && typeof response === "object") {
3101 if (response.data && typeof response.data === "object") {
3102 if (response.data.success === true && Array.isArray(response.data.data)) {
3103 trips = response.data.data;
3104 } else if (Array.isArray(response.data.data)) {
3105 trips = response.data.data;
3106 } else if (Array.isArray(response.data)) {
3107 trips = response.data;
3108 }
3109 } else if (response.success === true && Array.isArray(response.data)) {
3110 trips = response.data;
3111 } else if (Array.isArray(response.data)) {
3112 trips = response.data;
3113 } else if (Array.isArray(response)) {
3114 trips = response;
3115 }
3116 }
3117 if (trips.length > 0) {
3118 }
3119 return trips;
3120 } catch (error) {
3121 console.error("Error fetching saved trips:", error);
3122 return [];
3123 }
3124 }
3125 });
3126 const savedTrips = Array.isArray(savedTripsData) ? savedTripsData : [];
3127 const currency2 = (value) => new Intl.NumberFormat(void 0, {
3128 style: "currency",
3129 currency: "USD"
3130 }).format(value);
3131 const stats = reactExports.useMemo(() => {
3132 const outstanding = payments.filter((p) => p.status === "pending").reduce((sum, payment) => sum + payment.amount, 0);
3133 const upcoming = bookings.filter(
3134 (b) => new Date(b.travel_date) > /* @__PURE__ */ new Date()
3135 ).length;
3136 const totalSpent = (displayProfile == null ? void 0 : displayProfile.total_spent) ?? 0;
3137 const totalBookings = bookings.length;
3138 return [
3139 {
3140 label: __("Total Bookings", "yatra"),
3141 value: (displayProfile == null ? void 0 : displayProfile.total_bookings) ?? totalBookings,
3142 icon: Package,
3143 badge: (displayProfile == null ? void 0 : displayProfile.loyalty_tier) || ""
3144 },
3145 {
3146 label: __("Upcoming Trips", "yatra"),
3147 value: upcoming,
3148 icon: Calendar
3149 },
3150 {
3151 label: __("Outstanding Balance", "yatra"),
3152 value: currency2(outstanding),
3153 icon: DollarSign
3154 },
3155 {
3156 label: __("Total Spent", "yatra"),
3157 value: currency2(totalSpent),
3158 icon: ShieldCheck
3159 }
3160 ];
3161 }, [bookings, payments, displayProfile]);
3162 const renderSection = () => {
3163 switch (section) {
3164 case "dashboard":
3165 return /* @__PURE__ */ jsxRuntimeExports.jsx(
3166 Dashboard,
3167 {
3168 bookings,
3169 payments,
3170 displayProfile: displayProfile || null,
3171 stats,
3172 notifications,
3173 conciergePhone: accountShell.companyPhone,
3174 conciergeEmail: accountShell.companyEmail,
3175 onSectionChange: (section2) => handleSectionChange(section2)
3176 }
3177 );
3178 case "bookings":
3179 return /* @__PURE__ */ jsxRuntimeExports.jsx(
3180 Bookings,
3181 {
3182 bookings,
3183 conciergePhone: accountShell.companyPhone,
3184 conciergeEmail: accountShell.companyEmail,
3185 onSectionChange: (section2) => handleSectionChange(section2)
3186 }
3187 );
3188 case "payments":
3189 return /* @__PURE__ */ jsxRuntimeExports.jsx(
3190 Payments,
3191 {
3192 payments,
3193 onSectionChange: (section2) => handleSectionChange(section2)
3194 }
3195 );
3196 case "documents":
3197 return /* @__PURE__ */ jsxRuntimeExports.jsx(Documents, { documents });
3198 case "saved-trips":
3199 if (!wishlistEnabled) {
3200 return null;
3201 }
3202 return /* @__PURE__ */ jsxRuntimeExports.jsx(SavedTrips, { savedTrips, isLoading: isLoadingSavedTrips });
3203 case "profile":
3204 return /* @__PURE__ */ jsxRuntimeExports.jsx(
3205 Profile,
3206 {
3207 profile: displayProfile || null,
3208 savedTrips,
3209 wishlistEnabled
3210 }
3211 );
3212 default:
3213 return null;
3214 }
3215 };
3216 return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-screen bg-gray-50 dark:bg-gray-900 py-10 pb-16 px-4 sm:px-6 lg:px-8", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "max-w-7xl mx-auto space-y-6 pb-8", children: [
3217 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-800 rounded-xl shadow-sm p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between", children: [
3218 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
3219 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: (displayProfile == null ? void 0 : displayProfile.registered_at) ? formatDate(displayProfile.registered_at) : "" }),
3220 /* @__PURE__ */ jsxRuntimeExports.jsxs("h1", { className: "text-xl font-bold text-gray-900 dark:text-white", children: [
3221 __("Hello,", "yatra"),
3222 " ",
3223 (displayProfile == null ? void 0 : displayProfile.name) || __("Guest", "yatra")
3224 ] }),
3225 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: __(
3226 "Manage bookings, payments, and documents – everything for your adventures in one place.",
3227 "yatra"
3228 ) })
3229 ] }),
3230 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-wrap gap-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
3231 "div",
3232 {
3233 role: "button",
3234 tabIndex: 0,
3235 onClick: () => {
3236 const url = accountShell.logoutUrl;
3237 if (url) {
3238 window.location.href = url;
3239 }
3240 },
3241 onKeyDown: (e) => {
3242 if (e.key === "Enter" || e.key === " ") {
3243 e.preventDefault();
3244 const url = accountShell.logoutUrl;
3245 if (url) {
3246 window.location.href = url;
3247 }
3248 }
3249 },
3250 className: "inline-flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-600 cursor-pointer text-sm",
3251 children: [
3252 /* @__PURE__ */ jsxRuntimeExports.jsx(LogOut, { className: "w-4 h-4" }),
3253 " ",
3254 __("Logout", "yatra")
3255 ]
3256 }
3257 ) })
3258 ] }) }),
3259 /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-6 lg:flex-row lg:items-start", children: [
3260 /* @__PURE__ */ jsxRuntimeExports.jsxs("aside", { className: "w-full lg:w-64 flex-shrink-0 space-y-4 lg:sticky lg:top-10 self-start bg-transparent", children: [
3261 /* @__PURE__ */ jsxRuntimeExports.jsx("nav", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-800 rounded-xl divide-y divide-gray-100 dark:divide-gray-800", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 space-y-1", children: accountNavigation.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
3262 "div",
3263 {
3264 role: "button",
3265 tabIndex: 0,
3266 onClick: () => handleSectionChange(item.id),
3267 className: `yatra-nav-item yatra-nav-item-${item.id} w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition cursor-pointer ${section === item.id ? "bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-200" : "text-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-900/40"}`,
3268 children: [
3269 /* @__PURE__ */ jsxRuntimeExports.jsx(item.icon, { className: "w-4 h-4" }),
3270 item.label
3271 ]
3272 },
3273 item.id
3274 )) }) }),
3275 /* @__PURE__ */ jsxRuntimeExports.jsxs(
3276 "div",
3277 {
3278 className: "bg-gradient-to-br from-blue-600 to-indigo-600 rounded-xl p-6 text-white space-y-2 shadow-xl",
3279 style: {
3280 backgroundColor: "#2563eb",
3281 backgroundImage: "linear-gradient(to bottom right, #2563eb, #4f46e5)"
3282 },
3283 children: [
3284 /* @__PURE__ */ jsxRuntimeExports.jsx(ShieldCheck, { className: "w-6 h-6 text-white" }),
3285 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-white", children: __("Need help right away?", "yatra") }),
3286 /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-semibold text-lg text-white", children: accountShell.companyName || __("Concierge Desk", "yatra") }),
3287 accountShell.companyPhone ? /* @__PURE__ */ jsxRuntimeExports.jsx(
3288 "a",
3289 {
3290 href: phoneToTelHref(accountShell.companyPhone),
3291 className: "text-sm font-medium text-white hover:underline",
3292 children: accountShell.companyPhone
3293 }
3294 ) : accountShell.companyEmail ? /* @__PURE__ */ jsxRuntimeExports.jsx(
3295 "a",
3296 {
3297 href: `mailto:${encodeURIComponent(accountShell.companyEmail)}`,
3298 className: "text-sm font-medium text-white hover:underline break-all",
3299 children: accountShell.companyEmail
3300 }
3301 ) : null
3302 ]
3303 }
3304 )
3305 ] }),
3306 /* @__PURE__ */ jsxRuntimeExports.jsx("section", { className: "flex-1 min-w-0 space-y-6", style: { minWidth: 0 }, children: isLoadingProfile && !profile ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
3307 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-xl shadow-sm p-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "animate-pulse", children: [
3308 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 bg-gray-200 dark:bg-gray-700 rounded w-48 mb-2" }),
3309 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-96" })
3310 ] }) }),
3311 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-nowrap gap-6 overflow-x-auto", children: [1, 2, 3, 4, 5].map((i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
3312 "div",
3313 {
3314 className: "flex-shrink-0 bg-white dark:bg-gray-800 rounded-xl p-6 border border-gray-100 dark:border-gray-700 min-w-0 flex-1",
3315 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "animate-pulse", children: [
3316 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-20 mb-3" }),
3317 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-8 bg-gray-200 dark:bg-gray-700 rounded w-16" })
3318 ] })
3319 },
3320 i
3321 )) }),
3322 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
3323 "div",
3324 {
3325 className: "bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-6",
3326 children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "animate-pulse", children: [
3327 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-5 bg-gray-200 dark:bg-gray-700 rounded w-64 mb-4" }),
3328 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-full mb-2" }),
3329 /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4" })
3330 ] })
3331 },
3332 i
3333 )) })
3334 ] }) : renderSection() })
3335 ] })
3336 ] }) });
3337 };
3338 const queryClient = new QueryClient({
3339 defaultOptions: {
3340 queries: {
3341 refetchOnWindowFocus: false,
3342 retry: 1,
3343 staleTime: 5 * 60 * 1e3
3344 // 5 minutes
3345 }
3346 }
3347 });
3348 const rootElement = document.getElementById("yatra-account-page-root");
3349 if (rootElement) {
3350 try {
3351 const root = client.createRoot(rootElement);
3352 root.render(
3353 /* @__PURE__ */ jsxRuntimeExports.jsx(React.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ToastProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(AccountPage, {}) }) }) })
3354 );
3355 } catch (error) {
3356 console.error("Error rendering account page:", error);
3357 rootElement.innerHTML = '<div style="padding: 40px; text-align: center;"><h2>Error loading account page</h2><p>Please refresh the page or contact support.</p></div>';
3358 }
3359 }
3360 //# sourceMappingURL=account-page.js.map
3361