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