| 1 |
import { j as jsxRuntimeExports, a6 as React, w as useMutation, d as Mail, y as ChevronDown, r as reactExports, u as useQuery, D as ArrowLeft, aX as Download, aA as AlertCircle, q as Calendar, U as Users, a_ as Phone, k as FileText, i as CreditCard, F as FileSignature, aw as CheckCircle, as as Clock, bk as Send } from "./react-vendor-CithbthY.js"; |
| 2 |
import { u as useToast, _ as __, a as apiClient, i as getCountryName, e as formatDate, f as formatYatraMoney, b as apiService } from "./index-Dec_weLB.js"; |
| 3 |
import { ag as Popover, ah as PopoverTrigger, B as Button, ai as PopoverContent, u as usePermissions, X as Skeleton, C as Card, f as CardHeader, d as CardContent, P as PageHeader, z as ConditionalRender, g as CardTitle, aj as downloadAdminBookingInvoice } from "../../admin/dist/js/app.js"; |
| 4 |
function phoneData() { |
| 5 |
return window.yatraPhoneData || {}; |
| 6 |
} |
| 7 |
function detectPhoneCountry(raw) { |
| 8 |
raw = (raw || "").trim(); |
| 9 |
if (!raw || raw.charAt(0) !== "+") return null; |
| 10 |
const digits = raw.replace(/\D+/g, ""); |
| 11 |
if (!digits) return null; |
| 12 |
const countries = phoneData().countries || []; |
| 13 |
const priority = phoneData().priority || {}; |
| 14 |
for (let len = Math.min(4, digits.length); len >= 1; len--) { |
| 15 |
const prefix = digits.slice(0, len); |
| 16 |
const matches = countries.filter((c) => c.dial === prefix); |
| 17 |
if (matches.length) { |
| 18 |
const iso = priority[prefix] || matches[0].iso; |
| 19 |
return { iso, dial: prefix, national: digits.slice(len) }; |
| 20 |
} |
| 21 |
} |
| 22 |
return null; |
| 23 |
} |
| 24 |
function flagUrl(iso) { |
| 25 |
const base = phoneData().flagBase || ""; |
| 26 |
return base ? `${base}${String(iso).toLowerCase()}.svg` : ""; |
| 27 |
} |
| 28 |
function formatPhone(raw) { |
| 29 |
const d = detectPhoneCountry(raw); |
| 30 |
if (!d) return raw; |
| 31 |
return `+${d.dial}${d.national ? " " + d.national : ""}`; |
| 32 |
} |
| 33 |
const PhoneDisplay = ({ |
| 34 |
value, |
| 35 |
className |
| 36 |
}) => { |
| 37 |
const raw = (value || "").trim(); |
| 38 |
if (!raw) return null; |
| 39 |
const detected = detectPhoneCountry(raw); |
| 40 |
const url = detected ? flagUrl(detected.iso) : ""; |
| 41 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 42 |
"span", |
| 43 |
{ |
| 44 |
className, |
| 45 |
style: { display: "inline-flex", alignItems: "center", gap: 6 }, |
| 46 |
children: [ |
| 47 |
url && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 48 |
"img", |
| 49 |
{ |
| 50 |
src: url, |
| 51 |
alt: detected ? detected.iso : "", |
| 52 |
width: 18, |
| 53 |
height: 13, |
| 54 |
loading: "lazy", |
| 55 |
style: { |
| 56 |
borderRadius: 2, |
| 57 |
objectFit: "cover", |
| 58 |
boxShadow: "0 0 0 1px rgba(0,0,0,0.08)", |
| 59 |
flex: "0 0 auto" |
| 60 |
} |
| 61 |
} |
| 62 |
), |
| 63 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: detected ? formatPhone(raw) : raw }) |
| 64 |
] |
| 65 |
} |
| 66 |
); |
| 67 |
}; |
| 68 |
const EMAIL_ITEMS = [ |
| 69 |
{ type: "confirmation", label: __("Booking confirmation", "yatra"), group: "customer" }, |
| 70 |
{ |
| 71 |
type: "payment_confirmation", |
| 72 |
label: __("Payment confirmation", "yatra"), |
| 73 |
group: "customer", |
| 74 |
needsPayment: true |
| 75 |
}, |
| 76 |
{ type: "reminder", label: __("Trip reminder", "yatra"), group: "customer" }, |
| 77 |
{ |
| 78 |
type: "cancellation", |
| 79 |
label: __("Cancellation notice", "yatra"), |
| 80 |
group: "customer", |
| 81 |
statuses: ["cancelled"] |
| 82 |
}, |
| 83 |
{ |
| 84 |
type: "completed", |
| 85 |
label: __("Trip completed / thank-you", "yatra"), |
| 86 |
group: "customer", |
| 87 |
statuses: ["completed"] |
| 88 |
}, |
| 89 |
{ type: "admin_new_booking", label: __("New booking", "yatra"), group: "admin" }, |
| 90 |
{ |
| 91 |
type: "admin_payment_received", |
| 92 |
label: __("Payment received", "yatra"), |
| 93 |
group: "admin", |
| 94 |
needsPayment: true |
| 95 |
} |
| 96 |
]; |
| 97 |
const ResendEmailMenu = ({ |
| 98 |
bookingId, |
| 99 |
status = "", |
| 100 |
amountPaid = 0 |
| 101 |
}) => { |
| 102 |
const { showToast } = useToast(); |
| 103 |
const [open, setOpen] = React.useState(false); |
| 104 |
const mutation = useMutation({ |
| 105 |
mutationFn: async (type) => { |
| 106 |
const res = await apiClient.post(`/bookings/${bookingId}/send-email`, { |
| 107 |
type |
| 108 |
}); |
| 109 |
if (res && res.success === false) { |
| 110 |
throw new Error(res.message || __("Failed to send email.", "yatra")); |
| 111 |
} |
| 112 |
return res; |
| 113 |
}, |
| 114 |
onSuccess: (res) => { |
| 115 |
showToast((res == null ? void 0 : res.message) || __("Email sent.", "yatra"), "success"); |
| 116 |
setOpen(false); |
| 117 |
}, |
| 118 |
onError: (err) => { |
| 119 |
showToast((err == null ? void 0 : err.message) || __("Failed to send email.", "yatra"), "error"); |
| 120 |
} |
| 121 |
}); |
| 122 |
const paid = Number(amountPaid || 0) > 0; |
| 123 |
const items = EMAIL_ITEMS.filter((item) => { |
| 124 |
if (item.needsPayment && !paid) return false; |
| 125 |
if (item.statuses && !item.statuses.includes(status)) return false; |
| 126 |
return true; |
| 127 |
}); |
| 128 |
const customerItems = items.filter((i) => i.group === "customer"); |
| 129 |
const adminItems = items.filter((i) => i.group === "admin"); |
| 130 |
const renderItem = (item) => /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 131 |
"button", |
| 132 |
{ |
| 133 |
type: "button", |
| 134 |
disabled: mutation.isPending, |
| 135 |
onClick: () => mutation.mutate(item.type), |
| 136 |
className: "w-full text-left px-3 py-2 text-sm rounded-md text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed", |
| 137 |
children: item.label |
| 138 |
}, |
| 139 |
item.type |
| 140 |
); |
| 141 |
const groupLabel = (text) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-3 pt-2 pb-1 text-[11px] font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500", children: text }); |
| 142 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Popover, { open, onOpenChange: setOpen, children: [ |
| 143 |
/* @__PURE__ */ jsxRuntimeExports.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "outline", className: "flex items-center gap-2", children: [ |
| 144 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Mail, { className: "w-4 h-4" }), |
| 145 |
__("Resend Email", "yatra"), |
| 146 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "w-4 h-4" }) |
| 147 |
] }) }), |
| 148 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(PopoverContent, { align: "end", className: "w-64 p-1", children: [ |
| 149 |
customerItems.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 150 |
groupLabel(__("To customer", "yatra")), |
| 151 |
customerItems.map(renderItem) |
| 152 |
] }), |
| 153 |
adminItems.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 154 |
groupLabel(__("To admin", "yatra")), |
| 155 |
adminItems.map(renderItem) |
| 156 |
] }), |
| 157 |
mutation.isPending && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-3 py-2 text-xs text-gray-400", children: __("Sending…", "yatra") }) |
| 158 |
] }) |
| 159 |
] }); |
| 160 |
}; |
| 161 |
const optionLabel = (field, value) => { |
| 162 |
const raw = String(value ?? ""); |
| 163 |
if ((field == null ? void 0 : field.type) === "select" && Array.isArray(field.options)) { |
| 164 |
const match = field.options.find((o) => String(o.value) === raw); |
| 165 |
if (match == null ? void 0 : match.label) return match.label; |
| 166 |
} |
| 167 |
return raw; |
| 168 |
}; |
| 169 |
const ViewBooking = () => { |
| 170 |
var _a, _b, _c, _d, _e, _f, _g, _h; |
| 171 |
const { can } = usePermissions(); |
| 172 |
const bookingId = reactExports.useMemo(() => { |
| 173 |
const params = new URLSearchParams(window.location.search); |
| 174 |
return params.get("id") ? parseInt(params.get("id") || "0") : null; |
| 175 |
}, []); |
| 176 |
const getFieldLabel = (fieldId, fields) => { |
| 177 |
const field = fields.find((f) => f.id === fieldId); |
| 178 |
return (field == null ? void 0 : field.label) || fieldId.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()); |
| 179 |
}; |
| 180 |
const { |
| 181 |
data: booking, |
| 182 |
isLoading, |
| 183 |
error |
| 184 |
} = useQuery({ |
| 185 |
queryKey: ["booking", bookingId], |
| 186 |
queryFn: async () => { |
| 187 |
var _a2, _b2; |
| 188 |
if (!bookingId) return null; |
| 189 |
const result = await apiService.getBooking(bookingId); |
| 190 |
if (!result) { |
| 191 |
throw new Error("Failed to fetch booking"); |
| 192 |
} |
| 193 |
const data = (result == null ? void 0 : result.data) ?? result; |
| 194 |
if (data && data.id) { |
| 195 |
const contact = data.contact || {}; |
| 196 |
return { |
| 197 |
id: data.id, |
| 198 |
booking_number: data.reference, |
| 199 |
customer_name: data.customer_name || (((_a2 = data.contact) == null ? void 0 : _a2.first_name) && ((_b2 = data.contact) == null ? void 0 : _b2.last_name) ? `${data.contact.first_name} ${data.contact.last_name}`.trim() : `${data.contact_first_name || ""} ${data.contact_last_name || ""}`.trim()) || "N/A", |
| 200 |
customer_email: data.customer_email || data.contact_email || contact.email || "", |
| 201 |
customer_phone: data.customer_phone || data.contact_phone || contact.phone || "", |
| 202 |
customer_country: data.contact_country || contact.country || "", |
| 203 |
trip_id: data.trip_id, |
| 204 |
trip_title: data.trip_title || `Trip #${data.trip_id}`, |
| 205 |
trip_image: data.trip_image, |
| 206 |
trip_price: (parseFloat(data.subtotal) || data.total_amount || 0) / (data.travelers_count || 1), |
| 207 |
booking_date: data.created_at, |
| 208 |
travel_date: data.travel_date, |
| 209 |
travelers: data.travelers_count, |
| 210 |
travelers_data: data.travelers || [], |
| 211 |
total_amount: data.total_amount, |
| 212 |
amount_paid: data.amount_paid || 0, |
| 213 |
amount_due: data.amount_due || 0, |
| 214 |
discount_amount: data.discount_amount || 0, |
| 215 |
discount_code: data.discount_code || null, |
| 216 |
currency: data.currency || "USD", |
| 217 |
// Tax fields |
| 218 |
subtotal: data.subtotal, |
| 219 |
tax_amount: data.tax_amount, |
| 220 |
tax_rate: data.tax_rate, |
| 221 |
tax_inclusive: data.tax_inclusive, |
| 222 |
tax_details: data.tax_details, |
| 223 |
tax_breakdown: data.tax_breakdown, |
| 224 |
taxable_amount: data.taxable_amount, |
| 225 |
// Itinerary costs |
| 226 |
itinerary_costs: data.itinerary_costs, |
| 227 |
itinerary_costs_total: data.itinerary_costs_total, |
| 228 |
// Additional services |
| 229 |
additional_services: data.additional_services, |
| 230 |
services_total: data.services_total, |
| 231 |
// End tax fields |
| 232 |
payment_status: data.payment_status, |
| 233 |
booking_status: data.status, |
| 234 |
payment_method: data.payment_gateway, |
| 235 |
payment_date: data.payment_date, |
| 236 |
notes: data.special_requests, |
| 237 |
internal_notes: data.internal_notes, |
| 238 |
emergency_contact: data.emergency_contact, |
| 239 |
contact_data: data.contact_data, |
| 240 |
payments: data.payments || [], |
| 241 |
created_at: data.created_at, |
| 242 |
updated_at: data.updated_at, |
| 243 |
confirmed_at: data.confirmed_at, |
| 244 |
completed_at: data.completed_at, |
| 245 |
cancelled_at: data.cancelled_at, |
| 246 |
cancellation_reason: data.cancellation_reason, |
| 247 |
trip_details: data.trip_details, |
| 248 |
google_calendar: data.google_calendar |
| 249 |
}; |
| 250 |
} |
| 251 |
return null; |
| 252 |
}, |
| 253 |
enabled: !!bookingId && can("yatra_view_bookings") |
| 254 |
}); |
| 255 |
const bookingTripId = (booking == null ? void 0 : booking.trip_id) ? Number(booking.trip_id) : null; |
| 256 |
const { data: formConfig } = useQuery({ |
| 257 |
queryKey: ["booking-form-config", bookingTripId], |
| 258 |
queryFn: async () => { |
| 259 |
var _a2; |
| 260 |
const response = await apiService.getBookingFormConfig(bookingTripId); |
| 261 |
return ((_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.booking_form_config) || (response == null ? void 0 : response.booking_form_config) || null; |
| 262 |
}, |
| 263 |
enabled: !!booking |
| 264 |
}); |
| 265 |
const travelerFields = reactExports.useMemo(() => { |
| 266 |
var _a2; |
| 267 |
if (!((_a2 = formConfig == null ? void 0 : formConfig.traveler_form) == null ? void 0 : _a2.fields)) return []; |
| 268 |
return formConfig.traveler_form.fields.filter((field) => field.enabled).sort((a, b) => a.order - b.order); |
| 269 |
}, [formConfig]); |
| 270 |
const emergencyFields = reactExports.useMemo(() => { |
| 271 |
var _a2; |
| 272 |
if (!((_a2 = formConfig == null ? void 0 : formConfig.emergency_contact_form) == null ? void 0 : _a2.fields)) return []; |
| 273 |
return formConfig.emergency_contact_form.fields.filter((field) => field.enabled).sort((a, b) => a.order - b.order); |
| 274 |
}, [formConfig]); |
| 275 |
const contactFields = reactExports.useMemo(() => { |
| 276 |
var _a2; |
| 277 |
if (!((_a2 = formConfig == null ? void 0 : formConfig.contact_form) == null ? void 0 : _a2.fields)) return []; |
| 278 |
return formConfig.contact_form.fields.filter((field) => field.enabled).sort((a, b) => a.order - b.order); |
| 279 |
}, [formConfig]); |
| 280 |
const isPro = !!((_a = window.yatraAdmin) == null ? void 0 : _a.isPro); |
| 281 |
const { data: consentStatus } = useQuery({ |
| 282 |
queryKey: ["booking-consent-status", bookingId], |
| 283 |
queryFn: async () => { |
| 284 |
if (!bookingId) return null; |
| 285 |
const response = await apiClient.get( |
| 286 |
`/bookings/${bookingId}/consent-status` |
| 287 |
); |
| 288 |
return (response == null ? void 0 : response.data) || null; |
| 289 |
}, |
| 290 |
enabled: !!bookingId && isPro |
| 291 |
}); |
| 292 |
const formatDate$1 = (dateString) => { |
| 293 |
return formatDate(dateString); |
| 294 |
}; |
| 295 |
const formatPrice = (price, currencyCode = "USD") => formatYatraMoney(Number(price) || 0, currencyCode, { |
| 296 |
zeroAsUnknown: false |
| 297 |
}); |
| 298 |
const getBookingStatusBadge = (status) => { |
| 299 |
const statusMap = { |
| 300 |
confirmed: { |
| 301 |
className: "bg-green-100 text-green-700 dark:bg-green-900/20 dark:text-green-400", |
| 302 |
label: __("Confirmed", "yatra") |
| 303 |
}, |
| 304 |
pending: { |
| 305 |
className: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/20 dark:text-yellow-400", |
| 306 |
label: __("Pending", "yatra") |
| 307 |
}, |
| 308 |
cancelled: { |
| 309 |
className: "bg-red-100 text-red-700 dark:bg-red-900/20 dark:text-red-400", |
| 310 |
label: __("Cancelled", "yatra") |
| 311 |
}, |
| 312 |
completed: { |
| 313 |
className: "bg-blue-100 text-blue-700 dark:bg-blue-900/20 dark:text-blue-400", |
| 314 |
label: __("Completed", "yatra") |
| 315 |
} |
| 316 |
}; |
| 317 |
const statusInfo = statusMap[status] || { |
| 318 |
className: "bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-400", |
| 319 |
label: status |
| 320 |
}; |
| 321 |
return /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 322 |
"span", |
| 323 |
{ |
| 324 |
className: `inline-flex items-center px-3 py-1 rounded-md text-sm font-medium ${statusInfo.className}`, |
| 325 |
children: statusInfo.label |
| 326 |
} |
| 327 |
); |
| 328 |
}; |
| 329 |
const getPaymentStatusBadge = (status) => { |
| 330 |
const statusMap = { |
| 331 |
paid: { |
| 332 |
className: "bg-green-100 text-green-700 dark:bg-green-900/20 dark:text-green-400", |
| 333 |
label: __("Paid", "yatra") |
| 334 |
}, |
| 335 |
pending: { |
| 336 |
className: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/20 dark:text-yellow-400", |
| 337 |
label: __("Pending", "yatra") |
| 338 |
}, |
| 339 |
partial: { |
| 340 |
className: "bg-orange-100 text-orange-700 dark:bg-orange-900/20 dark:text-orange-400", |
| 341 |
label: __("Partial", "yatra") |
| 342 |
}, |
| 343 |
refunded: { |
| 344 |
className: "bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-400", |
| 345 |
label: __("Refunded", "yatra") |
| 346 |
} |
| 347 |
}; |
| 348 |
const statusInfo = statusMap[status] || { |
| 349 |
className: "bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-400", |
| 350 |
label: status |
| 351 |
}; |
| 352 |
return /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 353 |
"span", |
| 354 |
{ |
| 355 |
className: `inline-flex items-center px-3 py-1 rounded-md text-sm font-medium ${statusInfo.className}`, |
| 356 |
children: statusInfo.label |
| 357 |
} |
| 358 |
); |
| 359 |
}; |
| 360 |
const handleBack = () => { |
| 361 |
var _a2; |
| 362 |
window.location.href = `${((_a2 = window.yatraAdmin) == null ? void 0 : _a2.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=bookings`; |
| 363 |
}; |
| 364 |
const handleEdit = () => { |
| 365 |
var _a2; |
| 366 |
window.location.href = `${((_a2 = window.yatraAdmin) == null ? void 0 : _a2.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=bookings&action=edit&id=${bookingId}`; |
| 367 |
}; |
| 368 |
const [invoiceError, setInvoiceError] = reactExports.useState(""); |
| 369 |
const handleDownloadInvoice = async () => { |
| 370 |
const id = Number((booking == null ? void 0 : booking.id) ?? 0); |
| 371 |
if (!id) { |
| 372 |
return; |
| 373 |
} |
| 374 |
setInvoiceError(""); |
| 375 |
try { |
| 376 |
await downloadAdminBookingInvoice(id); |
| 377 |
} catch (error2) { |
| 378 |
setInvoiceError( |
| 379 |
(error2 == null ? void 0 : error2.message) || __("Failed to download invoice", "yatra") |
| 380 |
); |
| 381 |
} |
| 382 |
}; |
| 383 |
if (isLoading) { |
| 384 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 385 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [ |
| 386 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 387 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-8 w-48" }), |
| 388 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-64" }) |
| 389 |
] }), |
| 390 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [ |
| 391 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-10 w-28" }), |
| 392 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-10 w-20" }) |
| 393 |
] }) |
| 394 |
] }), |
| 395 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-3 gap-3", children: [ |
| 396 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "lg:col-span-2 space-y-3", children: [ |
| 397 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 398 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [ |
| 399 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-5 w-36" }), |
| 400 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 401 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-6 w-20 rounded-md" }), |
| 402 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-6 w-16 rounded-md" }) |
| 403 |
] }) |
| 404 |
] }) }), |
| 405 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "space-y-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [...Array(6)].map((_, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [ |
| 406 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-24" }), |
| 407 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-5 w-32" }) |
| 408 |
] }, i)) }) }) |
| 409 |
] }), |
| 410 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 411 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-5 w-40" }) }), |
| 412 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 413 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-5 w-36" }), |
| 414 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4", children: [ |
| 415 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-48" }), |
| 416 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-32" }) |
| 417 |
] }) |
| 418 |
] }) |
| 419 |
] }), |
| 420 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 421 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-5 w-16" }) }), |
| 422 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-20 w-full" }) }) |
| 423 |
] }) |
| 424 |
] }), |
| 425 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 426 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 427 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-5 w-36" }) }), |
| 428 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 429 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [ |
| 430 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-24" }), |
| 431 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-6 w-16 rounded-md" }) |
| 432 |
] }), |
| 433 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [ |
| 434 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-28" }), |
| 435 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-24" }) |
| 436 |
] }), |
| 437 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [ |
| 438 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-32" }), |
| 439 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-20" }) |
| 440 |
] }), |
| 441 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [ |
| 442 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-24" }), |
| 443 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-6 w-28" }) |
| 444 |
] }) |
| 445 |
] }) |
| 446 |
] }), |
| 447 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 448 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-5 w-20" }) }), |
| 449 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 450 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [ |
| 451 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-16" }), |
| 452 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-40" }) |
| 453 |
] }), |
| 454 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [ |
| 455 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-24" }), |
| 456 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-4 w-40" }) |
| 457 |
] }) |
| 458 |
] }) |
| 459 |
] }) |
| 460 |
] }) |
| 461 |
] }) |
| 462 |
] }); |
| 463 |
} |
| 464 |
if (error || !booking) { |
| 465 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 466 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 467 |
PageHeader, |
| 468 |
{ |
| 469 |
title: __("Booking Not Found", "yatra"), |
| 470 |
description: __( |
| 471 |
"The booking you are looking for does not exist", |
| 472 |
"yatra" |
| 473 |
), |
| 474 |
actions: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 475 |
Button, |
| 476 |
{ |
| 477 |
variant: "outline", |
| 478 |
onClick: handleBack, |
| 479 |
className: "flex items-center gap-2", |
| 480 |
children: [ |
| 481 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ArrowLeft, { className: "w-4 h-4" }), |
| 482 |
__("Back to Bookings", "yatra") |
| 483 |
] |
| 484 |
} |
| 485 |
) |
| 486 |
} |
| 487 |
), |
| 488 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Card, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "p-8 text-center text-red-500", children: __("Error loading booking or booking not found", "yatra") }) }) |
| 489 |
] }); |
| 490 |
} |
| 491 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 492 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 493 |
PageHeader, |
| 494 |
{ |
| 495 |
title: __("Booking Details", "yatra"), |
| 496 |
description: __("View complete booking information", "yatra"), |
| 497 |
actions: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [ |
| 498 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ConditionalRender, { capability: "yatra_view_bookings", children: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 499 |
Button, |
| 500 |
{ |
| 501 |
variant: "outline", |
| 502 |
onClick: handleDownloadInvoice, |
| 503 |
className: "flex items-center gap-2", |
| 504 |
children: [ |
| 505 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Download, { className: "w-4 h-4" }), |
| 506 |
__("Download invoice", "yatra") |
| 507 |
] |
| 508 |
} |
| 509 |
) }), |
| 510 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ConditionalRender, { capability: "yatra_edit_bookings", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 511 |
ResendEmailMenu, |
| 512 |
{ |
| 513 |
bookingId: Number(booking.id), |
| 514 |
status: booking.booking_status, |
| 515 |
amountPaid: Number(booking.amount_paid) || 0 |
| 516 |
} |
| 517 |
) }), |
| 518 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ConditionalRender, { capability: "yatra_edit_bookings", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: handleEdit, className: "flex items-center gap-2", children: __("Edit Booking", "yatra") }) }), |
| 519 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 520 |
Button, |
| 521 |
{ |
| 522 |
variant: "outline", |
| 523 |
onClick: handleBack, |
| 524 |
className: "flex items-center gap-2", |
| 525 |
children: [ |
| 526 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ArrowLeft, { className: "w-4 h-4" }), |
| 527 |
__("Back", "yatra") |
| 528 |
] |
| 529 |
} |
| 530 |
) |
| 531 |
] }) |
| 532 |
} |
| 533 |
), |
| 534 |
invoiceError && /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 535 |
"div", |
| 536 |
{ |
| 537 |
role: "alert", |
| 538 |
className: "flex items-center gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-400", |
| 539 |
children: [ |
| 540 |
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "w-4 h-4 shrink-0" }), |
| 541 |
invoiceError |
| 542 |
] |
| 543 |
} |
| 544 |
), |
| 545 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ConditionalRender, { capability: "yatra_view_bookings", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-3 gap-3", children: [ |
| 546 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "lg:col-span-2 space-y-3", children: [ |
| 547 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 548 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [ |
| 549 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Booking Overview", "yatra") }), |
| 550 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 551 |
getBookingStatusBadge(booking.booking_status), |
| 552 |
getPaymentStatusBadge(booking.payment_status) |
| 553 |
] }) |
| 554 |
] }) }), |
| 555 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-4", children: [ |
| 556 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [ |
| 557 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 558 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Booking Number", "yatra") }), |
| 559 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: booking.booking_number }) |
| 560 |
] }), |
| 561 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 562 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Trip", "yatra") }), |
| 563 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: booking.trip_title }), |
| 564 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: [ |
| 565 |
__("Trip ID", "yatra"), |
| 566 |
": #", |
| 567 |
booking.trip_id |
| 568 |
] }) |
| 569 |
] }), |
| 570 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 571 |
/* @__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: [ |
| 572 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-3 h-3" }), |
| 573 |
__("Booking Date", "yatra") |
| 574 |
] }), |
| 575 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: formatDate$1(booking.booking_date) }) |
| 576 |
] }), |
| 577 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 578 |
/* @__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: [ |
| 579 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-3 h-3" }), |
| 580 |
__("Travel Date", "yatra") |
| 581 |
] }), |
| 582 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: formatDate$1(booking.travel_date) }) |
| 583 |
] }), |
| 584 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 585 |
/* @__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: [ |
| 586 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Users, { className: "w-3 h-3" }), |
| 587 |
__("Number of Travelers", "yatra") |
| 588 |
] }), |
| 589 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm text-gray-900 dark:text-white", children: [ |
| 590 |
booking.travelers, |
| 591 |
" ", |
| 592 |
booking.travelers === 1 ? __("Traveler", "yatra") : __("Travelers", "yatra") |
| 593 |
] }) |
| 594 |
] }) |
| 595 |
] }), |
| 596 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 pt-4 border-t border-gray-200 dark:border-gray-700", children: [ |
| 597 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-3", children: __("Payment Summary", "yatra") }), |
| 598 |
(() => { |
| 599 |
const dbSubtotal = parseFloat(booking.subtotal) || booking.total_amount || 0; |
| 600 |
const discountAmount = booking.discount_amount || 0; |
| 601 |
const itineraryCostsTotal = parseFloat(booking.itinerary_costs_total) || 0; |
| 602 |
const taxAmount = parseFloat(booking.tax_amount) || 0; |
| 603 |
const taxInclusiveRaw = booking.tax_inclusive; |
| 604 |
const taxInclusive = taxInclusiveRaw === true || parseInt(String(taxInclusiveRaw), 10) === 1; |
| 605 |
const totalAmount = booking.total_amount || 0; |
| 606 |
const amountPaid = booking.amount_paid || 0; |
| 607 |
const amountDue = booking.amount_due || 0; |
| 608 |
let taxLines = []; |
| 609 |
const taxBreakdownRaw = booking.tax_breakdown; |
| 610 |
if (Array.isArray(taxBreakdownRaw) && taxBreakdownRaw.length > 0) { |
| 611 |
taxLines = taxBreakdownRaw; |
| 612 |
} else { |
| 613 |
const taxDetailsRaw = booking.tax_details; |
| 614 |
if (taxDetailsRaw) { |
| 615 |
try { |
| 616 |
const parsed = typeof taxDetailsRaw === "string" ? JSON.parse(taxDetailsRaw) : taxDetailsRaw; |
| 617 |
if (Array.isArray(parsed) && parsed.length > 0) |
| 618 |
taxLines = parsed; |
| 619 |
} catch (_) { |
| 620 |
} |
| 621 |
} |
| 622 |
if (taxLines.length === 0 && taxAmount > 0) { |
| 623 |
taxLines = [ |
| 624 |
{ |
| 625 |
name: __("Tax", "yatra"), |
| 626 |
rate: parseFloat(booking.tax_rate) || 0, |
| 627 |
amount: taxAmount |
| 628 |
} |
| 629 |
]; |
| 630 |
} |
| 631 |
} |
| 632 |
let itineraryCosts = []; |
| 633 |
const itineraryCostsRaw = booking.itinerary_costs; |
| 634 |
if (typeof itineraryCostsRaw === "string") { |
| 635 |
try { |
| 636 |
itineraryCosts = JSON.parse(itineraryCostsRaw); |
| 637 |
} catch (_) { |
| 638 |
} |
| 639 |
} else if (Array.isArray(itineraryCostsRaw)) { |
| 640 |
itineraryCosts = itineraryCostsRaw; |
| 641 |
} |
| 642 |
const rawServices = booking.additional_services; |
| 643 |
const selectedServices = Array.isArray(rawServices) ? rawServices.filter((s) => (s == null ? void 0 : s.selected) !== false) : []; |
| 644 |
const getServiceAmt = (s) => parseFloat( |
| 645 |
(s == null ? void 0 : s.total_price) ?? (s == null ? void 0 : s.calculated_price) ?? (s == null ? void 0 : s.total_cost) ?? (s == null ? void 0 : s.amount) ?? (s == null ? void 0 : s.unit_price) ?? (s == null ? void 0 : s.price) ?? 0 |
| 646 |
); |
| 647 |
const servicesTotal = selectedServices.reduce( |
| 648 |
(sum, s) => sum + getServiceAmt(s), |
| 649 |
0 |
| 650 |
); |
| 651 |
const baseTripCost = dbSubtotal - servicesTotal; |
| 652 |
const taxableAmount = Math.max(0, dbSubtotal - discountAmount) + itineraryCostsTotal; |
| 653 |
const hasServices = selectedServices.length > 0; |
| 654 |
const hasDiscount = discountAmount > 0; |
| 655 |
const hasItinerary = itineraryCosts.length > 0 && itineraryCostsTotal > 0; |
| 656 |
const hasTax = taxLines.length > 0; |
| 657 |
const showTaxableRow = hasTax && (hasDiscount || hasItinerary); |
| 658 |
const Row = ({ |
| 659 |
label, |
| 660 |
value, |
| 661 |
sub = false, |
| 662 |
green = false, |
| 663 |
bold = false |
| 664 |
}) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 665 |
"div", |
| 666 |
{ |
| 667 |
className: `flex justify-between text-sm${sub ? " ml-4" : ""}`, |
| 668 |
children: [ |
| 669 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 670 |
"span", |
| 671 |
{ |
| 672 |
className: bold ? "font-semibold text-gray-900 dark:text-white" : "text-gray-600 dark:text-gray-400", |
| 673 |
children: label |
| 674 |
} |
| 675 |
), |
| 676 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 677 |
"span", |
| 678 |
{ |
| 679 |
className: bold ? "font-semibold text-gray-900 dark:text-white" : green ? "text-green-600 dark:text-green-400" : "text-gray-900 dark:text-white", |
| 680 |
children: value |
| 681 |
} |
| 682 |
) |
| 683 |
] |
| 684 |
} |
| 685 |
); |
| 686 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1.5", children: [ |
| 687 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-sm", children: [ |
| 688 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-gray-600 dark:text-gray-400 flex items-center gap-1.5", children: [ |
| 689 |
__("Trip Base Price", "yatra"), |
| 690 |
taxInclusive && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300", children: __("Tax Incl.", "yatra") }) |
| 691 |
] }), |
| 692 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: formatPrice(baseTripCost, booking.currency) }) |
| 693 |
] }), |
| 694 |
hasServices && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 695 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-xs font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500 mt-1", children: [ |
| 696 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ |
| 697 |
"+ ", |
| 698 |
__("Additional Services", "yatra") |
| 699 |
] }), |
| 700 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", {}) |
| 701 |
] }), |
| 702 |
selectedServices.map((s, i) => /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 703 |
Row, |
| 704 |
{ |
| 705 |
sub: true, |
| 706 |
label: (s == null ? void 0 : s.service_name) || (s == null ? void 0 : s.name) || (s == null ? void 0 : s.title) || (s == null ? void 0 : s.label) || __("Service", "yatra"), |
| 707 |
value: formatPrice( |
| 708 |
getServiceAmt(s), |
| 709 |
booking.currency |
| 710 |
) |
| 711 |
}, |
| 712 |
i |
| 713 |
)), |
| 714 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-sm font-semibold border-t border-gray-200 dark:border-gray-600 pt-1.5 mt-0.5", children: [ |
| 715 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: __("Gross Total", "yatra") }), |
| 716 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: formatPrice(dbSubtotal, booking.currency) }) |
| 717 |
] }) |
| 718 |
] }), |
| 719 |
hasDiscount && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 720 |
Row, |
| 721 |
{ |
| 722 |
label: __("Discount", "yatra"), |
| 723 |
value: `-${formatPrice(discountAmount, booking.currency)}`, |
| 724 |
green: true |
| 725 |
} |
| 726 |
), |
| 727 |
hasItinerary && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 728 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-xs font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500 mt-1", children: [ |
| 729 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ |
| 730 |
"+ ", |
| 731 |
__("Itinerary Costs", "yatra") |
| 732 |
] }), |
| 733 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", {}) |
| 734 |
] }), |
| 735 |
itineraryCosts.map((cost, i) => /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 736 |
Row, |
| 737 |
{ |
| 738 |
sub: true, |
| 739 |
label: `${cost.name} ${cost.price_per === "person" ? __("(per person)", "yatra") : cost.price_per === "group" ? __("(per booking)", "yatra") : __("(flat rate)", "yatra")}`, |
| 740 |
value: formatPrice( |
| 741 |
cost.total_cost ?? cost.price, |
| 742 |
booking.currency |
| 743 |
) |
| 744 |
}, |
| 745 |
i |
| 746 |
)) |
| 747 |
] }), |
| 748 |
!taxInclusive && showTaxableRow && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-sm font-semibold border-t border-dashed border-gray-300 dark:border-gray-600 pt-1.5 mt-0.5", children: [ |
| 749 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-700 dark:text-gray-300", children: __("Taxable Amount", "yatra") }), |
| 750 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: formatPrice(taxableAmount, booking.currency) }) |
| 751 |
] }), |
| 752 |
hasTax && !taxInclusive && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 753 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-xs font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500 mt-1", children: [ |
| 754 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ |
| 755 |
"+ ", |
| 756 |
__("Tax", "yatra") |
| 757 |
] }), |
| 758 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", {}) |
| 759 |
] }), |
| 760 |
taxLines.map((tax, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 761 |
"div", |
| 762 |
{ |
| 763 |
className: "flex justify-between text-sm ml-4", |
| 764 |
children: [ |
| 765 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-gray-600 dark:text-gray-400", children: [ |
| 766 |
tax.name, |
| 767 |
tax.rate > 0 ? ` (${tax.rate}%)` : "" |
| 768 |
] }), |
| 769 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-gray-900 dark:text-white", children: [ |
| 770 |
"+", |
| 771 |
formatPrice( |
| 772 |
parseFloat(tax.amount) || 0, |
| 773 |
booking.currency |
| 774 |
) |
| 775 |
] }) |
| 776 |
] |
| 777 |
}, |
| 778 |
i |
| 779 |
)) |
| 780 |
] }), |
| 781 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-base font-bold border-t-2 border-gray-800 dark:border-gray-300 pt-2 mt-1", children: [ |
| 782 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: __("Net Amount", "yatra") }), |
| 783 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-900 dark:text-white", children: formatPrice(totalAmount, booking.currency) }) |
| 784 |
] }), |
| 785 |
hasTax && taxInclusive && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-1 space-y-0.5", children: taxLines.map((tax, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 786 |
"div", |
| 787 |
{ |
| 788 |
className: "text-xs text-gray-400 dark:text-gray-500 italic", |
| 789 |
children: [ |
| 790 |
__("Incl.", "yatra"), |
| 791 |
" ", |
| 792 |
tax.name, |
| 793 |
tax.rate > 0 ? ` (${tax.rate}%)` : "", |
| 794 |
":", |
| 795 |
" ", |
| 796 |
formatPrice( |
| 797 |
parseFloat(tax.amount) || 0, |
| 798 |
booking.currency |
| 799 |
) |
| 800 |
] |
| 801 |
}, |
| 802 |
i |
| 803 |
)) }), |
| 804 |
amountPaid > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 805 |
Row, |
| 806 |
{ |
| 807 |
label: __("Amount Paid", "yatra"), |
| 808 |
value: formatPrice(amountPaid, booking.currency), |
| 809 |
green: true |
| 810 |
} |
| 811 |
), |
| 812 |
amountDue > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-sm font-semibold", children: [ |
| 813 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-orange-600 dark:text-orange-400", children: __("Due Now", "yatra") }), |
| 814 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-orange-600 dark:text-orange-400", children: formatPrice(amountDue, booking.currency) }) |
| 815 |
] }) |
| 816 |
] }); |
| 817 |
})() |
| 818 |
] }) |
| 819 |
] }) |
| 820 |
] }), |
| 821 |
Array.isArray(booking.payments) && booking.payments.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { "data-testid": "booking-payments-card", children: [ |
| 822 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Payments", "yatra") }) }), |
| 823 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "divide-y divide-gray-100 dark:divide-gray-800", children: booking.payments.map((payment) => { |
| 824 |
const status = String( |
| 825 |
payment.status || payment.payment_status || "pending" |
| 826 |
); |
| 827 |
const statusClass = status === "completed" ? "bg-green-100 text-green-700 dark:bg-green-900/20 dark:text-green-400" : status === "pending" ? "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/20 dark:text-yellow-400" : status === "refunded" ? "bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-400" : "bg-red-100 text-red-700 dark:bg-red-900/20 dark:text-red-400"; |
| 828 |
const statusLabel = { |
| 829 |
completed: __("Completed", "yatra"), |
| 830 |
pending: __("Pending", "yatra"), |
| 831 |
failed: __("Failed", "yatra"), |
| 832 |
refunded: __("Refunded", "yatra"), |
| 833 |
cancelled: __("Cancelled", "yatra") |
| 834 |
}; |
| 835 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 836 |
"div", |
| 837 |
{ |
| 838 |
className: "py-2 flex items-start justify-between gap-3 text-sm", |
| 839 |
children: [ |
| 840 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [ |
| 841 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "font-medium text-gray-900 dark:text-white", children: [ |
| 842 |
formatPrice( |
| 843 |
Number(payment.amount || 0), |
| 844 |
payment.currency || booking.currency |
| 845 |
), |
| 846 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-2 font-normal text-gray-500 dark:text-gray-400", children: payment.payment_method_label || payment.gateway || "" }) |
| 847 |
] }), |
| 848 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 truncate", children: [ |
| 849 |
payment.payment_date ? formatDate$1(payment.payment_date) : "", |
| 850 |
payment.transaction_id ? ` · ${payment.transaction_id}` : "", |
| 851 |
payment.payment_number ? ` · ${payment.payment_number}` : "" |
| 852 |
] }) |
| 853 |
] }), |
| 854 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 855 |
"span", |
| 856 |
{ |
| 857 |
className: `inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium whitespace-nowrap ${statusClass}`, |
| 858 |
children: statusLabel[status] || status |
| 859 |
} |
| 860 |
) |
| 861 |
] |
| 862 |
}, |
| 863 |
payment.id |
| 864 |
); |
| 865 |
}) }) }) |
| 866 |
] }), |
| 867 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 868 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Customer Information", "yatra") }) }), |
| 869 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 870 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 871 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-medium text-gray-900 dark:text-white mb-1", children: booking.customer_name }), |
| 872 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400", children: [ |
| 873 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5", children: [ |
| 874 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Mail, { className: "w-4 h-4" }), |
| 875 |
booking.customer_email |
| 876 |
] }), |
| 877 |
booking.customer_phone && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5", children: [ |
| 878 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Phone, { className: "w-4 h-4" }), |
| 879 |
/* @__PURE__ */ jsxRuntimeExports.jsx(PhoneDisplay, { value: booking.customer_phone }) |
| 880 |
] }) |
| 881 |
] }) |
| 882 |
] }), |
| 883 |
(() => { |
| 884 |
const cd = booking.contact_data && typeof booking.contact_data === "object" ? booking.contact_data : {}; |
| 885 |
const CORE = ["first_name", "last_name", "email", "phone"]; |
| 886 |
const extras = Object.entries(cd).filter( |
| 887 |
([k, v]) => !CORE.includes(k) && k !== "country" && v != null && String(v).trim() !== "" |
| 888 |
); |
| 889 |
const countryCode = booking.customer_country || (cd.country ? String(cd.country) : ""); |
| 890 |
if (!countryCode && extras.length === 0) return null; |
| 891 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-3 pt-1 border-t border-gray-100 dark:border-gray-700", children: [ |
| 892 |
countryCode && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 893 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 mb-0.5", children: getFieldLabel("country", contactFields) }), |
| 894 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-medium text-gray-900 dark:text-white", children: getCountryName(countryCode) }) |
| 895 |
] }), |
| 896 |
extras.map(([fieldId, value]) => { |
| 897 |
const field = contactFields.find( |
| 898 |
(f) => f.id === fieldId |
| 899 |
); |
| 900 |
const display = (field == null ? void 0 : field.type) === "country" ? getCountryName(String(value)) : optionLabel(field, value); |
| 901 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 902 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 mb-0.5", children: getFieldLabel(fieldId, contactFields) }), |
| 903 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-medium text-gray-900 dark:text-white", children: display }) |
| 904 |
] }, fieldId); |
| 905 |
}) |
| 906 |
] }); |
| 907 |
})() |
| 908 |
] }) |
| 909 |
] }), |
| 910 |
booking.travelers_data && booking.travelers_data.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 911 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-base flex items-center gap-2", children: [ |
| 912 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Users, { className: "w-4 h-4" }), |
| 913 |
((_b = formConfig == null ? void 0 : formConfig.traveler_form) == null ? void 0 : _b.title) || __("Travelers Information", "yatra"), |
| 914 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-2 text-xs font-normal text-gray-500 dark:text-gray-400", children: [ |
| 915 |
"(", |
| 916 |
booking.travelers_data.length, |
| 917 |
" ", |
| 918 |
booking.travelers_data.length === 1 ? __("traveler", "yatra") : __("travelers", "yatra"), |
| 919 |
")" |
| 920 |
] }) |
| 921 |
] }) }), |
| 922 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "space-y-4", children: booking.travelers_data.map( |
| 923 |
(traveler, index) => { |
| 924 |
const travelerFieldsData = traveler.fields || traveler; |
| 925 |
const systemFields = [ |
| 926 |
"id", |
| 927 |
"booking_id", |
| 928 |
"traveller_index", |
| 929 |
"is_lead", |
| 930 |
"created_at", |
| 931 |
"updated_at", |
| 932 |
"fields" |
| 933 |
]; |
| 934 |
const travelerEntries = Object.entries( |
| 935 |
travelerFieldsData |
| 936 |
).filter(([key, value]) => { |
| 937 |
if (systemFields.includes(key)) return false; |
| 938 |
if (!value || typeof value === "string" && value.trim() === "") |
| 939 |
return false; |
| 940 |
if (typeof value === "object" && !Array.isArray(value)) |
| 941 |
return false; |
| 942 |
return true; |
| 943 |
}); |
| 944 |
const firstName = travelerFieldsData.first_name || traveler.first_name || ""; |
| 945 |
const lastName = travelerFieldsData.last_name || traveler.last_name || ""; |
| 946 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 947 |
"div", |
| 948 |
{ |
| 949 |
className: `p-4 rounded-lg ${index === 0 ? "bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800" : "bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700"}`, |
| 950 |
children: [ |
| 951 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-3", children: [ |
| 952 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: [ |
| 953 |
index === 0 ? __("Lead Traveler", "yatra") : `${__("Traveler", "yatra")} ${index + 1}`, |
| 954 |
(firstName || lastName) && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-normal text-gray-500 dark:text-gray-400 ml-2", children: [ |
| 955 |
"-", |
| 956 |
" ", |
| 957 |
[firstName, lastName].filter(Boolean).join(" ") |
| 958 |
] }) |
| 959 |
] }), |
| 960 |
index === 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300 px-2 py-0.5 rounded", children: __("Primary Contact", "yatra") }) |
| 961 |
] }), |
| 962 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 gap-3", children: travelerEntries.map(([fieldId, fieldValue]) => { |
| 963 |
if (fieldId === "first_name" || fieldId === "last_name") |
| 964 |
return null; |
| 965 |
const fieldConfig = travelerFields.find( |
| 966 |
(f) => f.id === fieldId |
| 967 |
); |
| 968 |
const label = (fieldConfig == null ? void 0 : fieldConfig.label) || getFieldLabel(fieldId, travelerFields); |
| 969 |
const isLongField = (fieldConfig == null ? void 0 : fieldConfig.type) === "textarea" || String(fieldValue).length > 50; |
| 970 |
let displayValue = String(fieldValue); |
| 971 |
if ((fieldConfig == null ? void 0 : fieldConfig.type) === "date" || fieldId.includes("date") || fieldId.includes("birth") || fieldId.includes("dob") || fieldId.includes("expiry")) { |
| 972 |
displayValue = formatDate$1(fieldValue); |
| 973 |
} |
| 974 |
if ((fieldId === "nationality" || fieldId === "country") && fieldValue && typeof fieldValue === "string" && fieldValue.length === 2) { |
| 975 |
displayValue = getCountryName(fieldValue); |
| 976 |
} |
| 977 |
let asWritten = false; |
| 978 |
if ((fieldConfig == null ? void 0 : fieldConfig.type) === "select") { |
| 979 |
displayValue = optionLabel( |
| 980 |
fieldConfig, |
| 981 |
fieldValue |
| 982 |
); |
| 983 |
asWritten = displayValue !== String(fieldValue); |
| 984 |
} |
| 985 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 986 |
"div", |
| 987 |
{ |
| 988 |
className: isLongField ? "col-span-2 md:col-span-3" : "", |
| 989 |
children: [ |
| 990 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 mb-0.5", children: label }), |
| 991 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 992 |
"div", |
| 993 |
{ |
| 994 |
className: `text-sm text-gray-900 dark:text-white ${fieldId === "passport" ? "font-mono" : ""} ${asWritten ? "" : "capitalize"}`, |
| 995 |
children: displayValue |
| 996 |
} |
| 997 |
) |
| 998 |
] |
| 999 |
}, |
| 1000 |
fieldId |
| 1001 |
); |
| 1002 |
}) }), |
| 1003 |
travelerEntries.length <= 2 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-400 dark:text-gray-500 italic mt-2", children: __( |
| 1004 |
"Limited traveler information provided", |
| 1005 |
"yatra" |
| 1006 |
) }) |
| 1007 |
] |
| 1008 |
}, |
| 1009 |
index |
| 1010 |
); |
| 1011 |
} |
| 1012 |
) }) |
| 1013 |
] }), |
| 1014 |
booking.emergency_contact && Object.values(booking.emergency_contact).some( |
| 1015 |
(v) => v && String(v).trim() !== "" |
| 1016 |
) && /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 1017 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-base flex items-center gap-2", children: [ |
| 1018 |
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "w-4 h-4" }), |
| 1019 |
((_c = formConfig == null ? void 0 : formConfig.emergency_contact_form) == null ? void 0 : _c.title) || __("Emergency Contact", "yatra") |
| 1020 |
] }) }), |
| 1021 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-3", children: Object.entries(booking.emergency_contact).filter( |
| 1022 |
([_, value]) => value && String(value).trim() !== "" |
| 1023 |
).map(([fieldId, fieldValue]) => { |
| 1024 |
const label = getFieldLabel(fieldId, emergencyFields); |
| 1025 |
const emergencyField = emergencyFields.find( |
| 1026 |
(f) => f.id === fieldId |
| 1027 |
); |
| 1028 |
const emergencyDisplay = optionLabel( |
| 1029 |
emergencyField, |
| 1030 |
fieldValue |
| 1031 |
); |
| 1032 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1033 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 mb-0.5", children: label }), |
| 1034 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1035 |
"div", |
| 1036 |
{ |
| 1037 |
className: `text-sm font-medium text-gray-900 dark:text-white ${emergencyDisplay !== String(fieldValue) ? "" : "capitalize"}`, |
| 1038 |
children: emergencyDisplay |
| 1039 |
} |
| 1040 |
) |
| 1041 |
] }, fieldId); |
| 1042 |
}) }) }) |
| 1043 |
] }), |
| 1044 |
booking.notes && /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 1045 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-base flex items-center gap-2", children: [ |
| 1046 |
/* @__PURE__ */ jsxRuntimeExports.jsx(FileText, { className: "w-4 h-4" }), |
| 1047 |
__("Special Requests", "yatra") |
| 1048 |
] }) }), |
| 1049 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap", children: booking.notes }) }) |
| 1050 |
] }) |
| 1051 |
] }), |
| 1052 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 1053 |
((_d = window.yatraAdmin) == null ? void 0 : _d.isPro) && !!((_f = (_e = window.yatraAdmin) == null ? void 0 : _e.googleCalendar) == null ? void 0 : _f.enabled) && booking.google_calendar && /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 1054 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Google Calendar Sync", "yatra") }) }), |
| 1055 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "space-y-3", children: (() => { |
| 1056 |
const gc = booking.google_calendar; |
| 1057 |
const status = gc.sync_status || (gc.synced ? "synced" : "not_synced"); |
| 1058 |
const statusClass = status === "synced" ? "bg-green-100 text-green-700 dark:bg-green-900/20 dark:text-green-400" : status === "failed" ? "bg-red-100 text-red-700 dark:bg-red-900/20 dark:text-red-400" : "bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-400"; |
| 1059 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 1060 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1061 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Status", "yatra") }), |
| 1062 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1063 |
"span", |
| 1064 |
{ |
| 1065 |
className: `inline-flex items-center px-3 py-1 rounded-md text-sm font-medium ${statusClass}`, |
| 1066 |
children: status |
| 1067 |
} |
| 1068 |
) |
| 1069 |
] }), |
| 1070 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1071 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Last Synced", "yatra") }), |
| 1072 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: gc.last_synced_at ? formatDate$1(gc.last_synced_at) : __("—", "yatra") }) |
| 1073 |
] }), |
| 1074 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1075 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Calendar", "yatra") }), |
| 1076 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white break-all", children: gc.calendar_id || __("—", "yatra") }) |
| 1077 |
] }), |
| 1078 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1079 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Event ID", "yatra") }), |
| 1080 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white font-mono break-all", children: gc.event_id || __("—", "yatra") }) |
| 1081 |
] }), |
| 1082 |
gc.error_message && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1083 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Error", "yatra") }), |
| 1084 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-red-600 dark:text-red-400 whitespace-pre-wrap", children: gc.error_message }) |
| 1085 |
] }) |
| 1086 |
] }); |
| 1087 |
})() }) |
| 1088 |
] }), |
| 1089 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 1090 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Payment Information", "yatra") }) }), |
| 1091 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 1092 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1093 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Payment Status", "yatra") }), |
| 1094 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-1", children: getPaymentStatusBadge(booking.payment_status) }) |
| 1095 |
] }), |
| 1096 |
booking.payment_method && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1097 |
/* @__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: [ |
| 1098 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CreditCard, { className: "w-3 h-3" }), |
| 1099 |
__("Payment Method", "yatra") |
| 1100 |
] }), |
| 1101 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: booking.payment_method }) |
| 1102 |
] }), |
| 1103 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1104 |
/* @__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: [ |
| 1105 |
__("Trip Price per Person", "yatra"), |
| 1106 |
((v) => v === true || parseInt(String(v), 10) === 1)( |
| 1107 |
booking.tax_inclusive |
| 1108 |
) && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300 normal-case tracking-normal", children: __("Tax Incl.", "yatra") }) |
| 1109 |
] }), |
| 1110 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: (() => { |
| 1111 |
const subtotal = parseFloat(booking.subtotal) || booking.total_amount || 0; |
| 1112 |
const travelers = booking.travelers || 1; |
| 1113 |
const rawServices = booking.additional_services; |
| 1114 |
const servicesTotal = Array.isArray(rawServices) ? rawServices.filter((s) => (s == null ? void 0 : s.selected) !== false).reduce( |
| 1115 |
(sum, s) => sum + parseFloat( |
| 1116 |
(s == null ? void 0 : s.total_price) ?? (s == null ? void 0 : s.calculated_price) ?? (s == null ? void 0 : s.total_cost) ?? (s == null ? void 0 : s.amount) ?? (s == null ? void 0 : s.unit_price) ?? (s == null ? void 0 : s.price) ?? 0 |
| 1117 |
), |
| 1118 |
0 |
| 1119 |
) : 0; |
| 1120 |
const baseTripCost = subtotal - servicesTotal; |
| 1121 |
return formatPrice( |
| 1122 |
baseTripCost / travelers, |
| 1123 |
booking.currency |
| 1124 |
); |
| 1125 |
})() }) |
| 1126 |
] }), |
| 1127 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1128 |
/* @__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: [ |
| 1129 |
__("Total Amount", "yatra"), |
| 1130 |
((v) => v === true || parseInt(String(v), 10) === 1)( |
| 1131 |
booking.tax_inclusive |
| 1132 |
) && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300 normal-case tracking-normal", children: __("Tax Incl.", "yatra") }) |
| 1133 |
] }), |
| 1134 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: formatPrice(booking.total_amount || 0, booking.currency) }) |
| 1135 |
] }) |
| 1136 |
] }) |
| 1137 |
] }), |
| 1138 |
booking.discount_amount > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "border-emerald-200 dark:border-emerald-800 bg-emerald-50 dark:bg-emerald-900/20", children: [ |
| 1139 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-base flex items-center gap-2 text-emerald-700 dark:text-emerald-400", children: [ |
| 1140 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1141 |
"svg", |
| 1142 |
{ |
| 1143 |
width: "16", |
| 1144 |
height: "16", |
| 1145 |
viewBox: "0 0 24 24", |
| 1146 |
fill: "none", |
| 1147 |
stroke: "currentColor", |
| 1148 |
strokeWidth: "2", |
| 1149 |
className: "w-4 h-4", |
| 1150 |
children: [ |
| 1151 |
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 2L2 7l10 5 10-5-10-5z" }), |
| 1152 |
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M2 17l10 5 10-5" }), |
| 1153 |
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M2 12l10 5 10-5" }) |
| 1154 |
] |
| 1155 |
} |
| 1156 |
), |
| 1157 |
__("Discount Applied", "yatra") |
| 1158 |
] }) }), |
| 1159 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 1160 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1161 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-emerald-600 dark:text-emerald-400 uppercase tracking-wide mb-1", children: __("Discount Type", "yatra") }), |
| 1162 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-medium text-emerald-700 dark:text-emerald-300", children: ((_g = booking.discount_code) == null ? void 0 : _g.toLowerCase().includes("group")) || ((_h = booking.discount_code) == null ? void 0 : _h.includes("GROUP")) ? __("Group Discount", "yatra") : __("Coupon Discount", "yatra") }) |
| 1163 |
] }), |
| 1164 |
booking.discount_code && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1165 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-emerald-600 dark:text-emerald-400 uppercase tracking-wide mb-1", children: __("Code", "yatra") }), |
| 1166 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-mono font-medium text-emerald-700 dark:text-emerald-300 bg-emerald-100 dark:bg-emerald-900/40 px-2 py-1 rounded inline-block", children: booking.discount_code }) |
| 1167 |
] }), |
| 1168 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1169 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-emerald-600 dark:text-emerald-400 uppercase tracking-wide mb-1", children: __("Savings", "yatra") }), |
| 1170 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xl font-bold text-emerald-700 dark:text-emerald-300", children: [ |
| 1171 |
"-", |
| 1172 |
formatPrice(booking.discount_amount, booking.currency) |
| 1173 |
] }) |
| 1174 |
] }) |
| 1175 |
] }) |
| 1176 |
] }), |
| 1177 |
isPro && consentStatus && consentStatus.total_required > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1178 |
Card, |
| 1179 |
{ |
| 1180 |
className: consentStatus.all_signed ? "border-green-200 dark:border-green-800 bg-green-50 dark:bg-green-900/20" : "border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20", |
| 1181 |
children: [ |
| 1182 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1183 |
CardTitle, |
| 1184 |
{ |
| 1185 |
className: `text-base flex items-center gap-2 ${consentStatus.all_signed ? "text-green-700 dark:text-green-400" : "text-amber-700 dark:text-amber-400"}`, |
| 1186 |
children: [ |
| 1187 |
/* @__PURE__ */ jsxRuntimeExports.jsx(FileSignature, { className: "w-4 h-4" }), |
| 1188 |
__("Consent Status", "yatra") |
| 1189 |
] |
| 1190 |
} |
| 1191 |
) }), |
| 1192 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 1193 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1194 |
"span", |
| 1195 |
{ |
| 1196 |
className: `text-sm ${consentStatus.all_signed ? "text-green-600 dark:text-green-400" : "text-amber-600 dark:text-amber-400"}`, |
| 1197 |
children: consentStatus.all_signed ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-1", children: [ |
| 1198 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }), |
| 1199 |
__("All Consents Signed", "yatra") |
| 1200 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-1", children: [ |
| 1201 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Clock, { className: "w-4 h-4" }), |
| 1202 |
__("Pending Signatures", "yatra") |
| 1203 |
] }) |
| 1204 |
} |
| 1205 |
) }), |
| 1206 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between text-sm", children: [ |
| 1207 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600 dark:text-gray-400", children: __("Signed", "yatra") }), |
| 1208 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-medium text-gray-900 dark:text-white", children: [ |
| 1209 |
consentStatus.total_signed, |
| 1210 |
" /", |
| 1211 |
" ", |
| 1212 |
consentStatus.total_required |
| 1213 |
] }) |
| 1214 |
] }), |
| 1215 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1216 |
"div", |
| 1217 |
{ |
| 1218 |
className: `h-2 rounded-full ${consentStatus.all_signed ? "bg-green-500" : "bg-amber-500"}`, |
| 1219 |
style: { |
| 1220 |
width: `${consentStatus.total_signed / consentStatus.total_required * 100}%` |
| 1221 |
} |
| 1222 |
} |
| 1223 |
) }), |
| 1224 |
consentStatus.pending_requests && consentStatus.pending_requests.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pt-2 border-t border-amber-200 dark:border-amber-700", children: [ |
| 1225 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-amber-600 dark:text-amber-400 uppercase tracking-wide mb-2", children: __("Pending", "yatra") }), |
| 1226 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [ |
| 1227 |
consentStatus.pending_requests.slice(0, 3).map((req, idx) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1228 |
"div", |
| 1229 |
{ |
| 1230 |
className: "text-xs text-gray-600 dark:text-gray-400 flex items-center gap-1", |
| 1231 |
children: [ |
| 1232 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Send, { className: "w-3 h-3" }), |
| 1233 |
req.recipient_name || req.recipient_email |
| 1234 |
] |
| 1235 |
}, |
| 1236 |
idx |
| 1237 |
)), |
| 1238 |
consentStatus.pending_requests.length > 3 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500", children: [ |
| 1239 |
"+", |
| 1240 |
consentStatus.pending_requests.length - 3, |
| 1241 |
" ", |
| 1242 |
__("more", "yatra") |
| 1243 |
] }) |
| 1244 |
] }) |
| 1245 |
] }), |
| 1246 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1247 |
Button, |
| 1248 |
{ |
| 1249 |
variant: "outline", |
| 1250 |
size: "sm", |
| 1251 |
className: "w-full mt-2", |
| 1252 |
onClick: () => { |
| 1253 |
var _a2; |
| 1254 |
window.location.href = `${((_a2 = window.yatraAdmin) == null ? void 0 : _a2.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=trips&tab=trip-consent`; |
| 1255 |
}, |
| 1256 |
children: __("Manage Consents", "yatra") |
| 1257 |
} |
| 1258 |
) |
| 1259 |
] }) |
| 1260 |
] |
| 1261 |
} |
| 1262 |
), |
| 1263 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 1264 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Timeline", "yatra") }) }), |
| 1265 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 1266 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1267 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Created", "yatra") }), |
| 1268 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: formatDate$1(booking.created_at) }) |
| 1269 |
] }), |
| 1270 |
booking.updated_at && booking.updated_at !== booking.created_at && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1271 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1", children: __("Last Updated", "yatra") }), |
| 1272 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-900 dark:text-white", children: formatDate$1(booking.updated_at) }) |
| 1273 |
] }) |
| 1274 |
] }) |
| 1275 |
] }) |
| 1276 |
] }) |
| 1277 |
] }) }) |
| 1278 |
] }); |
| 1279 |
}; |
| 1280 |
export { |
| 1281 |
ViewBooking as default |
| 1282 |
}; |
| 1283 |
//# sourceMappingURL=ViewBooking-CgYCok3W.js.map |
| 1284 |
|