| 1 |
import { r as reactExports, j as jsxRuntimeExports, ax as Plus, aO as Trash2, bc as GripVertical, aL as ArrowUp, aM as ArrowDown, bb as Lock, n as Star, aR as Eye, by as EyeOff, aV as Pen, bd as ChevronUp, y as ChevronDown, R as RotateCcw, v as useQueryClient, u as useQuery, a6 as React, w as useMutation, bO as Building2, bP as Palette, q as Calendar, bQ as ClipboardList, bR as SlidersHorizontal, at as DollarSign, bS as Percent, U as Users, bT as Receipt, b2 as Globe, bU as Plug, T as TrendingUp, av as Shield, E as Loader2, aW as Save, l as Settings$1, m as BarChart3, X as ExternalLink, O as RefreshCw, ay as X, aT as Image, aG as Info, d as Mail, aw as CheckCircle, b9 as XCircle, aB as Check, aA as AlertCircle, z as ChevronRight } from "./react-vendor-CithbthY.js"; |
| 2 |
import { a as apiClient, A as API_ENDPOINTS, _ as __, I as Input, s as sprintf, u as useToast, S as SearchableSelect, m as getCurrencyOptions, b as apiService } from "./index-Dec_weLB.js"; |
| 3 |
import { r as unwrapApiPayload, C as Card, f as CardHeader, g as CardTitle, B as Button, d as CardContent, s as Label, S as Select, k as ConfirmationDialog, t as useTripTargets, M as Modal, v as describeTargets, n as MultiSelect, w as decodeTargets, x as encodeTargets, y as hasTargets, u as usePermissions, P as PageHeader, z as ConditionalRender, E as CardFooter, F as PremiumUpgradeDialog, o as prepareWordPressMediaFrameOpen, G as buildYatraAccountViewUrl, J as navigateMenu, K as saveSettings, N as buildYatraListingPublicUrl, m as isWordPressPlainPermalink, O as postInsertBookingShortcode, Q as postFlushRewriteRules, U as fetchBookingPageShortcodeStatus, q as fetchSettings, V as fetchPaymentGatewayDefinitions, W as fetchWordPressPages } from "../../admin/dist/js/app.js"; |
| 4 |
import { P as ProBadge, a as ProFeature } from "./ProFeature-DE6oH70S.js"; |
| 5 |
async function fetchUsageTrackingStatus() { |
| 6 |
return unwrapApiPayload( |
| 7 |
await apiClient.get(API_ENDPOINTS.USAGE_TRACKING_STATUS) |
| 8 |
); |
| 9 |
} |
| 10 |
async function postUsageTrackingSettings(enabled) { |
| 11 |
return unwrapApiPayload( |
| 12 |
await apiClient.post(API_ENDPOINTS.USAGE_TRACKING_SETTINGS, { enabled }) |
| 13 |
); |
| 14 |
} |
| 15 |
async function postUsageTrackingSend(options) { |
| 16 |
const body = {}; |
| 17 |
if (options == null ? void 0 : options.force) { |
| 18 |
body.force = true; |
| 19 |
} |
| 20 |
return apiClient.post(API_ENDPOINTS.USAGE_TRACKING_SEND, body); |
| 21 |
} |
| 22 |
const withOrder = (fields) => fields.map((field, i) => ({ ...field, order: i + 1 })); |
| 23 |
const BookingFormFieldsEditor = ({ |
| 24 |
formType, |
| 25 |
fields, |
| 26 |
onChange, |
| 27 |
fieldTypes, |
| 28 |
widthOptions, |
| 29 |
appliesToOptions, |
| 30 |
headerExtra |
| 31 |
}) => { |
| 32 |
const [editingField, setEditingField] = reactExports.useState(null); |
| 33 |
const [fieldIdDraft, setFieldIdDraft] = reactExports.useState(null); |
| 34 |
reactExports.useEffect(() => { |
| 35 |
setFieldIdDraft(null); |
| 36 |
}, [editingField]); |
| 37 |
const [showAddField, setShowAddField] = reactExports.useState(false); |
| 38 |
const [newField, setNewField] = reactExports.useState({ |
| 39 |
id: "", |
| 40 |
type: "text", |
| 41 |
label: "", |
| 42 |
placeholder: "", |
| 43 |
required: false, |
| 44 |
enabled: true, |
| 45 |
width: "full", |
| 46 |
options: [], |
| 47 |
applies_to: "all" |
| 48 |
}); |
| 49 |
const [deleteConfirm, setDeleteConfirm] = reactExports.useState({ |
| 50 |
isOpen: false, |
| 51 |
fieldId: null, |
| 52 |
fieldLabel: "" |
| 53 |
}); |
| 54 |
const [draggedFieldId, setDraggedFieldId] = reactExports.useState(null); |
| 55 |
const [dragOverFieldId, setDragOverFieldId] = reactExports.useState(null); |
| 56 |
const generateIdFromLabel = (label) => { |
| 57 |
return label.toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, ""); |
| 58 |
}; |
| 59 |
const sanitizeId = (id) => { |
| 60 |
return id.toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, ""); |
| 61 |
}; |
| 62 |
const handleNewFieldLabelChange = (label) => { |
| 63 |
const autoId = generateIdFromLabel(label); |
| 64 |
setNewField((prev) => ({ |
| 65 |
...prev, |
| 66 |
label, |
| 67 |
// Only auto-generate ID if it hasn't been manually edited |
| 68 |
id: prev.id === "" || prev.id === generateIdFromLabel(prev.label || "") ? autoId : prev.id |
| 69 |
})); |
| 70 |
}; |
| 71 |
const updateField = (fieldId, updates) => { |
| 72 |
onChange( |
| 73 |
fields.map( |
| 74 |
(field) => field.id === fieldId ? { ...field, ...updates } : field |
| 75 |
) |
| 76 |
); |
| 77 |
}; |
| 78 |
const toggleFieldEnabled = (fieldId) => { |
| 79 |
const field = fields.find((f) => f.id === fieldId); |
| 80 |
if (field && !field.locked) { |
| 81 |
updateField(fieldId, { enabled: !field.enabled }); |
| 82 |
} |
| 83 |
}; |
| 84 |
const toggleFieldRequired = (fieldId) => { |
| 85 |
const field = fields.find((f) => f.id === fieldId); |
| 86 |
if (field) { |
| 87 |
updateField(fieldId, { required: !field.required }); |
| 88 |
} |
| 89 |
}; |
| 90 |
const moveField = (fieldId, direction) => { |
| 91 |
const next = [...fields]; |
| 92 |
const index = next.findIndex((f) => f.id === fieldId); |
| 93 |
if (direction === "up" && index > 0) { |
| 94 |
[next[index - 1], next[index]] = [next[index], next[index - 1]]; |
| 95 |
} else if (direction === "down" && index < next.length - 1) { |
| 96 |
[next[index], next[index + 1]] = [next[index + 1], next[index]]; |
| 97 |
} |
| 98 |
onChange(withOrder(next)); |
| 99 |
}; |
| 100 |
const handleDragStart = (e, fieldId) => { |
| 101 |
setDraggedFieldId(fieldId); |
| 102 |
e.dataTransfer.effectAllowed = "move"; |
| 103 |
}; |
| 104 |
const handleDragOver = (e, fieldId) => { |
| 105 |
e.preventDefault(); |
| 106 |
e.dataTransfer.dropEffect = "move"; |
| 107 |
if (fieldId !== draggedFieldId) { |
| 108 |
setDragOverFieldId(fieldId); |
| 109 |
} |
| 110 |
}; |
| 111 |
const handleDragLeave = () => { |
| 112 |
setDragOverFieldId(null); |
| 113 |
}; |
| 114 |
const handleDrop = (e, targetFieldId) => { |
| 115 |
e.preventDefault(); |
| 116 |
if (!draggedFieldId || draggedFieldId === targetFieldId) { |
| 117 |
setDraggedFieldId(null); |
| 118 |
setDragOverFieldId(null); |
| 119 |
return; |
| 120 |
} |
| 121 |
const next = [...fields]; |
| 122 |
const draggedIndex = next.findIndex((f) => f.id === draggedFieldId); |
| 123 |
const targetIndex = next.findIndex((f) => f.id === targetFieldId); |
| 124 |
if (draggedIndex !== -1 && targetIndex !== -1) { |
| 125 |
const [draggedField] = next.splice(draggedIndex, 1); |
| 126 |
next.splice(targetIndex, 0, draggedField); |
| 127 |
onChange(withOrder(next)); |
| 128 |
} |
| 129 |
setDraggedFieldId(null); |
| 130 |
setDragOverFieldId(null); |
| 131 |
}; |
| 132 |
const handleDragEnd = () => { |
| 133 |
setDraggedFieldId(null); |
| 134 |
setDragOverFieldId(null); |
| 135 |
}; |
| 136 |
const deleteField = (fieldId) => { |
| 137 |
onChange(withOrder(fields.filter((f) => f.id !== fieldId))); |
| 138 |
setDeleteConfirm({ isOpen: false, fieldId: null, fieldLabel: "" }); |
| 139 |
}; |
| 140 |
const addNewField = () => { |
| 141 |
const isTextBlock = newField.type === "text_block"; |
| 142 |
let fieldId; |
| 143 |
if (isTextBlock) { |
| 144 |
if (!newField.content || !newField.content.trim()) return; |
| 145 |
let n = 1; |
| 146 |
while (fields.some((f) => f.id === `text_block_${n}`)) n++; |
| 147 |
fieldId = `text_block_${n}`; |
| 148 |
} else { |
| 149 |
if (!newField.label || !newField.id) return; |
| 150 |
fieldId = sanitizeId(newField.id); |
| 151 |
} |
| 152 |
if (fields.some((f) => f.id === fieldId)) { |
| 153 |
window.alert( |
| 154 |
"A field with this ID already exists. Please use a different ID." |
| 155 |
); |
| 156 |
return; |
| 157 |
} |
| 158 |
const newFieldConfig = { |
| 159 |
id: fieldId, |
| 160 |
type: newField.type || "text", |
| 161 |
label: newField.label || "", |
| 162 |
placeholder: newField.placeholder || "", |
| 163 |
required: newField.required || false, |
| 164 |
enabled: true, |
| 165 |
order: fields.length + 1, |
| 166 |
width: newField.width || "full", |
| 167 |
// Per-traveler targeting only applies to the Traveler section. |
| 168 |
...formType === "traveler_form" ? { applies_to: newField.applies_to || "all" } : {}, |
| 169 |
// Phone fields carry the country-code toggle (default on). |
| 170 |
...newField.type === "tel" ? { show_country_code: newField.show_country_code !== false } : {} |
| 171 |
}; |
| 172 |
if (newField.type === "select" && newField.options && newField.options.length > 0) { |
| 173 |
newFieldConfig.options = newField.options.filter( |
| 174 |
(opt) => opt.value && opt.label |
| 175 |
); |
| 176 |
} |
| 177 |
if (isTextBlock) { |
| 178 |
newFieldConfig.content = newField.content || ""; |
| 179 |
newFieldConfig.required = false; |
| 180 |
} |
| 181 |
onChange([...fields, newFieldConfig]); |
| 182 |
setNewField({ |
| 183 |
id: "", |
| 184 |
type: "text", |
| 185 |
label: "", |
| 186 |
placeholder: "", |
| 187 |
required: false, |
| 188 |
enabled: true, |
| 189 |
width: "full", |
| 190 |
options: [], |
| 191 |
content: "" |
| 192 |
}); |
| 193 |
setShowAddField(false); |
| 194 |
}; |
| 195 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 196 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 197 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row flex-wrap items-center justify-between gap-2 w-full", children: [ |
| 198 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Form Fields", "yatra") }), |
| 199 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 200 |
headerExtra, |
| 201 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 202 |
Button, |
| 203 |
{ |
| 204 |
variant: "outline", |
| 205 |
size: "sm", |
| 206 |
onClick: () => setShowAddField(!showAddField), |
| 207 |
className: "flex items-center gap-2", |
| 208 |
"data-testid": "add-field-toggle", |
| 209 |
children: [ |
| 210 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4" }), |
| 211 |
__("Add Field", "yatra") |
| 212 |
] |
| 213 |
} |
| 214 |
) |
| 215 |
] }) |
| 216 |
] }) }), |
| 217 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 218 |
showAddField && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800 mb-4", children: [ |
| 219 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "font-medium text-sm mb-3", children: __("Add New Field", "yatra") }), |
| 220 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-5 gap-3", children: [ |
| 221 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 222 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Field Type", "yatra") }), |
| 223 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 224 |
Select, |
| 225 |
{ |
| 226 |
value: newField.type || "text", |
| 227 |
onChange: (e) => setNewField((prev) => ({ |
| 228 |
...prev, |
| 229 |
type: e.target.value |
| 230 |
})), |
| 231 |
className: "mt-1", |
| 232 |
children: fieldTypes.map((type) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: type.value, children: type.label }, type.value)) |
| 233 |
} |
| 234 |
) |
| 235 |
] }), |
| 236 |
newField.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 237 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { className: "text-xs", children: [ |
| 238 |
__("Label", "yatra"), |
| 239 |
" *" |
| 240 |
] }), |
| 241 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 242 |
Input, |
| 243 |
{ |
| 244 |
value: newField.label || "", |
| 245 |
onChange: (e) => handleNewFieldLabelChange(e.target.value), |
| 246 |
placeholder: "Field label", |
| 247 |
className: "mt-1" |
| 248 |
} |
| 249 |
) |
| 250 |
] }), |
| 251 |
newField.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 252 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { className: "text-xs", children: [ |
| 253 |
__("Field ID", "yatra"), |
| 254 |
" *" |
| 255 |
] }), |
| 256 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 257 |
Input, |
| 258 |
{ |
| 259 |
value: newField.id || "", |
| 260 |
onChange: (e) => setNewField((prev) => ({ |
| 261 |
...prev, |
| 262 |
id: sanitizeId(e.target.value) |
| 263 |
})), |
| 264 |
placeholder: "field_id", |
| 265 |
className: "mt-1 font-mono text-xs" |
| 266 |
} |
| 267 |
), |
| 268 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] text-gray-400 mt-0.5", children: __("Lowercase, no spaces", "yatra") }) |
| 269 |
] }), |
| 270 |
newField.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 271 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Placeholder", "yatra") }), |
| 272 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 273 |
Input, |
| 274 |
{ |
| 275 |
value: newField.placeholder || "", |
| 276 |
onChange: (e) => setNewField((prev) => ({ |
| 277 |
...prev, |
| 278 |
placeholder: e.target.value |
| 279 |
})), |
| 280 |
placeholder: "Placeholder text", |
| 281 |
className: "mt-1" |
| 282 |
} |
| 283 |
) |
| 284 |
] }), |
| 285 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 286 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Width", "yatra") }), |
| 287 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 288 |
Select, |
| 289 |
{ |
| 290 |
value: newField.width || "full", |
| 291 |
onChange: (e) => setNewField((prev) => ({ |
| 292 |
...prev, |
| 293 |
width: e.target.value |
| 294 |
})), |
| 295 |
className: "mt-1", |
| 296 |
children: widthOptions.map((w) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: w.value, children: w.label }, w.value)) |
| 297 |
} |
| 298 |
) |
| 299 |
] }), |
| 300 |
formType === "traveler_form" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 301 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Applies to", "yatra") }), |
| 302 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 303 |
Select, |
| 304 |
{ |
| 305 |
value: newField.applies_to || "all", |
| 306 |
onChange: (e) => setNewField((prev) => ({ |
| 307 |
...prev, |
| 308 |
applies_to: e.target.value |
| 309 |
})), |
| 310 |
className: "mt-1", |
| 311 |
children: appliesToOptions.map((a) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: a.value, children: a.label }, a.value)) |
| 312 |
} |
| 313 |
) |
| 314 |
] }) |
| 315 |
] }), |
| 316 |
newField.type === "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3", children: [ |
| 317 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-medium", children: __("Content", "yatra") }), |
| 318 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 319 |
"textarea", |
| 320 |
{ |
| 321 |
value: newField.content || "", |
| 322 |
onChange: (e) => setNewField((prev) => ({ |
| 323 |
...prev, |
| 324 |
content: e.target.value |
| 325 |
})), |
| 326 |
rows: 4, |
| 327 |
placeholder: __( |
| 328 |
"Text shown to customers between fields. Basic HTML (bold, links, lists) is allowed.", |
| 329 |
"yatra" |
| 330 |
), |
| 331 |
className: "mt-1 w-full rounded-md border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 px-3 py-2 text-sm" |
| 332 |
} |
| 333 |
), |
| 334 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] text-gray-400 mt-0.5", children: __( |
| 335 |
"Display only — this is not an input and is not submitted by the customer.", |
| 336 |
"yatra" |
| 337 |
) }) |
| 338 |
] }), |
| 339 |
newField.type === "select" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 p-3 bg-white dark:bg-gray-800 rounded-lg border border-blue-100 dark:border-blue-900", children: [ |
| 340 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-2", children: [ |
| 341 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-medium", children: __("Dropdown Options", "yatra") }), |
| 342 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 343 |
Button, |
| 344 |
{ |
| 345 |
type: "button", |
| 346 |
variant: "ghost", |
| 347 |
size: "sm", |
| 348 |
onClick: () => { |
| 349 |
const currentOptions = newField.options || []; |
| 350 |
setNewField((prev) => ({ |
| 351 |
...prev, |
| 352 |
options: [ |
| 353 |
...currentOptions, |
| 354 |
{ value: "", label: "" } |
| 355 |
] |
| 356 |
})); |
| 357 |
}, |
| 358 |
className: "h-6 text-xs", |
| 359 |
children: [ |
| 360 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-3 h-3 mr-1" }), |
| 361 |
__("Add Option", "yatra") |
| 362 |
] |
| 363 |
} |
| 364 |
) |
| 365 |
] }), |
| 366 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 367 |
(newField.options || []).map((option, optIndex) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 368 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 369 |
Input, |
| 370 |
{ |
| 371 |
value: option.value, |
| 372 |
onChange: (e) => { |
| 373 |
const newOptions = [...newField.options || []]; |
| 374 |
newOptions[optIndex] = { |
| 375 |
...newOptions[optIndex], |
| 376 |
value: e.target.value |
| 377 |
}; |
| 378 |
setNewField((prev) => ({ |
| 379 |
...prev, |
| 380 |
options: newOptions |
| 381 |
})); |
| 382 |
}, |
| 383 |
placeholder: "Value (e.g., option1)", |
| 384 |
className: "text-xs flex-1" |
| 385 |
} |
| 386 |
), |
| 387 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 388 |
Input, |
| 389 |
{ |
| 390 |
value: option.label, |
| 391 |
onChange: (e) => { |
| 392 |
const newOptions = [...newField.options || []]; |
| 393 |
newOptions[optIndex] = { |
| 394 |
...newOptions[optIndex], |
| 395 |
label: e.target.value |
| 396 |
}; |
| 397 |
setNewField((prev) => ({ |
| 398 |
...prev, |
| 399 |
options: newOptions |
| 400 |
})); |
| 401 |
}, |
| 402 |
placeholder: "Label (e.g., Option 1)", |
| 403 |
className: "text-xs flex-1" |
| 404 |
} |
| 405 |
), |
| 406 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 407 |
"button", |
| 408 |
{ |
| 409 |
type: "button", |
| 410 |
onClick: () => { |
| 411 |
const newOptions = (newField.options || []).filter( |
| 412 |
(_, i) => i !== optIndex |
| 413 |
); |
| 414 |
setNewField((prev) => ({ |
| 415 |
...prev, |
| 416 |
options: newOptions |
| 417 |
})); |
| 418 |
}, |
| 419 |
className: "p-1 text-gray-400 hover:text-red-500", |
| 420 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "w-3 h-3" }) |
| 421 |
} |
| 422 |
) |
| 423 |
] }, optIndex)), |
| 424 |
(!newField.options || newField.options.length === 0) && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-400 italic", children: __( |
| 425 |
'Click "Add Option" to add dropdown choices.', |
| 426 |
"yatra" |
| 427 |
) }) |
| 428 |
] }) |
| 429 |
] }), |
| 430 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4 mt-3", children: [ |
| 431 |
newField.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [ |
| 432 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 433 |
"input", |
| 434 |
{ |
| 435 |
type: "checkbox", |
| 436 |
checked: newField.required || false, |
| 437 |
onChange: (e) => setNewField((prev) => ({ |
| 438 |
...prev, |
| 439 |
required: e.target.checked |
| 440 |
})), |
| 441 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600" |
| 442 |
} |
| 443 |
), |
| 444 |
__("Required", "yatra") |
| 445 |
] }), |
| 446 |
newField.type === "tel" && /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [ |
| 447 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 448 |
"input", |
| 449 |
{ |
| 450 |
type: "checkbox", |
| 451 |
checked: newField.show_country_code !== false, |
| 452 |
onChange: (e) => setNewField((prev) => ({ |
| 453 |
...prev, |
| 454 |
show_country_code: e.target.checked |
| 455 |
})), |
| 456 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600" |
| 457 |
} |
| 458 |
), |
| 459 |
__("Show country code", "yatra") |
| 460 |
] }), |
| 461 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1" }), |
| 462 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 463 |
Button, |
| 464 |
{ |
| 465 |
variant: "ghost", |
| 466 |
size: "sm", |
| 467 |
onClick: () => setShowAddField(false), |
| 468 |
children: __("Cancel", "yatra") |
| 469 |
} |
| 470 |
), |
| 471 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 472 |
Button, |
| 473 |
{ |
| 474 |
size: "sm", |
| 475 |
onClick: addNewField, |
| 476 |
disabled: newField.type === "text_block" ? !newField.content || !newField.content.trim() : !newField.id || !newField.label, |
| 477 |
children: __("Add Field", "yatra") |
| 478 |
} |
| 479 |
) |
| 480 |
] }) |
| 481 |
] }), |
| 482 |
(fields == null ? void 0 : fields.length) === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __( |
| 483 |
'No fields configured. Click "Add Field" to get started.', |
| 484 |
"yatra" |
| 485 |
) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: fields == null ? void 0 : fields.map((field, index) => { |
| 486 |
var _a, _b; |
| 487 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 488 |
"div", |
| 489 |
{ |
| 490 |
draggable: true, |
| 491 |
onDragStart: (e) => handleDragStart(e, field.id), |
| 492 |
onDragOver: (e) => handleDragOver(e, field.id), |
| 493 |
onDragLeave: handleDragLeave, |
| 494 |
onDrop: (e) => handleDrop(e, field.id), |
| 495 |
onDragEnd: handleDragEnd, |
| 496 |
className: `flex items-center gap-3 p-3 rounded-lg border transition-all cursor-grab active:cursor-grabbing ${draggedFieldId === field.id ? "opacity-50 border-dashed" : ""} ${dragOverFieldId === field.id ? "border-blue-500 bg-blue-50 dark:bg-blue-900/20" : ""} ${field.enabled ? "bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700" : "bg-gray-50 dark:bg-gray-900 border-gray-100 dark:border-gray-800 opacity-60"}`, |
| 497 |
children: [ |
| 498 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [ |
| 499 |
/* @__PURE__ */ jsxRuntimeExports.jsx(GripVertical, { className: "w-4 h-4 text-gray-400" }), |
| 500 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-0.5", children: [ |
| 501 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 502 |
"button", |
| 503 |
{ |
| 504 |
type: "button", |
| 505 |
onClick: () => moveField(field.id, "up"), |
| 506 |
disabled: index === 0, |
| 507 |
className: "p-0.5 text-gray-400 hover:text-gray-600 disabled:opacity-30 disabled:cursor-not-allowed", |
| 508 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowUp, { className: "w-3 h-3" }) |
| 509 |
} |
| 510 |
), |
| 511 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 512 |
"button", |
| 513 |
{ |
| 514 |
type: "button", |
| 515 |
onClick: () => moveField(field.id, "down"), |
| 516 |
disabled: index === fields.length - 1, |
| 517 |
className: "p-0.5 text-gray-400 hover:text-gray-600 disabled:opacity-30 disabled:cursor-not-allowed", |
| 518 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowDown, { className: "w-3 h-3" }) |
| 519 |
} |
| 520 |
) |
| 521 |
] }) |
| 522 |
] }), |
| 523 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 min-w-0", children: editingField === field.id ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 524 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-4 gap-2", children: [ |
| 525 |
field.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 526 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 527 |
Input, |
| 528 |
{ |
| 529 |
value: field.label, |
| 530 |
onChange: (e) => updateField(field.id, { |
| 531 |
label: e.target.value |
| 532 |
}), |
| 533 |
placeholder: "Label", |
| 534 |
className: "text-sm" |
| 535 |
} |
| 536 |
), |
| 537 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 538 |
Input, |
| 539 |
{ |
| 540 |
value: field.placeholder, |
| 541 |
onChange: (e) => updateField(field.id, { |
| 542 |
placeholder: e.target.value |
| 543 |
}), |
| 544 |
placeholder: "Placeholder", |
| 545 |
className: "text-sm" |
| 546 |
} |
| 547 |
) |
| 548 |
] }), |
| 549 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 550 |
Select, |
| 551 |
{ |
| 552 |
value: field.type, |
| 553 |
onChange: (e) => !field.locked && updateField(field.id, { |
| 554 |
type: e.target.value |
| 555 |
}), |
| 556 |
disabled: field.locked, |
| 557 |
title: field.locked ? "Locked fields cannot change type" : void 0, |
| 558 |
className: "text-sm", |
| 559 |
children: fieldTypes.map((type) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: type.value, children: type.label }, type.value)) |
| 560 |
} |
| 561 |
), |
| 562 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 563 |
Select, |
| 564 |
{ |
| 565 |
value: field.width, |
| 566 |
onChange: (e) => updateField(field.id, { |
| 567 |
width: e.target.value |
| 568 |
}), |
| 569 |
className: "text-sm", |
| 570 |
children: widthOptions.map((w) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: w.value, children: w.label }, w.value)) |
| 571 |
} |
| 572 |
), |
| 573 |
formType === "traveler_form" && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 574 |
Select, |
| 575 |
{ |
| 576 |
value: field.applies_to || "all", |
| 577 |
onChange: (e) => updateField(field.id, { |
| 578 |
applies_to: e.target.value |
| 579 |
}), |
| 580 |
className: "text-sm", |
| 581 |
title: __( |
| 582 |
"Which travelers see this field", |
| 583 |
"yatra" |
| 584 |
), |
| 585 |
children: appliesToOptions.map((a) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: a.value, children: a.label }, a.value)) |
| 586 |
} |
| 587 |
), |
| 588 |
field.type === "tel" && /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 589 |
"label", |
| 590 |
{ |
| 591 |
className: "flex items-center gap-2 text-sm whitespace-nowrap px-1", |
| 592 |
title: __( |
| 593 |
"Show the international country flag + dial code selector on this phone field", |
| 594 |
"yatra" |
| 595 |
), |
| 596 |
children: [ |
| 597 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 598 |
"input", |
| 599 |
{ |
| 600 |
type: "checkbox", |
| 601 |
checked: field.show_country_code !== false, |
| 602 |
onChange: (e) => updateField(field.id, { |
| 603 |
show_country_code: e.target.checked |
| 604 |
}), |
| 605 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600" |
| 606 |
} |
| 607 |
), |
| 608 |
__("Show country code", "yatra") |
| 609 |
] |
| 610 |
} |
| 611 |
) |
| 612 |
] }), |
| 613 |
field.type === "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 614 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-medium", children: __("Content", "yatra") }), |
| 615 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 616 |
"textarea", |
| 617 |
{ |
| 618 |
value: field.content || "", |
| 619 |
onChange: (e) => updateField(field.id, { |
| 620 |
content: e.target.value |
| 621 |
}), |
| 622 |
rows: 4, |
| 623 |
placeholder: __( |
| 624 |
"Text shown to customers between fields. Basic HTML (bold, links, lists) is allowed.", |
| 625 |
"yatra" |
| 626 |
), |
| 627 |
className: "mt-1 w-full rounded-md border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 px-3 py-2 text-sm" |
| 628 |
} |
| 629 |
), |
| 630 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] text-gray-400 mt-0.5", children: __( |
| 631 |
"Display only — this is not an input and is not submitted by the customer.", |
| 632 |
"yatra" |
| 633 |
) }) |
| 634 |
] }), |
| 635 |
field.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-2 bg-gray-50 dark:bg-gray-900 rounded", children: [ |
| 636 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs text-gray-500 whitespace-nowrap", children: __("Field ID:", "yatra") }), |
| 637 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 638 |
Input, |
| 639 |
{ |
| 640 |
value: fieldIdDraft !== null ? fieldIdDraft : field.id, |
| 641 |
onChange: (e) => { |
| 642 |
if (!field.locked) { |
| 643 |
setFieldIdDraft(sanitizeId(e.target.value)); |
| 644 |
} |
| 645 |
}, |
| 646 |
onBlur: () => { |
| 647 |
if (fieldIdDraft === null) return; |
| 648 |
const next = fieldIdDraft; |
| 649 |
setFieldIdDraft(null); |
| 650 |
if (!field.locked && next !== "" && next !== field.id) { |
| 651 |
updateField(field.id, { id: next }); |
| 652 |
setEditingField( |
| 653 |
(cur) => cur === field.id ? next : cur |
| 654 |
); |
| 655 |
} |
| 656 |
}, |
| 657 |
onKeyDown: (e) => { |
| 658 |
if (e.key === "Enter") { |
| 659 |
e.preventDefault(); |
| 660 |
e.currentTarget.blur(); |
| 661 |
} |
| 662 |
}, |
| 663 |
placeholder: "field_id", |
| 664 |
className: "text-sm font-mono flex-1 max-w-xs", |
| 665 |
disabled: field.locked, |
| 666 |
title: field.locked ? "Locked fields cannot change ID" : "Field ID (lowercase, no spaces)" |
| 667 |
} |
| 668 |
), |
| 669 |
field.locked && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-amber-600", children: __("(locked)", "yatra") }) |
| 670 |
] }), |
| 671 |
field.type === "select" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700", children: [ |
| 672 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-2", children: [ |
| 673 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-medium", children: __("Dropdown Options", "yatra") }), |
| 674 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 675 |
Button, |
| 676 |
{ |
| 677 |
type: "button", |
| 678 |
variant: "ghost", |
| 679 |
size: "sm", |
| 680 |
onClick: () => { |
| 681 |
const newOptions = [ |
| 682 |
...field.options || [], |
| 683 |
{ value: "", label: "" } |
| 684 |
]; |
| 685 |
updateField(field.id, { |
| 686 |
options: newOptions |
| 687 |
}); |
| 688 |
}, |
| 689 |
className: "h-6 text-xs", |
| 690 |
children: [ |
| 691 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-3 h-3 mr-1" }), |
| 692 |
__("Add Option", "yatra") |
| 693 |
] |
| 694 |
} |
| 695 |
) |
| 696 |
] }), |
| 697 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 698 |
(field.options || []).map((option, optIndex) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 699 |
"div", |
| 700 |
{ |
| 701 |
className: "flex items-center gap-2", |
| 702 |
children: [ |
| 703 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 704 |
Input, |
| 705 |
{ |
| 706 |
value: option.value, |
| 707 |
onChange: (e) => { |
| 708 |
const newOptions = [ |
| 709 |
...field.options || [] |
| 710 |
]; |
| 711 |
newOptions[optIndex] = { |
| 712 |
...newOptions[optIndex], |
| 713 |
value: e.target.value |
| 714 |
}; |
| 715 |
updateField(field.id, { |
| 716 |
options: newOptions |
| 717 |
}); |
| 718 |
}, |
| 719 |
placeholder: "Value (e.g., spouse)", |
| 720 |
className: "text-xs flex-1" |
| 721 |
} |
| 722 |
), |
| 723 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 724 |
Input, |
| 725 |
{ |
| 726 |
value: option.label, |
| 727 |
onChange: (e) => { |
| 728 |
const newOptions = [ |
| 729 |
...field.options || [] |
| 730 |
]; |
| 731 |
newOptions[optIndex] = { |
| 732 |
...newOptions[optIndex], |
| 733 |
label: e.target.value |
| 734 |
}; |
| 735 |
updateField(field.id, { |
| 736 |
options: newOptions |
| 737 |
}); |
| 738 |
}, |
| 739 |
placeholder: "Label (e.g., Spouse/Partner)", |
| 740 |
className: "text-xs flex-1" |
| 741 |
} |
| 742 |
), |
| 743 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 744 |
"button", |
| 745 |
{ |
| 746 |
type: "button", |
| 747 |
onClick: () => { |
| 748 |
const newOptions = (field.options || []).filter((_, i) => i !== optIndex); |
| 749 |
updateField(field.id, { |
| 750 |
options: newOptions |
| 751 |
}); |
| 752 |
}, |
| 753 |
className: "p-1 text-gray-400 hover:text-red-500", |
| 754 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "w-3 h-3" }) |
| 755 |
} |
| 756 |
) |
| 757 |
] |
| 758 |
}, |
| 759 |
optIndex |
| 760 |
)), |
| 761 |
(!field.options || field.options.length === 0) && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-400 italic", children: __( |
| 762 |
'No options. Click "Add Option" to add dropdown choices.', |
| 763 |
"yatra" |
| 764 |
) }) |
| 765 |
] }) |
| 766 |
] }) |
| 767 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 flex-wrap", children: [ |
| 768 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-sm", children: field.type === "text_block" ? __("Text Block", "yatra") : field.label }), |
| 769 |
field.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "text-xs text-gray-500 dark:text-gray-400 px-1.5 py-0.5 bg-gray-100 dark:bg-gray-700 rounded font-mono", children: field.id }), |
| 770 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400 dark:text-gray-500 px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded", children: ((_a = fieldTypes.find((t) => t.value === field.type)) == null ? void 0 : _a.label) || field.type }), |
| 771 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400 dark:text-gray-500", children: ((_b = widthOptions.find((w) => w.value === field.width)) == null ? void 0 : _b.label) || "Full" }), |
| 772 |
field.type === "text_block" && field.content && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-gray-500 dark:text-gray-400 italic truncate max-w-[16rem]", children: [ |
| 773 |
'"', |
| 774 |
field.content.replace(/<[^>]*>/g, "").slice(0, 60), |
| 775 |
'"' |
| 776 |
] }), |
| 777 |
field.type === "select" && field.options && field.options.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-blue-500 dark:text-blue-400", children: [ |
| 778 |
"(", |
| 779 |
field.options.length, |
| 780 |
" ", |
| 781 |
field.options.length === 1 ? "option" : "options", |
| 782 |
")" |
| 783 |
] }), |
| 784 |
field.required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-red-500 font-medium", children: __("Required", "yatra") }), |
| 785 |
formType === "traveler_form" && field.applies_to === "lead" && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs px-1.5 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400 font-medium", children: __("Lead only", "yatra") }), |
| 786 |
field.locked && /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 787 |
"span", |
| 788 |
{ |
| 789 |
className: "inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 px-1.5 py-0.5 bg-amber-50 dark:bg-amber-900/20 rounded", |
| 790 |
title: "This field is protected and cannot be deleted", |
| 791 |
children: [ |
| 792 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Lock, { className: "w-3 h-3" }), |
| 793 |
"Locked" |
| 794 |
] |
| 795 |
} |
| 796 |
) |
| 797 |
] }) }), |
| 798 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [ |
| 799 |
field.type !== "text_block" && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 800 |
"button", |
| 801 |
{ |
| 802 |
type: "button", |
| 803 |
onClick: () => !field.locked && toggleFieldRequired(field.id), |
| 804 |
disabled: field.locked, |
| 805 |
className: `p-1.5 rounded ${field.locked ? "cursor-not-allowed opacity-50" : ""} ${field.required ? "text-red-500 bg-red-50 dark:bg-red-900/20" : "text-gray-400 hover:text-gray-600"}`, |
| 806 |
title: field.locked ? "This field is required and cannot be changed" : field.required ? "Make optional" : "Make required", |
| 807 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 808 |
Star, |
| 809 |
{ |
| 810 |
className: "w-4 h-4", |
| 811 |
fill: field.required ? "currentColor" : "none" |
| 812 |
} |
| 813 |
) |
| 814 |
} |
| 815 |
), |
| 816 |
!field.locked && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 817 |
"button", |
| 818 |
{ |
| 819 |
type: "button", |
| 820 |
onClick: () => toggleFieldEnabled(field.id), |
| 821 |
className: `p-1.5 rounded ${field.enabled ? "text-green-500" : "text-gray-400"}`, |
| 822 |
title: field.enabled ? "Disable field" : "Enable field", |
| 823 |
children: field.enabled ? /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "w-4 h-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { className: "w-4 h-4" }) |
| 824 |
} |
| 825 |
), |
| 826 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 827 |
"button", |
| 828 |
{ |
| 829 |
type: "button", |
| 830 |
onClick: () => setEditingField( |
| 831 |
editingField === field.id ? null : field.id |
| 832 |
), |
| 833 |
className: "p-1.5 rounded text-gray-400 hover:text-blue-500", |
| 834 |
title: "Edit field", |
| 835 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Pen, { className: "w-4 h-4" }) |
| 836 |
} |
| 837 |
), |
| 838 |
!field.locked && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 839 |
"button", |
| 840 |
{ |
| 841 |
type: "button", |
| 842 |
onClick: () => setDeleteConfirm({ |
| 843 |
isOpen: true, |
| 844 |
fieldId: field.id, |
| 845 |
fieldLabel: field.label |
| 846 |
}), |
| 847 |
className: "p-1.5 rounded text-gray-400 hover:text-red-500", |
| 848 |
title: "Delete field", |
| 849 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "w-4 h-4" }) |
| 850 |
} |
| 851 |
) |
| 852 |
] }) |
| 853 |
] |
| 854 |
}, |
| 855 |
field.id |
| 856 |
); |
| 857 |
}) }) |
| 858 |
] }) |
| 859 |
] }), |
| 860 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 861 |
ConfirmationDialog, |
| 862 |
{ |
| 863 |
isOpen: deleteConfirm.isOpen, |
| 864 |
onClose: () => setDeleteConfirm({ isOpen: false, fieldId: null, fieldLabel: "" }), |
| 865 |
onConfirm: () => { |
| 866 |
if (deleteConfirm.fieldId) { |
| 867 |
deleteField(deleteConfirm.fieldId); |
| 868 |
} |
| 869 |
}, |
| 870 |
title: __("Delete Field", "yatra"), |
| 871 |
message: `Are you sure you want to delete the field "${deleteConfirm.fieldLabel}"? This action cannot be undone.`, |
| 872 |
confirmText: __("Delete", "yatra"), |
| 873 |
cancelText: __("Cancel", "yatra"), |
| 874 |
variant: "danger" |
| 875 |
} |
| 876 |
) |
| 877 |
] }); |
| 878 |
}; |
| 879 |
const clone = (v) => JSON.parse(JSON.stringify(v)); |
| 880 |
const reorder = (fields) => fields.map((f, i) => ({ ...f, order: i + 1 })); |
| 881 |
const newConditionFrom = (section) => ({ |
| 882 |
id: `condition_${Date.now().toString(36)}`, |
| 883 |
targets: {}, |
| 884 |
title: section.title || "", |
| 885 |
description: section.description || "", |
| 886 |
fields: clone(section.fields || []) |
| 887 |
}); |
| 888 |
const BookingFormConditionsModal = ({ |
| 889 |
isOpen, |
| 890 |
onClose, |
| 891 |
formType, |
| 892 |
formLabel, |
| 893 |
section, |
| 894 |
onSave, |
| 895 |
fieldTypes, |
| 896 |
widthOptions, |
| 897 |
appliesToOptions |
| 898 |
}) => { |
| 899 |
const [draft, setDraft] = reactExports.useState([]); |
| 900 |
const [collapsed, setCollapsed] = reactExports.useState(/* @__PURE__ */ new Set()); |
| 901 |
const [addFromGlobal, setAddFromGlobal] = reactExports.useState(null); |
| 902 |
const [error, setError] = reactExports.useState(null); |
| 903 |
const { options: targetOptions } = useTripTargets(isOpen); |
| 904 |
reactExports.useEffect(() => { |
| 905 |
if (!isOpen) return; |
| 906 |
setDraft(clone(section.conditions || [])); |
| 907 |
setCollapsed(/* @__PURE__ */ new Set()); |
| 908 |
setAddFromGlobal(null); |
| 909 |
setError(null); |
| 910 |
}, [isOpen, section.conditions]); |
| 911 |
const globalFields = section.fields || []; |
| 912 |
const update = (ci, patch) => setDraft((d) => d.map((c, i) => i === ci ? { ...c, ...patch } : c)); |
| 913 |
const moveCondition = (ci, delta) => setDraft((d) => { |
| 914 |
const next = [...d]; |
| 915 |
const to = ci + delta; |
| 916 |
if (to < 0 || to >= next.length) return next; |
| 917 |
[next[ci], next[to]] = [next[to], next[ci]]; |
| 918 |
return next; |
| 919 |
}); |
| 920 |
const toggleCollapsed = (ci) => setCollapsed((s) => { |
| 921 |
const n = new Set(s); |
| 922 |
if (n.has(ci)) n.delete(ci); |
| 923 |
else n.add(ci); |
| 924 |
return n; |
| 925 |
}); |
| 926 |
const addCondition = () => { |
| 927 |
setDraft((d) => [...d, newConditionFrom(section)]); |
| 928 |
setCollapsed(new Set(draft.map((_, i) => i))); |
| 929 |
}; |
| 930 |
const done = () => { |
| 931 |
const bad = draft.findIndex((c) => !hasTargets(c.targets)); |
| 932 |
if (bad >= 0) { |
| 933 |
setError( |
| 934 |
sprintf( |
| 935 |
__( |
| 936 |
"Condition %d needs at least one trip, category or trip type.", |
| 937 |
"yatra" |
| 938 |
), |
| 939 |
bad + 1 |
| 940 |
) |
| 941 |
); |
| 942 |
setCollapsed((s) => { |
| 943 |
const n = new Set(s); |
| 944 |
n.delete(bad); |
| 945 |
return n; |
| 946 |
}); |
| 947 |
return; |
| 948 |
} |
| 949 |
onSave(draft); |
| 950 |
onClose(); |
| 951 |
}; |
| 952 |
const typeLabel = (t) => { |
| 953 |
var _a; |
| 954 |
return ((_a = fieldTypes.find((x) => x.value === t)) == null ? void 0 : _a.label) || t; |
| 955 |
}; |
| 956 |
const renderCondition = (c, ci) => { |
| 957 |
const isCollapsed = collapsed.has(ci); |
| 958 |
const missingFromGlobal = globalFields.filter( |
| 959 |
(g) => !c.fields.some((f) => f.id === g.id) |
| 960 |
); |
| 961 |
const enabledCount = c.fields.filter((f) => f.enabled !== false).length; |
| 962 |
const where = describeTargets(c.targets, targetOptions); |
| 963 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 964 |
"div", |
| 965 |
{ |
| 966 |
className: "rounded-lg border border-gray-200 dark:border-gray-700 border-l-4 border-l-purple-500 overflow-hidden", |
| 967 |
"data-testid": `condition-${ci}`, |
| 968 |
children: [ |
| 969 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800/60 border-b border-gray-200 dark:border-gray-700", children: [ |
| 970 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[11px] font-mono font-semibold px-1.5 py-0.5 rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300", children: sprintf(__("COND %d", "yatra"), ci + 1) }), |
| 971 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm font-semibold", children: where || __("Choose where this applies", "yatra") }), |
| 972 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-500", children: sprintf( |
| 973 |
__("→ “%1$s” · %2$d fields", "yatra"), |
| 974 |
c.title, |
| 975 |
enabledCount |
| 976 |
) }), |
| 977 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex-1" }), |
| 978 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 979 |
"button", |
| 980 |
{ |
| 981 |
type: "button", |
| 982 |
className: "p-1 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 disabled:opacity-30", |
| 983 |
disabled: ci === 0, |
| 984 |
onClick: () => moveCondition(ci, -1), |
| 985 |
title: __("Higher priority", "yatra"), |
| 986 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronUp, { className: "w-4 h-4" }) |
| 987 |
} |
| 988 |
), |
| 989 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 990 |
"button", |
| 991 |
{ |
| 992 |
type: "button", |
| 993 |
className: "p-1 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 disabled:opacity-30", |
| 994 |
disabled: ci === draft.length - 1, |
| 995 |
onClick: () => moveCondition(ci, 1), |
| 996 |
title: __("Lower priority", "yatra"), |
| 997 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "w-4 h-4" }) |
| 998 |
} |
| 999 |
), |
| 1000 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1001 |
Button, |
| 1002 |
{ |
| 1003 |
type: "button", |
| 1004 |
variant: "ghost", |
| 1005 |
size: "sm", |
| 1006 |
onClick: () => { |
| 1007 |
const fresh = newConditionFrom(section); |
| 1008 |
update(ci, { |
| 1009 |
title: fresh.title, |
| 1010 |
description: fresh.description, |
| 1011 |
fields: fresh.fields |
| 1012 |
}); |
| 1013 |
}, |
| 1014 |
title: __( |
| 1015 |
"Replace this condition's form with a fresh copy of the global form", |
| 1016 |
"yatra" |
| 1017 |
), |
| 1018 |
children: [ |
| 1019 |
/* @__PURE__ */ jsxRuntimeExports.jsx(RotateCcw, { className: "w-3 h-3 mr-1" }), |
| 1020 |
__("Reset to global form", "yatra") |
| 1021 |
] |
| 1022 |
} |
| 1023 |
), |
| 1024 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1025 |
Button, |
| 1026 |
{ |
| 1027 |
type: "button", |
| 1028 |
variant: "ghost", |
| 1029 |
size: "sm", |
| 1030 |
className: "text-red-600", |
| 1031 |
onClick: () => setDraft((d) => d.filter((_, i) => i !== ci)), |
| 1032 |
children: __("Remove", "yatra") |
| 1033 |
} |
| 1034 |
), |
| 1035 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1036 |
Button, |
| 1037 |
{ |
| 1038 |
type: "button", |
| 1039 |
variant: "ghost", |
| 1040 |
size: "sm", |
| 1041 |
onClick: () => toggleCollapsed(ci), |
| 1042 |
children: isCollapsed ? __("Expand", "yatra") : __("Collapse", "yatra") |
| 1043 |
} |
| 1044 |
) |
| 1045 |
] }), |
| 1046 |
!isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 space-y-4", children: [ |
| 1047 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1048 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { className: "text-xs", children: [ |
| 1049 |
__("Use this form on", "yatra"), |
| 1050 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-2 font-normal text-gray-400", children: __( |
| 1051 |
"trips, categories or trip types — any match applies", |
| 1052 |
"yatra" |
| 1053 |
) }) |
| 1054 |
] }), |
| 1055 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1056 |
MultiSelect, |
| 1057 |
{ |
| 1058 |
value: encodeTargets(c.targets), |
| 1059 |
onChange: (vals) => update(ci, { targets: decodeTargets(vals) }), |
| 1060 |
options: targetOptions, |
| 1061 |
placeholder: __( |
| 1062 |
"Search trips, categories, trip types…", |
| 1063 |
"yatra" |
| 1064 |
), |
| 1065 |
className: "mt-1" |
| 1066 |
} |
| 1067 |
), |
| 1068 |
!hasTargets(c.targets) && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-red-600 mt-1", children: __( |
| 1069 |
"Pick at least one trip, category or trip type.", |
| 1070 |
"yatra" |
| 1071 |
) }) |
| 1072 |
] }), |
| 1073 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-lg border border-gray-200 dark:border-gray-700", children: [ |
| 1074 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-3 py-2 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between", children: [ |
| 1075 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm font-semibold", children: __("Form Section Settings", "yatra") }), |
| 1076 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400", children: __("for these trips", "yatra") }) |
| 1077 |
] }), |
| 1078 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 grid grid-cols-1 md:grid-cols-2 gap-3", children: [ |
| 1079 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1080 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Section Title", "yatra") }), |
| 1081 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1082 |
Input, |
| 1083 |
{ |
| 1084 |
value: c.title, |
| 1085 |
onChange: (e) => update(ci, { title: e.target.value }), |
| 1086 |
className: "mt-1 text-sm", |
| 1087 |
"data-testid": `condition-${ci}-title` |
| 1088 |
} |
| 1089 |
) |
| 1090 |
] }), |
| 1091 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1092 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: __("Section Description", "yatra") }), |
| 1093 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1094 |
Input, |
| 1095 |
{ |
| 1096 |
value: c.description, |
| 1097 |
onChange: (e) => update(ci, { description: e.target.value }), |
| 1098 |
className: "mt-1 text-sm" |
| 1099 |
} |
| 1100 |
) |
| 1101 |
] }) |
| 1102 |
] }) |
| 1103 |
] }), |
| 1104 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1105 |
BookingFormFieldsEditor, |
| 1106 |
{ |
| 1107 |
formType, |
| 1108 |
fields: c.fields, |
| 1109 |
onChange: (fields) => update(ci, { fields }), |
| 1110 |
fieldTypes, |
| 1111 |
widthOptions, |
| 1112 |
appliesToOptions, |
| 1113 |
headerExtra: addFromGlobal === ci ? /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1114 |
Select, |
| 1115 |
{ |
| 1116 |
autoFocus: true, |
| 1117 |
className: "text-sm h-9 w-56", |
| 1118 |
value: "", |
| 1119 |
onChange: (e) => { |
| 1120 |
const g = globalFields.find( |
| 1121 |
(f) => f.id === e.target.value |
| 1122 |
); |
| 1123 |
if (g) { |
| 1124 |
update(ci, { |
| 1125 |
fields: reorder([...c.fields, clone(g)]) |
| 1126 |
}); |
| 1127 |
} |
| 1128 |
setAddFromGlobal(null); |
| 1129 |
}, |
| 1130 |
onBlur: () => setAddFromGlobal(null), |
| 1131 |
"data-testid": "add-from-global-select", |
| 1132 |
children: [ |
| 1133 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: __("Pick a global field…", "yatra") }), |
| 1134 |
missingFromGlobal.map((g) => /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: g.id, children: [ |
| 1135 |
g.type === "text_block" ? __("Text Block", "yatra") : g.label, |
| 1136 |
" ", |
| 1137 |
"(", |
| 1138 |
typeLabel(g.type), |
| 1139 |
")" |
| 1140 |
] }, g.id)) |
| 1141 |
] |
| 1142 |
} |
| 1143 |
) : /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1144 |
Button, |
| 1145 |
{ |
| 1146 |
type: "button", |
| 1147 |
size: "sm", |
| 1148 |
variant: "outline", |
| 1149 |
disabled: missingFromGlobal.length === 0, |
| 1150 |
onClick: () => setAddFromGlobal(ci), |
| 1151 |
title: missingFromGlobal.length === 0 ? __( |
| 1152 |
"Every global field is already in this condition", |
| 1153 |
"yatra" |
| 1154 |
) : void 0, |
| 1155 |
"data-testid": "add-from-global", |
| 1156 |
children: __("Add from global form", "yatra") |
| 1157 |
} |
| 1158 |
) |
| 1159 |
} |
| 1160 |
) |
| 1161 |
] }) |
| 1162 |
] |
| 1163 |
}, |
| 1164 |
c.id |
| 1165 |
); |
| 1166 |
}; |
| 1167 |
return /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1168 |
Modal, |
| 1169 |
{ |
| 1170 |
isOpen, |
| 1171 |
onClose, |
| 1172 |
size: "xl", |
| 1173 |
title: sprintf(__("Conditions — %s", "yatra"), formLabel), |
| 1174 |
description: __( |
| 1175 |
"Give some trips their own version of this form. Each condition is a full copy of the form builder — change the section title, add or remove fields, reorder, edit labels, required, widths and options — and applies only to the trips it names.", |
| 1176 |
"yatra" |
| 1177 |
), |
| 1178 |
footer: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3 w-full", children: [ |
| 1179 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-500", children: __( |
| 1180 |
"Conditions are saved with Save Settings, like every other form change.", |
| 1181 |
"yatra" |
| 1182 |
) }), |
| 1183 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 1184 |
error && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-red-600", children: error }), |
| 1185 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: __("Cancel", "yatra") }), |
| 1186 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "button", onClick: done, "data-testid": "conditions-done", children: __("Done", "yatra") }) |
| 1187 |
] }) |
| 1188 |
] }), |
| 1189 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", "data-testid": "conditions-modal", children: [ |
| 1190 |
draft.length === 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500", children: __( |
| 1191 |
"No conditions yet — every trip uses the global form. Add one to give some trips their own version.", |
| 1192 |
"yatra" |
| 1193 |
) }), |
| 1194 |
draft.map(renderCondition), |
| 1195 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1196 |
"button", |
| 1197 |
{ |
| 1198 |
type: "button", |
| 1199 |
className: "w-full flex items-center justify-center gap-2 p-3 rounded-lg border border-dashed border-gray-300 dark:border-gray-600 text-sm text-gray-500 hover:border-purple-500 hover:text-purple-700 hover:bg-purple-50 dark:hover:bg-purple-900/10", |
| 1200 |
onClick: addCondition, |
| 1201 |
"data-testid": "add-condition", |
| 1202 |
children: [ |
| 1203 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4" }), |
| 1204 |
__("Add condition", "yatra"), |
| 1205 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-400", children: __("— starts as a copy of the global form", "yatra") }) |
| 1206 |
] |
| 1207 |
} |
| 1208 |
), |
| 1209 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 rounded-lg bg-gray-50 dark:bg-gray-800/60 text-sm", children: [ |
| 1210 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold", children: __("All other trips", "yatra") }), |
| 1211 |
" ", |
| 1212 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-500", children: __( |
| 1213 |
"Trips that match no condition use the global form behind this popup — the behaviour before conditions existed.", |
| 1214 |
"yatra" |
| 1215 |
) }) |
| 1216 |
] }) |
| 1217 |
] }) |
| 1218 |
} |
| 1219 |
); |
| 1220 |
}; |
| 1221 |
const MultipleTaxesEditor = React.memo( |
| 1222 |
({ |
| 1223 |
taxes, |
| 1224 |
onChange |
| 1225 |
}) => { |
| 1226 |
const removeTax = (index) => { |
| 1227 |
onChange(taxes.filter((_, i) => i !== index)); |
| 1228 |
}; |
| 1229 |
const updateTax = (index, field, value) => { |
| 1230 |
const updated = [...taxes]; |
| 1231 |
if (field === "rate") { |
| 1232 |
updated[index].rate = parseFloat(value) || 0; |
| 1233 |
} else { |
| 1234 |
updated[index].name = value; |
| 1235 |
} |
| 1236 |
onChange(updated); |
| 1237 |
}; |
| 1238 |
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-3", children: taxes.filter((tax) => tax.name && tax.name.trim() !== "").map((tax, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1239 |
"div", |
| 1240 |
{ |
| 1241 |
className: "relative p-4 border rounded-lg bg-gray-50 dark:bg-gray-800 w-full", |
| 1242 |
children: [ |
| 1243 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1244 |
Button, |
| 1245 |
{ |
| 1246 |
type: "button", |
| 1247 |
variant: "outline", |
| 1248 |
size: "sm", |
| 1249 |
onClick: () => removeTax(index), |
| 1250 |
className: "absolute top-3 right-3 text-red-600 hover:text-red-700 p-2", |
| 1251 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "w-4 h-4" }) |
| 1252 |
} |
| 1253 |
), |
| 1254 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 pr-12", children: [ |
| 1255 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1256 |
Input, |
| 1257 |
{ |
| 1258 |
value: tax.name, |
| 1259 |
onChange: (e) => updateTax(index, "name", e.target.value), |
| 1260 |
placeholder: __("Tax name (e.g., VAT, GST)", "yatra"), |
| 1261 |
className: "w-full" |
| 1262 |
} |
| 1263 |
) }), |
| 1264 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [ |
| 1265 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1266 |
Input, |
| 1267 |
{ |
| 1268 |
type: "number", |
| 1269 |
value: tax.rate, |
| 1270 |
onChange: (e) => updateTax(index, "rate", e.target.value), |
| 1271 |
min: "0", |
| 1272 |
max: "100", |
| 1273 |
step: "0.01", |
| 1274 |
placeholder: __("Rate", "yatra"), |
| 1275 |
className: "w-full" |
| 1276 |
} |
| 1277 |
), |
| 1278 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "%" }) |
| 1279 |
] }) }) |
| 1280 |
] }) |
| 1281 |
] |
| 1282 |
}, |
| 1283 |
index |
| 1284 |
)) }) }); |
| 1285 |
} |
| 1286 |
); |
| 1287 |
const FormField = React.memo( |
| 1288 |
({ |
| 1289 |
id, |
| 1290 |
label, |
| 1291 |
description, |
| 1292 |
required = false, |
| 1293 |
actionButton, |
| 1294 |
children |
| 1295 |
}) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 1296 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { htmlFor: id, className: "flex items-center gap-1.5", children: [ |
| 1297 |
label, |
| 1298 |
required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 1299 |
] }), |
| 1300 |
description && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 flex items-start gap-1.5", children: [ |
| 1301 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-3.5 h-3.5 mt-0.5 flex-shrink-0" }), |
| 1302 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "min-w-0 leading-relaxed", children: description }) |
| 1303 |
] }), |
| 1304 |
actionButton ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [ |
| 1305 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children }), |
| 1306 |
actionButton |
| 1307 |
] }) : children |
| 1308 |
] }) |
| 1309 |
); |
| 1310 |
FormField.displayName = "FormField"; |
| 1311 |
const GoogleCalendarIntegrationSection = ({ formData, setFormData }) => { |
| 1312 |
const yatraAdmin = window.yatraAdmin || {}; |
| 1313 |
const gcSettings = yatraAdmin.googleCalendar || {}; |
| 1314 |
const siteUrl = yatraAdmin.siteUrl || ""; |
| 1315 |
const gcDashboardUrl = `${yatraAdmin.adminUrl || "admin.php"}?page=yatra&subpage=google-calendar`; |
| 1316 |
const [clientId, setClientId] = reactExports.useState( |
| 1317 |
formData.google_calendar_client_id || gcSettings.client_id || "" |
| 1318 |
); |
| 1319 |
const [clientSecret, setClientSecret] = reactExports.useState( |
| 1320 |
formData.google_calendar_client_secret || gcSettings.client_secret || "" |
| 1321 |
); |
| 1322 |
const [calendarId, setCalendarId] = reactExports.useState( |
| 1323 |
formData.google_calendar_calendar_id || gcSettings.calendar_id || "" |
| 1324 |
); |
| 1325 |
const [calendarName, setCalendarName] = reactExports.useState( |
| 1326 |
formData.google_calendar_calendar_name || gcSettings.calendar_name || "" |
| 1327 |
); |
| 1328 |
const [connected, setConnected] = reactExports.useState( |
| 1329 |
formData.google_calendar_connected || gcSettings.connected || false |
| 1330 |
); |
| 1331 |
const [connecting, setConnecting] = reactExports.useState(false); |
| 1332 |
const [syncing, setSyncing] = reactExports.useState(false); |
| 1333 |
const [savingCalendar, setSavingCalendar] = reactExports.useState(false); |
| 1334 |
const { showToast } = useToast(); |
| 1335 |
const redirectUri = yatraAdmin.googleCalendarRedirectUri || gcSettings.redirect_uri || `${siteUrl}/wp-json/yatra/v1/google-calendar/callback`; |
| 1336 |
const lastSync = formData.google_calendar_last_sync || gcSettings.last_sync || null; |
| 1337 |
const syncSettingsToFormData = () => { |
| 1338 |
const allSettings = { |
| 1339 |
google_calendar_client_id: clientId, |
| 1340 |
google_calendar_client_secret: clientSecret, |
| 1341 |
google_calendar_enabled: true, |
| 1342 |
// Enable by default when settings are provided |
| 1343 |
// Persist the target calendar through the MAIN page Save too (the option |
| 1344 |
// name matches what the sync path reads), so the user's natural action — |
| 1345 |
// clicking the page's Save button — keeps the chosen calendar. |
| 1346 |
google_calendar_calendar_id: calendarId, |
| 1347 |
google_calendar_calendar_name: calendarName |
| 1348 |
}; |
| 1349 |
setFormData((prev) => { |
| 1350 |
if (!prev) return prev; |
| 1351 |
return { |
| 1352 |
...prev, |
| 1353 |
...allSettings |
| 1354 |
}; |
| 1355 |
}); |
| 1356 |
}; |
| 1357 |
reactExports.useEffect(() => { |
| 1358 |
syncSettingsToFormData(); |
| 1359 |
}, [clientId, clientSecret, calendarId, calendarName]); |
| 1360 |
const handleConnect = async () => { |
| 1361 |
var _a; |
| 1362 |
setConnecting(true); |
| 1363 |
try { |
| 1364 |
const response = await apiClient.post("/google-calendar/connect"); |
| 1365 |
if ((_a = response.data) == null ? void 0 : _a.auth_url) { |
| 1366 |
window.open(response.data.auth_url, "_blank"); |
| 1367 |
} |
| 1368 |
} catch (error) { |
| 1369 |
console.error("Failed to connect:", error); |
| 1370 |
} finally { |
| 1371 |
setConnecting(false); |
| 1372 |
} |
| 1373 |
}; |
| 1374 |
const handleDisconnect = async () => { |
| 1375 |
if (!confirm( |
| 1376 |
__( |
| 1377 |
"Are you sure you want to disconnect from Google Calendar?", |
| 1378 |
"yatra" |
| 1379 |
) |
| 1380 |
)) { |
| 1381 |
return; |
| 1382 |
} |
| 1383 |
try { |
| 1384 |
await apiClient.post("/google-calendar/disconnect"); |
| 1385 |
setConnected(false); |
| 1386 |
setCalendarId(""); |
| 1387 |
setCalendarName(""); |
| 1388 |
showToast(__("Disconnected from Google Calendar.", "yatra"), "success"); |
| 1389 |
} catch (error) { |
| 1390 |
showToast( |
| 1391 |
__("Failed to disconnect. Please try again.", "yatra"), |
| 1392 |
"error" |
| 1393 |
); |
| 1394 |
} |
| 1395 |
}; |
| 1396 |
const handleSync = async () => { |
| 1397 |
setSyncing(true); |
| 1398 |
try { |
| 1399 |
const res = await apiClient.post("/google-calendar/sync-all"); |
| 1400 |
if (res && res.success === false) { |
| 1401 |
showToast( |
| 1402 |
res.message || __("Failed to sync bookings.", "yatra"), |
| 1403 |
"error" |
| 1404 |
); |
| 1405 |
} else { |
| 1406 |
showToast( |
| 1407 |
res && res.message || __("Bookings synced to Google Calendar.", "yatra"), |
| 1408 |
"success" |
| 1409 |
); |
| 1410 |
} |
| 1411 |
} catch (error) { |
| 1412 |
showToast( |
| 1413 |
__("Failed to sync bookings. Please try again.", "yatra"), |
| 1414 |
"error" |
| 1415 |
); |
| 1416 |
} finally { |
| 1417 |
setSyncing(false); |
| 1418 |
} |
| 1419 |
}; |
| 1420 |
const handleSaveCalendar = async () => { |
| 1421 |
setSavingCalendar(true); |
| 1422 |
try { |
| 1423 |
await apiClient.post("/google-calendar/settings", { |
| 1424 |
calendar_id: calendarId.trim(), |
| 1425 |
calendar_name: calendarName.trim() |
| 1426 |
}); |
| 1427 |
showToast(__("Calendar settings saved.", "yatra"), "success"); |
| 1428 |
} catch (error) { |
| 1429 |
showToast( |
| 1430 |
__("Failed to save calendar settings. Please try again.", "yatra"), |
| 1431 |
"error" |
| 1432 |
); |
| 1433 |
} finally { |
| 1434 |
setSavingCalendar(false); |
| 1435 |
} |
| 1436 |
}; |
| 1437 |
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 1438 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [ |
| 1439 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-lg flex items-center gap-2", children: [ |
| 1440 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-5 h-5 text-blue-500" }), |
| 1441 |
__("Google Calendar Settings", "yatra") |
| 1442 |
] }), |
| 1443 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center gap-2", children: connected ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-green-600 dark:text-green-400", children: [ |
| 1444 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }), |
| 1445 |
__("Connected", "yatra") |
| 1446 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-gray-500 dark:text-gray-400", children: [ |
| 1447 |
/* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-4 h-4" }), |
| 1448 |
__("Not Connected", "yatra") |
| 1449 |
] }) }) |
| 1450 |
] }), |
| 1451 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-4", children: [ |
| 1452 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300", children: __( |
| 1453 |
"Connect your Google Calendar to automatically sync bookings and departures. Events will be created for each booking with trip details, traveler information, and departure dates.", |
| 1454 |
"yatra" |
| 1455 |
) }), |
| 1456 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [ |
| 1457 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1458 |
FormField, |
| 1459 |
{ |
| 1460 |
id: "gc_client_id", |
| 1461 |
label: __("Client ID", "yatra"), |
| 1462 |
description: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 1463 |
__("Create an OAuth client in", "yatra"), |
| 1464 |
" ", |
| 1465 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1466 |
"a", |
| 1467 |
{ |
| 1468 |
href: "https://console.cloud.google.com/apis/credentials", |
| 1469 |
target: "_blank", |
| 1470 |
rel: "noopener noreferrer", |
| 1471 |
className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline", |
| 1472 |
children: __("Google Cloud Credentials", "yatra") |
| 1473 |
} |
| 1474 |
), |
| 1475 |
__(", then paste the OAuth 2.0 Client ID here.", "yatra"), |
| 1476 |
" ", |
| 1477 |
__("Example:", "yatra"), |
| 1478 |
" ", |
| 1479 |
/* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "font-mono", children: "123...apps.googleusercontent.com" }) |
| 1480 |
] }), |
| 1481 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1482 |
Input, |
| 1483 |
{ |
| 1484 |
id: "gc_client_id", |
| 1485 |
value: clientId, |
| 1486 |
onChange: (e) => setClientId(e.target.value), |
| 1487 |
placeholder: "123456789-xxxxx.apps.googleusercontent.com" |
| 1488 |
} |
| 1489 |
) |
| 1490 |
} |
| 1491 |
), |
| 1492 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1493 |
FormField, |
| 1494 |
{ |
| 1495 |
id: "gc_client_secret", |
| 1496 |
label: __("Client Secret", "yatra"), |
| 1497 |
description: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 1498 |
__( |
| 1499 |
"Copy the Client Secret from the same OAuth client in", |
| 1500 |
"yatra" |
| 1501 |
), |
| 1502 |
" ", |
| 1503 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1504 |
"a", |
| 1505 |
{ |
| 1506 |
href: "https://console.cloud.google.com/apis/credentials", |
| 1507 |
target: "_blank", |
| 1508 |
rel: "noopener noreferrer", |
| 1509 |
className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline", |
| 1510 |
children: __("Google Cloud Credentials", "yatra") |
| 1511 |
} |
| 1512 |
), |
| 1513 |
__(".", "yatra"), |
| 1514 |
" ", |
| 1515 |
__("Keep this private.", "yatra") |
| 1516 |
] }), |
| 1517 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1518 |
Input, |
| 1519 |
{ |
| 1520 |
id: "gc_client_secret", |
| 1521 |
type: "password", |
| 1522 |
value: clientSecret, |
| 1523 |
onChange: (e) => setClientSecret(e.target.value), |
| 1524 |
placeholder: "GOCSPX-xxxxxxxxxxxxxxxxxx" |
| 1525 |
} |
| 1526 |
) |
| 1527 |
} |
| 1528 |
) |
| 1529 |
] }), |
| 1530 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1531 |
FormField, |
| 1532 |
{ |
| 1533 |
id: "gc_redirect_uri", |
| 1534 |
label: __("Redirect URI (OAuth Callback URL)", "yatra"), |
| 1535 |
description: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 1536 |
__( |
| 1537 |
'Add this to your OAuth client under "Authorized redirect URIs" in', |
| 1538 |
"yatra" |
| 1539 |
), |
| 1540 |
" ", |
| 1541 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1542 |
"a", |
| 1543 |
{ |
| 1544 |
href: "https://console.cloud.google.com/apis/credentials", |
| 1545 |
target: "_blank", |
| 1546 |
rel: "noopener noreferrer", |
| 1547 |
className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline", |
| 1548 |
children: __("Google Cloud Credentials", "yatra") |
| 1549 |
} |
| 1550 |
), |
| 1551 |
__(".", "yatra"), |
| 1552 |
" ", |
| 1553 |
__("Make sure the", "yatra"), |
| 1554 |
" ", |
| 1555 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1556 |
"a", |
| 1557 |
{ |
| 1558 |
href: "https://console.cloud.google.com/apis/library/calendar-json.googleapis.com", |
| 1559 |
target: "_blank", |
| 1560 |
rel: "noopener noreferrer", |
| 1561 |
className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline", |
| 1562 |
children: __("Google Calendar API", "yatra") |
| 1563 |
} |
| 1564 |
), |
| 1565 |
" ", |
| 1566 |
__("is enabled.", "yatra") |
| 1567 |
] }), |
| 1568 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 1569 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1570 |
Input, |
| 1571 |
{ |
| 1572 |
id: "gc_redirect_uri", |
| 1573 |
value: redirectUri, |
| 1574 |
readOnly: true, |
| 1575 |
className: "bg-gray-50 dark:bg-gray-900 font-mono text-sm" |
| 1576 |
} |
| 1577 |
), |
| 1578 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1579 |
Button, |
| 1580 |
{ |
| 1581 |
variant: "outline", |
| 1582 |
size: "sm", |
| 1583 |
onClick: () => navigator.clipboard.writeText(redirectUri), |
| 1584 |
children: __("Copy", "yatra") |
| 1585 |
} |
| 1586 |
) |
| 1587 |
] }) |
| 1588 |
} |
| 1589 |
), |
| 1590 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-md", children: [ |
| 1591 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-amber-800 dark:text-amber-300 flex items-start gap-2", children: [ |
| 1592 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Shield, { className: "w-4 h-4 mt-0.5 flex-shrink-0" }), |
| 1593 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0 leading-relaxed", children: [ |
| 1594 |
__( |
| 1595 |
"OAuth scopes required (add these on the Google OAuth consent screen):", |
| 1596 |
"yatra" |
| 1597 |
), |
| 1598 |
" ", |
| 1599 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1600 |
"a", |
| 1601 |
{ |
| 1602 |
href: "https://console.cloud.google.com/apis/credentials/consent", |
| 1603 |
target: "_blank", |
| 1604 |
rel: "noopener noreferrer", |
| 1605 |
className: "text-amber-900 dark:text-amber-200 underline", |
| 1606 |
children: __("OAuth Consent Screen", "yatra") |
| 1607 |
} |
| 1608 |
) |
| 1609 |
] }) |
| 1610 |
] }), |
| 1611 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 space-y-1", children: [ |
| 1612 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-amber-800 dark:text-amber-300 flex items-start gap-2", children: [ |
| 1613 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4 mt-0.5 flex-shrink-0" }), |
| 1614 |
/* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "text-[11px] bg-amber-100 dark:bg-amber-900/40 px-1 py-0.5 rounded", children: "https://www.googleapis.com/auth/calendar" }) |
| 1615 |
] }), |
| 1616 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-amber-800 dark:text-amber-300 flex items-start gap-2", children: [ |
| 1617 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4 mt-0.5 flex-shrink-0" }), |
| 1618 |
/* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "text-[11px] bg-amber-100 dark:bg-amber-900/40 px-1 py-0.5 rounded", children: "https://www.googleapis.com/auth/calendar.events" }) |
| 1619 |
] }) |
| 1620 |
] }) |
| 1621 |
] }), |
| 1622 |
connected && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-md space-y-4", children: [ |
| 1623 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("h4", { className: "font-medium text-sm text-green-800 dark:text-green-400 flex items-center gap-2", children: [ |
| 1624 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }), |
| 1625 |
__("Connected Calendar", "yatra") |
| 1626 |
] }), |
| 1627 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4 md:items-end", children: [ |
| 1628 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1629 |
FormField, |
| 1630 |
{ |
| 1631 |
id: "gc_calendar_id", |
| 1632 |
label: __("Calendar ID", "yatra"), |
| 1633 |
description: __( |
| 1634 |
'The ID of the Google Calendar to sync events to. Use "primary" for your main calendar, or enter a specific calendar ID.', |
| 1635 |
"yatra" |
| 1636 |
), |
| 1637 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1638 |
Input, |
| 1639 |
{ |
| 1640 |
id: "gc_calendar_id", |
| 1641 |
value: calendarId, |
| 1642 |
onChange: (e) => setCalendarId(e.target.value), |
| 1643 |
placeholder: "primary" |
| 1644 |
} |
| 1645 |
) |
| 1646 |
} |
| 1647 |
), |
| 1648 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1649 |
FormField, |
| 1650 |
{ |
| 1651 |
id: "gc_calendar_name", |
| 1652 |
label: __("Calendar Name", "yatra"), |
| 1653 |
description: __( |
| 1654 |
"A friendly name for this calendar connection (for your reference only).", |
| 1655 |
"yatra" |
| 1656 |
), |
| 1657 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1658 |
Input, |
| 1659 |
{ |
| 1660 |
id: "gc_calendar_name", |
| 1661 |
value: calendarName, |
| 1662 |
onChange: (e) => setCalendarName(e.target.value), |
| 1663 |
placeholder: __("My Booking Calendar", "yatra") |
| 1664 |
} |
| 1665 |
) |
| 1666 |
} |
| 1667 |
) |
| 1668 |
] }), |
| 1669 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between pt-2 border-t border-green-200 dark:border-green-800", children: [ |
| 1670 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-green-700 dark:text-green-400", children: lastSync ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 1671 |
__("Last sync:", "yatra"), |
| 1672 |
" ", |
| 1673 |
new Date(lastSync).toLocaleString() |
| 1674 |
] }) : __("Never synced", "yatra") }), |
| 1675 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 1676 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1677 |
"a", |
| 1678 |
{ |
| 1679 |
href: gcDashboardUrl, |
| 1680 |
className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md border border-green-300 dark:border-green-700 text-green-800 dark:text-green-300 hover:bg-green-100 dark:hover:bg-green-900/40", |
| 1681 |
children: [ |
| 1682 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-4 h-4" }), |
| 1683 |
__("Open dashboard", "yatra") |
| 1684 |
] |
| 1685 |
} |
| 1686 |
), |
| 1687 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1688 |
Button, |
| 1689 |
{ |
| 1690 |
size: "sm", |
| 1691 |
onClick: handleSaveCalendar, |
| 1692 |
disabled: savingCalendar, |
| 1693 |
className: "flex items-center gap-2", |
| 1694 |
children: [ |
| 1695 |
savingCalendar ? /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }), |
| 1696 |
__("Save Calendar", "yatra") |
| 1697 |
] |
| 1698 |
} |
| 1699 |
), |
| 1700 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1701 |
Button, |
| 1702 |
{ |
| 1703 |
variant: "outline", |
| 1704 |
size: "sm", |
| 1705 |
onClick: handleSync, |
| 1706 |
disabled: syncing, |
| 1707 |
className: "flex items-center gap-2", |
| 1708 |
children: [ |
| 1709 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1710 |
RefreshCw, |
| 1711 |
{ |
| 1712 |
className: `w-4 h-4 ${syncing ? "animate-spin" : ""}` |
| 1713 |
} |
| 1714 |
), |
| 1715 |
__("Sync Now", "yatra") |
| 1716 |
] |
| 1717 |
} |
| 1718 |
) |
| 1719 |
] }) |
| 1720 |
] }) |
| 1721 |
] }), |
| 1722 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap justify-between items-center gap-3 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700", children: [ |
| 1723 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap gap-3", children: [ |
| 1724 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1725 |
"a", |
| 1726 |
{ |
| 1727 |
href: gcDashboardUrl, |
| 1728 |
className: "flex items-center gap-1 text-blue-600 hover:text-blue-500 dark:text-blue-400 text-sm font-medium", |
| 1729 |
children: [ |
| 1730 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-3.5 h-3.5" }), |
| 1731 |
__("Open Google Calendar dashboard", "yatra") |
| 1732 |
] |
| 1733 |
} |
| 1734 |
), |
| 1735 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1736 |
"a", |
| 1737 |
{ |
| 1738 |
href: "https://console.cloud.google.com/apis/credentials", |
| 1739 |
target: "_blank", |
| 1740 |
rel: "noopener noreferrer", |
| 1741 |
className: "flex items-center gap-1 text-blue-600 hover:text-blue-500 dark:text-blue-400 text-sm", |
| 1742 |
children: [ |
| 1743 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }), |
| 1744 |
__("Credentials", "yatra") |
| 1745 |
] |
| 1746 |
} |
| 1747 |
), |
| 1748 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1749 |
"a", |
| 1750 |
{ |
| 1751 |
href: "https://console.cloud.google.com/apis/library/calendar-json.googleapis.com", |
| 1752 |
target: "_blank", |
| 1753 |
rel: "noopener noreferrer", |
| 1754 |
className: "flex items-center gap-1 text-blue-600 hover:text-blue-500 dark:text-blue-400 text-sm", |
| 1755 |
children: [ |
| 1756 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }), |
| 1757 |
__("Calendar API", "yatra") |
| 1758 |
] |
| 1759 |
} |
| 1760 |
), |
| 1761 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1762 |
"a", |
| 1763 |
{ |
| 1764 |
href: "https://console.cloud.google.com/apis/credentials/consent", |
| 1765 |
target: "_blank", |
| 1766 |
rel: "noopener noreferrer", |
| 1767 |
className: "flex items-center gap-1 text-blue-600 hover:text-blue-500 dark:text-blue-400 text-sm", |
| 1768 |
children: [ |
| 1769 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }), |
| 1770 |
__("OAuth Consent", "yatra") |
| 1771 |
] |
| 1772 |
} |
| 1773 |
) |
| 1774 |
] }), |
| 1775 |
connected ? /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1776 |
Button, |
| 1777 |
{ |
| 1778 |
variant: "destructive", |
| 1779 |
onClick: handleDisconnect, |
| 1780 |
className: "flex items-center gap-2", |
| 1781 |
children: [ |
| 1782 |
/* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-4 h-4" }), |
| 1783 |
__("Disconnect", "yatra") |
| 1784 |
] |
| 1785 |
} |
| 1786 |
) : /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1787 |
Button, |
| 1788 |
{ |
| 1789 |
onClick: handleConnect, |
| 1790 |
disabled: connecting || !clientId || !clientSecret, |
| 1791 |
className: "flex items-center gap-2", |
| 1792 |
children: [ |
| 1793 |
connecting ? /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "w-4 h-4" }), |
| 1794 |
__("Connect to Google Calendar", "yatra") |
| 1795 |
] |
| 1796 |
} |
| 1797 |
) |
| 1798 |
] }) |
| 1799 |
] }) |
| 1800 |
] }) }); |
| 1801 |
}; |
| 1802 |
const getInitialFormSubTab = () => { |
| 1803 |
if (typeof window !== "undefined") { |
| 1804 |
const saved = localStorage.getItem("yatra_settings_booking_form_subtab"); |
| 1805 |
if (saved && ["contact_form", "emergency_contact_form", "traveler_form"].includes( |
| 1806 |
saved |
| 1807 |
)) { |
| 1808 |
return saved; |
| 1809 |
} |
| 1810 |
} |
| 1811 |
return "contact_form"; |
| 1812 |
}; |
| 1813 |
const BookingFormBuilder = ({ |
| 1814 |
formData, |
| 1815 |
setFormData |
| 1816 |
}) => { |
| 1817 |
var _a, _b, _c, _d, _e, _f, _g, _h; |
| 1818 |
const [activeFormTab, setActiveFormTab] = reactExports.useState(getInitialFormSubTab); |
| 1819 |
const { data: modulesData } = useQuery({ |
| 1820 |
queryKey: ["modules", "raw-envelope"], |
| 1821 |
queryFn: async () => { |
| 1822 |
const response = await apiService.getModules(); |
| 1823 |
return response; |
| 1824 |
}, |
| 1825 |
staleTime: 3e4 |
| 1826 |
// Cache for 30 seconds |
| 1827 |
}); |
| 1828 |
const isDynamicFormFieldEnabled = React.useMemo(() => { |
| 1829 |
var _a2; |
| 1830 |
if (modulesData == null ? void 0 : modulesData.data) { |
| 1831 |
const module = modulesData.data.find( |
| 1832 |
(m) => m.slug === "dynamic_form_field" |
| 1833 |
); |
| 1834 |
return (module == null ? void 0 : module.enabled) === true && (module == null ? void 0 : module.is_available) === true; |
| 1835 |
} |
| 1836 |
return !!((_a2 = window.yatraAdmin) == null ? void 0 : _a2.dynamicFormFieldEnabled); |
| 1837 |
}, [modulesData]); |
| 1838 |
const conditionsSupported = isDynamicFormFieldEnabled && !!((_a = window.yatraAdmin) == null ? void 0 : _a.bookingFormConditionsEnabled); |
| 1839 |
const [conditionsOpen, setConditionsOpen] = reactExports.useState(false); |
| 1840 |
const hasAnyConditions = React.useMemo(() => { |
| 1841 |
const cfg = formData == null ? void 0 : formData.booking_form_config; |
| 1842 |
return !!cfg && Object.values(cfg).some( |
| 1843 |
(s) => Array.isArray(s == null ? void 0 : s.conditions) && s.conditions.length > 0 |
| 1844 |
); |
| 1845 |
}, [formData == null ? void 0 : formData.booking_form_config]); |
| 1846 |
const { options: conditionTargetOptions } = useTripTargets( |
| 1847 |
conditionsSupported && hasAnyConditions |
| 1848 |
); |
| 1849 |
const handleSubTabChange = (tab) => { |
| 1850 |
setActiveFormTab(tab); |
| 1851 |
if (typeof window !== "undefined") { |
| 1852 |
localStorage.setItem("yatra_settings_booking_form_subtab", tab); |
| 1853 |
} |
| 1854 |
}; |
| 1855 |
const appliesToOptions = [ |
| 1856 |
{ value: "all", label: __("All travelers", "yatra") }, |
| 1857 |
{ value: "lead", label: __("Lead traveler only", "yatra") } |
| 1858 |
]; |
| 1859 |
const formTabs = [ |
| 1860 |
{ |
| 1861 |
id: "contact_form", |
| 1862 |
label: __("Contact Form", "yatra"), |
| 1863 |
description: "Lead traveler contact details" |
| 1864 |
}, |
| 1865 |
{ |
| 1866 |
id: "emergency_contact_form", |
| 1867 |
label: __("Emergency Contact", "yatra"), |
| 1868 |
description: "Emergency contact information" |
| 1869 |
}, |
| 1870 |
{ |
| 1871 |
id: "traveler_form", |
| 1872 |
label: __("Traveler Form", "yatra"), |
| 1873 |
description: "Individual traveler details" |
| 1874 |
} |
| 1875 |
]; |
| 1876 |
const fieldTypes = [ |
| 1877 |
{ value: "text", label: __("Text", "yatra") }, |
| 1878 |
{ value: "email", label: __("Email", "yatra") }, |
| 1879 |
{ value: "tel", label: __("Phone", "yatra") }, |
| 1880 |
{ value: "date", label: __("Date", "yatra") }, |
| 1881 |
{ value: "select", label: __("Dropdown", "yatra") }, |
| 1882 |
{ value: "country", label: __("Country Selector", "yatra") }, |
| 1883 |
{ value: "textarea", label: __("Text Area", "yatra") }, |
| 1884 |
{ value: "number", label: __("Number", "yatra") }, |
| 1885 |
{ value: "checkbox", label: __("Checkbox", "yatra") }, |
| 1886 |
{ value: "text_block", label: __("Text Block (display only)", "yatra") } |
| 1887 |
]; |
| 1888 |
const widthOptions = [ |
| 1889 |
{ value: "full", label: "Full Width" }, |
| 1890 |
{ value: "half", label: "Half Width" }, |
| 1891 |
{ value: "third", label: "One Third" } |
| 1892 |
]; |
| 1893 |
const getCurrentFormConfig = () => { |
| 1894 |
var _a2; |
| 1895 |
return ((_a2 = formData == null ? void 0 : formData.booking_form_config) == null ? void 0 : _a2[activeFormTab]) || { |
| 1896 |
title: "", |
| 1897 |
description: "", |
| 1898 |
enabled: true, |
| 1899 |
fields: [] |
| 1900 |
}; |
| 1901 |
}; |
| 1902 |
const bookingFormCapturesEmail = (() => { |
| 1903 |
const cfg = formData == null ? void 0 : formData.booking_form_config; |
| 1904 |
if (!cfg) return true; |
| 1905 |
const sectionHasEnabledEmail = (section) => { |
| 1906 |
if (!section || section.enabled === false) return false; |
| 1907 |
return (section.fields || []).some( |
| 1908 |
(f) => (f.type === "email" || f.id === "email") && f.enabled !== false |
| 1909 |
); |
| 1910 |
}; |
| 1911 |
return sectionHasEnabledEmail(cfg.contact_form) || sectionHasEnabledEmail(cfg.traveler_form); |
| 1912 |
})(); |
| 1913 |
const updateFormConfig = (updates) => { |
| 1914 |
setFormData((prev) => { |
| 1915 |
if (!prev) return prev; |
| 1916 |
return { |
| 1917 |
...prev, |
| 1918 |
booking_form_config: { |
| 1919 |
...prev.booking_form_config, |
| 1920 |
[activeFormTab]: { |
| 1921 |
...prev.booking_form_config[activeFormTab], |
| 1922 |
...updates |
| 1923 |
} |
| 1924 |
} |
| 1925 |
}; |
| 1926 |
}); |
| 1927 |
}; |
| 1928 |
const currentConfig = getCurrentFormConfig(); |
| 1929 |
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1930 |
ProFeature, |
| 1931 |
{ |
| 1932 |
title: __("Dynamic Form Field", "yatra"), |
| 1933 |
description: __( |
| 1934 |
"customize your booking forms with drag-and-drop field builder", |
| 1935 |
"yatra" |
| 1936 |
), |
| 1937 |
moduleName: "Dynamic Form Field", |
| 1938 |
pricingUrl: "https://wpyatra.com/pricing?module=dynamic-form-field", |
| 1939 |
isProActive: (_b = window.yatraAdmin) == null ? void 0 : _b.isPro, |
| 1940 |
isModuleEnabled: isDynamicFormFieldEnabled, |
| 1941 |
children: [ |
| 1942 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsx("nav", { className: "flex gap-4", "aria-label": "Form Types", children: formTabs.map((tab) => /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1943 |
"button", |
| 1944 |
{ |
| 1945 |
onClick: () => handleSubTabChange(tab.id), |
| 1946 |
className: `pb-3 px-1 border-b-2 font-medium text-sm transition-colors ${activeFormTab === tab.id ? "border-blue-500 text-blue-600 dark:text-blue-400" : "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-300"}`, |
| 1947 |
children: tab.label |
| 1948 |
}, |
| 1949 |
tab.id |
| 1950 |
)) }) }), |
| 1951 |
!bookingFormCapturesEmail && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 p-3 rounded-md border border-red-300 bg-red-50 dark:border-red-700 dark:bg-red-900/20 text-sm text-red-800 dark:text-red-300", children: [ |
| 1952 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold", children: "⚠" }), |
| 1953 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: __( |
| 1954 |
"No form is set to collect an email address. An email is required for booking confirmation, the customer account and the voucher. Please enable an email field on the Contact or Traveler form — otherwise customers can't complete checkout.", |
| 1955 |
"yatra" |
| 1956 |
) }) |
| 1957 |
] }), |
| 1958 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 1959 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [ |
| 1960 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Form Section Settings", "yatra") }), |
| 1961 |
conditionsSupported && /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1962 |
Button, |
| 1963 |
{ |
| 1964 |
type: "button", |
| 1965 |
variant: "outline", |
| 1966 |
size: "sm", |
| 1967 |
onClick: () => setConditionsOpen(true), |
| 1968 |
className: "border-purple-300 text-purple-700 hover:bg-purple-50 dark:border-purple-700 dark:text-purple-300 dark:hover:bg-purple-900/20", |
| 1969 |
title: __( |
| 1970 |
"Give some trips their own version of this form", |
| 1971 |
"yatra" |
| 1972 |
), |
| 1973 |
"data-testid": "open-conditions", |
| 1974 |
children: [ |
| 1975 |
/* @__PURE__ */ jsxRuntimeExports.jsx(SlidersHorizontal, { className: "w-4 h-4 mr-1.5" }), |
| 1976 |
__("Conditions", "yatra"), |
| 1977 |
(((_c = currentConfig.conditions) == null ? void 0 : _c.length) ?? 0) > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-1.5 text-[11px] px-1.5 py-0.5 rounded-full bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300 font-semibold", children: (_d = currentConfig.conditions) == null ? void 0 : _d.length }) |
| 1978 |
] |
| 1979 |
} |
| 1980 |
) |
| 1981 |
] }) }), |
| 1982 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-4", children: [ |
| 1983 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 1984 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1985 |
"input", |
| 1986 |
{ |
| 1987 |
type: "checkbox", |
| 1988 |
id: "form_section_enabled", |
| 1989 |
checked: currentConfig.enabled !== false, |
| 1990 |
onChange: (e) => updateFormConfig({ enabled: e.target.checked }), |
| 1991 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 1992 |
} |
| 1993 |
), |
| 1994 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1995 |
Label, |
| 1996 |
{ |
| 1997 |
htmlFor: "form_section_enabled", |
| 1998 |
className: "font-medium cursor-pointer", |
| 1999 |
children: __("Enable this form section", "yatra") |
| 2000 |
} |
| 2001 |
) |
| 2002 |
] }), |
| 2003 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [ |
| 2004 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 2005 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "form_title", children: __("Section Title", "yatra") }), |
| 2006 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 2007 |
Input, |
| 2008 |
{ |
| 2009 |
id: "form_title", |
| 2010 |
value: currentConfig.title || "", |
| 2011 |
onChange: (e) => updateFormConfig({ title: e.target.value }), |
| 2012 |
placeholder: "Enter section title", |
| 2013 |
className: "mt-1" |
| 2014 |
} |
| 2015 |
) |
| 2016 |
] }), |
| 2017 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 2018 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "form_description", children: __("Section Description", "yatra") }), |
| 2019 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 2020 |
Input, |
| 2021 |
{ |
| 2022 |
id: "form_description", |
| 2023 |
value: currentConfig.description || "", |
| 2024 |
onChange: (e) => updateFormConfig({ description: e.target.value }), |
| 2025 |
placeholder: "Enter description", |
| 2026 |
className: "mt-1" |
| 2027 |
} |
| 2028 |
) |
| 2029 |
] }) |
| 2030 |
] }), |
| 2031 |
conditionsSupported && (((_e = currentConfig.conditions) == null ? void 0 : _e.length) ?? 0) > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", "data-testid": "conditions-summary", children: [ |
| 2032 |
(_f = currentConfig.conditions) == null ? void 0 : _f.map((c, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 2033 |
"div", |
| 2034 |
{ |
| 2035 |
className: "flex flex-wrap items-center gap-2 px-3 py-2 rounded-md border border-dashed border-gray-300 dark:border-gray-600 text-sm", |
| 2036 |
children: [ |
| 2037 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-500", children: __("On", "yatra") }), |
| 2038 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: describeTargets(c.targets, conditionTargetOptions) || __("(no trips selected)", "yatra") }), |
| 2039 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-500", children: sprintf( |
| 2040 |
__("→ “%1$s” · %2$d fields", "yatra"), |
| 2041 |
c.title, |
| 2042 |
c.fields.filter((f) => f.enabled !== false).length |
| 2043 |
) }), |
| 2044 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex-1" }), |
| 2045 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 2046 |
Button, |
| 2047 |
{ |
| 2048 |
type: "button", |
| 2049 |
variant: "ghost", |
| 2050 |
size: "sm", |
| 2051 |
onClick: () => setConditionsOpen(true), |
| 2052 |
children: __("Edit", "yatra") |
| 2053 |
} |
| 2054 |
) |
| 2055 |
] |
| 2056 |
}, |
| 2057 |
c.id || i |
| 2058 |
)), |
| 2059 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-2 px-3 py-2 rounded-md bg-gray-50 dark:bg-gray-800 text-sm", children: [ |
| 2060 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: __("All other trips", "yatra") }), |
| 2061 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-500", children: __("use this form (below)", "yatra") }) |
| 2062 |
] }) |
| 2063 |
] }) |
| 2064 |
] }) |
| 2065 |
] }), |
| 2066 |
conditionsSupported && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 2067 |
BookingFormConditionsModal, |
| 2068 |
{ |
| 2069 |
isOpen: conditionsOpen, |
| 2070 |
onClose: () => setConditionsOpen(false), |
| 2071 |
formType: activeFormTab, |
| 2072 |
formLabel: ((_g = formTabs.find((t) => t.id === activeFormTab)) == null ? void 0 : _g.label) || "", |
| 2073 |
section: currentConfig, |
| 2074 |
onSave: (conditions) => updateFormConfig({ |
| 2075 |
conditions: conditions.length > 0 ? conditions : void 0 |
| 2076 |
}), |
| 2077 |
fieldTypes, |
| 2078 |
widthOptions, |
| 2079 |
appliesToOptions |
| 2080 |
} |
| 2081 |
), |
| 2082 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 2083 |
BookingFormFieldsEditor, |
| 2084 |
{ |
| 2085 |
formType: activeFormTab, |
| 2086 |
fields: currentConfig.fields, |
| 2087 |
onChange: (fields) => updateFormConfig({ fields }), |
| 2088 |
fieldTypes, |
| 2089 |
widthOptions, |
| 2090 |
appliesToOptions |
| 2091 |
} |
| 2092 |
), |
| 2093 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 2094 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Preview", "yatra") }) }), |
| 2095 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 bg-gray-50 dark:bg-gray-800 rounded-lg", children: [ |
| 2096 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-semibold text-lg mb-1", children: currentConfig.title || "Form Section" }), |
| 2097 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mb-4", children: currentConfig.description }), |
| 2098 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 gap-4", children: (_h = currentConfig.fields) == null ? void 0 : _h.filter((f) => f.enabled).map((field) => /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 2099 |
"div", |
| 2100 |
{ |
| 2101 |
className: field.width === "full" ? "col-span-2" : field.width === "third" ? "col-span-1" : "col-span-1", |
| 2102 |
children: field.type === "text_block" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "yatra-form-text-block text-sm text-gray-600 dark:text-gray-300 whitespace-pre-line", children: (field.content || "").replace(/<[^>]*>/g, "") }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 2103 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { className: "text-sm", children: [ |
| 2104 |
field.label, |
| 2105 |
field.required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500 ml-1", children: "*" }) |
| 2106 |
] }), |
| 2107 |
field.type === "select" || field.type === "country" ? /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { disabled: true, className: "mt-1 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx("option", { children: field.placeholder || "Select..." }) }) : field.type === "textarea" ? /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 2108 |
"textarea", |
| 2109 |
{ |
| 2110 |
disabled: true, |
| 2111 |
placeholder: field.placeholder, |
| 2112 |
className: "mt-1 w-full px-3 py-2 border border-gray-300 rounded-md bg-white dark:bg-gray-700 text-sm", |
| 2113 |
rows: 2 |
| 2114 |
} |
| 2115 |
) : /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 2116 |
Input, |
| 2117 |
{ |
| 2118 |
disabled: true, |
| 2119 |
type: field.type, |
| 2120 |
placeholder: field.placeholder, |
| 2121 |
className: "mt-1" |
| 2122 |
} |
| 2123 |
) |
| 2124 |
] }) |
| 2125 |
}, |
| 2126 |
field.id |
| 2127 |
)) }) |
| 2128 |
] }) }) |
| 2129 |
] }) |
| 2130 |
] |
| 2131 |
} |
| 2132 |
) }); |
| 2133 |
}; |
| 2134 |
const Settings = () => { |
| 2135 |
var _a, _b; |
| 2136 |
const queryClient = useQueryClient(); |
| 2137 |
const { can } = usePermissions(); |
| 2138 |
const { showToast } = useToast(); |
| 2139 |
const getInitialActiveSection = () => { |
| 2140 |
const VALID_SECTIONS = [ |
| 2141 |
"general", |
| 2142 |
"design", |
| 2143 |
"booking", |
| 2144 |
"booking_form", |
| 2145 |
"payment", |
| 2146 |
"trip", |
| 2147 |
"customer", |
| 2148 |
"review", |
| 2149 |
"tax", |
| 2150 |
"currency", |
| 2151 |
"integration", |
| 2152 |
"permalink", |
| 2153 |
"seo", |
| 2154 |
"advanced" |
| 2155 |
]; |
| 2156 |
if (typeof window !== "undefined") { |
| 2157 |
const fromUrl = new URLSearchParams(window.location.search).get( |
| 2158 |
"section" |
| 2159 |
); |
| 2160 |
if (fromUrl && VALID_SECTIONS.includes(fromUrl)) { |
| 2161 |
return fromUrl; |
| 2162 |
} |
| 2163 |
const saved = localStorage.getItem("yatra_settings_active_section"); |
| 2164 |
if (saved === "email" || saved === "notification") { |
| 2165 |
return "general"; |
| 2166 |
} |
| 2167 |
if (saved && [ |
| 2168 |
"general", |
| 2169 |
"design", |
| 2170 |
"booking", |
| 2171 |
"booking_form", |
| 2172 |
"payment", |
| 2173 |
"trip", |
| 2174 |
"customer", |
| 2175 |
"review", |
| 2176 |
"tax", |
| 2177 |
"currency", |
| 2178 |
"integration", |
| 2179 |
"permalink", |
| 2180 |
"seo", |
| 2181 |
"advanced" |
| 2182 |
].includes(saved)) { |
| 2183 |
return saved; |
| 2184 |
} |
| 2185 |
} |
| 2186 |
return "general"; |
| 2187 |
}; |
| 2188 |
const [activeSection, setActiveSection] = reactExports.useState( |
| 2189 |
getInitialActiveSection() |
| 2190 |
); |
| 2191 |
const [viewingSection, setViewingSection] = reactExports.useState( |
| 2192 |
getInitialActiveSection() |
| 2193 |
); |
| 2194 |
const [isSaving, setIsSaving] = reactExports.useState(false); |
| 2195 |
const [expandedGateways, setExpandedGateways] = reactExports.useState({}); |
| 2196 |
const [gatewayOrder, setGatewayOrder] = reactExports.useState([]); |
| 2197 |
const [draggedGateway, setDraggedGateway] = reactExports.useState(null); |
| 2198 |
const [usageStatus, setUsageStatus] = reactExports.useState( |
| 2199 |
null |
| 2200 |
); |
| 2201 |
const [usageBusy, setUsageBusy] = reactExports.useState(false); |
| 2202 |
const [usageLoading, setUsageLoading] = reactExports.useState(false); |
| 2203 |
const [usageError, setUsageError] = reactExports.useState(""); |
| 2204 |
reactExports.useEffect(() => { |
| 2205 |
setViewingSection(activeSection); |
| 2206 |
}, [activeSection]); |
| 2207 |
const { |
| 2208 |
data: settings, |
| 2209 |
isLoading, |
| 2210 |
error |
| 2211 |
} = useQuery({ |
| 2212 |
queryKey: ["settings"], |
| 2213 |
queryFn: async () => { |
| 2214 |
try { |
| 2215 |
return await fetchSettings(); |
| 2216 |
} catch (error2) { |
| 2217 |
console.error("Error fetching settings:", error2); |
| 2218 |
showToast( |
| 2219 |
(error2 == null ? void 0 : error2.message) || __("Failed to load settings", "yatra"), |
| 2220 |
"error" |
| 2221 |
); |
| 2222 |
throw error2; |
| 2223 |
} |
| 2224 |
}, |
| 2225 |
enabled: can("yatra_manage_settings") |
| 2226 |
// Avoid overwriting in-progress edits due to background refetches |
| 2227 |
}); |
| 2228 |
const { data: gatewayDefinitions } = useQuery({ |
| 2229 |
queryKey: ["payment-gateways-definitions"], |
| 2230 |
queryFn: async () => { |
| 2231 |
try { |
| 2232 |
const response = await fetchPaymentGatewayDefinitions(); |
| 2233 |
return response.gateways || {}; |
| 2234 |
} catch (error2) { |
| 2235 |
console.error("Failed to load gateway definitions:", error2); |
| 2236 |
return {}; |
| 2237 |
} |
| 2238 |
}, |
| 2239 |
enabled: can("yatra_manage_settings"), |
| 2240 |
staleTime: Infinity |
| 2241 |
}); |
| 2242 |
reactExports.useEffect(() => { |
| 2243 |
if (viewingSection !== "advanced" || !can("yatra_manage_settings")) { |
| 2244 |
return; |
| 2245 |
} |
| 2246 |
let cancelled = false; |
| 2247 |
setUsageLoading(true); |
| 2248 |
setUsageError(""); |
| 2249 |
(async () => { |
| 2250 |
var _a2; |
| 2251 |
try { |
| 2252 |
const s = await fetchUsageTrackingStatus(); |
| 2253 |
if (!cancelled) { |
| 2254 |
setUsageStatus(s); |
| 2255 |
} |
| 2256 |
} catch (e) { |
| 2257 |
if (!cancelled) { |
| 2258 |
setUsageStatus(null); |
| 2259 |
const status = ((_a2 = e == null ? void 0 : e.response) == null ? void 0 : _a2.status) != null ? ` (HTTP ${e.response.status})` : ""; |
| 2260 |
const msg = (typeof (e == null ? void 0 : e.message) === "string" && e.message.trim() !== "" ? e.message : __("Failed to load usage tracking status", "yatra")) + status; |
| 2261 |
setUsageError(msg); |
| 2262 |
} |
| 2263 |
} finally { |
| 2264 |
setUsageLoading(false); |
| 2265 |
} |
| 2266 |
})(); |
| 2267 |
return () => { |
| 2268 |
cancelled = true; |
| 2269 |
}; |
| 2270 |
}, [viewingSection, can]); |
| 2271 |
const defaultSettings = reactExports.useMemo( |
| 2272 |
() => ({ |
| 2273 |
company_name: "Yatra Travel Agency", |
| 2274 |
company_email: "[email protected]", |
| 2275 |
company_phone: "+1-234-567-8900", |
| 2276 |
company_address: "123 Travel Street", |
| 2277 |
company_city: "Kathmandu", |
| 2278 |
company_state: "Bagmati", |
| 2279 |
company_country: "Nepal", |
| 2280 |
company_zip: "44600", |
| 2281 |
company_website: "https://wpyatra.com", |
| 2282 |
company_logo: "", |
| 2283 |
timezone: "Asia/Kathmandu", |
| 2284 |
date_format: "Y-m-d", |
| 2285 |
time_format: "H:i", |
| 2286 |
frontend_primary_color: "#3b82f6", |
| 2287 |
frontend_container_max_width: "", |
| 2288 |
frontend_listing_card_layout: "standard", |
| 2289 |
// Search & Listing — defaults match current behaviour (all fields shown, |
| 2290 |
// mobile filters expanded) so existing sites are unchanged. |
| 2291 |
search_show_keyword: true, |
| 2292 |
search_show_destination: true, |
| 2293 |
search_show_activities: true, |
| 2294 |
search_show_duration: true, |
| 2295 |
search_show_budget: true, |
| 2296 |
search_show_date: false, |
| 2297 |
collapse_filters_on_mobile: false, |
| 2298 |
booking_confirmation: true, |
| 2299 |
auto_confirm_bookings: false, |
| 2300 |
auto_confirm_mode: "online", |
| 2301 |
require_login: false, |
| 2302 |
allow_guest_checkout: true, |
| 2303 |
require_guest_email_verification: false, |
| 2304 |
booking_expiry_hours: 24, |
| 2305 |
booking_reminder_days: 3, |
| 2306 |
allow_waitlist: true, |
| 2307 |
waitlist_auto_confirm: false, |
| 2308 |
date_picker_as_dropdown: false, |
| 2309 |
currency: "USD", |
| 2310 |
payment_test_mode: true, |
| 2311 |
payment_gateways: ["pay_later"], |
| 2312 |
payment_methods: ["credit_card", "paypal", "bank_transfer"], |
| 2313 |
partial_payment: true, |
| 2314 |
partial_payment_percentage: 30, |
| 2315 |
deposit_required: true, |
| 2316 |
deposit_percentage: 20, |
| 2317 |
auto_confirm_pay_later: true, |
| 2318 |
enable_scheduled_payments: false, |
| 2319 |
scheduled_payment_type: "single", |
| 2320 |
scheduled_payment_days: 15, |
| 2321 |
scheduled_payment_installments: 1, |
| 2322 |
discount_stacking_mode: "both", |
| 2323 |
scheduled_payment_interval: 30, |
| 2324 |
scheduled_payment_reminder_days: 3, |
| 2325 |
balance_anchor: "booking", |
| 2326 |
balance_due_days: 14, |
| 2327 |
gateway_configs: { |
| 2328 |
stripe: { |
| 2329 |
enabled: true, |
| 2330 |
title: "Stripe", |
| 2331 |
description: "Accept credit and debit cards", |
| 2332 |
api_key: "", |
| 2333 |
api_secret: "", |
| 2334 |
webhook_secret: "" |
| 2335 |
}, |
| 2336 |
paypal: { |
| 2337 |
enabled: true, |
| 2338 |
title: "PayPal", |
| 2339 |
description: "Accept PayPal payments", |
| 2340 |
client_id: "", |
| 2341 |
client_secret: "" |
| 2342 |
}, |
| 2343 |
razorpay: { |
| 2344 |
enabled: false, |
| 2345 |
title: "Razorpay", |
| 2346 |
description: "Accept payments via Razorpay", |
| 2347 |
api_key: "", |
| 2348 |
api_secret: "" |
| 2349 |
}, |
| 2350 |
square: { |
| 2351 |
enabled: false, |
| 2352 |
title: "Square", |
| 2353 |
description: "Accept payments via Square", |
| 2354 |
api_key: "", |
| 2355 |
api_secret: "" |
| 2356 |
}, |
| 2357 |
authorize_net: { |
| 2358 |
enabled: false, |
| 2359 |
title: "Authorize.net", |
| 2360 |
description: "Accept payments via Authorize.net", |
| 2361 |
api_key: "", |
| 2362 |
api_secret: "" |
| 2363 |
}, |
| 2364 |
bank_transfer: { |
| 2365 |
enabled: false, |
| 2366 |
title: "Bank Transfer", |
| 2367 |
description: "Accept manual bank transfer payments", |
| 2368 |
api_key: "", |
| 2369 |
// Used for bank account name |
| 2370 |
api_secret: "", |
| 2371 |
// Used for bank account number |
| 2372 |
public_key: "", |
| 2373 |
// Used for bank name |
| 2374 |
private_key: "" |
| 2375 |
// Used for routing/SWIFT code |
| 2376 |
}, |
| 2377 |
esewa: { |
| 2378 |
enabled: false, |
| 2379 |
title: "eSewa", |
| 2380 |
description: "Accept payments via eSewa (Nepal)", |
| 2381 |
api_key: "", |
| 2382 |
api_secret: "" |
| 2383 |
}, |
| 2384 |
khalti: { |
| 2385 |
enabled: false, |
| 2386 |
title: "Khalti", |
| 2387 |
description: "Accept payments via Khalti (Nepal)", |
| 2388 |
api_key: "", |
| 2389 |
api_secret: "" |
| 2390 |
}, |
| 2391 |
pay_later: { |
| 2392 |
enabled: false, |
| 2393 |
title: "Book Now, Pay Later", |
| 2394 |
description: "Allow customers to reserve now and pay before the trip", |
| 2395 |
api_key: "", |
| 2396 |
// Used for payment deadline days |
| 2397 |
api_secret: "" |
| 2398 |
// Used for auto-cancel days |
| 2399 |
} |
| 2400 |
}, |
| 2401 |
gateway_order: [ |
| 2402 |
"pay_later", |
| 2403 |
"stripe", |
| 2404 |
"paypal", |
| 2405 |
"razorpay", |
| 2406 |
"square", |
| 2407 |
"authorize_net", |
| 2408 |
"bank_transfer", |
| 2409 |
"esewa", |
| 2410 |
"khalti" |
| 2411 |
], |
| 2412 |
admin_email: "[email protected]", |
| 2413 |
from_email: "[email protected]", |
| 2414 |
from_name: "Yatra Travel", |
| 2415 |
email_template_booking: true, |
| 2416 |
email_template_confirmation: true, |
| 2417 |
email_template_cancellation: true, |
| 2418 |
email_template_reminder: true, |
| 2419 |
email_template_admin_new_booking: true, |
| 2420 |
email_template_admin_payment: true, |
| 2421 |
email_template_admin_cancellation: true, |
| 2422 |
email_template_trip_consent: true, |
| 2423 |
email_template_customer_verification: true, |
| 2424 |
email_template_guest_verification: true, |
| 2425 |
email_template_booking_completed: true, |
| 2426 |
email_template_booking_expired_customer: true, |
| 2427 |
email_template_admin_booking_expired: true, |
| 2428 |
email_template_scheduled_payment_reminder: true, |
| 2429 |
email_template_scheduled_payment_succeeded: true, |
| 2430 |
email_template_scheduled_payment_failed: true, |
| 2431 |
email_template_admin_scheduled_payment_failed: true, |
| 2432 |
email_template_enquiry_received: true, |
| 2433 |
email_template_enquiry_admin: true, |
| 2434 |
email_template_enquiry_response: true, |
| 2435 |
email_template_review_request: true, |
| 2436 |
email_template_abandoned_booking_recovery_first: true, |
| 2437 |
email_template_abandoned_booking_recovery_second: true, |
| 2438 |
email_template_abandoned_booking_recovery_final: true, |
| 2439 |
smtp_enabled: false, |
| 2440 |
smtp_host: "smtp.gmail.com", |
| 2441 |
smtp_port: 587, |
| 2442 |
smtp_username: "", |
| 2443 |
smtp_password: "", |
| 2444 |
smtp_encryption: "tls", |
| 2445 |
email_tpl_booking_subject: "", |
| 2446 |
email_tpl_booking_body: "", |
| 2447 |
email_tpl_payment_subject: "", |
| 2448 |
email_tpl_payment_body: "", |
| 2449 |
email_tpl_cancellation_subject: "", |
| 2450 |
email_tpl_cancellation_body: "", |
| 2451 |
email_tpl_reminder_subject: "", |
| 2452 |
email_tpl_reminder_body: "", |
| 2453 |
email_tpl_admin_booking_subject: "", |
| 2454 |
email_tpl_admin_booking_body: "", |
| 2455 |
email_tpl_admin_payment_subject: "", |
| 2456 |
email_tpl_admin_payment_body: "", |
| 2457 |
email_tpl_admin_cancellation_subject: "", |
| 2458 |
email_tpl_admin_cancellation_body: "", |
| 2459 |
email_tpl_trip_consent_subject: "", |
| 2460 |
email_tpl_trip_consent_body: "", |
| 2461 |
email_tpl_customer_verification_subject: "", |
| 2462 |
email_tpl_customer_verification_body: "", |
| 2463 |
email_tpl_guest_verification_subject: "", |
| 2464 |
email_tpl_guest_verification_body: "", |
| 2465 |
email_tpl_booking_completed_subject: "", |
| 2466 |
email_tpl_booking_completed_body: "", |
| 2467 |
email_tpl_booking_expired_customer_subject: "", |
| 2468 |
email_tpl_booking_expired_customer_body: "", |
| 2469 |
email_tpl_admin_booking_expired_subject: "", |
| 2470 |
email_tpl_admin_booking_expired_body: "", |
| 2471 |
email_tpl_scheduled_payment_reminder_subject: "", |
| 2472 |
email_tpl_scheduled_payment_reminder_body: "", |
| 2473 |
email_tpl_scheduled_payment_succeeded_subject: "", |
| 2474 |
email_tpl_scheduled_payment_succeeded_body: "", |
| 2475 |
email_tpl_scheduled_payment_failed_subject: "", |
| 2476 |
email_tpl_scheduled_payment_failed_body: "", |
| 2477 |
email_tpl_admin_scheduled_payment_failed_subject: "", |
| 2478 |
email_tpl_admin_scheduled_payment_failed_body: "", |
| 2479 |
email_tpl_enquiry_received_subject: "", |
| 2480 |
email_tpl_enquiry_received_body: "", |
| 2481 |
email_tpl_enquiry_admin_subject: "", |
| 2482 |
email_tpl_enquiry_admin_body: "", |
| 2483 |
email_tpl_enquiry_response_subject: "", |
| 2484 |
email_tpl_enquiry_response_body: "", |
| 2485 |
email_tpl_review_request_subject: "", |
| 2486 |
email_tpl_review_request_body: "", |
| 2487 |
email_tpl_abandoned_booking_recovery_first_subject: "", |
| 2488 |
email_tpl_abandoned_booking_recovery_first_body: "", |
| 2489 |
email_tpl_abandoned_booking_recovery_second_subject: "", |
| 2490 |
email_tpl_abandoned_booking_recovery_second_body: "", |
| 2491 |
email_tpl_abandoned_booking_recovery_final_subject: "", |
| 2492 |
email_tpl_abandoned_booking_recovery_final_body: "", |
| 2493 |
customer_registration: true, |
| 2494 |
customer_fields: ["name", "email", "phone", "address"], |
| 2495 |
require_email_verification: false, |
| 2496 |
customer_account_page: "/my-account", |
| 2497 |
allow_customer_reviews: true, |
| 2498 |
customer_dashboard_enabled: true, |
| 2499 |
enable_reviews: true, |
| 2500 |
require_booking: true, |
| 2501 |
auto_approve_reviews: false, |
| 2502 |
review_moderation: true, |
| 2503 |
min_rating: 1, |
| 2504 |
allow_anonymous_reviews: false, |
| 2505 |
review_reminder_days: 7, |
| 2506 |
enable_tax: true, |
| 2507 |
tax_name: __("Tax", "yatra"), |
| 2508 |
tax_rate: 10, |
| 2509 |
tax_inclusive: false, |
| 2510 |
vat_number: "", |
| 2511 |
tax_by_country: false, |
| 2512 |
tax_rates: {}, |
| 2513 |
multiple_taxes_enabled: false, |
| 2514 |
multiple_taxes: [], |
| 2515 |
multiple_taxes_by_country: {}, |
| 2516 |
default_currency: "USD", |
| 2517 |
multi_currency: false, |
| 2518 |
currency_position: "left", |
| 2519 |
currency_decimals: 2, |
| 2520 |
thousand_separator: ",", |
| 2521 |
decimal_separator: ".", |
| 2522 |
sms_notifications: false, |
| 2523 |
sms_provider: "twilio", |
| 2524 |
sms_api_key: "", |
| 2525 |
google_analytics: "", |
| 2526 |
facebook_pixel: "", |
| 2527 |
recaptcha_enabled: false, |
| 2528 |
recaptcha_site_key: "", |
| 2529 |
recaptcha_secret_key: "", |
| 2530 |
recaptcha_score_threshold: 0.5, |
| 2531 |
recaptcha_protect_enquiry: false, |
| 2532 |
recaptcha_protect_booking: false, |
| 2533 |
recaptcha_protect_registration: false, |
| 2534 |
trip_base: "trip", |
| 2535 |
destination_base: "destination", |
| 2536 |
activity_base: "activity", |
| 2537 |
trip_category_base: "trip-category", |
| 2538 |
booking_base: "book", |
| 2539 |
enable_wishlist: false, |
| 2540 |
show_sold_out: true, |
| 2541 |
availability_horizon_months: 12, |
| 2542 |
use_booking_page: false, |
| 2543 |
booking_page_id: 0, |
| 2544 |
terms_page_id: 0, |
| 2545 |
privacy_policy_page_id: 0, |
| 2546 |
debug_mode: false, |
| 2547 |
enable_logging: false, |
| 2548 |
cache_enabled: true, |
| 2549 |
api_key: "", |
| 2550 |
api_rate_limit: 100, |
| 2551 |
session_timeout: 3600, |
| 2552 |
// Booking Form Builder |
| 2553 |
booking_form_config: { |
| 2554 |
contact_form: { |
| 2555 |
title: "Lead Traveler / Contact Information", |
| 2556 |
description: "Primary contact person for this booking", |
| 2557 |
enabled: true, |
| 2558 |
fields: [ |
| 2559 |
{ |
| 2560 |
id: "first_name", |
| 2561 |
type: "text", |
| 2562 |
label: "First Name", |
| 2563 |
placeholder: "Enter first name", |
| 2564 |
required: true, |
| 2565 |
enabled: true, |
| 2566 |
order: 1, |
| 2567 |
width: "half", |
| 2568 |
locked: true |
| 2569 |
}, |
| 2570 |
{ |
| 2571 |
id: "last_name", |
| 2572 |
type: "text", |
| 2573 |
label: "Last Name", |
| 2574 |
placeholder: "Enter last name", |
| 2575 |
required: true, |
| 2576 |
enabled: true, |
| 2577 |
order: 2, |
| 2578 |
width: "half", |
| 2579 |
locked: true |
| 2580 |
}, |
| 2581 |
{ |
| 2582 |
id: "email", |
| 2583 |
type: "email", |
| 2584 |
label: "Email Address", |
| 2585 |
placeholder: "[email protected]", |
| 2586 |
required: true, |
| 2587 |
enabled: true, |
| 2588 |
order: 3, |
| 2589 |
width: "half", |
| 2590 |
locked: true |
| 2591 |
}, |
| 2592 |
{ |
| 2593 |
id: "phone", |
| 2594 |
type: "tel", |
| 2595 |
label: "Phone Number", |
| 2596 |
placeholder: "+1 234 567 8900", |
| 2597 |
required: true, |
| 2598 |
enabled: true, |
| 2599 |
order: 4, |
| 2600 |
width: "half", |
| 2601 |
locked: true |
| 2602 |
}, |
| 2603 |
{ |
| 2604 |
id: "country", |
| 2605 |
type: "country", |
| 2606 |
label: "Country", |
| 2607 |
placeholder: "Select Country", |
| 2608 |
required: true, |
| 2609 |
enabled: true, |
| 2610 |
order: 5, |
| 2611 |
width: "half", |
| 2612 |
locked: true |
| 2613 |
}, |
| 2614 |
{ |
| 2615 |
id: "nationality", |
| 2616 |
type: "country", |
| 2617 |
label: "Nationality", |
| 2618 |
placeholder: "Select Nationality", |
| 2619 |
required: false, |
| 2620 |
enabled: true, |
| 2621 |
order: 6, |
| 2622 |
width: "half" |
| 2623 |
}, |
| 2624 |
{ |
| 2625 |
id: "address", |
| 2626 |
type: "text", |
| 2627 |
label: "Address", |
| 2628 |
placeholder: "Street address (optional)", |
| 2629 |
required: false, |
| 2630 |
enabled: true, |
| 2631 |
order: 7, |
| 2632 |
width: "full" |
| 2633 |
} |
| 2634 |
] |
| 2635 |
}, |
| 2636 |
emergency_contact_form: { |
| 2637 |
title: "Emergency Contact", |
| 2638 |
description: "Person to contact in case of emergency", |
| 2639 |
enabled: true, |
| 2640 |
fields: [ |
| 2641 |
{ |
| 2642 |
id: "name", |
| 2643 |
type: "text", |
| 2644 |
label: "Contact Name", |
| 2645 |
placeholder: "Full name", |
| 2646 |
required: true, |
| 2647 |
enabled: true, |
| 2648 |
order: 1, |
| 2649 |
width: "half" |
| 2650 |
}, |
| 2651 |
{ |
| 2652 |
id: "phone", |
| 2653 |
type: "tel", |
| 2654 |
label: "Contact Phone", |
| 2655 |
placeholder: "+1 234 567 8900", |
| 2656 |
required: true, |
| 2657 |
enabled: true, |
| 2658 |
order: 2, |
| 2659 |
width: "half" |
| 2660 |
}, |
| 2661 |
{ |
| 2662 |
id: "relationship", |
| 2663 |
type: "select", |
| 2664 |
label: "Relationship", |
| 2665 |
placeholder: "Select Relationship", |
| 2666 |
required: false, |
| 2667 |
enabled: true, |
| 2668 |
order: 3, |
| 2669 |
width: "full", |
| 2670 |
options: [ |
| 2671 |
{ value: "spouse", label: "Spouse/Partner" }, |
| 2672 |
{ value: "parent", label: "Parent" }, |
| 2673 |
{ value: "sibling", label: "Sibling" }, |
| 2674 |
{ value: "child", label: "Child" }, |
| 2675 |
{ value: "friend", label: "Friend" }, |
| 2676 |
{ value: "other", label: "Other" } |
| 2677 |
] |
| 2678 |
} |
| 2679 |
] |
| 2680 |
}, |
| 2681 |
traveler_form: { |
| 2682 |
title: "Traveler Information", |
| 2683 |
description: "Please provide details for each traveler", |
| 2684 |
enabled: true, |
| 2685 |
fields: [ |
| 2686 |
{ |
| 2687 |
id: "first_name", |
| 2688 |
type: "text", |
| 2689 |
label: "First Name", |
| 2690 |
placeholder: "Legal first name", |
| 2691 |
required: true, |
| 2692 |
enabled: true, |
| 2693 |
order: 1, |
| 2694 |
width: "half" |
| 2695 |
}, |
| 2696 |
{ |
| 2697 |
id: "last_name", |
| 2698 |
type: "text", |
| 2699 |
label: "Last Name", |
| 2700 |
placeholder: "Legal last name", |
| 2701 |
required: true, |
| 2702 |
enabled: true, |
| 2703 |
order: 2, |
| 2704 |
width: "half" |
| 2705 |
}, |
| 2706 |
{ |
| 2707 |
id: "date_of_birth", |
| 2708 |
type: "date", |
| 2709 |
label: "Date of Birth", |
| 2710 |
placeholder: "", |
| 2711 |
required: true, |
| 2712 |
enabled: true, |
| 2713 |
order: 3, |
| 2714 |
width: "half" |
| 2715 |
}, |
| 2716 |
{ |
| 2717 |
id: "gender", |
| 2718 |
type: "select", |
| 2719 |
label: "Gender", |
| 2720 |
placeholder: "Select Gender", |
| 2721 |
required: true, |
| 2722 |
enabled: true, |
| 2723 |
order: 4, |
| 2724 |
width: "half", |
| 2725 |
options: [ |
| 2726 |
{ value: "male", label: "Male" }, |
| 2727 |
{ value: "female", label: "Female" }, |
| 2728 |
{ value: "other", label: "Other" } |
| 2729 |
] |
| 2730 |
}, |
| 2731 |
{ |
| 2732 |
id: "nationality", |
| 2733 |
type: "country", |
| 2734 |
label: "Nationality", |
| 2735 |
placeholder: "Select Nationality", |
| 2736 |
required: true, |
| 2737 |
enabled: true, |
| 2738 |
order: 5, |
| 2739 |
width: "full" |
| 2740 |
}, |
| 2741 |
{ |
| 2742 |
id: "dietary", |
| 2743 |
type: "select", |
| 2744 |
label: "Dietary Requirements", |
| 2745 |
placeholder: "Select", |
| 2746 |
required: false, |
| 2747 |
enabled: true, |
| 2748 |
order: 6, |
| 2749 |
width: "half", |
| 2750 |
section: "dietary_medical", |
| 2751 |
options: [ |
| 2752 |
{ value: "none", label: "No special requirements" }, |
| 2753 |
{ value: "vegetarian", label: "Vegetarian" }, |
| 2754 |
{ value: "vegan", label: "Vegan" }, |
| 2755 |
{ value: "halal", label: "Halal" }, |
| 2756 |
{ value: "kosher", label: "Kosher" }, |
| 2757 |
{ value: "gluten_free", label: "Gluten Free" }, |
| 2758 |
{ value: "lactose_free", label: "Lactose Free" }, |
| 2759 |
{ value: "other", label: "Other (specify in notes)" } |
| 2760 |
] |
| 2761 |
}, |
| 2762 |
{ |
| 2763 |
id: "medical", |
| 2764 |
type: "text", |
| 2765 |
label: "Medical Conditions / Allergies", |
| 2766 |
placeholder: "Any allergies or conditions", |
| 2767 |
required: false, |
| 2768 |
enabled: true, |
| 2769 |
order: 7, |
| 2770 |
width: "half", |
| 2771 |
section: "dietary_medical" |
| 2772 |
} |
| 2773 |
] |
| 2774 |
} |
| 2775 |
}, |
| 2776 |
// SEO Settings |
| 2777 |
seo_trip_meta_title: "", |
| 2778 |
seo_trip_meta_description: "", |
| 2779 |
seo_trip_meta_keywords: "", |
| 2780 |
seo_trip_meta_image: 0, |
| 2781 |
enable_sitemap: true, |
| 2782 |
sitemap_types: ["archive", "trip", "destination", "activity", "category"], |
| 2783 |
sitemap_noindex_excluded: false |
| 2784 |
}), |
| 2785 |
[] |
| 2786 |
); |
| 2787 |
const [formData, setFormData] = reactExports.useState(null); |
| 2788 |
const isInitializedRef = React.useRef(false); |
| 2789 |
const [mailchimpConnectionStatus, setMailchimpConnectionStatus] = reactExports.useState(null); |
| 2790 |
const [mailchimpLists, setMailchimpLists] = reactExports.useState([]); |
| 2791 |
const [mailchimpMergeFields, setMailchimpMergeFields] = reactExports.useState([]); |
| 2792 |
const [showApiKey, setShowApiKey] = reactExports.useState(false); |
| 2793 |
const [validatingApiKey, setValidatingApiKey] = reactExports.useState(false); |
| 2794 |
const [showFacebookToken, setShowFacebookToken] = reactExports.useState(false); |
| 2795 |
const [showGa4ApiSecret, setShowGa4ApiSecret] = reactExports.useState(false); |
| 2796 |
const [seoImageUrl, setSeoImageUrl] = reactExports.useState(""); |
| 2797 |
const [seoImageLoading, setSeoImageLoading] = reactExports.useState(false); |
| 2798 |
const [seoImageError, setSeoImageError] = reactExports.useState(""); |
| 2799 |
const [newTaxName, setNewTaxName] = reactExports.useState(""); |
| 2800 |
const [newTaxRate, setNewTaxRate] = reactExports.useState(""); |
| 2801 |
const [showPremiumDialog, setShowPremiumDialog] = reactExports.useState(false); |
| 2802 |
const [selectedPremiumGateway, setSelectedPremiumGateway] = reactExports.useState(""); |
| 2803 |
const [validatingPixel, setValidatingPixel] = reactExports.useState(false); |
| 2804 |
const [validatingToken, setValidatingToken] = reactExports.useState(false); |
| 2805 |
const [validatingMeasurementId, setValidatingMeasurementId] = reactExports.useState(false); |
| 2806 |
const [validatingApiSecret, setValidatingApiSecret] = reactExports.useState(false); |
| 2807 |
const validateMailchimpApiKey = async () => { |
| 2808 |
var _a2, _b2; |
| 2809 |
if (!(formData == null ? void 0 : formData.mailchimp_api_key)) return; |
| 2810 |
setValidatingApiKey(true); |
| 2811 |
try { |
| 2812 |
const response = await apiClient.post("/mailchimp/test", { |
| 2813 |
api_key: formData.mailchimp_api_key |
| 2814 |
}); |
| 2815 |
if (response.success) { |
| 2816 |
const updatedMailchimpData = { |
| 2817 |
...((_a2 = window.yatraAdmin) == null ? void 0 : _a2.mailchimp) || {}, |
| 2818 |
connectionStatus: { |
| 2819 |
connected: true, |
| 2820 |
error: null |
| 2821 |
} |
| 2822 |
}; |
| 2823 |
if (window.yatraAdmin) { |
| 2824 |
window.yatraAdmin.mailchimp = updatedMailchimpData; |
| 2825 |
} |
| 2826 |
setMailchimpConnectionStatus({ |
| 2827 |
connected: true, |
| 2828 |
error: void 0 |
| 2829 |
}); |
| 2830 |
await loadMailchimpLists(); |
| 2831 |
} |
| 2832 |
} catch (error2) { |
| 2833 |
const updatedMailchimpData = { |
| 2834 |
...((_b2 = window.yatraAdmin) == null ? void 0 : _b2.mailchimp) || {}, |
| 2835 |
connectionStatus: { |
| 2836 |
connected: false, |
| 2837 |
error: error2.message || __("Invalid API key", "yatra") |
| 2838 |
} |
| 2839 |
}; |
| 2840 |
if (window.yatraAdmin) { |
| 2841 |
window.yatraAdmin.mailchimp = updatedMailchimpData; |
| 2842 |
} |
| 2843 |
setMailchimpConnectionStatus({ |
| 2844 |
connected: false, |
| 2845 |
error: error2.message || __("Invalid API key", "yatra") |
| 2846 |
}); |
| 2847 |
console.error("API key validation failed:", error2); |
| 2848 |
} finally { |
| 2849 |
setValidatingApiKey(false); |
| 2850 |
} |
| 2851 |
}; |
| 2852 |
const loadMailchimpLists = async () => { |
| 2853 |
var _a2; |
| 2854 |
try { |
| 2855 |
const response = await apiClient.get("/mailchimp/lists"); |
| 2856 |
if (response.success && response.data) { |
| 2857 |
setMailchimpLists(response.data); |
| 2858 |
const updatedMailchimpData = { |
| 2859 |
...((_a2 = window.yatraAdmin) == null ? void 0 : _a2.mailchimp) || {}, |
| 2860 |
availableLists: response.data |
| 2861 |
}; |
| 2862 |
if (window.yatraAdmin) { |
| 2863 |
window.yatraAdmin.mailchimp = updatedMailchimpData; |
| 2864 |
} |
| 2865 |
} |
| 2866 |
} catch (error2) { |
| 2867 |
console.error("Error loading Mailchimp lists:", error2); |
| 2868 |
setMailchimpLists([]); |
| 2869 |
} |
| 2870 |
}; |
| 2871 |
const loadMailchimpMergeFields = async (listId) => { |
| 2872 |
var _a2; |
| 2873 |
if (!listId) { |
| 2874 |
setMailchimpMergeFields([]); |
| 2875 |
return; |
| 2876 |
} |
| 2877 |
try { |
| 2878 |
const response = await apiClient.get( |
| 2879 |
`/mailchimp/lists/${listId}/merge-fields` |
| 2880 |
); |
| 2881 |
if (response.success && response.data) { |
| 2882 |
setMailchimpMergeFields(response.data); |
| 2883 |
const updatedMailchimpData = { |
| 2884 |
...((_a2 = window.yatraAdmin) == null ? void 0 : _a2.mailchimp) || {}, |
| 2885 |
mergeFields: response.data |
| 2886 |
}; |
| 2887 |
if (window.yatraAdmin) { |
| 2888 |
window.yatraAdmin.mailchimp = updatedMailchimpData; |
| 2889 |
} |
| 2890 |
} |
| 2891 |
} catch (error2) { |
| 2892 |
console.error("Error loading Mailchimp merge fields:", error2); |
| 2893 |
setMailchimpMergeFields([]); |
| 2894 |
} |
| 2895 |
}; |
| 2896 |
React.useEffect(() => { |
| 2897 |
if ((formData == null ? void 0 : formData.mailchimp_list_id) && (mailchimpConnectionStatus == null ? void 0 : mailchimpConnectionStatus.connected)) { |
| 2898 |
loadMailchimpMergeFields(formData.mailchimp_list_id); |
| 2899 |
} |
| 2900 |
}, [formData == null ? void 0 : formData.mailchimp_list_id, mailchimpConnectionStatus == null ? void 0 : mailchimpConnectionStatus.connected]); |
| 2901 |
React.useEffect(() => { |
| 2902 |
var _a2, _b2; |
| 2903 |
if ((_b2 = (_a2 = window.yatraAdmin) == null ? void 0 : _a2.mailchimp) == null ? void 0 : _b2.connectionStatus) { |
| 2904 |
setMailchimpConnectionStatus( |
| 2905 |
window.yatraAdmin.mailchimp.connectionStatus |
| 2906 |
); |
| 2907 |
} |
| 2908 |
}, []); |
| 2909 |
const validateMeasurementId = async () => { |
| 2910 |
if (!(formData == null ? void 0 : formData.ga4_measurement_id)) return; |
| 2911 |
setValidatingMeasurementId(true); |
| 2912 |
try { |
| 2913 |
const raw = await apiService.validateGoogleAnalyticsMeasurementId( |
| 2914 |
formData.ga4_measurement_id |
| 2915 |
); |
| 2916 |
if (raw == null ? void 0 : raw.success) { |
| 2917 |
showToast( |
| 2918 |
__("Measurement ID validated successfully!", "yatra"), |
| 2919 |
"success" |
| 2920 |
); |
| 2921 |
} else { |
| 2922 |
showToast( |
| 2923 |
(raw == null ? void 0 : raw.message) || __("Measurement ID validation failed.", "yatra"), |
| 2924 |
"error" |
| 2925 |
); |
| 2926 |
} |
| 2927 |
} catch (error2) { |
| 2928 |
showToast( |
| 2929 |
error2.message || __("Failed to validate Measurement ID.", "yatra"), |
| 2930 |
"error" |
| 2931 |
); |
| 2932 |
} finally { |
| 2933 |
setValidatingMeasurementId(false); |
| 2934 |
} |
| 2935 |
}; |
| 2936 |
const validateApiSecret = async () => { |
| 2937 |
if (!(formData == null ? void 0 : formData.ga4_measurement_id) || !(formData == null ? void 0 : formData.ga4_api_secret)) return; |
| 2938 |
setValidatingApiSecret(true); |
| 2939 |
try { |
| 2940 |
const raw = await apiService.validateGoogleAnalyticsApiSecret( |
| 2941 |
formData.ga4_measurement_id, |
| 2942 |
formData.ga4_api_secret |
| 2943 |
); |
| 2944 |
if (raw == null ? void 0 : raw.success) { |
| 2945 |
showToast(__("API Secret validated successfully!", "yatra"), "success"); |
| 2946 |
} else { |
| 2947 |
showToast( |
| 2948 |
(raw == null ? void 0 : raw.message) || __("API Secret validation failed.", "yatra"), |
| 2949 |
"error" |
| 2950 |
); |
| 2951 |
} |
| 2952 |
} catch (error2) { |
| 2953 |
showToast( |
| 2954 |
error2.message || __("Failed to validate API Secret.", "yatra"), |
| 2955 |
"error" |
| 2956 |
); |
| 2957 |
} finally { |
| 2958 |
setValidatingApiSecret(false); |
| 2959 |
} |
| 2960 |
}; |
| 2961 |
const validateFacebookPixel = async () => { |
| 2962 |
var _a2, _b2, _c, _d, _e, _f; |
| 2963 |
if (!(formData == null ? void 0 : formData.facebook_pixel_id)) return; |
| 2964 |
setValidatingPixel(true); |
| 2965 |
try { |
| 2966 |
const response = await apiClient.post("/facebook-pixel/test", { |
| 2967 |
pixel_id: formData.facebook_pixel_id |
| 2968 |
}); |
| 2969 |
if (response.success) { |
| 2970 |
const updatedFacebookPixelData = { |
| 2971 |
...((_a2 = window.yatraAdmin) == null ? void 0 : _a2.facebookPixel) || {}, |
| 2972 |
connectionStatus: { |
| 2973 |
...((_c = (_b2 = window.yatraAdmin) == null ? void 0 : _b2.facebookPixel) == null ? void 0 : _c.connectionStatus) || {}, |
| 2974 |
pixelConnected: true, |
| 2975 |
pixelError: null |
| 2976 |
} |
| 2977 |
}; |
| 2978 |
if (window.yatraAdmin) { |
| 2979 |
window.yatraAdmin.facebookPixel = updatedFacebookPixelData; |
| 2980 |
} |
| 2981 |
} |
| 2982 |
} catch (error2) { |
| 2983 |
const updatedFacebookPixelData = { |
| 2984 |
...((_d = window.yatraAdmin) == null ? void 0 : _d.facebookPixel) || {}, |
| 2985 |
connectionStatus: { |
| 2986 |
...((_f = (_e = window.yatraAdmin) == null ? void 0 : _e.facebookPixel) == null ? void 0 : _f.connectionStatus) || {}, |
| 2987 |
pixelConnected: false, |
| 2988 |
pixelError: error2.message || __("Invalid Pixel ID", "yatra") |
| 2989 |
} |
| 2990 |
}; |
| 2991 |
if (window.yatraAdmin) { |
| 2992 |
window.yatraAdmin.facebookPixel = updatedFacebookPixelData; |
| 2993 |
} |
| 2994 |
console.error("Pixel validation failed:", error2); |
| 2995 |
} finally { |
| 2996 |
setValidatingPixel(false); |
| 2997 |
} |
| 2998 |
}; |
| 2999 |
const validateFacebookToken = async () => { |
| 3000 |
var _a2, _b2, _c, _d, _e, _f; |
| 3001 |
if (!(formData == null ? void 0 : formData.facebook_access_token)) return; |
| 3002 |
setValidatingToken(true); |
| 3003 |
try { |
| 3004 |
const response = await apiClient.post("/facebook-pixel/test-token", { |
| 3005 |
access_token: formData.facebook_access_token |
| 3006 |
}); |
| 3007 |
if (response.success) { |
| 3008 |
const updatedFacebookPixelData = { |
| 3009 |
...((_a2 = window.yatraAdmin) == null ? void 0 : _a2.facebookPixel) || {}, |
| 3010 |
connectionStatus: { |
| 3011 |
...((_c = (_b2 = window.yatraAdmin) == null ? void 0 : _b2.facebookPixel) == null ? void 0 : _c.connectionStatus) || {}, |
| 3012 |
tokenConnected: true, |
| 3013 |
tokenError: null |
| 3014 |
} |
| 3015 |
}; |
| 3016 |
if (window.yatraAdmin) { |
| 3017 |
window.yatraAdmin.facebookPixel = updatedFacebookPixelData; |
| 3018 |
} |
| 3019 |
} |
| 3020 |
} catch (error2) { |
| 3021 |
const updatedFacebookPixelData = { |
| 3022 |
...((_d = window.yatraAdmin) == null ? void 0 : _d.facebookPixel) || {}, |
| 3023 |
connectionStatus: { |
| 3024 |
...((_f = (_e = window.yatraAdmin) == null ? void 0 : _e.facebookPixel) == null ? void 0 : _f.connectionStatus) || {}, |
| 3025 |
tokenConnected: false, |
| 3026 |
tokenError: error2.message || __("Invalid access token", "yatra") |
| 3027 |
} |
| 3028 |
}; |
| 3029 |
if (window.yatraAdmin) { |
| 3030 |
window.yatraAdmin.facebookPixel = updatedFacebookPixelData; |
| 3031 |
} |
| 3032 |
console.error("Access token validation failed:", error2); |
| 3033 |
} finally { |
| 3034 |
setValidatingToken(false); |
| 3035 |
} |
| 3036 |
}; |
| 3037 |
React.useEffect(() => { |
| 3038 |
if (isInitializedRef.current) return; |
| 3039 |
if (settings) { |
| 3040 |
const mergedSettings = { |
| 3041 |
...defaultSettings, |
| 3042 |
...settings, |
| 3043 |
// Ensure gateway_configs from defaults are merged with any saved configs |
| 3044 |
gateway_configs: { |
| 3045 |
...defaultSettings.gateway_configs, |
| 3046 |
...settings.gateway_configs || {} |
| 3047 |
} |
| 3048 |
}; |
| 3049 |
setFormData(mergedSettings); |
| 3050 |
isInitializedRef.current = true; |
| 3051 |
} else if (!isLoading && !settings) { |
| 3052 |
setFormData(defaultSettings); |
| 3053 |
isInitializedRef.current = true; |
| 3054 |
} |
| 3055 |
}, [settings, isLoading]); |
| 3056 |
React.useEffect(() => { |
| 3057 |
let isMounted = true; |
| 3058 |
const controller = new AbortController(); |
| 3059 |
const fetchSeoImageUrl = async () => { |
| 3060 |
var _a2; |
| 3061 |
const imageId = formData == null ? void 0 : formData.seo_trip_meta_image; |
| 3062 |
if (!imageId || imageId <= 0) { |
| 3063 |
if (isMounted) { |
| 3064 |
setSeoImageUrl(""); |
| 3065 |
setSeoImageLoading(false); |
| 3066 |
setSeoImageError(""); |
| 3067 |
} |
| 3068 |
return; |
| 3069 |
} |
| 3070 |
if (isMounted) { |
| 3071 |
setSeoImageLoading(true); |
| 3072 |
setSeoImageError(""); |
| 3073 |
} |
| 3074 |
try { |
| 3075 |
const siteUrl = ((_a2 = window.yatraAdmin) == null ? void 0 : _a2.siteUrl) || ""; |
| 3076 |
const response = await fetch( |
| 3077 |
`${siteUrl}/wp-json/wp/v2/media/${imageId}`, |
| 3078 |
{ |
| 3079 |
signal: controller.signal, |
| 3080 |
headers: { |
| 3081 |
Accept: "application/json" |
| 3082 |
} |
| 3083 |
} |
| 3084 |
); |
| 3085 |
if (!isMounted) return; |
| 3086 |
if (response.ok) { |
| 3087 |
const mediaData = await response.json(); |
| 3088 |
const imageUrl = mediaData == null ? void 0 : mediaData.source_url; |
| 3089 |
if (imageUrl && typeof imageUrl === "string") { |
| 3090 |
setSeoImageUrl(imageUrl); |
| 3091 |
setSeoImageError(""); |
| 3092 |
} else { |
| 3093 |
setSeoImageUrl(""); |
| 3094 |
setSeoImageError("Image not found"); |
| 3095 |
} |
| 3096 |
} else { |
| 3097 |
setSeoImageUrl(""); |
| 3098 |
setSeoImageError(`Failed to load image (${response.status})`); |
| 3099 |
} |
| 3100 |
} catch (error2) { |
| 3101 |
if (isMounted) { |
| 3102 |
console.error("Error fetching SEO image:", error2); |
| 3103 |
setSeoImageUrl(""); |
| 3104 |
setSeoImageError( |
| 3105 |
error2 instanceof Error ? error2.message : "Unknown error" |
| 3106 |
); |
| 3107 |
} |
| 3108 |
} finally { |
| 3109 |
if (isMounted) { |
| 3110 |
setSeoImageLoading(false); |
| 3111 |
} |
| 3112 |
} |
| 3113 |
}; |
| 3114 |
fetchSeoImageUrl(); |
| 3115 |
return () => { |
| 3116 |
isMounted = false; |
| 3117 |
controller.abort(); |
| 3118 |
}; |
| 3119 |
}, [formData == null ? void 0 : formData.seo_trip_meta_image]); |
| 3120 |
const gatewayOrderInitialized = React.useRef(false); |
| 3121 |
React.useEffect(() => { |
| 3122 |
if (gatewayOrderInitialized.current) return; |
| 3123 |
if (!gatewayDefinitions || Object.keys(gatewayDefinitions).length === 0) { |
| 3124 |
return; |
| 3125 |
} |
| 3126 |
if (settings === void 0) return; |
| 3127 |
const allGateways = Object.keys(gatewayDefinitions); |
| 3128 |
const savedOrder = settings == null ? void 0 : settings.gateway_order; |
| 3129 |
if (Array.isArray(savedOrder) && savedOrder.length > 0) { |
| 3130 |
const validSavedOrder = savedOrder.filter( |
| 3131 |
(id) => allGateways.includes(id) |
| 3132 |
); |
| 3133 |
const newGateways = allGateways.filter( |
| 3134 |
(id) => !validSavedOrder.includes(id) |
| 3135 |
); |
| 3136 |
setGatewayOrder([...validSavedOrder, ...newGateways]); |
| 3137 |
} else { |
| 3138 |
setGatewayOrder(allGateways); |
| 3139 |
} |
| 3140 |
gatewayOrderInitialized.current = true; |
| 3141 |
}, [gatewayDefinitions, settings]); |
| 3142 |
const handleFieldChange = React.useCallback( |
| 3143 |
(e) => { |
| 3144 |
const field = e.target.name || e.target.id; |
| 3145 |
let value; |
| 3146 |
if (e.target.type === "checkbox") { |
| 3147 |
value = e.target.checked; |
| 3148 |
} else if (e.target.type === "number") { |
| 3149 |
const raw = e.target.value; |
| 3150 |
if (raw === "") { |
| 3151 |
value = ""; |
| 3152 |
} else { |
| 3153 |
const numValue = parseFloat(raw); |
| 3154 |
value = isNaN(numValue) ? 0 : numValue; |
| 3155 |
} |
| 3156 |
} else { |
| 3157 |
value = e.target.value; |
| 3158 |
} |
| 3159 |
setFormData((prev) => { |
| 3160 |
if (!prev) return prev; |
| 3161 |
return { ...prev, [field]: value }; |
| 3162 |
}); |
| 3163 |
}, |
| 3164 |
[] |
| 3165 |
); |
| 3166 |
const timeZoneSelectOptions = reactExports.useMemo(() => { |
| 3167 |
var _a2; |
| 3168 |
const ya = window.yatraAdmin || {}; |
| 3169 |
const raw = ya.timeZoneIdentifiers; |
| 3170 |
let ids = []; |
| 3171 |
if (Array.isArray(raw) && raw.length > 0 && raw.every((x) => typeof x === "string")) { |
| 3172 |
ids = raw; |
| 3173 |
} else { |
| 3174 |
ids = [ |
| 3175 |
"UTC", |
| 3176 |
"America/New_York", |
| 3177 |
"America/Los_Angeles", |
| 3178 |
"Europe/London", |
| 3179 |
"Europe/Paris", |
| 3180 |
"Asia/Dubai", |
| 3181 |
"Asia/Kolkata", |
| 3182 |
"Asia/Kathmandu", |
| 3183 |
"Australia/Sydney" |
| 3184 |
]; |
| 3185 |
} |
| 3186 |
const set = new Set(ids); |
| 3187 |
const wpTz = typeof ya.wordPressTimezone === "string" ? ya.wordPressTimezone.trim() : ""; |
| 3188 |
if (wpTz) { |
| 3189 |
set.add(wpTz); |
| 3190 |
} |
| 3191 |
const current = (_a2 = formData == null ? void 0 : formData.timezone) == null ? void 0 : _a2.trim(); |
| 3192 |
if (current) { |
| 3193 |
set.add(current); |
| 3194 |
} |
| 3195 |
return Array.from(set).sort((a, b) => a.localeCompare(b)).map((z) => ({ value: z, label: z })); |
| 3196 |
}, [formData == null ? void 0 : formData.timezone]); |
| 3197 |
const handleGatewayConfigChange = React.useCallback( |
| 3198 |
(gateway, field, value) => { |
| 3199 |
setFormData((prev) => { |
| 3200 |
if (!prev) return prev; |
| 3201 |
const configs = { ...prev.gateway_configs || {} }; |
| 3202 |
const existingConfig = configs[gateway] || { |
| 3203 |
enabled: false, |
| 3204 |
title: gateway, |
| 3205 |
description: "" |
| 3206 |
}; |
| 3207 |
configs[gateway] = { ...existingConfig, [field]: value }; |
| 3208 |
return { ...prev, gateway_configs: configs }; |
| 3209 |
}); |
| 3210 |
if (field === "enabled" && value === true) { |
| 3211 |
setExpandedGateways((prev) => ({ ...prev, [gateway]: true })); |
| 3212 |
} |
| 3213 |
if (field === "enabled" && value === false) { |
| 3214 |
setExpandedGateways((prev) => ({ ...prev, [gateway]: false })); |
| 3215 |
} |
| 3216 |
}, |
| 3217 |
[] |
| 3218 |
); |
| 3219 |
const toggleGatewayExpanded = (gateway) => { |
| 3220 |
setExpandedGateways((prev) => ({ ...prev, [gateway]: !prev[gateway] })); |
| 3221 |
}; |
| 3222 |
const moveGatewayUp = (gatewayId) => { |
| 3223 |
setGatewayOrder((prev) => { |
| 3224 |
const index = prev.indexOf(gatewayId); |
| 3225 |
if (index <= 0) return prev; |
| 3226 |
const newOrder = [...prev]; |
| 3227 |
[newOrder[index - 1], newOrder[index]] = [ |
| 3228 |
newOrder[index], |
| 3229 |
newOrder[index - 1] |
| 3230 |
]; |
| 3231 |
setFormData( |
| 3232 |
(current) => current ? { ...current, gateway_order: newOrder } : current |
| 3233 |
); |
| 3234 |
return newOrder; |
| 3235 |
}); |
| 3236 |
}; |
| 3237 |
const moveGatewayDown = (gatewayId) => { |
| 3238 |
setGatewayOrder((prev) => { |
| 3239 |
const index = prev.indexOf(gatewayId); |
| 3240 |
if (index < 0 || index >= prev.length - 1) return prev; |
| 3241 |
const newOrder = [...prev]; |
| 3242 |
[newOrder[index], newOrder[index + 1]] = [ |
| 3243 |
newOrder[index + 1], |
| 3244 |
newOrder[index] |
| 3245 |
]; |
| 3246 |
setFormData( |
| 3247 |
(current) => current ? { ...current, gateway_order: newOrder } : current |
| 3248 |
); |
| 3249 |
return newOrder; |
| 3250 |
}); |
| 3251 |
}; |
| 3252 |
const handleDragStart = (e, gatewayId) => { |
| 3253 |
setDraggedGateway(gatewayId); |
| 3254 |
e.dataTransfer.effectAllowed = "move"; |
| 3255 |
}; |
| 3256 |
const handleDragOver = (e) => { |
| 3257 |
e.preventDefault(); |
| 3258 |
e.dataTransfer.dropEffect = "move"; |
| 3259 |
}; |
| 3260 |
const handleDrop = (e, targetGatewayId) => { |
| 3261 |
e.preventDefault(); |
| 3262 |
if (!draggedGateway || draggedGateway === targetGatewayId) { |
| 3263 |
setDraggedGateway(null); |
| 3264 |
return; |
| 3265 |
} |
| 3266 |
setGatewayOrder((prev) => { |
| 3267 |
const dragIndex = prev.indexOf(draggedGateway); |
| 3268 |
const dropIndex = prev.indexOf(targetGatewayId); |
| 3269 |
if (dragIndex < 0 || dropIndex < 0) return prev; |
| 3270 |
const newOrder = [...prev]; |
| 3271 |
newOrder.splice(dragIndex, 1); |
| 3272 |
newOrder.splice(dropIndex, 0, draggedGateway); |
| 3273 |
setFormData( |
| 3274 |
(current) => current ? { ...current, gateway_order: newOrder } : current |
| 3275 |
); |
| 3276 |
return newOrder; |
| 3277 |
}); |
| 3278 |
setDraggedGateway(null); |
| 3279 |
}; |
| 3280 |
const handleDragEnd = () => { |
| 3281 |
setDraggedGateway(null); |
| 3282 |
}; |
| 3283 |
const saveMutation = useMutation({ |
| 3284 |
mutationFn: async (data) => { |
| 3285 |
try { |
| 3286 |
await saveSettings(data); |
| 3287 |
return data; |
| 3288 |
} catch (error2) { |
| 3289 |
showToast( |
| 3290 |
(error2 == null ? void 0 : error2.message) || __("Failed to save settings", "yatra"), |
| 3291 |
"error" |
| 3292 |
); |
| 3293 |
throw error2; |
| 3294 |
} |
| 3295 |
}, |
| 3296 |
onSuccess: (savedData) => { |
| 3297 |
queryClient.setQueryData(["settings"], savedData); |
| 3298 |
showToast(__("Settings saved successfully", "yatra"), "success"); |
| 3299 |
setIsSaving(false); |
| 3300 |
setFormData(savedData); |
| 3301 |
isInitializedRef.current = true; |
| 3302 |
}, |
| 3303 |
onError: (error2) => { |
| 3304 |
setIsSaving(false); |
| 3305 |
const errorMessage = (error2 == null ? void 0 : error2.message) || __("Error saving settings", "yatra"); |
| 3306 |
showToast(errorMessage, "error"); |
| 3307 |
} |
| 3308 |
}); |
| 3309 |
const flushRewriteRulesMutation = useMutation({ |
| 3310 |
mutationFn: async () => { |
| 3311 |
return await postFlushRewriteRules(); |
| 3312 |
}, |
| 3313 |
onSuccess: () => { |
| 3314 |
showToast(__("Rewrite rules flushed successfully", "yatra"), "success"); |
| 3315 |
}, |
| 3316 |
onError: (error2) => { |
| 3317 |
showToast( |
| 3318 |
(error2 == null ? void 0 : error2.message) || __("Failed to flush rewrite rules", "yatra"), |
| 3319 |
"error" |
| 3320 |
); |
| 3321 |
} |
| 3322 |
}); |
| 3323 |
const { data: pagesData } = useQuery({ |
| 3324 |
queryKey: ["wordpress-pages"], |
| 3325 |
queryFn: async () => { |
| 3326 |
const response = await fetchWordPressPages(); |
| 3327 |
return response; |
| 3328 |
}, |
| 3329 |
// Used by multiple sections (Booking page, Legal pages, etc.), so keep it available |
| 3330 |
// whenever the user can manage Yatra settings. |
| 3331 |
enabled: can("yatra_manage_settings") |
| 3332 |
}); |
| 3333 |
const checkShortcodeMutation = useMutation({ |
| 3334 |
mutationFn: async (pageId) => { |
| 3335 |
const response = await fetchBookingPageShortcodeStatus(pageId); |
| 3336 |
return response; |
| 3337 |
} |
| 3338 |
}); |
| 3339 |
const insertShortcodeMutation = useMutation({ |
| 3340 |
mutationFn: async (pageId) => { |
| 3341 |
return await postInsertBookingShortcode(pageId); |
| 3342 |
}, |
| 3343 |
onSuccess: () => { |
| 3344 |
showToast(__("Shortcode added successfully", "yatra"), "success"); |
| 3345 |
queryClient.invalidateQueries({ queryKey: ["wordpress-pages"] }); |
| 3346 |
}, |
| 3347 |
onError: (error2) => { |
| 3348 |
showToast( |
| 3349 |
(error2 == null ? void 0 : error2.message) || __("Failed to add shortcode", "yatra"), |
| 3350 |
"error" |
| 3351 |
); |
| 3352 |
} |
| 3353 |
}); |
| 3354 |
const [showShortcodeDialog, setShowShortcodeDialog] = reactExports.useState(false); |
| 3355 |
const [selectedPageForShortcode, setSelectedPageForShortcode] = reactExports.useState(null); |
| 3356 |
const [isCheckingShortcode, setIsCheckingShortcode] = reactExports.useState(false); |
| 3357 |
const handleBookingPageChange = async (pageId) => { |
| 3358 |
if (pageId === 0) { |
| 3359 |
handleFieldChange({ |
| 3360 |
target: { name: "booking_page_id", value: 0 } |
| 3361 |
}); |
| 3362 |
handleFieldChange({ |
| 3363 |
target: { name: "use_booking_page", value: false } |
| 3364 |
}); |
| 3365 |
return; |
| 3366 |
} |
| 3367 |
const page = pagesData == null ? void 0 : pagesData.find((p) => p.id === pageId); |
| 3368 |
if (!page) return; |
| 3369 |
setIsCheckingShortcode(true); |
| 3370 |
try { |
| 3371 |
const result = await checkShortcodeMutation.mutateAsync(pageId); |
| 3372 |
if (result.has_shortcode) { |
| 3373 |
handleFieldChange({ |
| 3374 |
target: { name: "booking_page_id", value: pageId } |
| 3375 |
}); |
| 3376 |
handleFieldChange({ |
| 3377 |
target: { name: "use_booking_page", value: true } |
| 3378 |
}); |
| 3379 |
showToast(__("Booking page selected successfully", "yatra"), "success"); |
| 3380 |
} else { |
| 3381 |
setSelectedPageForShortcode({ id: pageId, title: page.title }); |
| 3382 |
setShowShortcodeDialog(true); |
| 3383 |
} |
| 3384 |
} catch (error2) { |
| 3385 |
showToast((error2 == null ? void 0 : error2.message) || __("Failed to check page", "yatra"), "error"); |
| 3386 |
} finally { |
| 3387 |
setIsCheckingShortcode(false); |
| 3388 |
} |
| 3389 |
}; |
| 3390 |
const handleConfirmInsertShortcode = async () => { |
| 3391 |
if (!selectedPageForShortcode) return; |
| 3392 |
try { |
| 3393 |
await insertShortcodeMutation.mutateAsync(selectedPageForShortcode.id); |
| 3394 |
handleFieldChange({ |
| 3395 |
target: { name: "booking_page_id", value: selectedPageForShortcode.id } |
| 3396 |
}); |
| 3397 |
handleFieldChange({ |
| 3398 |
target: { name: "use_booking_page", value: true } |
| 3399 |
}); |
| 3400 |
setShowShortcodeDialog(false); |
| 3401 |
setSelectedPageForShortcode(null); |
| 3402 |
} catch (error2) { |
| 3403 |
} |
| 3404 |
}; |
| 3405 |
const handleSave = () => { |
| 3406 |
if (formData) { |
| 3407 |
setIsSaving(true); |
| 3408 |
let updatedFormData = { ...formData }; |
| 3409 |
saveMutation.mutate(updatedFormData, { |
| 3410 |
onSuccess: () => { |
| 3411 |
setActiveSection(viewingSection); |
| 3412 |
if (typeof window !== "undefined") { |
| 3413 |
localStorage.setItem( |
| 3414 |
"yatra_settings_active_section", |
| 3415 |
viewingSection |
| 3416 |
); |
| 3417 |
} |
| 3418 |
}, |
| 3419 |
onSettled: () => { |
| 3420 |
setIsSaving(false); |
| 3421 |
} |
| 3422 |
}); |
| 3423 |
} |
| 3424 |
}; |
| 3425 |
const settingsSections = [ |
| 3426 |
{ |
| 3427 |
id: "general", |
| 3428 |
label: __("General", "yatra"), |
| 3429 |
icon: Building2 |
| 3430 |
}, |
| 3431 |
{ |
| 3432 |
id: "design", |
| 3433 |
label: __("Design", "yatra"), |
| 3434 |
icon: Palette |
| 3435 |
}, |
| 3436 |
{ |
| 3437 |
id: "booking", |
| 3438 |
label: __("Booking", "yatra"), |
| 3439 |
icon: Calendar |
| 3440 |
}, |
| 3441 |
{ |
| 3442 |
id: "booking_form", |
| 3443 |
label: __("Booking Form", "yatra"), |
| 3444 |
icon: ClipboardList |
| 3445 |
}, |
| 3446 |
{ |
| 3447 |
id: "search", |
| 3448 |
label: __("Search & Listing", "yatra"), |
| 3449 |
icon: SlidersHorizontal |
| 3450 |
}, |
| 3451 |
{ |
| 3452 |
id: "payment", |
| 3453 |
label: __("Payment", "yatra"), |
| 3454 |
icon: DollarSign |
| 3455 |
}, |
| 3456 |
// Pricing tab — visible on every Pro install so the Discount |
| 3457 |
// Stacking control is *discoverable*. The setting itself only |
| 3458 |
// takes effect when BOTH Advanced Discount and Dynamic Pricing |
| 3459 |
// are enabled; the case "pricing" render gives a clear status |
| 3460 |
// banner + disables the dropdown when prerequisites are missing. |
| 3461 |
// |
| 3462 |
// Truthy check (not `=== true`) because some WP installs end up |
| 3463 |
// with `isPro` serialized as `1` instead of `true` through the |
| 3464 |
// PHP→JSON→JS pipeline. Free installs serialize false (or omit |
| 3465 |
// the key), which stays falsy and correctly hides the tab. |
| 3466 |
...((_a = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _a.isPro) ? [ |
| 3467 |
{ |
| 3468 |
id: "pricing", |
| 3469 |
label: __("Pricing", "yatra"), |
| 3470 |
icon: Percent |
| 3471 |
} |
| 3472 |
] : [], |
| 3473 |
{ |
| 3474 |
id: "customer", |
| 3475 |
label: __("Customer", "yatra"), |
| 3476 |
icon: Users |
| 3477 |
}, |
| 3478 |
{ |
| 3479 |
id: "review", |
| 3480 |
label: __("Review", "yatra"), |
| 3481 |
icon: Star |
| 3482 |
}, |
| 3483 |
{ id: "tax", label: __("Tax", "yatra"), icon: Receipt }, |
| 3484 |
{ |
| 3485 |
id: "currency", |
| 3486 |
label: __("Currency", "yatra"), |
| 3487 |
icon: Globe |
| 3488 |
}, |
| 3489 |
{ |
| 3490 |
id: "integration", |
| 3491 |
label: __("Integration", "yatra"), |
| 3492 |
icon: Plug |
| 3493 |
}, |
| 3494 |
{ |
| 3495 |
id: "permalink", |
| 3496 |
label: __("Permalink", "yatra"), |
| 3497 |
icon: Globe |
| 3498 |
}, |
| 3499 |
{ |
| 3500 |
id: "seo", |
| 3501 |
label: __("SEO", "yatra"), |
| 3502 |
icon: TrendingUp |
| 3503 |
}, |
| 3504 |
{ |
| 3505 |
id: "advanced", |
| 3506 |
label: __("Advanced", "yatra"), |
| 3507 |
icon: Shield |
| 3508 |
} |
| 3509 |
]; |
| 3510 |
const SectionDivider = ({ title }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "border-t border-gray-200 dark:border-gray-700 pt-4 mt-6", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: title }) }); |
| 3511 |
const renderSettingsContent = () => { |
| 3512 |
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __2, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia; |
| 3513 |
if (!formData) return null; |
| 3514 |
switch (viewingSection) { |
| 3515 |
case "general": |
| 3516 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 3517 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 3518 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Company Information", "yatra") }), |
| 3519 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 3520 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3521 |
FormField, |
| 3522 |
{ |
| 3523 |
id: "company_name", |
| 3524 |
label: __("Company Name", "yatra"), |
| 3525 |
description: __( |
| 3526 |
"Your travel agency or company name", |
| 3527 |
"yatra" |
| 3528 |
), |
| 3529 |
required: true, |
| 3530 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3531 |
Input, |
| 3532 |
{ |
| 3533 |
id: "company_name", |
| 3534 |
name: "company_name", |
| 3535 |
value: formData.company_name || "", |
| 3536 |
onChange: handleFieldChange, |
| 3537 |
placeholder: __("Enter company name", "yatra") |
| 3538 |
} |
| 3539 |
) |
| 3540 |
} |
| 3541 |
), |
| 3542 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [ |
| 3543 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3544 |
FormField, |
| 3545 |
{ |
| 3546 |
id: "company_email", |
| 3547 |
label: __("Company Email", "yatra"), |
| 3548 |
description: __("Primary contact email address", "yatra"), |
| 3549 |
required: true, |
| 3550 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3551 |
Input, |
| 3552 |
{ |
| 3553 |
id: "company_email", |
| 3554 |
name: "company_email", |
| 3555 |
type: "email", |
| 3556 |
value: formData.company_email || "", |
| 3557 |
onChange: handleFieldChange, |
| 3558 |
placeholder: __("[email protected]", "yatra") |
| 3559 |
} |
| 3560 |
) |
| 3561 |
} |
| 3562 |
), |
| 3563 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3564 |
FormField, |
| 3565 |
{ |
| 3566 |
id: "company_phone", |
| 3567 |
label: __("Company Phone", "yatra"), |
| 3568 |
description: __("Primary contact phone number", "yatra"), |
| 3569 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3570 |
Input, |
| 3571 |
{ |
| 3572 |
id: "company_phone", |
| 3573 |
name: "company_phone", |
| 3574 |
value: formData.company_phone || "", |
| 3575 |
onChange: handleFieldChange, |
| 3576 |
placeholder: __("+1-234-567-8900", "yatra") |
| 3577 |
} |
| 3578 |
) |
| 3579 |
} |
| 3580 |
) |
| 3581 |
] }), |
| 3582 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3583 |
FormField, |
| 3584 |
{ |
| 3585 |
id: "company_address", |
| 3586 |
label: __("Street Address", "yatra"), |
| 3587 |
description: __("Street address of your company", "yatra"), |
| 3588 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3589 |
Input, |
| 3590 |
{ |
| 3591 |
id: "company_address", |
| 3592 |
name: "company_address", |
| 3593 |
value: formData.company_address || "", |
| 3594 |
onChange: handleFieldChange, |
| 3595 |
placeholder: __("123 Main Street", "yatra") |
| 3596 |
} |
| 3597 |
) |
| 3598 |
} |
| 3599 |
), |
| 3600 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [ |
| 3601 |
/* @__PURE__ */ jsxRuntimeExports.jsx(FormField, { id: "company_city", label: __("City", "yatra"), children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3602 |
Input, |
| 3603 |
{ |
| 3604 |
id: "company_city", |
| 3605 |
name: "company_city", |
| 3606 |
value: formData.company_city || "", |
| 3607 |
onChange: handleFieldChange, |
| 3608 |
placeholder: __("City", "yatra") |
| 3609 |
} |
| 3610 |
) }), |
| 3611 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3612 |
FormField, |
| 3613 |
{ |
| 3614 |
id: "company_state", |
| 3615 |
label: __("State/Province", "yatra"), |
| 3616 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3617 |
Input, |
| 3618 |
{ |
| 3619 |
id: "company_state", |
| 3620 |
name: "company_state", |
| 3621 |
value: formData.company_state || "", |
| 3622 |
onChange: handleFieldChange, |
| 3623 |
placeholder: __("State or Province", "yatra") |
| 3624 |
} |
| 3625 |
) |
| 3626 |
} |
| 3627 |
) |
| 3628 |
] }), |
| 3629 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [ |
| 3630 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3631 |
FormField, |
| 3632 |
{ |
| 3633 |
id: "company_country", |
| 3634 |
label: __("Country", "yatra"), |
| 3635 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3636 |
Input, |
| 3637 |
{ |
| 3638 |
id: "company_country", |
| 3639 |
name: "company_country", |
| 3640 |
value: formData.company_country || "", |
| 3641 |
onChange: handleFieldChange, |
| 3642 |
placeholder: __("Country", "yatra") |
| 3643 |
} |
| 3644 |
) |
| 3645 |
} |
| 3646 |
), |
| 3647 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3648 |
FormField, |
| 3649 |
{ |
| 3650 |
id: "company_zip", |
| 3651 |
label: __("ZIP/Postal Code", "yatra"), |
| 3652 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3653 |
Input, |
| 3654 |
{ |
| 3655 |
id: "company_zip", |
| 3656 |
value: formData.company_zip, |
| 3657 |
name: "company_zip", |
| 3658 |
onChange: handleFieldChange, |
| 3659 |
placeholder: __("ZIP Code", "yatra") |
| 3660 |
} |
| 3661 |
) |
| 3662 |
} |
| 3663 |
) |
| 3664 |
] }), |
| 3665 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3666 |
FormField, |
| 3667 |
{ |
| 3668 |
id: "company_website", |
| 3669 |
label: __("Website URL", "yatra"), |
| 3670 |
description: __("Your company website address", "yatra"), |
| 3671 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3672 |
Input, |
| 3673 |
{ |
| 3674 |
id: "company_website", |
| 3675 |
type: "url", |
| 3676 |
value: formData.company_website, |
| 3677 |
name: "company_website", |
| 3678 |
onChange: handleFieldChange, |
| 3679 |
placeholder: __("https://example.com", "yatra") |
| 3680 |
} |
| 3681 |
) |
| 3682 |
} |
| 3683 |
) |
| 3684 |
] }) |
| 3685 |
] }), |
| 3686 |
/* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Regional Settings", "yatra") }), |
| 3687 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: [ |
| 3688 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3689 |
FormField, |
| 3690 |
{ |
| 3691 |
id: "timezone", |
| 3692 |
label: __("Timezone", "yatra"), |
| 3693 |
description: __( |
| 3694 |
"Used for booking logic, emails, and date display. Search the full IANA list (same identifiers PHP uses).", |
| 3695 |
"yatra" |
| 3696 |
), |
| 3697 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 3698 |
((_a2 = window.yatraAdmin) == null ? void 0 : _a2.wordPressTimezone) ? /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 3699 |
Button, |
| 3700 |
{ |
| 3701 |
type: "button", |
| 3702 |
variant: "outline", |
| 3703 |
size: "sm", |
| 3704 |
className: "w-full sm:w-auto", |
| 3705 |
onClick: () => handleFieldChange({ |
| 3706 |
target: { |
| 3707 |
name: "timezone", |
| 3708 |
id: "timezone", |
| 3709 |
value: String( |
| 3710 |
window.yatraAdmin.wordPressTimezone |
| 3711 |
), |
| 3712 |
type: "select-one" |
| 3713 |
} |
| 3714 |
}), |
| 3715 |
children: [ |
| 3716 |
__("Use WordPress site timezone", "yatra"), |
| 3717 |
": ", |
| 3718 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-mono text-xs", children: window.yatraAdmin.wordPressTimezone }) |
| 3719 |
] |
| 3720 |
} |
| 3721 |
) : null, |
| 3722 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3723 |
SearchableSelect, |
| 3724 |
{ |
| 3725 |
value: formData.timezone, |
| 3726 |
onChange: (val) => handleFieldChange({ |
| 3727 |
target: { |
| 3728 |
name: "timezone", |
| 3729 |
id: "timezone", |
| 3730 |
value: val, |
| 3731 |
type: "select-one" |
| 3732 |
} |
| 3733 |
}), |
| 3734 |
options: timeZoneSelectOptions, |
| 3735 |
searchPlaceholder: __( |
| 3736 |
"Search by city, region, or code…", |
| 3737 |
"yatra" |
| 3738 |
), |
| 3739 |
placeholder: __("Select timezone…", "yatra"), |
| 3740 |
showValueId: false |
| 3741 |
} |
| 3742 |
) |
| 3743 |
] }) |
| 3744 |
} |
| 3745 |
), |
| 3746 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3747 |
FormField, |
| 3748 |
{ |
| 3749 |
id: "date_format", |
| 3750 |
label: __("Date Format", "yatra"), |
| 3751 |
description: __("How dates are displayed", "yatra"), |
| 3752 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 3753 |
Select, |
| 3754 |
{ |
| 3755 |
id: "date_format", |
| 3756 |
value: formData.date_format, |
| 3757 |
name: "date_format", |
| 3758 |
onChange: handleFieldChange, |
| 3759 |
children: [ |
| 3760 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "Y-m-d", children: [ |
| 3761 |
(/* @__PURE__ */ new Date()).toLocaleDateString("en-CA"), |
| 3762 |
" (YYYY-MM-DD)" |
| 3763 |
] }), |
| 3764 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "Y/m/d", children: [ |
| 3765 |
`${(/* @__PURE__ */ new Date()).getFullYear()}/${String((/* @__PURE__ */ new Date()).getMonth() + 1).padStart(2, "0")}/${String((/* @__PURE__ */ new Date()).getDate()).padStart(2, "0")}`, |
| 3766 |
" ", |
| 3767 |
"(YYYY/MM/DD)" |
| 3768 |
] }), |
| 3769 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "m/d/Y", children: [ |
| 3770 |
`${String((/* @__PURE__ */ new Date()).getMonth() + 1).padStart(2, "0")}/${String((/* @__PURE__ */ new Date()).getDate()).padStart(2, "0")}/${(/* @__PURE__ */ new Date()).getFullYear()}`, |
| 3771 |
" ", |
| 3772 |
"(MM/DD/YYYY)" |
| 3773 |
] }), |
| 3774 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "d/m/Y", children: [ |
| 3775 |
`${String((/* @__PURE__ */ new Date()).getDate()).padStart(2, "0")}/${String((/* @__PURE__ */ new Date()).getMonth() + 1).padStart(2, "0")}/${(/* @__PURE__ */ new Date()).getFullYear()}`, |
| 3776 |
" ", |
| 3777 |
"(DD/MM/YYYY)" |
| 3778 |
] }), |
| 3779 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "d-m-Y", children: [ |
| 3780 |
`${String((/* @__PURE__ */ new Date()).getDate()).padStart(2, "0")}-${String((/* @__PURE__ */ new Date()).getMonth() + 1).padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getFullYear()}`, |
| 3781 |
" ", |
| 3782 |
"(DD-MM-YYYY)" |
| 3783 |
] }), |
| 3784 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "d.m.Y", children: [ |
| 3785 |
`${String((/* @__PURE__ */ new Date()).getDate()).padStart(2, "0")}.${String((/* @__PURE__ */ new Date()).getMonth() + 1).padStart(2, "0")}.${(/* @__PURE__ */ new Date()).getFullYear()}`, |
| 3786 |
" ", |
| 3787 |
"(DD.MM.YYYY)" |
| 3788 |
] }), |
| 3789 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "M j, Y", children: [ |
| 3790 |
(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { |
| 3791 |
month: "short", |
| 3792 |
day: "numeric", |
| 3793 |
year: "numeric" |
| 3794 |
}), |
| 3795 |
" ", |
| 3796 |
"(Mon D, YYYY)" |
| 3797 |
] }), |
| 3798 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "F j, Y", children: [ |
| 3799 |
(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { |
| 3800 |
month: "long", |
| 3801 |
day: "numeric", |
| 3802 |
year: "numeric" |
| 3803 |
}), |
| 3804 |
" ", |
| 3805 |
"(Month D, YYYY)" |
| 3806 |
] }), |
| 3807 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "j M Y", children: [ |
| 3808 |
`${(/* @__PURE__ */ new Date()).getDate()} ${(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { month: "short" })} ${(/* @__PURE__ */ new Date()).getFullYear()}`, |
| 3809 |
" ", |
| 3810 |
"(D Mon YYYY)" |
| 3811 |
] }), |
| 3812 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "j F Y", children: [ |
| 3813 |
`${(/* @__PURE__ */ new Date()).getDate()} ${(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { month: "long" })} ${(/* @__PURE__ */ new Date()).getFullYear()}`, |
| 3814 |
" ", |
| 3815 |
"(D Month YYYY)" |
| 3816 |
] }), |
| 3817 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "Y M j", children: [ |
| 3818 |
`${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { month: "short" })} ${(/* @__PURE__ */ new Date()).getDate()}`, |
| 3819 |
" ", |
| 3820 |
"(YYYY Mon D)" |
| 3821 |
] }), |
| 3822 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "Y F j", children: [ |
| 3823 |
`${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { month: "long" })} ${(/* @__PURE__ */ new Date()).getDate()}`, |
| 3824 |
" ", |
| 3825 |
"(YYYY Month D)" |
| 3826 |
] }), |
| 3827 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "l, F j, Y", children: [ |
| 3828 |
(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { |
| 3829 |
weekday: "long", |
| 3830 |
month: "long", |
| 3831 |
day: "numeric", |
| 3832 |
year: "numeric" |
| 3833 |
}), |
| 3834 |
" ", |
| 3835 |
"(Day, Month D, YYYY)" |
| 3836 |
] }), |
| 3837 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "D, M j, Y", children: [ |
| 3838 |
(/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { |
| 3839 |
weekday: "short", |
| 3840 |
month: "short", |
| 3841 |
day: "numeric", |
| 3842 |
year: "numeric" |
| 3843 |
}), |
| 3844 |
" ", |
| 3845 |
"(Day, Mon D, YYYY)" |
| 3846 |
] }) |
| 3847 |
] |
| 3848 |
} |
| 3849 |
) |
| 3850 |
} |
| 3851 |
), |
| 3852 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3853 |
FormField, |
| 3854 |
{ |
| 3855 |
id: "time_format", |
| 3856 |
label: __("Time Format", "yatra"), |
| 3857 |
description: __("12-hour or 24-hour format", "yatra"), |
| 3858 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 3859 |
Select, |
| 3860 |
{ |
| 3861 |
id: "time_format", |
| 3862 |
value: formData.time_format, |
| 3863 |
name: "time_format", |
| 3864 |
onChange: handleFieldChange, |
| 3865 |
children: [ |
| 3866 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "H:i", children: "24 Hour (14:30)" }), |
| 3867 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "h:i A", children: "12 Hour (2:30 PM)" }) |
| 3868 |
] |
| 3869 |
} |
| 3870 |
) |
| 3871 |
} |
| 3872 |
) |
| 3873 |
] }) }) |
| 3874 |
] }); |
| 3875 |
case "design": |
| 3876 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 3877 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __( |
| 3878 |
"Control how Yatra looks on the public site (trip pages, booking, listings, and shortcodes). These options complement your WordPress theme.", |
| 3879 |
"yatra" |
| 3880 |
) }), |
| 3881 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 3882 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3883 |
FormField, |
| 3884 |
{ |
| 3885 |
id: "frontend_primary_color", |
| 3886 |
label: __("Primary brand color", "yatra"), |
| 3887 |
description: __( |
| 3888 |
"Buttons, links, and highlights. Default is the standard Yatra blue; choose a hex color that matches your brand or theme accent.", |
| 3889 |
"yatra" |
| 3890 |
), |
| 3891 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [ |
| 3892 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3893 |
"input", |
| 3894 |
{ |
| 3895 |
type: "color", |
| 3896 |
id: "frontend_primary_color_picker", |
| 3897 |
"aria-label": __("Pick primary color", "yatra"), |
| 3898 |
className: "h-10 w-14 cursor-pointer rounded border border-gray-300 bg-white p-0.5 dark:border-gray-600", |
| 3899 |
value: /^#[0-9A-Fa-f]{6}$/.test( |
| 3900 |
(formData.frontend_primary_color || "").trim() |
| 3901 |
) ? (formData.frontend_primary_color || "").trim() : "#3b82f6", |
| 3902 |
onChange: (e) => handleFieldChange({ |
| 3903 |
target: { |
| 3904 |
name: "frontend_primary_color", |
| 3905 |
id: "frontend_primary_color", |
| 3906 |
value: e.target.value, |
| 3907 |
type: "text" |
| 3908 |
} |
| 3909 |
}) |
| 3910 |
} |
| 3911 |
), |
| 3912 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3913 |
Input, |
| 3914 |
{ |
| 3915 |
id: "frontend_primary_color", |
| 3916 |
name: "frontend_primary_color", |
| 3917 |
className: "max-w-[10rem] font-mono text-sm", |
| 3918 |
value: formData.frontend_primary_color || "", |
| 3919 |
onChange: handleFieldChange, |
| 3920 |
placeholder: "#3b82f6", |
| 3921 |
spellCheck: false |
| 3922 |
} |
| 3923 |
), |
| 3924 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3925 |
Button, |
| 3926 |
{ |
| 3927 |
type: "button", |
| 3928 |
variant: "outline", |
| 3929 |
size: "sm", |
| 3930 |
onClick: () => handleFieldChange({ |
| 3931 |
target: { |
| 3932 |
name: "frontend_primary_color", |
| 3933 |
id: "frontend_primary_color", |
| 3934 |
value: "#3b82f6", |
| 3935 |
type: "text" |
| 3936 |
} |
| 3937 |
}), |
| 3938 |
children: __("Reset to default", "yatra") |
| 3939 |
} |
| 3940 |
) |
| 3941 |
] }) |
| 3942 |
} |
| 3943 |
), |
| 3944 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3945 |
FormField, |
| 3946 |
{ |
| 3947 |
id: "frontend_container_max_width", |
| 3948 |
label: __("Container max width", "yatra"), |
| 3949 |
description: __( |
| 3950 |
"Optional. CSS width for trip listings, booking flow, and shortcode layouts (e.g. 1200px, 72rem, min(100%,80rem)). Leave empty to use your block theme layout (theme.json) or theme content width.", |
| 3951 |
"yatra" |
| 3952 |
), |
| 3953 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3954 |
Input, |
| 3955 |
{ |
| 3956 |
id: "frontend_container_max_width", |
| 3957 |
name: "frontend_container_max_width", |
| 3958 |
className: "max-w-md font-mono text-sm", |
| 3959 |
value: formData.frontend_container_max_width || "", |
| 3960 |
onChange: handleFieldChange, |
| 3961 |
placeholder: "1200px", |
| 3962 |
spellCheck: false, |
| 3963 |
autoComplete: "off" |
| 3964 |
} |
| 3965 |
) |
| 3966 |
} |
| 3967 |
), |
| 3968 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3969 |
FormField, |
| 3970 |
{ |
| 3971 |
id: "frontend_listing_card_layout", |
| 3972 |
label: __("Listing card layout", "yatra"), |
| 3973 |
description: __( |
| 3974 |
"How trip cards appear in listings and search results. Compact shows a dense card — image, title, price and a View Details button only — so several trips fit per screen. Ideal for phones. Existing sites keep the Standard card.", |
| 3975 |
"yatra" |
| 3976 |
), |
| 3977 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 3978 |
"div", |
| 3979 |
{ |
| 3980 |
role: "radiogroup", |
| 3981 |
"aria-label": __("Listing card layout", "yatra"), |
| 3982 |
className: "grid grid-cols-1 sm:grid-cols-3 gap-3 max-w-2xl", |
| 3983 |
children: [ |
| 3984 |
{ |
| 3985 |
value: "standard", |
| 3986 |
label: __("Standard", "yatra"), |
| 3987 |
sub: __("Full card (default)", "yatra"), |
| 3988 |
svg: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 3989 |
"svg", |
| 3990 |
{ |
| 3991 |
viewBox: "0 0 160 100", |
| 3992 |
className: "w-full h-full", |
| 3993 |
fill: "none", |
| 3994 |
children: [ |
| 3995 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "46", y: "6", width: "68", height: "88", rx: "6", fill: "#ffffff", stroke: "#cbd5e1", strokeWidth: "2" }), |
| 3996 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "12", width: "56", height: "30", rx: "3", fill: "#60a5fa" }), |
| 3997 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "49", width: "44", height: "5", rx: "2.5", fill: "#94a3b8" }), |
| 3998 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "59", width: "34", height: "3", rx: "1.5", fill: "#cbd5e1" }), |
| 3999 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "66", width: "50", height: "3", rx: "1.5", fill: "#e2e8f0" }), |
| 4000 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "73", width: "50", height: "3", rx: "1.5", fill: "#e2e8f0" }), |
| 4001 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "52", y: "82", width: "18", height: "6", rx: "2", fill: "#475569" }), |
| 4002 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "86", y: "81", width: "22", height: "8", rx: "3", fill: "#3b82f6" }) |
| 4003 |
] |
| 4004 |
} |
| 4005 |
) |
| 4006 |
}, |
| 4007 |
{ |
| 4008 |
value: "compact_mobile", |
| 4009 |
label: __("Compact — mobile", "yatra"), |
| 4010 |
sub: __("Dense on phones · desktop unchanged", "yatra"), |
| 4011 |
svg: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 4012 |
"svg", |
| 4013 |
{ |
| 4014 |
viewBox: "0 0 160 100", |
| 4015 |
className: "w-full h-full", |
| 4016 |
fill: "none", |
| 4017 |
children: [ |
| 4018 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "50", y: "4", width: "60", height: "92", rx: "9", fill: "#ffffff", stroke: "#cbd5e1", strokeWidth: "2" }), |
| 4019 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "72", y: "8", width: "16", height: "3", rx: "1.5", fill: "#e2e8f0" }), |
| 4020 |
[0, 26, 52].map((dy) => /* @__PURE__ */ jsxRuntimeExports.jsxs("g", { transform: `translate(0,${dy})`, children: [ |
| 4021 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "56", y: "16", width: "48", height: "22", rx: "3", fill: "#f1f5f9" }), |
| 4022 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "59", y: "19", width: "16", height: "16", rx: "2", fill: "#60a5fa" }), |
| 4023 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "79", y: "21", width: "20", height: "3", rx: "1.5", fill: "#94a3b8" }), |
| 4024 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "79", y: "27", width: "12", height: "2.5", rx: "1.25", fill: "#cbd5e1" }), |
| 4025 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "79", y: "32", width: "9", height: "3", rx: "1.5", fill: "#475569" }), |
| 4026 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "93", y: "31.5", width: "6", height: "4", rx: "1.5", fill: "#3b82f6" }) |
| 4027 |
] }, dy)) |
| 4028 |
] |
| 4029 |
} |
| 4030 |
) |
| 4031 |
}, |
| 4032 |
{ |
| 4033 |
value: "compact_all", |
| 4034 |
label: __("Compact — everywhere", "yatra"), |
| 4035 |
sub: __("Dense on mobile & desktop", "yatra"), |
| 4036 |
svg: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 4037 |
"svg", |
| 4038 |
{ |
| 4039 |
viewBox: "0 0 160 100", |
| 4040 |
className: "w-full h-full", |
| 4041 |
fill: "none", |
| 4042 |
children: [ |
| 4043 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "10", y: "12", width: "98", height: "58", rx: "4", fill: "#ffffff", stroke: "#cbd5e1", strokeWidth: "2" }), |
| 4044 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "51", y: "70", width: "16", height: "8", fill: "#cbd5e1" }), |
| 4045 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "39", y: "78", width: "40", height: "4", rx: "2", fill: "#cbd5e1" }), |
| 4046 |
[0, 24].map((dy) => /* @__PURE__ */ jsxRuntimeExports.jsxs("g", { transform: `translate(0,${dy})`, children: [ |
| 4047 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "16", y: "18", width: "86", height: "20", rx: "3", fill: "#f1f5f9" }), |
| 4048 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "19", y: "21", width: "14", height: "14", rx: "2", fill: "#60a5fa" }), |
| 4049 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "37", y: "23", width: "34", height: "3", rx: "1.5", fill: "#94a3b8" }), |
| 4050 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "37", y: "29", width: "20", height: "2.5", rx: "1.25", fill: "#cbd5e1" }), |
| 4051 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "86", y: "27", width: "12", height: "6", rx: "2", fill: "#3b82f6" }) |
| 4052 |
] }, dy)), |
| 4053 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "120", y: "26", width: "30", height: "62", rx: "5", fill: "#ffffff", stroke: "#cbd5e1", strokeWidth: "2" }), |
| 4054 |
[0, 18, 36].map((dy) => /* @__PURE__ */ jsxRuntimeExports.jsxs("g", { transform: `translate(0,${dy})`, children: [ |
| 4055 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "124", y: "32", width: "22", height: "14", rx: "2", fill: "#f1f5f9" }), |
| 4056 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "126", y: "34", width: "10", height: "10", rx: "1.5", fill: "#60a5fa" }), |
| 4057 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "138", y: "36", width: "7", height: "2", rx: "1", fill: "#94a3b8" }), |
| 4058 |
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "138", y: "40", width: "5", height: "2", rx: "1", fill: "#cbd5e1" }) |
| 4059 |
] }, dy)) |
| 4060 |
] |
| 4061 |
} |
| 4062 |
) |
| 4063 |
} |
| 4064 |
].map((opt) => { |
| 4065 |
const selected = (formData.frontend_listing_card_layout || "standard") === opt.value; |
| 4066 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 4067 |
"button", |
| 4068 |
{ |
| 4069 |
type: "button", |
| 4070 |
role: "radio", |
| 4071 |
"aria-checked": selected, |
| 4072 |
onClick: () => handleFieldChange({ |
| 4073 |
target: { |
| 4074 |
name: "frontend_listing_card_layout", |
| 4075 |
id: "frontend_listing_card_layout", |
| 4076 |
value: opt.value, |
| 4077 |
type: "text" |
| 4078 |
} |
| 4079 |
}), |
| 4080 |
className: `relative rounded-lg border-2 p-2.5 text-left transition focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 ${selected ? "border-blue-600 ring-1 ring-blue-600 bg-blue-50/60 dark:bg-blue-900/20" : "border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`, |
| 4081 |
children: [ |
| 4082 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "aspect-[8/5] w-full overflow-hidden rounded-md bg-gray-50 dark:bg-gray-800/60", children: opt.svg }), |
| 4083 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 text-sm font-medium text-gray-900 dark:text-white", children: opt.label }), |
| 4084 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400", children: opt.sub }), |
| 4085 |
selected && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "absolute top-2 right-2 inline-flex h-5 w-5 items-center justify-center rounded-full bg-blue-600 text-white", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M16.7 5.3a1 1 0 010 1.4l-7 7a1 1 0 01-1.4 0l-3-3a1 1 0 011.4-1.4L9 11.6l6.3-6.3a1 1 0 011.4 0z" }) }) }) |
| 4086 |
] |
| 4087 |
}, |
| 4088 |
opt.value |
| 4089 |
); |
| 4090 |
}) |
| 4091 |
} |
| 4092 |
) |
| 4093 |
} |
| 4094 |
) |
| 4095 |
] }) |
| 4096 |
] }); |
| 4097 |
case "booking_form": |
| 4098 |
return /* @__PURE__ */ jsxRuntimeExports.jsx(BookingFormBuilder, { formData, setFormData }); |
| 4099 |
case "payment": |
| 4100 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 4101 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 4102 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 4103 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: [ |
| 4104 |
__("Flexible Payments", "yatra"), |
| 4105 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ProBadge, { isProActive: (_b2 = window.yatraAdmin) == null ? void 0 : _b2.isPro }) |
| 4106 |
] }), |
| 4107 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300 mb-4", children: __( |
| 4108 |
"Enable deposit and partial payment options for bookings. Allow customers to pay a percentage upfront and the rest later.", |
| 4109 |
"yatra" |
| 4110 |
) }), |
| 4111 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4112 |
ProFeature, |
| 4113 |
{ |
| 4114 |
title: __("Flexible Payments", "yatra"), |
| 4115 |
description: __( |
| 4116 |
"offer deposit and partial payment options to your customers", |
| 4117 |
"yatra" |
| 4118 |
), |
| 4119 |
moduleName: "Flexible Payments", |
| 4120 |
pricingUrl: "https://wpyatra.com/pricing?module=flexible-payments", |
| 4121 |
isProActive: (_c = window.yatraAdmin) == null ? void 0 : _c.isPro, |
| 4122 |
isModuleEnabled: (_d = window.yatraAdmin) == null ? void 0 : _d.flexiblePaymentsEnabled, |
| 4123 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 4124 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 4125 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4126 |
"input", |
| 4127 |
{ |
| 4128 |
type: "checkbox", |
| 4129 |
id: "partial_payment", |
| 4130 |
checked: formData.partial_payment, |
| 4131 |
name: "partial_payment", |
| 4132 |
onChange: handleFieldChange, |
| 4133 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 4134 |
} |
| 4135 |
), |
| 4136 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 4137 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4138 |
Label, |
| 4139 |
{ |
| 4140 |
htmlFor: "partial_payment", |
| 4141 |
className: "font-medium cursor-pointer", |
| 4142 |
children: __("Enable Partial Payment", "yatra") |
| 4143 |
} |
| 4144 |
), |
| 4145 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 4146 |
"Allow customers to pay a portion now and the rest later", |
| 4147 |
"yatra" |
| 4148 |
) }) |
| 4149 |
] }) |
| 4150 |
] }), |
| 4151 |
formData.partial_payment && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4152 |
FormField, |
| 4153 |
{ |
| 4154 |
id: "partial_payment_percentage", |
| 4155 |
label: __("Partial Payment Percentage", "yatra"), |
| 4156 |
description: __( |
| 4157 |
"Percentage of total amount required for partial payment", |
| 4158 |
"yatra" |
| 4159 |
), |
| 4160 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 4161 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4162 |
Input, |
| 4163 |
{ |
| 4164 |
id: "partial_payment_percentage", |
| 4165 |
type: "number", |
| 4166 |
value: formData.partial_payment_percentage, |
| 4167 |
name: "partial_payment_percentage", |
| 4168 |
onChange: handleFieldChange, |
| 4169 |
min: "0", |
| 4170 |
max: "100", |
| 4171 |
className: "flex-1" |
| 4172 |
} |
| 4173 |
), |
| 4174 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "%" }) |
| 4175 |
] }) |
| 4176 |
} |
| 4177 |
), |
| 4178 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 4179 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4180 |
"input", |
| 4181 |
{ |
| 4182 |
type: "checkbox", |
| 4183 |
id: "deposit_required", |
| 4184 |
checked: formData.deposit_required, |
| 4185 |
name: "deposit_required", |
| 4186 |
onChange: handleFieldChange, |
| 4187 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 4188 |
} |
| 4189 |
), |
| 4190 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 4191 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4192 |
Label, |
| 4193 |
{ |
| 4194 |
htmlFor: "deposit_required", |
| 4195 |
className: "font-medium cursor-pointer", |
| 4196 |
children: __("Require Deposit", "yatra") |
| 4197 |
} |
| 4198 |
), |
| 4199 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __("Require a deposit to confirm bookings", "yatra") }) |
| 4200 |
] }) |
| 4201 |
] }), |
| 4202 |
formData.deposit_required && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4203 |
FormField, |
| 4204 |
{ |
| 4205 |
id: "deposit_percentage", |
| 4206 |
label: __("Deposit Percentage", "yatra"), |
| 4207 |
description: __( |
| 4208 |
"Percentage of total amount required as deposit", |
| 4209 |
"yatra" |
| 4210 |
), |
| 4211 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 4212 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4213 |
Input, |
| 4214 |
{ |
| 4215 |
id: "deposit_percentage", |
| 4216 |
type: "number", |
| 4217 |
value: formData.deposit_percentage, |
| 4218 |
name: "deposit_percentage", |
| 4219 |
onChange: handleFieldChange, |
| 4220 |
min: "0", |
| 4221 |
max: "100", |
| 4222 |
className: "flex-1" |
| 4223 |
} |
| 4224 |
), |
| 4225 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "%" }) |
| 4226 |
] }) |
| 4227 |
} |
| 4228 |
) |
| 4229 |
] }) |
| 4230 |
} |
| 4231 |
) |
| 4232 |
] }), |
| 4233 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 4234 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: [ |
| 4235 |
__("Scheduled balance payments", "yatra"), |
| 4236 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ProBadge, { isProActive: (_e = window.yatraAdmin) == null ? void 0 : _e.isPro }) |
| 4237 |
] }), |
| 4238 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300 mb-4", children: __( |
| 4239 |
"After a deposit or partial payment, automatically schedule the remaining balance with your gateway (Stripe invoices or subscription schedules). Requires a gateway customer and payment method from checkout.", |
| 4240 |
"yatra" |
| 4241 |
) }), |
| 4242 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4243 |
ProFeature, |
| 4244 |
{ |
| 4245 |
title: __("Scheduled Payments", "yatra"), |
| 4246 |
description: __( |
| 4247 |
"schedule the remaining balance after partial or deposit payments", |
| 4248 |
"yatra" |
| 4249 |
), |
| 4250 |
moduleName: "Scheduled Payments", |
| 4251 |
pricingUrl: "https://wpyatra.com/pricing?module=scheduled-payments", |
| 4252 |
isProActive: (_f = window.yatraAdmin) == null ? void 0 : _f.isPro, |
| 4253 |
isModuleEnabled: (_g = window.yatraAdmin) == null ? void 0 : _g.scheduledPaymentsEnabled, |
| 4254 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 4255 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 4256 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4257 |
"input", |
| 4258 |
{ |
| 4259 |
type: "checkbox", |
| 4260 |
id: "enable_scheduled_payments", |
| 4261 |
checked: formData.enable_scheduled_payments, |
| 4262 |
name: "enable_scheduled_payments", |
| 4263 |
onChange: handleFieldChange, |
| 4264 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 4265 |
} |
| 4266 |
), |
| 4267 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 4268 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4269 |
Label, |
| 4270 |
{ |
| 4271 |
htmlFor: "enable_scheduled_payments", |
| 4272 |
className: "font-medium cursor-pointer", |
| 4273 |
children: __("Enable scheduled balance payments", "yatra") |
| 4274 |
} |
| 4275 |
), |
| 4276 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 4277 |
"When a booking still has an amount due after checkout, create gateway-side schedules using the rules below.", |
| 4278 |
"yatra" |
| 4279 |
) }) |
| 4280 |
] }) |
| 4281 |
] }), |
| 4282 |
formData.enable_scheduled_payments && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 4283 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4284 |
FormField, |
| 4285 |
{ |
| 4286 |
id: "balance_anchor", |
| 4287 |
label: __("Balance schedule", "yatra"), |
| 4288 |
description: __( |
| 4289 |
"Whether the remaining balance is scheduled a fixed number of days after the deposit, or relative to the tour start date.", |
| 4290 |
"yatra" |
| 4291 |
), |
| 4292 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 4293 |
Select, |
| 4294 |
{ |
| 4295 |
id: "balance_anchor", |
| 4296 |
name: "balance_anchor", |
| 4297 |
value: formData.balance_anchor, |
| 4298 |
onChange: handleFieldChange, |
| 4299 |
children: [ |
| 4300 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "booking", children: __("A fixed number of days after the deposit", "yatra") }), |
| 4301 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "tour", children: __("A number of days before the tour date", "yatra") }) |
| 4302 |
] |
| 4303 |
} |
| 4304 |
) |
| 4305 |
} |
| 4306 |
), |
| 4307 |
formData.balance_anchor === "tour" && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4308 |
FormField, |
| 4309 |
{ |
| 4310 |
id: "balance_due_days", |
| 4311 |
label: __("Days before tour", "yatra"), |
| 4312 |
description: __( |
| 4313 |
"The balance is collected this many days before the tour starts. Bookings made inside this window must pay in full up front.", |
| 4314 |
"yatra" |
| 4315 |
), |
| 4316 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4317 |
Input, |
| 4318 |
{ |
| 4319 |
id: "balance_due_days", |
| 4320 |
type: "number", |
| 4321 |
min: 1, |
| 4322 |
max: 365, |
| 4323 |
value: formData.balance_due_days, |
| 4324 |
name: "balance_due_days", |
| 4325 |
onChange: handleFieldChange, |
| 4326 |
className: "max-w-xs" |
| 4327 |
} |
| 4328 |
) |
| 4329 |
} |
| 4330 |
), |
| 4331 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4332 |
FormField, |
| 4333 |
{ |
| 4334 |
id: "scheduled_payment_type", |
| 4335 |
label: __("Schedule type", "yatra"), |
| 4336 |
description: __( |
| 4337 |
"Single final charge on a date, or multiple installments.", |
| 4338 |
"yatra" |
| 4339 |
), |
| 4340 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 4341 |
Select, |
| 4342 |
{ |
| 4343 |
id: "scheduled_payment_type", |
| 4344 |
name: "scheduled_payment_type", |
| 4345 |
value: formData.scheduled_payment_type, |
| 4346 |
onChange: handleFieldChange, |
| 4347 |
children: [ |
| 4348 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "single", children: __("Single balance payment", "yatra") }), |
| 4349 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "installments", children: __("Multiple installments", "yatra") }) |
| 4350 |
] |
| 4351 |
} |
| 4352 |
) |
| 4353 |
} |
| 4354 |
), |
| 4355 |
formData.balance_anchor !== "tour" && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4356 |
FormField, |
| 4357 |
{ |
| 4358 |
id: "scheduled_payment_days", |
| 4359 |
label: __("Days until first charge", "yatra"), |
| 4360 |
description: __( |
| 4361 |
"How many days after the initial payment to schedule the first balance collection.", |
| 4362 |
"yatra" |
| 4363 |
), |
| 4364 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4365 |
Input, |
| 4366 |
{ |
| 4367 |
id: "scheduled_payment_days", |
| 4368 |
type: "number", |
| 4369 |
min: 0, |
| 4370 |
max: 365, |
| 4371 |
value: formData.scheduled_payment_days, |
| 4372 |
name: "scheduled_payment_days", |
| 4373 |
onChange: handleFieldChange, |
| 4374 |
className: "max-w-xs" |
| 4375 |
} |
| 4376 |
) |
| 4377 |
} |
| 4378 |
), |
| 4379 |
formData.scheduled_payment_type === "installments" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 4380 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4381 |
FormField, |
| 4382 |
{ |
| 4383 |
id: "scheduled_payment_installments", |
| 4384 |
label: __("Number of installments", "yatra"), |
| 4385 |
description: __( |
| 4386 |
"Total installments including the scheduled balance (Stripe subscription schedule).", |
| 4387 |
"yatra" |
| 4388 |
), |
| 4389 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4390 |
Input, |
| 4391 |
{ |
| 4392 |
id: "scheduled_payment_installments", |
| 4393 |
type: "number", |
| 4394 |
min: 2, |
| 4395 |
max: 24, |
| 4396 |
value: formData.scheduled_payment_installments, |
| 4397 |
name: "scheduled_payment_installments", |
| 4398 |
onChange: handleFieldChange, |
| 4399 |
className: "max-w-xs" |
| 4400 |
} |
| 4401 |
) |
| 4402 |
} |
| 4403 |
), |
| 4404 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4405 |
FormField, |
| 4406 |
{ |
| 4407 |
id: "scheduled_payment_interval", |
| 4408 |
label: __("Days between installments", "yatra"), |
| 4409 |
description: __( |
| 4410 |
"Spacing between installment charges when using multiple installments.", |
| 4411 |
"yatra" |
| 4412 |
), |
| 4413 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4414 |
Input, |
| 4415 |
{ |
| 4416 |
id: "scheduled_payment_interval", |
| 4417 |
type: "number", |
| 4418 |
min: 1, |
| 4419 |
max: 365, |
| 4420 |
value: formData.scheduled_payment_interval, |
| 4421 |
name: "scheduled_payment_interval", |
| 4422 |
onChange: handleFieldChange, |
| 4423 |
className: "max-w-xs" |
| 4424 |
} |
| 4425 |
) |
| 4426 |
} |
| 4427 |
) |
| 4428 |
] }), |
| 4429 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4430 |
FormField, |
| 4431 |
{ |
| 4432 |
id: "scheduled_payment_reminder_days", |
| 4433 |
label: __("Payment reminder (days before)", "yatra"), |
| 4434 |
description: __( |
| 4435 |
"Send the scheduled payment reminder email this many days before the due date (0 to disable reminders).", |
| 4436 |
"yatra" |
| 4437 |
), |
| 4438 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4439 |
Input, |
| 4440 |
{ |
| 4441 |
id: "scheduled_payment_reminder_days", |
| 4442 |
type: "number", |
| 4443 |
min: 0, |
| 4444 |
max: 30, |
| 4445 |
value: formData.scheduled_payment_reminder_days, |
| 4446 |
name: "scheduled_payment_reminder_days", |
| 4447 |
onChange: handleFieldChange, |
| 4448 |
className: "max-w-xs" |
| 4449 |
} |
| 4450 |
) |
| 4451 |
} |
| 4452 |
) |
| 4453 |
] }) |
| 4454 |
] }) |
| 4455 |
} |
| 4456 |
) |
| 4457 |
] }), |
| 4458 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 4459 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4460 |
"input", |
| 4461 |
{ |
| 4462 |
type: "checkbox", |
| 4463 |
id: "auto_confirm_pay_later", |
| 4464 |
checked: formData.auto_confirm_pay_later, |
| 4465 |
name: "auto_confirm_pay_later", |
| 4466 |
onChange: handleFieldChange, |
| 4467 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 4468 |
} |
| 4469 |
), |
| 4470 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 4471 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4472 |
Label, |
| 4473 |
{ |
| 4474 |
htmlFor: "auto_confirm_pay_later", |
| 4475 |
className: "font-medium cursor-pointer", |
| 4476 |
children: __('Auto-confirm "Pay Later" Bookings', "yatra") |
| 4477 |
} |
| 4478 |
), |
| 4479 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 4480 |
'Automatically confirm bookings when "Book Now, Pay Later" is selected. If disabled, bookings will remain pending until payment is received.', |
| 4481 |
"yatra" |
| 4482 |
) }) |
| 4483 |
] }) |
| 4484 |
] }) |
| 4485 |
] }), |
| 4486 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 4487 |
/* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Payment Gateways", "yatra") }), |
| 4488 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 p-4 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg mb-4", children: [ |
| 4489 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4490 |
"input", |
| 4491 |
{ |
| 4492 |
type: "checkbox", |
| 4493 |
id: "payment_test_mode", |
| 4494 |
checked: formData.payment_test_mode, |
| 4495 |
name: "payment_test_mode", |
| 4496 |
onChange: handleFieldChange, |
| 4497 |
className: "w-5 h-5 rounded border-gray-300 text-amber-600 focus:ring-amber-500" |
| 4498 |
} |
| 4499 |
), |
| 4500 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 4501 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4502 |
Label, |
| 4503 |
{ |
| 4504 |
htmlFor: "payment_test_mode", |
| 4505 |
className: "font-semibold cursor-pointer text-amber-800 dark:text-amber-200", |
| 4506 |
children: __("Test Mode", "yatra") |
| 4507 |
} |
| 4508 |
), |
| 4509 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-amber-700 dark:text-amber-300 mt-0.5", children: __( |
| 4510 |
"Enable test/sandbox mode for all payment gateways. Use test API keys for development and testing. Disable this for live payments.", |
| 4511 |
"yatra" |
| 4512 |
) }) |
| 4513 |
] }), |
| 4514 |
formData.payment_test_mode && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "px-2 py-1 text-xs font-semibold bg-amber-200 dark:bg-amber-800 text-amber-800 dark:text-amber-200 rounded", children: __("TEST", "yatra") }) |
| 4515 |
] }), |
| 4516 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4 flex items-center gap-1", children: [ |
| 4517 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-3.5 h-3.5" }), |
| 4518 |
__( |
| 4519 |
"Drag and drop to reorder gateways. Use arrows for precise positioning.", |
| 4520 |
"yatra" |
| 4521 |
) |
| 4522 |
] }), |
| 4523 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 4524 |
gatewayDefinitions && gatewayOrder.filter((id) => gatewayDefinitions[id]).map((gatewayId, index) => { |
| 4525 |
var _a3, _b3; |
| 4526 |
const gateway = gatewayDefinitions[gatewayId]; |
| 4527 |
const config = ((_a3 = formData.gateway_configs) == null ? void 0 : _a3[gatewayId]) || gateway.config || { enabled: false }; |
| 4528 |
const isExpanded = expandedGateways[gatewayId]; |
| 4529 |
const isDragging = draggedGateway === gatewayId; |
| 4530 |
const isPremium = gateway.requires_pro || false; |
| 4531 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 4532 |
Card, |
| 4533 |
{ |
| 4534 |
className: `relative border transition-all !py-0 ${isDragging ? "border-blue-400 bg-blue-50 dark:bg-blue-900/20 opacity-75" : config.enabled ? "border-green-200 dark:border-green-800" : "border-gray-200 dark:border-gray-700"}`, |
| 4535 |
draggable: !isPremium, |
| 4536 |
onDragStart: (e) => !isPremium && handleDragStart(e, gatewayId), |
| 4537 |
onDragOver: !isPremium ? handleDragOver : void 0, |
| 4538 |
onDrop: (e) => !isPremium && handleDrop(e, gatewayId), |
| 4539 |
onDragEnd: !isPremium ? handleDragEnd : void 0, |
| 4540 |
children: [ |
| 4541 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [ |
| 4542 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [ |
| 4543 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "cursor-grab active:cursor-grabbing p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300", children: /* @__PURE__ */ jsxRuntimeExports.jsx(GripVertical, { className: "w-4 h-4" }) }), |
| 4544 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-0.5", children: [ |
| 4545 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4546 |
"button", |
| 4547 |
{ |
| 4548 |
type: "button", |
| 4549 |
onClick: () => moveGatewayUp(gatewayId), |
| 4550 |
disabled: index === 0, |
| 4551 |
className: "p-0.5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-30 disabled:cursor-not-allowed", |
| 4552 |
title: __("Move up", "yatra"), |
| 4553 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowUp, { className: "w-3 h-3" }) |
| 4554 |
} |
| 4555 |
), |
| 4556 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4557 |
"button", |
| 4558 |
{ |
| 4559 |
type: "button", |
| 4560 |
onClick: () => moveGatewayDown(gatewayId), |
| 4561 |
disabled: index === gatewayOrder.length - 1, |
| 4562 |
className: "p-0.5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-30 disabled:cursor-not-allowed", |
| 4563 |
title: __("Move down", "yatra"), |
| 4564 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowDown, { className: "w-3 h-3" }) |
| 4565 |
} |
| 4566 |
) |
| 4567 |
] }), |
| 4568 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4569 |
"input", |
| 4570 |
{ |
| 4571 |
type: "checkbox", |
| 4572 |
id: `gateway_enable_${gatewayId}`, |
| 4573 |
checked: config.enabled || false, |
| 4574 |
onChange: (e) => { |
| 4575 |
var _a4; |
| 4576 |
if (gateway.requires_pro && e.target.checked) { |
| 4577 |
e.preventDefault(); |
| 4578 |
const pricingUrl = ((_a4 = window.yatraAdmin) == null ? void 0 : _a4.pricingUrl) || "https://wpyatra.com/pricing"; |
| 4579 |
window.open(pricingUrl, "_blank"); |
| 4580 |
return; |
| 4581 |
} |
| 4582 |
handleGatewayConfigChange( |
| 4583 |
gatewayId, |
| 4584 |
"enabled", |
| 4585 |
e.target.checked |
| 4586 |
); |
| 4587 |
}, |
| 4588 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 4589 |
} |
| 4590 |
), |
| 4591 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 4592 |
gateway.icon && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4593 |
"img", |
| 4594 |
{ |
| 4595 |
src: gateway.icon, |
| 4596 |
alt: gateway.title, |
| 4597 |
className: "w-10 h-10 object-contain" |
| 4598 |
} |
| 4599 |
), |
| 4600 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 4601 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-sm font-semibold flex items-center gap-2", children: [ |
| 4602 |
gateway.title, |
| 4603 |
config.enabled && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-normal px-1.5 py-0.5 bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400 rounded", children: __("Active", "yatra") }), |
| 4604 |
formData.payment_test_mode && gateway.sandbox_url && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4605 |
"a", |
| 4606 |
{ |
| 4607 |
href: gateway.sandbox_url, |
| 4608 |
target: "_blank", |
| 4609 |
rel: "noopener noreferrer", |
| 4610 |
className: "text-xs font-normal px-1.5 py-0.5 bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400 rounded hover:bg-amber-200 dark:hover:bg-amber-800/40 transition-colors", |
| 4611 |
onClick: (e) => e.stopPropagation(), |
| 4612 |
children: __("Sandbox Docs →", "yatra") |
| 4613 |
} |
| 4614 |
) |
| 4615 |
] }), |
| 4616 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: gateway.description }) |
| 4617 |
] }) |
| 4618 |
] }) |
| 4619 |
] }), |
| 4620 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 4621 |
gateway.requires_pro && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-gradient-to-r from-purple-500 to-blue-500 text-white shadow-sm", children: "PRO" }), |
| 4622 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4623 |
Button, |
| 4624 |
{ |
| 4625 |
variant: "ghost", |
| 4626 |
size: "sm", |
| 4627 |
onClick: () => toggleGatewayExpanded(gatewayId), |
| 4628 |
className: "h-8", |
| 4629 |
disabled: !((_b3 = gateway.fields) == null ? void 0 : _b3.length), |
| 4630 |
children: isExpanded ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "w-4 h-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "w-4 h-4" }) |
| 4631 |
} |
| 4632 |
) |
| 4633 |
] }) |
| 4634 |
] }) }), |
| 4635 |
isExpanded && /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "pt-4 space-y-4 border-t border-gray-100 dark:border-gray-700", children: [ |
| 4636 |
gateway.is_offline && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-3 bg-blue-50 dark:bg-blue-900/20 rounded-md mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-blue-700 dark:text-blue-300", children: gateway.id === "pay_later" ? __( |
| 4637 |
"Allow customers to book now and pay later. Payment must be completed before the trip date.", |
| 4638 |
"yatra" |
| 4639 |
) : __( |
| 4640 |
"This is an offline payment method. Customers will be shown these details after booking.", |
| 4641 |
"yatra" |
| 4642 |
) }) }), |
| 4643 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 4644 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: __("Frontend Display Settings", "yatra") }), |
| 4645 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4646 |
FormField, |
| 4647 |
{ |
| 4648 |
id: `${gatewayId}_icon`, |
| 4649 |
label: __("Gateway Icon", "yatra"), |
| 4650 |
description: __( |
| 4651 |
"Icon URL or path displayed on the booking page", |
| 4652 |
"yatra" |
| 4653 |
), |
| 4654 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [ |
| 4655 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4656 |
Input, |
| 4657 |
{ |
| 4658 |
type: "text", |
| 4659 |
value: config.icon || gateway.icon || "", |
| 4660 |
onChange: (e) => handleGatewayConfigChange( |
| 4661 |
gatewayId, |
| 4662 |
"icon", |
| 4663 |
e.target.value |
| 4664 |
), |
| 4665 |
placeholder: __( |
| 4666 |
"Enter icon URL or leave empty to use default", |
| 4667 |
"yatra" |
| 4668 |
), |
| 4669 |
className: "flex-1" |
| 4670 |
} |
| 4671 |
), |
| 4672 |
config.icon || gateway.icon ? /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4673 |
"img", |
| 4674 |
{ |
| 4675 |
src: config.icon || gateway.icon, |
| 4676 |
alt: gateway.title, |
| 4677 |
className: "w-10 h-10 object-contain border border-gray-300 dark:border-gray-600 rounded p-1 bg-white dark:bg-gray-800", |
| 4678 |
onError: (e) => { |
| 4679 |
e.target.style.display = "none"; |
| 4680 |
} |
| 4681 |
} |
| 4682 |
) : null |
| 4683 |
] }) |
| 4684 |
} |
| 4685 |
), |
| 4686 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4687 |
FormField, |
| 4688 |
{ |
| 4689 |
id: `${gatewayId}_title`, |
| 4690 |
label: __("Gateway Title", "yatra"), |
| 4691 |
description: __( |
| 4692 |
"Title displayed on the booking page", |
| 4693 |
"yatra" |
| 4694 |
), |
| 4695 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4696 |
Input, |
| 4697 |
{ |
| 4698 |
type: "text", |
| 4699 |
value: config.title || gateway.title || "", |
| 4700 |
onChange: (e) => handleGatewayConfigChange( |
| 4701 |
gatewayId, |
| 4702 |
"title", |
| 4703 |
e.target.value |
| 4704 |
), |
| 4705 |
placeholder: gateway.title || __("Enter gateway title", "yatra") |
| 4706 |
} |
| 4707 |
) |
| 4708 |
} |
| 4709 |
), |
| 4710 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4711 |
FormField, |
| 4712 |
{ |
| 4713 |
id: `${gatewayId}_description`, |
| 4714 |
label: __("Gateway Description", "yatra"), |
| 4715 |
description: __( |
| 4716 |
"Description displayed below the title on the booking page", |
| 4717 |
"yatra" |
| 4718 |
), |
| 4719 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4720 |
"textarea", |
| 4721 |
{ |
| 4722 |
value: config.description || gateway.description || "", |
| 4723 |
onChange: (e) => handleGatewayConfigChange( |
| 4724 |
gatewayId, |
| 4725 |
"description", |
| 4726 |
e.target.value |
| 4727 |
), |
| 4728 |
placeholder: gateway.description || __("Enter gateway description", "yatra"), |
| 4729 |
className: "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none", |
| 4730 |
rows: 2 |
| 4731 |
} |
| 4732 |
) |
| 4733 |
} |
| 4734 |
) |
| 4735 |
] }), |
| 4736 |
gateway.fields && gateway.fields.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: gateway.fields.map((field) => { |
| 4737 |
if (field.condition && !config[field.condition]) { |
| 4738 |
return null; |
| 4739 |
} |
| 4740 |
if (field.show_when) { |
| 4741 |
const shouldShow = Object.entries( |
| 4742 |
field.show_when |
| 4743 |
).every( |
| 4744 |
([key, value]) => { |
| 4745 |
var _a4; |
| 4746 |
return (config[key] || ((_a4 = gateway.fields.find( |
| 4747 |
(f) => f.id === key |
| 4748 |
)) == null ? void 0 : _a4.default)) === value; |
| 4749 |
} |
| 4750 |
); |
| 4751 |
if (!shouldShow) { |
| 4752 |
return null; |
| 4753 |
} |
| 4754 |
} |
| 4755 |
if (field.type === "webhook_url") { |
| 4756 |
const webhookUrl = String( |
| 4757 |
field.default || config[field.id] || "" |
| 4758 |
); |
| 4759 |
const stripeSetupUrl = formData.payment_test_mode ? field.help_url_test || field.help_url_live : field.help_url_live || field.help_url_test; |
| 4760 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 4761 |
FormField, |
| 4762 |
{ |
| 4763 |
id: `${gatewayId}_${field.id}`, |
| 4764 |
label: field.label, |
| 4765 |
children: [ |
| 4766 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [ |
| 4767 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4768 |
Input, |
| 4769 |
{ |
| 4770 |
readOnly: true, |
| 4771 |
value: webhookUrl, |
| 4772 |
onFocus: (e) => e.currentTarget.select(), |
| 4773 |
className: "font-mono text-xs" |
| 4774 |
} |
| 4775 |
), |
| 4776 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4777 |
Button, |
| 4778 |
{ |
| 4779 |
type: "button", |
| 4780 |
variant: "outline", |
| 4781 |
size: "sm", |
| 4782 |
onClick: (e) => { |
| 4783 |
var _a4, _b4; |
| 4784 |
const btn = e.currentTarget; |
| 4785 |
const input = (_a4 = btn.parentElement) == null ? void 0 : _a4.querySelector( |
| 4786 |
"input" |
| 4787 |
); |
| 4788 |
let copied = false; |
| 4789 |
try { |
| 4790 |
if (input) { |
| 4791 |
input.focus(); |
| 4792 |
input.select(); |
| 4793 |
input.setSelectionRange( |
| 4794 |
0, |
| 4795 |
webhookUrl.length |
| 4796 |
); |
| 4797 |
copied = document.execCommand( |
| 4798 |
"copy" |
| 4799 |
); |
| 4800 |
} |
| 4801 |
} catch { |
| 4802 |
} |
| 4803 |
if ((_b4 = navigator.clipboard) == null ? void 0 : _b4.writeText) { |
| 4804 |
navigator.clipboard.writeText(webhookUrl).catch(() => { |
| 4805 |
}); |
| 4806 |
copied = true; |
| 4807 |
} |
| 4808 |
const orig = __( |
| 4809 |
"Copy", |
| 4810 |
"yatra" |
| 4811 |
); |
| 4812 |
btn.textContent = copied ? __("Copied!", "yatra") : __( |
| 4813 |
"Select & copy", |
| 4814 |
"yatra" |
| 4815 |
); |
| 4816 |
window.setTimeout(() => { |
| 4817 |
btn.textContent = orig; |
| 4818 |
}, 1500); |
| 4819 |
}, |
| 4820 |
children: __("Copy", "yatra") |
| 4821 |
} |
| 4822 |
) |
| 4823 |
] }), |
| 4824 |
field.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1.5 text-xs text-gray-500 dark:text-gray-400 leading-relaxed", children: field.description }), |
| 4825 |
stripeSetupUrl && /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 4826 |
"a", |
| 4827 |
{ |
| 4828 |
href: stripeSetupUrl, |
| 4829 |
target: "_blank", |
| 4830 |
rel: "noopener noreferrer", |
| 4831 |
className: "mt-1.5 inline-block text-xs font-medium text-blue-600 dark:text-blue-400 border-b border-blue-600 dark:border-blue-400 hover:border-transparent", |
| 4832 |
children: [ |
| 4833 |
field.help_text || __( |
| 4834 |
"Open Stripe → Webhooks", |
| 4835 |
"yatra" |
| 4836 |
), |
| 4837 |
" ", |
| 4838 |
"→" |
| 4839 |
] |
| 4840 |
} |
| 4841 |
) |
| 4842 |
] |
| 4843 |
}, |
| 4844 |
field.id |
| 4845 |
); |
| 4846 |
} |
| 4847 |
if (field.type === "checkbox") { |
| 4848 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 4849 |
"div", |
| 4850 |
{ |
| 4851 |
className: "flex items-center gap-2 p-3 bg-yellow-50 dark:bg-yellow-900/20 rounded-md", |
| 4852 |
children: [ |
| 4853 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4854 |
"input", |
| 4855 |
{ |
| 4856 |
type: "checkbox", |
| 4857 |
id: `${gatewayId}_${field.id}`, |
| 4858 |
checked: config[field.id] || false, |
| 4859 |
onChange: (e) => handleGatewayConfigChange( |
| 4860 |
gatewayId, |
| 4861 |
field.id, |
| 4862 |
e.target.checked |
| 4863 |
), |
| 4864 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 4865 |
} |
| 4866 |
), |
| 4867 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 4868 |
Label, |
| 4869 |
{ |
| 4870 |
htmlFor: `${gatewayId}_${field.id}`, |
| 4871 |
className: "font-normal cursor-pointer", |
| 4872 |
children: [ |
| 4873 |
field.label, |
| 4874 |
" ", |
| 4875 |
field.description && `- ${field.description}` |
| 4876 |
] |
| 4877 |
} |
| 4878 |
) |
| 4879 |
] |
| 4880 |
}, |
| 4881 |
field.id |
| 4882 |
); |
| 4883 |
} |
| 4884 |
if (field.type === "textarea") { |
| 4885 |
return /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4886 |
FormField, |
| 4887 |
{ |
| 4888 |
id: `${gatewayId}_${field.id}`, |
| 4889 |
label: field.label, |
| 4890 |
description: field.description, |
| 4891 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4892 |
"textarea", |
| 4893 |
{ |
| 4894 |
value: config[field.id] || field.default || "", |
| 4895 |
onChange: (e) => handleGatewayConfigChange( |
| 4896 |
gatewayId, |
| 4897 |
field.id, |
| 4898 |
e.target.value |
| 4899 |
), |
| 4900 |
placeholder: field.placeholder, |
| 4901 |
className: "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none", |
| 4902 |
rows: 3 |
| 4903 |
} |
| 4904 |
) |
| 4905 |
}, |
| 4906 |
field.id |
| 4907 |
); |
| 4908 |
} |
| 4909 |
if (gateway.id === "stripe" && field.id === "enabled_methods") { |
| 4910 |
const rawValue = config[field.id]; |
| 4911 |
const selectedValues = Array.isArray( |
| 4912 |
rawValue |
| 4913 |
) ? rawValue : typeof rawValue === "string" && rawValue.length > 0 ? rawValue.split(",").map((val) => val.trim()).filter(Boolean) : ["card", "google_pay", "apple_pay"]; |
| 4914 |
const methodOptions = [ |
| 4915 |
{ |
| 4916 |
value: "card", |
| 4917 |
label: __( |
| 4918 |
"Card (Stripe Elements)", |
| 4919 |
"yatra" |
| 4920 |
) |
| 4921 |
}, |
| 4922 |
{ |
| 4923 |
value: "google_pay", |
| 4924 |
label: __( |
| 4925 |
"Google Pay (Payment Request Button)", |
| 4926 |
"yatra" |
| 4927 |
) |
| 4928 |
}, |
| 4929 |
{ |
| 4930 |
value: "apple_pay", |
| 4931 |
label: __( |
| 4932 |
"Apple Pay (Payment Request Button)", |
| 4933 |
"yatra" |
| 4934 |
) |
| 4935 |
} |
| 4936 |
]; |
| 4937 |
const handleStripeMethodsChange = (values) => { |
| 4938 |
handleGatewayConfigChange( |
| 4939 |
gatewayId, |
| 4940 |
field.id, |
| 4941 |
values.join(",") |
| 4942 |
); |
| 4943 |
}; |
| 4944 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 4945 |
"div", |
| 4946 |
{ |
| 4947 |
className: "space-y-2", |
| 4948 |
children: [ |
| 4949 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4950 |
FormField, |
| 4951 |
{ |
| 4952 |
id: `${gatewayId}_${field.id}`, |
| 4953 |
label: field.label, |
| 4954 |
description: field.description, |
| 4955 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4956 |
MultiSelect, |
| 4957 |
{ |
| 4958 |
value: selectedValues, |
| 4959 |
onChange: handleStripeMethodsChange, |
| 4960 |
options: methodOptions, |
| 4961 |
placeholder: __( |
| 4962 |
"Select payment methods...", |
| 4963 |
"yatra" |
| 4964 |
) |
| 4965 |
} |
| 4966 |
) |
| 4967 |
} |
| 4968 |
), |
| 4969 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: [ |
| 4970 |
__( |
| 4971 |
"Apple Pay requires domain verification inside your Stripe Dashboard.", |
| 4972 |
"yatra" |
| 4973 |
), |
| 4974 |
(field.help_url || field.help_url_test || field.help_url_live) && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 4975 |
"a", |
| 4976 |
{ |
| 4977 |
href: formData.payment_test_mode ? field.help_url_test || field.help_url : field.help_url_live || field.help_url, |
| 4978 |
target: "_blank", |
| 4979 |
rel: "noopener noreferrer", |
| 4980 |
className: "ml-1 border-b border-blue-600 dark:border-blue-400 hover:border-transparent", |
| 4981 |
children: __("Learn more →", "yatra") |
| 4982 |
} |
| 4983 |
) |
| 4984 |
] }) |
| 4985 |
] |
| 4986 |
}, |
| 4987 |
field.id |
| 4988 |
); |
| 4989 |
} |
| 4990 |
if (field.type === "multiselect" && field.options) { |
| 4991 |
const rawValue = config[field.id]; |
| 4992 |
const selectedValues = Array.isArray( |
| 4993 |
rawValue |
| 4994 |
) ? rawValue : typeof rawValue === "string" && rawValue.length > 0 ? rawValue.split(",").map((val) => val.trim()).filter(Boolean) : Array.isArray(field.default) ? field.default : []; |
| 4995 |
const methodOptions = Object.entries(field.options).map( |
| 4996 |
([value, label]) => ({ |
| 4997 |
value, |
| 4998 |
label: String(label) |
| 4999 |
}) |
| 5000 |
); |
| 5001 |
const handleMultiSelectChange = (values) => { |
| 5002 |
handleGatewayConfigChange( |
| 5003 |
gatewayId, |
| 5004 |
field.id, |
| 5005 |
values |
| 5006 |
); |
| 5007 |
}; |
| 5008 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 5009 |
"div", |
| 5010 |
{ |
| 5011 |
className: "space-y-2", |
| 5012 |
children: [ |
| 5013 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5014 |
FormField, |
| 5015 |
{ |
| 5016 |
id: `${gatewayId}_${field.id}`, |
| 5017 |
label: field.label, |
| 5018 |
description: field.description, |
| 5019 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5020 |
MultiSelect, |
| 5021 |
{ |
| 5022 |
value: selectedValues, |
| 5023 |
onChange: handleMultiSelectChange, |
| 5024 |
options: methodOptions, |
| 5025 |
placeholder: __( |
| 5026 |
"Select options...", |
| 5027 |
"yatra" |
| 5028 |
) |
| 5029 |
} |
| 5030 |
) |
| 5031 |
} |
| 5032 |
), |
| 5033 |
field.help_text && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-blue-600 dark:text-blue-400", children: field.help_text }) |
| 5034 |
] |
| 5035 |
}, |
| 5036 |
field.id |
| 5037 |
); |
| 5038 |
} |
| 5039 |
if (field.type === "select" && field.options) { |
| 5040 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 5041 |
"div", |
| 5042 |
{ |
| 5043 |
className: "space-y-2", |
| 5044 |
children: [ |
| 5045 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5046 |
FormField, |
| 5047 |
{ |
| 5048 |
id: `${gatewayId}_${field.id}`, |
| 5049 |
label: field.label, |
| 5050 |
description: field.description, |
| 5051 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5052 |
Select, |
| 5053 |
{ |
| 5054 |
value: config[field.id] ?? field.default ?? "", |
| 5055 |
onChange: (e) => handleGatewayConfigChange( |
| 5056 |
gatewayId, |
| 5057 |
field.id, |
| 5058 |
e.target.value |
| 5059 |
), |
| 5060 |
children: Object.entries( |
| 5061 |
field.options |
| 5062 |
).map(([value, label]) => /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5063 |
"option", |
| 5064 |
{ |
| 5065 |
value, |
| 5066 |
children: label |
| 5067 |
}, |
| 5068 |
value |
| 5069 |
)) |
| 5070 |
} |
| 5071 |
) |
| 5072 |
} |
| 5073 |
), |
| 5074 |
field.help_text && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-blue-600 dark:text-blue-400", children: field.help_text }) |
| 5075 |
] |
| 5076 |
}, |
| 5077 |
field.id |
| 5078 |
); |
| 5079 |
} |
| 5080 |
if (field.readonly) { |
| 5081 |
const roValue = String( |
| 5082 |
config[field.id] ?? field.default ?? "" |
| 5083 |
); |
| 5084 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 5085 |
"div", |
| 5086 |
{ |
| 5087 |
className: "space-y-2", |
| 5088 |
children: [ |
| 5089 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5090 |
FormField, |
| 5091 |
{ |
| 5092 |
id: `${gatewayId}_${field.id}`, |
| 5093 |
label: field.label, |
| 5094 |
description: field.description, |
| 5095 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 5096 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5097 |
Input, |
| 5098 |
{ |
| 5099 |
id: `${gatewayId}_${field.id}`, |
| 5100 |
value: roValue, |
| 5101 |
readOnly: true, |
| 5102 |
className: "bg-gray-50 dark:bg-gray-900 font-mono text-sm" |
| 5103 |
} |
| 5104 |
), |
| 5105 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5106 |
Button, |
| 5107 |
{ |
| 5108 |
variant: "outline", |
| 5109 |
size: "sm", |
| 5110 |
onClick: () => navigator.clipboard.writeText( |
| 5111 |
roValue |
| 5112 |
), |
| 5113 |
children: __("Copy", "yatra") |
| 5114 |
} |
| 5115 |
) |
| 5116 |
] }) |
| 5117 |
} |
| 5118 |
), |
| 5119 |
field.help_text && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-blue-600 dark:text-blue-400", children: field.help_text }) |
| 5120 |
] |
| 5121 |
}, |
| 5122 |
field.id |
| 5123 |
); |
| 5124 |
} |
| 5125 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 5126 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5127 |
FormField, |
| 5128 |
{ |
| 5129 |
id: `${gatewayId}_${field.id}`, |
| 5130 |
label: field.label, |
| 5131 |
description: field.description, |
| 5132 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5133 |
Input, |
| 5134 |
{ |
| 5135 |
type: field.type === "email" ? "email" : field.type, |
| 5136 |
value: config[field.id] ?? field.default ?? "", |
| 5137 |
onChange: (e) => handleGatewayConfigChange( |
| 5138 |
gatewayId, |
| 5139 |
field.id, |
| 5140 |
// Keep an empty field empty while |
| 5141 |
// editing so the last character can |
| 5142 |
// be cleared and retyped. Coercing |
| 5143 |
// "" to 0 (parseFloat("") || 0) made |
| 5144 |
// the field snap back and blocked |
| 5145 |
// re-entry. Numbers are coerced on |
| 5146 |
// save; "" persists harmlessly. |
| 5147 |
field.type === "number" ? e.target.value === "" ? "" : parseFloat( |
| 5148 |
e.target.value |
| 5149 |
) || 0 : e.target.value |
| 5150 |
), |
| 5151 |
placeholder: field.placeholder, |
| 5152 |
min: field.min, |
| 5153 |
max: field.max |
| 5154 |
} |
| 5155 |
) |
| 5156 |
} |
| 5157 |
), |
| 5158 |
field.help_text && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-blue-600 dark:text-blue-400", children: [ |
| 5159 |
field.help_text, |
| 5160 |
(field.help_url || field.help_url_test || field.help_url_live) && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5161 |
"a", |
| 5162 |
{ |
| 5163 |
href: formData.payment_test_mode ? field.help_url_test || field.help_url : field.help_url_live || field.help_url, |
| 5164 |
target: "_blank", |
| 5165 |
rel: "noopener noreferrer", |
| 5166 |
className: "ml-1 border-b border-blue-600 dark:border-blue-400 hover:border-transparent transition-colors", |
| 5167 |
children: __("Learn more →", "yatra") |
| 5168 |
} |
| 5169 |
) |
| 5170 |
] }) |
| 5171 |
] }, field.id); |
| 5172 |
}) }) |
| 5173 |
] }), |
| 5174 |
isPremium && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5175 |
"div", |
| 5176 |
{ |
| 5177 |
className: "absolute inset-0 bg-gradient-to-br from-purple-500/5 to-blue-500/5 dark:from-purple-500/10 dark:to-blue-500/10 rounded-lg cursor-pointer hover:from-purple-500/10 hover:to-blue-500/10 dark:hover:from-purple-500/15 dark:hover:to-blue-500/15 transition-all duration-200", |
| 5178 |
onClick: () => { |
| 5179 |
setSelectedPremiumGateway(gateway.title); |
| 5180 |
setShowPremiumDialog(true); |
| 5181 |
} |
| 5182 |
} |
| 5183 |
) |
| 5184 |
] |
| 5185 |
}, |
| 5186 |
gatewayId |
| 5187 |
); |
| 5188 |
}), |
| 5189 |
(!gatewayDefinitions || Object.keys(gatewayDefinitions).length === 0) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __("Loading payment gateways...", "yatra") }) }) |
| 5190 |
] }) |
| 5191 |
] }) |
| 5192 |
] }); |
| 5193 |
case "search": |
| 5194 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 5195 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 5196 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-1", children: __("Search Bar Fields", "yatra") }), |
| 5197 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __( |
| 5198 |
"Choose which fields appear in the trip search bar. Turn off the ones you don't need for a cleaner search.", |
| 5199 |
"yatra" |
| 5200 |
) }), |
| 5201 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: [ |
| 5202 |
{ |
| 5203 |
key: "search_show_keyword", |
| 5204 |
label: __("Keyword search", "yatra"), |
| 5205 |
description: __( |
| 5206 |
"Free-text field to search by trip name or keyword.", |
| 5207 |
"yatra" |
| 5208 |
) |
| 5209 |
}, |
| 5210 |
{ |
| 5211 |
key: "search_show_destination", |
| 5212 |
label: __("Destination", "yatra"), |
| 5213 |
description: __( |
| 5214 |
"Dropdown to filter trips by destination.", |
| 5215 |
"yatra" |
| 5216 |
) |
| 5217 |
}, |
| 5218 |
{ |
| 5219 |
key: "search_show_activities", |
| 5220 |
label: __("Activities", "yatra"), |
| 5221 |
description: __( |
| 5222 |
"Dropdown to filter trips by activity.", |
| 5223 |
"yatra" |
| 5224 |
) |
| 5225 |
}, |
| 5226 |
{ |
| 5227 |
key: "search_show_duration", |
| 5228 |
label: __("Duration", "yatra"), |
| 5229 |
description: __( |
| 5230 |
"Range slider to filter trips by number of days.", |
| 5231 |
"yatra" |
| 5232 |
) |
| 5233 |
}, |
| 5234 |
{ |
| 5235 |
key: "search_show_budget", |
| 5236 |
label: __("Budget", "yatra"), |
| 5237 |
description: __( |
| 5238 |
"Dropdown to filter trips by price range.", |
| 5239 |
"yatra" |
| 5240 |
) |
| 5241 |
}, |
| 5242 |
{ |
| 5243 |
key: "search_show_date", |
| 5244 |
label: __("Date", "yatra"), |
| 5245 |
description: __( |
| 5246 |
"Date picker to find trips with a departure on a specific date.", |
| 5247 |
"yatra" |
| 5248 |
) |
| 5249 |
} |
| 5250 |
].map((row) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 5251 |
"div", |
| 5252 |
{ |
| 5253 |
className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", |
| 5254 |
children: [ |
| 5255 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5256 |
"input", |
| 5257 |
{ |
| 5258 |
type: "checkbox", |
| 5259 |
id: row.key, |
| 5260 |
checked: !!formData[row.key], |
| 5261 |
name: row.key, |
| 5262 |
onChange: handleFieldChange, |
| 5263 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5264 |
} |
| 5265 |
), |
| 5266 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5267 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5268 |
Label, |
| 5269 |
{ |
| 5270 |
htmlFor: row.key, |
| 5271 |
className: "font-medium cursor-pointer", |
| 5272 |
children: row.label |
| 5273 |
} |
| 5274 |
), |
| 5275 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: row.description }) |
| 5276 |
] }) |
| 5277 |
] |
| 5278 |
}, |
| 5279 |
row.key |
| 5280 |
)) }) |
| 5281 |
] }), |
| 5282 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 5283 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-1", children: __("Mobile Filters", "yatra") }), |
| 5284 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __( |
| 5285 |
"Controls the filter sidebar on the trip listing page on mobile devices.", |
| 5286 |
"yatra" |
| 5287 |
) }), |
| 5288 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5289 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5290 |
"input", |
| 5291 |
{ |
| 5292 |
type: "checkbox", |
| 5293 |
id: "collapse_filters_on_mobile", |
| 5294 |
checked: !!formData.collapse_filters_on_mobile, |
| 5295 |
name: "collapse_filters_on_mobile", |
| 5296 |
onChange: handleFieldChange, |
| 5297 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5298 |
} |
| 5299 |
), |
| 5300 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5301 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5302 |
Label, |
| 5303 |
{ |
| 5304 |
htmlFor: "collapse_filters_on_mobile", |
| 5305 |
className: "font-medium cursor-pointer", |
| 5306 |
children: __("Collapse filters by default on mobile", "yatra") |
| 5307 |
} |
| 5308 |
), |
| 5309 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5310 |
"On mobile, show filter sections collapsed so trip listings are visible right away. Visitors tap a section to expand it. Desktop is unaffected.", |
| 5311 |
"yatra" |
| 5312 |
) }) |
| 5313 |
] }) |
| 5314 |
] }) |
| 5315 |
] }) |
| 5316 |
] }); |
| 5317 |
case "booking": |
| 5318 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 5319 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 5320 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5321 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5322 |
"input", |
| 5323 |
{ |
| 5324 |
type: "checkbox", |
| 5325 |
id: "booking_confirmation", |
| 5326 |
checked: formData.booking_confirmation, |
| 5327 |
name: "booking_confirmation", |
| 5328 |
onChange: handleFieldChange, |
| 5329 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5330 |
} |
| 5331 |
), |
| 5332 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5333 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5334 |
Label, |
| 5335 |
{ |
| 5336 |
htmlFor: "booking_confirmation", |
| 5337 |
className: "font-medium cursor-pointer", |
| 5338 |
children: __("Send Booking Confirmation Email", "yatra") |
| 5339 |
} |
| 5340 |
), |
| 5341 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5342 |
"Send a confirmation email to the customer immediately after a successful booking. The post-checkout page is always shown; this toggle only controls the email.", |
| 5343 |
"yatra" |
| 5344 |
) }) |
| 5345 |
] }) |
| 5346 |
] }), |
| 5347 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5348 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium", children: __("Auto-Confirm Bookings", "yatra") }), |
| 5349 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5 mb-2", children: __( |
| 5350 |
"Choose when a booking is automatically set to Confirmed. Offline methods (bank transfer, pay later) stay pending until you confirm them.", |
| 5351 |
"yatra" |
| 5352 |
) }), |
| 5353 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { role: "radiogroup", className: "flex flex-col gap-2", children: [ |
| 5354 |
{ |
| 5355 |
value: "none", |
| 5356 |
label: __("Don't auto-confirm", "yatra"), |
| 5357 |
sub: __( |
| 5358 |
"Every booking stays Pending until you confirm it manually.", |
| 5359 |
"yatra" |
| 5360 |
) |
| 5361 |
}, |
| 5362 |
{ |
| 5363 |
value: "online", |
| 5364 |
label: __("Auto-confirm online payments only", "yatra"), |
| 5365 |
sub: __( |
| 5366 |
"When an online payment (Stripe, PayPal, Razorpay…) pays the balance in full, the booking is confirmed. Deposits/partial payments and offline methods stay Pending.", |
| 5367 |
"yatra" |
| 5368 |
) |
| 5369 |
}, |
| 5370 |
{ |
| 5371 |
value: "all", |
| 5372 |
label: __("Auto-confirm all bookings", "yatra"), |
| 5373 |
sub: __( |
| 5374 |
"Every booking is confirmed at checkout, whether or not it was paid.", |
| 5375 |
"yatra" |
| 5376 |
) |
| 5377 |
} |
| 5378 |
].map((opt) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 5379 |
"label", |
| 5380 |
{ |
| 5381 |
htmlFor: `auto_confirm_mode_${opt.value}`, |
| 5382 |
className: "flex items-start gap-2 cursor-pointer", |
| 5383 |
children: [ |
| 5384 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5385 |
"input", |
| 5386 |
{ |
| 5387 |
type: "radio", |
| 5388 |
id: `auto_confirm_mode_${opt.value}`, |
| 5389 |
name: "auto_confirm_mode", |
| 5390 |
value: opt.value, |
| 5391 |
checked: (formData.auto_confirm_mode || "none") === opt.value, |
| 5392 |
onChange: () => setFormData( |
| 5393 |
(prev) => prev ? { |
| 5394 |
...prev, |
| 5395 |
auto_confirm_mode: opt.value, |
| 5396 |
// Keep the legacy boolean in sync for any |
| 5397 |
// external reader (all → true, otherwise false). |
| 5398 |
auto_confirm_bookings: opt.value === "all" |
| 5399 |
} : prev |
| 5400 |
), |
| 5401 |
className: "mt-0.5 w-4 h-4 border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5402 |
} |
| 5403 |
), |
| 5404 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5405 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-sm", children: opt.label }), |
| 5406 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: opt.sub }) |
| 5407 |
] }) |
| 5408 |
] |
| 5409 |
}, |
| 5410 |
opt.value |
| 5411 |
)) }) |
| 5412 |
] }), |
| 5413 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5414 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5415 |
"input", |
| 5416 |
{ |
| 5417 |
type: "checkbox", |
| 5418 |
id: "require_login", |
| 5419 |
checked: formData.require_login, |
| 5420 |
name: "require_login", |
| 5421 |
onChange: handleFieldChange, |
| 5422 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5423 |
} |
| 5424 |
), |
| 5425 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5426 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5427 |
Label, |
| 5428 |
{ |
| 5429 |
htmlFor: "require_login", |
| 5430 |
className: "font-medium cursor-pointer", |
| 5431 |
children: __("Require Login for Booking", "yatra") |
| 5432 |
} |
| 5433 |
), |
| 5434 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5435 |
"Customers must create an account to make bookings", |
| 5436 |
"yatra" |
| 5437 |
) }) |
| 5438 |
] }) |
| 5439 |
] }), |
| 5440 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5441 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5442 |
"input", |
| 5443 |
{ |
| 5444 |
type: "checkbox", |
| 5445 |
id: "allow_guest_checkout", |
| 5446 |
checked: formData.allow_guest_checkout, |
| 5447 |
name: "allow_guest_checkout", |
| 5448 |
onChange: handleFieldChange, |
| 5449 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5450 |
} |
| 5451 |
), |
| 5452 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5453 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5454 |
Label, |
| 5455 |
{ |
| 5456 |
htmlFor: "allow_guest_checkout", |
| 5457 |
className: "font-medium cursor-pointer", |
| 5458 |
children: __("Allow Guest Checkout", "yatra") |
| 5459 |
} |
| 5460 |
), |
| 5461 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5462 |
"Allow customers to book without creating an account", |
| 5463 |
"yatra" |
| 5464 |
) }) |
| 5465 |
] }) |
| 5466 |
] }), |
| 5467 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5468 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5469 |
"input", |
| 5470 |
{ |
| 5471 |
type: "checkbox", |
| 5472 |
id: "require_guest_email_verification", |
| 5473 |
checked: formData.require_guest_email_verification, |
| 5474 |
name: "require_guest_email_verification", |
| 5475 |
onChange: handleFieldChange, |
| 5476 |
disabled: !formData.allow_guest_checkout || formData.require_login, |
| 5477 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 disabled:opacity-50" |
| 5478 |
} |
| 5479 |
), |
| 5480 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5481 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5482 |
Label, |
| 5483 |
{ |
| 5484 |
htmlFor: "require_guest_email_verification", |
| 5485 |
className: "font-medium cursor-pointer", |
| 5486 |
children: __("Require Guest Email Verification", "yatra") |
| 5487 |
} |
| 5488 |
), |
| 5489 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5490 |
"Hold guest bookings until the customer clicks a magic link sent to their email. Stops typo'd addresses and form-spam bots. Only applies when guest checkout is allowed and login isn't required — logged-in customers are already verified.", |
| 5491 |
"yatra" |
| 5492 |
) }) |
| 5493 |
] }) |
| 5494 |
] }), |
| 5495 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5496 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5497 |
"input", |
| 5498 |
{ |
| 5499 |
type: "checkbox", |
| 5500 |
id: "show_sold_out", |
| 5501 |
checked: formData.show_sold_out !== false, |
| 5502 |
name: "show_sold_out", |
| 5503 |
onChange: handleFieldChange, |
| 5504 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5505 |
} |
| 5506 |
), |
| 5507 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5508 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5509 |
Label, |
| 5510 |
{ |
| 5511 |
htmlFor: "show_sold_out", |
| 5512 |
className: "font-medium cursor-pointer", |
| 5513 |
children: __("Show sold-out dates", "yatra") |
| 5514 |
} |
| 5515 |
), |
| 5516 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5517 |
'Keep sold-out dates on the calendar marked "Sold out" — needed for the waitlist below. Turn this off to hide them entirely, the way blocked dates are hidden.', |
| 5518 |
"yatra" |
| 5519 |
) }) |
| 5520 |
] }) |
| 5521 |
] }), |
| 5522 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5523 |
FormField, |
| 5524 |
{ |
| 5525 |
id: "availability_horizon_months", |
| 5526 |
label: __("Booking horizon (months)", "yatra"), |
| 5527 |
description: __( |
| 5528 |
"How far ahead customers can see and book dates on the storefront calendar — 1 to 36 months (default 12). A trip whose Available To date is earlier stops there. Long horizons make flexible-booking trips (no dates or rules configured) load more dates per page.", |
| 5529 |
"yatra" |
| 5530 |
), |
| 5531 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5532 |
Input, |
| 5533 |
{ |
| 5534 |
id: "availability_horizon_months", |
| 5535 |
type: "number", |
| 5536 |
value: formData.availability_horizon_months ?? 12, |
| 5537 |
name: "availability_horizon_months", |
| 5538 |
onChange: handleFieldChange, |
| 5539 |
min: "1", |
| 5540 |
max: "36" |
| 5541 |
} |
| 5542 |
) |
| 5543 |
} |
| 5544 |
) }), |
| 5545 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5546 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5547 |
"input", |
| 5548 |
{ |
| 5549 |
type: "checkbox", |
| 5550 |
id: "allow_waitlist", |
| 5551 |
checked: formData.allow_waitlist, |
| 5552 |
name: "allow_waitlist", |
| 5553 |
onChange: handleFieldChange, |
| 5554 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5555 |
} |
| 5556 |
), |
| 5557 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5558 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5559 |
Label, |
| 5560 |
{ |
| 5561 |
htmlFor: "allow_waitlist", |
| 5562 |
className: "font-medium cursor-pointer", |
| 5563 |
children: __("Allow waitlist when a date is full", "yatra") |
| 5564 |
} |
| 5565 |
), |
| 5566 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5567 |
"Customers can join a waitlist instead of being blocked when seats are gone (per-trip caps still apply).", |
| 5568 |
"yatra" |
| 5569 |
) }) |
| 5570 |
] }) |
| 5571 |
] }), |
| 5572 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5573 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5574 |
"input", |
| 5575 |
{ |
| 5576 |
type: "checkbox", |
| 5577 |
id: "waitlist_auto_confirm", |
| 5578 |
checked: formData.waitlist_auto_confirm, |
| 5579 |
name: "waitlist_auto_confirm", |
| 5580 |
onChange: handleFieldChange, |
| 5581 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5582 |
} |
| 5583 |
), |
| 5584 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5585 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5586 |
Label, |
| 5587 |
{ |
| 5588 |
htmlFor: "waitlist_auto_confirm", |
| 5589 |
className: "font-medium cursor-pointer", |
| 5590 |
children: __("Auto-confirm promoted waitlist bookings", "yatra") |
| 5591 |
} |
| 5592 |
), |
| 5593 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5594 |
"When a spot opens, move the next waitlisted booking to confirmed; otherwise it becomes pending for staff review.", |
| 5595 |
"yatra" |
| 5596 |
) }) |
| 5597 |
] }) |
| 5598 |
] }), |
| 5599 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5600 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5601 |
"input", |
| 5602 |
{ |
| 5603 |
type: "checkbox", |
| 5604 |
id: "date_picker_as_dropdown", |
| 5605 |
checked: !!formData.date_picker_as_dropdown, |
| 5606 |
name: "date_picker_as_dropdown", |
| 5607 |
onChange: handleFieldChange, |
| 5608 |
disabled: !((_h = window.yatraAdmin) == null ? void 0 : _h.isPro), |
| 5609 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 disabled:opacity-50" |
| 5610 |
} |
| 5611 |
), |
| 5612 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5613 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 5614 |
Label, |
| 5615 |
{ |
| 5616 |
htmlFor: "date_picker_as_dropdown", |
| 5617 |
className: "font-medium cursor-pointer inline-flex items-center", |
| 5618 |
children: [ |
| 5619 |
__("Show available dates as a dropdown", "yatra"), |
| 5620 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5621 |
ProBadge, |
| 5622 |
{ |
| 5623 |
isProActive: !!((_i = window.yatraAdmin) == null ? void 0 : _i.isPro) |
| 5624 |
} |
| 5625 |
) |
| 5626 |
] |
| 5627 |
} |
| 5628 |
), |
| 5629 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5630 |
"Replace the calendar date picker with a dropdown listing every available departure date on the single-trip sidebar and the mobile sticky bar. Best for trips with a small set of fixed departures.", |
| 5631 |
"yatra" |
| 5632 |
) }) |
| 5633 |
] }) |
| 5634 |
] }) |
| 5635 |
] }), |
| 5636 |
/* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Booking Expiry & Reminders", "yatra") }), |
| 5637 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 5638 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5639 |
FormField, |
| 5640 |
{ |
| 5641 |
id: "booking_expiry_hours", |
| 5642 |
label: __("Booking Expiry Hours", "yatra"), |
| 5643 |
description: __( |
| 5644 |
"Hours before unpaid bookings expire and are cancelled", |
| 5645 |
"yatra" |
| 5646 |
), |
| 5647 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5648 |
Input, |
| 5649 |
{ |
| 5650 |
id: "booking_expiry_hours", |
| 5651 |
type: "number", |
| 5652 |
value: formData.booking_expiry_hours, |
| 5653 |
name: "booking_expiry_hours", |
| 5654 |
onChange: handleFieldChange, |
| 5655 |
min: "1" |
| 5656 |
} |
| 5657 |
) |
| 5658 |
} |
| 5659 |
), |
| 5660 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5661 |
FormField, |
| 5662 |
{ |
| 5663 |
id: "booking_reminder_days", |
| 5664 |
label: __("Booking Reminder Days", "yatra"), |
| 5665 |
description: __( |
| 5666 |
"Send reminder emails this many days before departure", |
| 5667 |
"yatra" |
| 5668 |
), |
| 5669 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5670 |
Input, |
| 5671 |
{ |
| 5672 |
id: "booking_reminder_days", |
| 5673 |
type: "number", |
| 5674 |
value: formData.booking_reminder_days, |
| 5675 |
name: "booking_reminder_days", |
| 5676 |
onChange: handleFieldChange, |
| 5677 |
min: "0" |
| 5678 |
} |
| 5679 |
) |
| 5680 |
} |
| 5681 |
) |
| 5682 |
] }) |
| 5683 |
] }); |
| 5684 |
case "pricing": { |
| 5685 |
const adEnabled = !!((_j = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _j.advancedDiscountEnabled); |
| 5686 |
const dpEnabled = !!((_k = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _k.dynamicPricingEnabled); |
| 5687 |
const bothActive = adEnabled && dpEnabled; |
| 5688 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 5689 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-600 dark:border-gray-700 dark:bg-gray-800/50 dark:text-gray-400", children: __( |
| 5690 |
"Controls what happens when both a Discount (coupon or group discount) and a Dynamic Pricing rule could apply to the same booking. The control only takes effect when both the Advanced Discount and Dynamic Pricing modules are turned on.", |
| 5691 |
"yatra" |
| 5692 |
) }), |
| 5693 |
bothActive ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-green-200 bg-green-50 p-3 text-xs text-green-800 dark:border-green-800 dark:bg-green-900/20 dark:text-green-200", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2", children: [ |
| 5694 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "mt-0.5 h-4 w-4 flex-shrink-0" }), |
| 5695 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 5696 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium", children: __("Active", "yatra") }), |
| 5697 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-0.5", children: __( |
| 5698 |
"Advanced Discount and Dynamic Pricing are both enabled. Your stacking choice below is being applied to every new booking calculation.", |
| 5699 |
"yatra" |
| 5700 |
) }) |
| 5701 |
] }) |
| 5702 |
] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-amber-200 bg-amber-50 p-3 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-200", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2", children: [ |
| 5703 |
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "mt-0.5 h-4 w-4 flex-shrink-0" }), |
| 5704 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 5705 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium", children: __("Not active yet", "yatra") }), |
| 5706 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-0.5", children: __( |
| 5707 |
"This setting only applies when BOTH modules below are enabled. Without both, bookings calculate exactly as they do today (no stacking control).", |
| 5708 |
"yatra" |
| 5709 |
) }), |
| 5710 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("ul", { className: "mt-2 space-y-1", children: [ |
| 5711 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "flex items-center gap-1.5", children: [ |
| 5712 |
adEnabled ? /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-3.5 w-3.5 text-green-600 dark:text-green-400" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "h-3.5 w-3.5 text-amber-600 dark:text-amber-400" }), |
| 5713 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ |
| 5714 |
__("Advanced Discount module", "yatra"), |
| 5715 |
" ", |
| 5716 |
adEnabled ? __("(enabled)", "yatra") : __("(not enabled)", "yatra") |
| 5717 |
] }) |
| 5718 |
] }), |
| 5719 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "flex items-center gap-1.5", children: [ |
| 5720 |
dpEnabled ? /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-3.5 w-3.5 text-green-600 dark:text-green-400" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "h-3.5 w-3.5 text-amber-600 dark:text-amber-400" }), |
| 5721 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ |
| 5722 |
__("Dynamic Pricing module", "yatra"), |
| 5723 |
" ", |
| 5724 |
dpEnabled ? __("(enabled)", "yatra") : __("(not enabled)", "yatra") |
| 5725 |
] }) |
| 5726 |
] }) |
| 5727 |
] }), |
| 5728 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 5729 |
"button", |
| 5730 |
{ |
| 5731 |
type: "button", |
| 5732 |
onClick: () => navigateMenu("modules"), |
| 5733 |
className: "mt-2 inline-flex items-center gap-1 text-amber-900 underline hover:text-amber-700 dark:text-amber-100 dark:hover:text-amber-300", |
| 5734 |
children: [ |
| 5735 |
__("Open Modules", "yatra"), |
| 5736 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "h-3 w-3" }) |
| 5737 |
] |
| 5738 |
} |
| 5739 |
) |
| 5740 |
] }) |
| 5741 |
] }) }), |
| 5742 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5743 |
FormField, |
| 5744 |
{ |
| 5745 |
id: "discount_stacking_mode", |
| 5746 |
label: __("Discount Stacking", "yatra"), |
| 5747 |
description: __( |
| 5748 |
"Pick how Discounts and Dynamic Pricing combine on the same booking.", |
| 5749 |
"yatra" |
| 5750 |
), |
| 5751 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 5752 |
Select, |
| 5753 |
{ |
| 5754 |
id: "discount_stacking_mode", |
| 5755 |
name: "discount_stacking_mode", |
| 5756 |
value: formData.discount_stacking_mode ?? "both", |
| 5757 |
onChange: handleFieldChange, |
| 5758 |
disabled: !bothActive, |
| 5759 |
children: [ |
| 5760 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "both", children: __( |
| 5761 |
"Both apply (legacy) — Dynamic Pricing and Discount stack", |
| 5762 |
"yatra" |
| 5763 |
) }), |
| 5764 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "best_for_customer", children: __( |
| 5765 |
"Best for the customer — pick whichever single mechanism gives the larger reduction", |
| 5766 |
"yatra" |
| 5767 |
) }), |
| 5768 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "discount_only", children: __( |
| 5769 |
"Discount only — if a coupon or group discount applies, ignore Dynamic Pricing", |
| 5770 |
"yatra" |
| 5771 |
) }), |
| 5772 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "dynamic_pricing_only", children: __( |
| 5773 |
"Dynamic Pricing only — if a Dynamic Pricing rule fires, ignore the discount", |
| 5774 |
"yatra" |
| 5775 |
) }) |
| 5776 |
] |
| 5777 |
} |
| 5778 |
) |
| 5779 |
} |
| 5780 |
), |
| 5781 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-md border border-blue-200 bg-blue-50 p-3 text-xs text-blue-800 dark:border-blue-800 dark:bg-blue-900/20 dark:text-blue-200", children: [ |
| 5782 |
__("What each mode does:", "yatra"), |
| 5783 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("ul", { className: "mt-2 ml-4 list-disc space-y-1", children: [ |
| 5784 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [ |
| 5785 |
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: __("Both apply", "yatra") }), |
| 5786 |
" — ", |
| 5787 |
__( |
| 5788 |
"default and matches the original behavior. A coupon stacks on top of the Dynamic Pricing-adjusted price.", |
| 5789 |
"yatra" |
| 5790 |
) |
| 5791 |
] }), |
| 5792 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [ |
| 5793 |
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: __("Best for the customer", "yatra") }), |
| 5794 |
" — ", |
| 5795 |
__( |
| 5796 |
"calculates both scenarios and picks the cheaper one for the customer. Never combines.", |
| 5797 |
"yatra" |
| 5798 |
) |
| 5799 |
] }), |
| 5800 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [ |
| 5801 |
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: __("Discount only", "yatra") }), |
| 5802 |
" — ", |
| 5803 |
__( |
| 5804 |
"when a discount is valid, Dynamic Pricing is skipped for that booking.", |
| 5805 |
"yatra" |
| 5806 |
) |
| 5807 |
] }), |
| 5808 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [ |
| 5809 |
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: __("Dynamic Pricing only", "yatra") }), |
| 5810 |
" — ", |
| 5811 |
__( |
| 5812 |
"when a Dynamic Pricing rule reduced the price, discount codes and group discounts are ignored for that booking.", |
| 5813 |
"yatra" |
| 5814 |
) |
| 5815 |
] }) |
| 5816 |
] }) |
| 5817 |
] }) |
| 5818 |
] }); |
| 5819 |
} |
| 5820 |
case "customer": |
| 5821 |
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 5822 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5823 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5824 |
"input", |
| 5825 |
{ |
| 5826 |
type: "checkbox", |
| 5827 |
id: "customer_registration", |
| 5828 |
checked: formData.customer_registration, |
| 5829 |
name: "customer_registration", |
| 5830 |
onChange: handleFieldChange, |
| 5831 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5832 |
} |
| 5833 |
), |
| 5834 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5835 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5836 |
Label, |
| 5837 |
{ |
| 5838 |
htmlFor: "customer_registration", |
| 5839 |
className: "font-medium cursor-pointer", |
| 5840 |
children: __("Enable Customer Registration", "yatra") |
| 5841 |
} |
| 5842 |
), |
| 5843 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5844 |
"Allow customers to create accounts on your website", |
| 5845 |
"yatra" |
| 5846 |
) }) |
| 5847 |
] }) |
| 5848 |
] }), |
| 5849 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5850 |
FormField, |
| 5851 |
{ |
| 5852 |
id: "customer_account_page", |
| 5853 |
label: __("Customer Account Page", "yatra"), |
| 5854 |
description: __( |
| 5855 |
"URL path segment for the account area (e.g. my-account → /my-account/dashboard). Must match your frontend routes.", |
| 5856 |
"yatra" |
| 5857 |
), |
| 5858 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 5859 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5860 |
Input, |
| 5861 |
{ |
| 5862 |
id: "customer_account_page", |
| 5863 |
value: formData.customer_account_page, |
| 5864 |
name: "customer_account_page", |
| 5865 |
onChange: handleFieldChange, |
| 5866 |
placeholder: "/my-account", |
| 5867 |
className: "flex-1" |
| 5868 |
} |
| 5869 |
), |
| 5870 |
formData.customer_account_page && (() => { |
| 5871 |
var _a3; |
| 5872 |
const siteUrl = ((_a3 = window.yatraAdmin) == null ? void 0 : _a3.siteUrl) || ""; |
| 5873 |
const accountUrl = buildYatraAccountViewUrl( |
| 5874 |
siteUrl, |
| 5875 |
formData.customer_account_page |
| 5876 |
); |
| 5877 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 5878 |
"a", |
| 5879 |
{ |
| 5880 |
href: accountUrl, |
| 5881 |
target: "_blank", |
| 5882 |
rel: "noopener noreferrer", |
| 5883 |
className: "px-4 py-2 text-sm font-medium text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 whitespace-nowrap border border-blue-300 dark:border-blue-600 rounded-md hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors", |
| 5884 |
children: [ |
| 5885 |
__("View Page", "yatra"), |
| 5886 |
" →" |
| 5887 |
] |
| 5888 |
} |
| 5889 |
); |
| 5890 |
})() |
| 5891 |
] }) |
| 5892 |
} |
| 5893 |
), |
| 5894 |
((_l = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _l.isPro) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md border border-gray-200 dark:border-gray-700", children: [ |
| 5895 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5896 |
"input", |
| 5897 |
{ |
| 5898 |
type: "checkbox", |
| 5899 |
id: "enable_wishlist", |
| 5900 |
checked: !!formData.enable_wishlist, |
| 5901 |
name: "enable_wishlist", |
| 5902 |
onChange: handleFieldChange, |
| 5903 |
className: "w-4 h-4 mt-1 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5904 |
} |
| 5905 |
), |
| 5906 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5907 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5908 |
Label, |
| 5909 |
{ |
| 5910 |
htmlFor: "enable_wishlist", |
| 5911 |
className: "font-medium cursor-pointer", |
| 5912 |
children: __("Enable wishlist (saved trips)", "yatra") |
| 5913 |
} |
| 5914 |
), |
| 5915 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5916 |
"Shows the heart control on trip cards and single trips, and the Saved Trips area in the customer account. Requires Yatra Pro.", |
| 5917 |
"yatra" |
| 5918 |
) }) |
| 5919 |
] }) |
| 5920 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg border border-amber-200 dark:border-amber-900/50 bg-amber-50 dark:bg-amber-950/30 text-sm text-amber-900 dark:text-amber-100", children: __( |
| 5921 |
"Wishlist / saved trips are a Yatra Pro feature. Install Yatra Pro to enable them and turn them on in Customer settings.", |
| 5922 |
"yatra" |
| 5923 |
) }), |
| 5924 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5925 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5926 |
"input", |
| 5927 |
{ |
| 5928 |
type: "checkbox", |
| 5929 |
id: "require_email_verification", |
| 5930 |
checked: formData.require_email_verification, |
| 5931 |
name: "require_email_verification", |
| 5932 |
onChange: handleFieldChange, |
| 5933 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5934 |
} |
| 5935 |
), |
| 5936 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5937 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5938 |
Label, |
| 5939 |
{ |
| 5940 |
htmlFor: "require_email_verification", |
| 5941 |
className: "font-medium cursor-pointer", |
| 5942 |
children: __("Require Email Verification", "yatra") |
| 5943 |
} |
| 5944 |
), |
| 5945 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5946 |
"Customers must verify their email before account activation", |
| 5947 |
"yatra" |
| 5948 |
) }) |
| 5949 |
] }) |
| 5950 |
] }) |
| 5951 |
] }) }); |
| 5952 |
case "review": |
| 5953 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 5954 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-600 dark:border-gray-700 dark:bg-gray-800/50 dark:text-gray-400", children: __( |
| 5955 |
"These options apply to trip review forms on the frontend (who may review, moderation, minimum stars, and reminder scheduling).", |
| 5956 |
"yatra" |
| 5957 |
) }), |
| 5958 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 5959 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5960 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5961 |
"input", |
| 5962 |
{ |
| 5963 |
type: "checkbox", |
| 5964 |
id: "enable_reviews", |
| 5965 |
checked: formData.enable_reviews, |
| 5966 |
name: "enable_reviews", |
| 5967 |
onChange: handleFieldChange, |
| 5968 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5969 |
} |
| 5970 |
), |
| 5971 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 5972 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5973 |
Label, |
| 5974 |
{ |
| 5975 |
htmlFor: "enable_reviews", |
| 5976 |
className: "font-medium cursor-pointer", |
| 5977 |
children: __("Enable Reviews", "yatra") |
| 5978 |
} |
| 5979 |
), |
| 5980 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 5981 |
"Allow customers to leave reviews and ratings", |
| 5982 |
"yatra" |
| 5983 |
) }) |
| 5984 |
] }) |
| 5985 |
] }), |
| 5986 |
formData.enable_reviews && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 5987 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 5988 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 5989 |
"input", |
| 5990 |
{ |
| 5991 |
type: "checkbox", |
| 5992 |
id: "require_booking", |
| 5993 |
checked: formData.require_booking, |
| 5994 |
name: "require_booking", |
| 5995 |
onChange: handleFieldChange, |
| 5996 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 5997 |
} |
| 5998 |
), |
| 5999 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 6000 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6001 |
Label, |
| 6002 |
{ |
| 6003 |
htmlFor: "require_booking", |
| 6004 |
className: "font-medium cursor-pointer", |
| 6005 |
children: __("Require Booking to Review", "yatra") |
| 6006 |
} |
| 6007 |
), |
| 6008 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 6009 |
"Only customers who have booked can leave reviews", |
| 6010 |
"yatra" |
| 6011 |
) }) |
| 6012 |
] }) |
| 6013 |
] }), |
| 6014 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 6015 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6016 |
"input", |
| 6017 |
{ |
| 6018 |
type: "checkbox", |
| 6019 |
id: "auto_approve_reviews", |
| 6020 |
checked: formData.auto_approve_reviews, |
| 6021 |
name: "auto_approve_reviews", |
| 6022 |
onChange: handleFieldChange, |
| 6023 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 6024 |
} |
| 6025 |
), |
| 6026 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 6027 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6028 |
Label, |
| 6029 |
{ |
| 6030 |
htmlFor: "auto_approve_reviews", |
| 6031 |
className: "font-medium cursor-pointer", |
| 6032 |
children: __("Auto-Approve Reviews", "yatra") |
| 6033 |
} |
| 6034 |
), |
| 6035 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 6036 |
"Automatically publish reviews without moderation", |
| 6037 |
"yatra" |
| 6038 |
) }) |
| 6039 |
] }) |
| 6040 |
] }), |
| 6041 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 6042 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6043 |
"input", |
| 6044 |
{ |
| 6045 |
type: "checkbox", |
| 6046 |
id: "review_moderation", |
| 6047 |
checked: formData.review_moderation, |
| 6048 |
name: "review_moderation", |
| 6049 |
onChange: handleFieldChange, |
| 6050 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 6051 |
} |
| 6052 |
), |
| 6053 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 6054 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6055 |
Label, |
| 6056 |
{ |
| 6057 |
htmlFor: "review_moderation", |
| 6058 |
className: "font-medium cursor-pointer", |
| 6059 |
children: __("Enable Review Moderation", "yatra") |
| 6060 |
} |
| 6061 |
), |
| 6062 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 6063 |
"Manually approve reviews before they are published", |
| 6064 |
"yatra" |
| 6065 |
) }) |
| 6066 |
] }) |
| 6067 |
] }), |
| 6068 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6069 |
FormField, |
| 6070 |
{ |
| 6071 |
id: "min_rating", |
| 6072 |
label: __("Minimum Rating", "yatra"), |
| 6073 |
description: __( |
| 6074 |
"Lowest rating value allowed (1-5 stars)", |
| 6075 |
"yatra" |
| 6076 |
), |
| 6077 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 6078 |
Select, |
| 6079 |
{ |
| 6080 |
id: "min_rating", |
| 6081 |
value: formData.min_rating, |
| 6082 |
name: "min_rating", |
| 6083 |
onChange: handleFieldChange, |
| 6084 |
children: [ |
| 6085 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "1", children: [ |
| 6086 |
"1 ", |
| 6087 |
__("Star", "yatra") |
| 6088 |
] }), |
| 6089 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "2", children: [ |
| 6090 |
"2 ", |
| 6091 |
__("Stars", "yatra") |
| 6092 |
] }), |
| 6093 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "3", children: [ |
| 6094 |
"3 ", |
| 6095 |
__("Stars", "yatra") |
| 6096 |
] }), |
| 6097 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "4", children: [ |
| 6098 |
"4 ", |
| 6099 |
__("Stars", "yatra") |
| 6100 |
] }), |
| 6101 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "5", children: [ |
| 6102 |
"5 ", |
| 6103 |
__("Stars", "yatra") |
| 6104 |
] }) |
| 6105 |
] |
| 6106 |
} |
| 6107 |
) |
| 6108 |
} |
| 6109 |
), |
| 6110 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6111 |
FormField, |
| 6112 |
{ |
| 6113 |
id: "review_reminder_days", |
| 6114 |
label: __("Review Reminder Days", "yatra"), |
| 6115 |
description: __( |
| 6116 |
"Send review reminder email this many days after trip completion", |
| 6117 |
"yatra" |
| 6118 |
), |
| 6119 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6120 |
Input, |
| 6121 |
{ |
| 6122 |
id: "review_reminder_days", |
| 6123 |
type: "number", |
| 6124 |
value: formData.review_reminder_days, |
| 6125 |
name: "review_reminder_days", |
| 6126 |
onChange: handleFieldChange, |
| 6127 |
min: "0" |
| 6128 |
} |
| 6129 |
) |
| 6130 |
} |
| 6131 |
) |
| 6132 |
] }) |
| 6133 |
] }) |
| 6134 |
] }); |
| 6135 |
case "tax": |
| 6136 |
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 6137 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 6138 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6139 |
"input", |
| 6140 |
{ |
| 6141 |
type: "checkbox", |
| 6142 |
id: "enable_tax", |
| 6143 |
checked: formData.enable_tax, |
| 6144 |
name: "enable_tax", |
| 6145 |
onChange: handleFieldChange, |
| 6146 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 6147 |
} |
| 6148 |
), |
| 6149 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 6150 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6151 |
Label, |
| 6152 |
{ |
| 6153 |
htmlFor: "enable_tax", |
| 6154 |
className: "font-medium cursor-pointer", |
| 6155 |
children: __("Enable Tax", "yatra") |
| 6156 |
} |
| 6157 |
), |
| 6158 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __("Add tax to booking prices", "yatra") }) |
| 6159 |
] }) |
| 6160 |
] }), |
| 6161 |
formData.enable_tax && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6162 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 6163 |
FormField, |
| 6164 |
{ |
| 6165 |
id: "multiple_taxes", |
| 6166 |
label: __("Taxes", "yatra"), |
| 6167 |
description: __( |
| 6168 |
"Configure taxes to apply to bookings", |
| 6169 |
"yatra" |
| 6170 |
), |
| 6171 |
children: [ |
| 6172 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6173 |
MultipleTaxesEditor, |
| 6174 |
{ |
| 6175 |
taxes: formData.multiple_taxes || [], |
| 6176 |
onChange: (taxes) => { |
| 6177 |
setFormData( |
| 6178 |
(prev) => prev ? { ...prev, multiple_taxes: taxes } : prev |
| 6179 |
); |
| 6180 |
} |
| 6181 |
} |
| 6182 |
), |
| 6183 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 border border-gray-200 rounded-lg bg-gray-50 dark:bg-gray-800 dark:border-gray-700 mt-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [ |
| 6184 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6185 |
Input, |
| 6186 |
{ |
| 6187 |
value: newTaxName, |
| 6188 |
onChange: (e) => setNewTaxName(e.target.value), |
| 6189 |
placeholder: __( |
| 6190 |
"Tax name (e.g., VAT, GST)", |
| 6191 |
"yatra" |
| 6192 |
), |
| 6193 |
className: "w-full" |
| 6194 |
} |
| 6195 |
) }), |
| 6196 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [ |
| 6197 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6198 |
Input, |
| 6199 |
{ |
| 6200 |
type: "number", |
| 6201 |
value: newTaxRate, |
| 6202 |
onChange: (e) => setNewTaxRate(e.target.value), |
| 6203 |
min: "0", |
| 6204 |
max: "100", |
| 6205 |
step: "0.01", |
| 6206 |
placeholder: __("Rate", "yatra"), |
| 6207 |
className: "w-full" |
| 6208 |
} |
| 6209 |
), |
| 6210 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "%" }) |
| 6211 |
] }) }), |
| 6212 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 6213 |
Button, |
| 6214 |
{ |
| 6215 |
type: "button", |
| 6216 |
onClick: () => { |
| 6217 |
if (newTaxName && newTaxRate && parseFloat(newTaxRate) >= 0 && parseFloat(newTaxRate) <= 100) { |
| 6218 |
setFormData((prev) => { |
| 6219 |
const currentTaxes = (prev == null ? void 0 : prev.multiple_taxes) || []; |
| 6220 |
const newTax = { |
| 6221 |
name: newTaxName, |
| 6222 |
rate: parseFloat(newTaxRate) |
| 6223 |
}; |
| 6224 |
const updatedTaxes = [...currentTaxes, newTax]; |
| 6225 |
return prev ? { ...prev, multiple_taxes: updatedTaxes } : prev; |
| 6226 |
}); |
| 6227 |
setNewTaxName(""); |
| 6228 |
setNewTaxRate(""); |
| 6229 |
} |
| 6230 |
}, |
| 6231 |
disabled: !newTaxName || !newTaxRate || parseFloat(newTaxRate) < 0 || parseFloat(newTaxRate) > 100, |
| 6232 |
className: "px-4 py-2 bg-green-600 hover:bg-green-700 text-white", |
| 6233 |
children: [ |
| 6234 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4 mr-2" }), |
| 6235 |
__("Add new Tax", "yatra") |
| 6236 |
] |
| 6237 |
} |
| 6238 |
) |
| 6239 |
] }) }), |
| 6240 |
(formData.multiple_taxes || []).length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800 mt-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm font-medium text-blue-800 dark:text-blue-200", children: [ |
| 6241 |
__("Total Tax Rate:", "yatra"), |
| 6242 |
" ", |
| 6243 |
(formData.multiple_taxes || []).reduce((sum, tax) => sum + tax.rate, 0).toFixed(2), |
| 6244 |
"%" |
| 6245 |
] }) }) |
| 6246 |
] |
| 6247 |
} |
| 6248 |
), |
| 6249 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 6250 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6251 |
"input", |
| 6252 |
{ |
| 6253 |
type: "checkbox", |
| 6254 |
id: "tax_inclusive", |
| 6255 |
checked: formData.tax_inclusive, |
| 6256 |
name: "tax_inclusive", |
| 6257 |
onChange: handleFieldChange, |
| 6258 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 6259 |
} |
| 6260 |
), |
| 6261 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 6262 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6263 |
Label, |
| 6264 |
{ |
| 6265 |
htmlFor: "tax_inclusive", |
| 6266 |
className: "font-medium cursor-pointer", |
| 6267 |
children: __("Tax Inclusive Pricing", "yatra") |
| 6268 |
} |
| 6269 |
), |
| 6270 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __("Tax is included in displayed prices", "yatra") }) |
| 6271 |
] }) |
| 6272 |
] }), |
| 6273 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6274 |
FormField, |
| 6275 |
{ |
| 6276 |
id: "vat_number", |
| 6277 |
label: __("VAT Number", "yatra"), |
| 6278 |
description: __( |
| 6279 |
"Your company VAT or tax identification number", |
| 6280 |
"yatra" |
| 6281 |
), |
| 6282 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6283 |
Input, |
| 6284 |
{ |
| 6285 |
id: "vat_number", |
| 6286 |
value: formData.vat_number, |
| 6287 |
name: "vat_number", |
| 6288 |
onChange: handleFieldChange, |
| 6289 |
placeholder: __("Enter VAT number", "yatra") |
| 6290 |
} |
| 6291 |
) |
| 6292 |
} |
| 6293 |
) |
| 6294 |
] }) |
| 6295 |
] }) }); |
| 6296 |
case "currency": |
| 6297 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 6298 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Currency Settings", "yatra") }), |
| 6299 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [ |
| 6300 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 6301 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6302 |
FormField, |
| 6303 |
{ |
| 6304 |
id: "currency", |
| 6305 |
label: __("Default Currency", "yatra"), |
| 6306 |
description: __( |
| 6307 |
"Primary currency for all transactions", |
| 6308 |
"yatra" |
| 6309 |
), |
| 6310 |
required: true, |
| 6311 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6312 |
SearchableSelect, |
| 6313 |
{ |
| 6314 |
value: formData.currency, |
| 6315 |
onChange: (val) => setFormData( |
| 6316 |
(prev) => prev ? { ...prev, currency: val } : prev |
| 6317 |
), |
| 6318 |
options: getCurrencyOptions(), |
| 6319 |
placeholder: __("Select currency...", "yatra"), |
| 6320 |
searchPlaceholder: __("Search currencies...", "yatra"), |
| 6321 |
showValueId: false |
| 6322 |
} |
| 6323 |
) |
| 6324 |
} |
| 6325 |
), |
| 6326 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6327 |
FormField, |
| 6328 |
{ |
| 6329 |
id: "currency_position", |
| 6330 |
label: __("Currency Position", "yatra"), |
| 6331 |
description: __( |
| 6332 |
"Where to display currency symbol relative to amount", |
| 6333 |
"yatra" |
| 6334 |
), |
| 6335 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 6336 |
Select, |
| 6337 |
{ |
| 6338 |
id: "currency_position", |
| 6339 |
value: formData.currency_position, |
| 6340 |
name: "currency_position", |
| 6341 |
onChange: handleFieldChange, |
| 6342 |
children: [ |
| 6343 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "left", children: "$100 (Left)" }), |
| 6344 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "right", children: "100$ (Right)" }), |
| 6345 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "left_space", children: "$ 100 (Left with Space)" }), |
| 6346 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "right_space", children: "100 $ (Right with Space)" }) |
| 6347 |
] |
| 6348 |
} |
| 6349 |
) |
| 6350 |
} |
| 6351 |
), |
| 6352 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6353 |
FormField, |
| 6354 |
{ |
| 6355 |
id: "thousand_separator", |
| 6356 |
label: __("Thousand Separator", "yatra"), |
| 6357 |
description: __( |
| 6358 |
"Character used to separate thousands (e.g., comma for 1,000)", |
| 6359 |
"yatra" |
| 6360 |
), |
| 6361 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6362 |
Input, |
| 6363 |
{ |
| 6364 |
id: "thousand_separator", |
| 6365 |
value: formData.thousand_separator, |
| 6366 |
name: "thousand_separator", |
| 6367 |
onChange: handleFieldChange, |
| 6368 |
maxLength: 1, |
| 6369 |
placeholder: "," |
| 6370 |
} |
| 6371 |
) |
| 6372 |
} |
| 6373 |
) |
| 6374 |
] }), |
| 6375 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 6376 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6377 |
FormField, |
| 6378 |
{ |
| 6379 |
id: "currency_decimals", |
| 6380 |
label: __("Decimal Places", "yatra"), |
| 6381 |
description: __( |
| 6382 |
"Number of decimal places to show in prices", |
| 6383 |
"yatra" |
| 6384 |
), |
| 6385 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6386 |
Input, |
| 6387 |
{ |
| 6388 |
id: "currency_decimals", |
| 6389 |
type: "number", |
| 6390 |
value: formData.currency_decimals, |
| 6391 |
name: "currency_decimals", |
| 6392 |
onChange: handleFieldChange, |
| 6393 |
min: "0", |
| 6394 |
max: "4" |
| 6395 |
} |
| 6396 |
) |
| 6397 |
} |
| 6398 |
), |
| 6399 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6400 |
FormField, |
| 6401 |
{ |
| 6402 |
id: "decimal_separator", |
| 6403 |
label: __("Decimal Separator", "yatra"), |
| 6404 |
description: __( |
| 6405 |
"Character used to separate decimal part (e.g., period for 99.99)", |
| 6406 |
"yatra" |
| 6407 |
), |
| 6408 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6409 |
Input, |
| 6410 |
{ |
| 6411 |
id: "decimal_separator", |
| 6412 |
value: formData.decimal_separator, |
| 6413 |
name: "decimal_separator", |
| 6414 |
onChange: handleFieldChange, |
| 6415 |
maxLength: 1, |
| 6416 |
placeholder: "." |
| 6417 |
} |
| 6418 |
) |
| 6419 |
} |
| 6420 |
) |
| 6421 |
] }) |
| 6422 |
] }) |
| 6423 |
] }); |
| 6424 |
case "integration": |
| 6425 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 6426 |
window.yatraAdmin && window.yatraAdmin.showGoogleCalendarSettingsUI && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6427 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6428 |
SectionDivider, |
| 6429 |
{ |
| 6430 |
title: __("Google Calendar Integration", "yatra") |
| 6431 |
} |
| 6432 |
), |
| 6433 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6434 |
GoogleCalendarIntegrationSection, |
| 6435 |
{ |
| 6436 |
formData, |
| 6437 |
setFormData |
| 6438 |
} |
| 6439 |
) |
| 6440 |
] }), |
| 6441 |
/* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Mailchimp Integration", "yatra") }), |
| 6442 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 6443 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [ |
| 6444 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-lg flex items-center gap-2", children: [ |
| 6445 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Mail, { className: "w-5 h-5 text-yellow-500" }), |
| 6446 |
__("Mailchimp", "yatra"), |
| 6447 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ProBadge, { isProActive: (_m = window.yatraAdmin) == null ? void 0 : _m.isPro }) |
| 6448 |
] }), |
| 6449 |
((_p = (_o = (_n = window.yatraAdmin) == null ? void 0 : _n.mailchimp) == null ? void 0 : _o.connectionStatus) == null ? void 0 : _p.connected) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-green-600 dark:text-green-400", children: [ |
| 6450 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }), |
| 6451 |
__("Connected", "yatra") |
| 6452 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-gray-500 dark:text-gray-400", children: [ |
| 6453 |
/* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-4 h-4" }), |
| 6454 |
__("Not Connected", "yatra") |
| 6455 |
] }) |
| 6456 |
] }), |
| 6457 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-4", children: [ |
| 6458 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300", children: __( |
| 6459 |
"Automatically sync customers to Mailchimp lists when they book. Add tags based on trips booked and build targeted email campaigns.", |
| 6460 |
"yatra" |
| 6461 |
) }), |
| 6462 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6463 |
ProFeature, |
| 6464 |
{ |
| 6465 |
title: __("Mailchimp", "yatra"), |
| 6466 |
description: __("automatically sync your customers", "yatra"), |
| 6467 |
moduleName: "Mailchimp", |
| 6468 |
pricingUrl: "https://wpyatra.com/pricing?module=mailchimp", |
| 6469 |
isProActive: (_q = window.yatraAdmin) == null ? void 0 : _q.isPro, |
| 6470 |
isModuleEnabled: (_r = window.yatraAdmin) == null ? void 0 : _r.showMailchimpSettingsUI, |
| 6471 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 6472 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 6473 |
FormField, |
| 6474 |
{ |
| 6475 |
id: "mailchimp_api_key", |
| 6476 |
label: __("API Key", "yatra"), |
| 6477 |
description: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6478 |
__("Get your API key from", "yatra"), |
| 6479 |
" ", |
| 6480 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6481 |
"a", |
| 6482 |
{ |
| 6483 |
href: "https://admin.mailchimp.com/account/api/", |
| 6484 |
target: "_blank", |
| 6485 |
rel: "noopener noreferrer", |
| 6486 |
className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline", |
| 6487 |
children: __("Mailchimp Account Settings", "yatra") |
| 6488 |
} |
| 6489 |
) |
| 6490 |
] }), |
| 6491 |
children: [ |
| 6492 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [ |
| 6493 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex-1", children: [ |
| 6494 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6495 |
Input, |
| 6496 |
{ |
| 6497 |
id: "mailchimp_api_key", |
| 6498 |
type: showApiKey ? "text" : "password", |
| 6499 |
value: formData.mailchimp_api_key || "", |
| 6500 |
name: "mailchimp_api_key", |
| 6501 |
onChange: handleFieldChange, |
| 6502 |
placeholder: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-us1", |
| 6503 |
className: "pr-10" |
| 6504 |
} |
| 6505 |
), |
| 6506 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6507 |
"button", |
| 6508 |
{ |
| 6509 |
type: "button", |
| 6510 |
onClick: () => setShowApiKey(!showApiKey), |
| 6511 |
className: "absolute inset-y-0 right-0 pr-3 flex items-center", |
| 6512 |
tabIndex: -1, |
| 6513 |
children: showApiKey ? /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4 text-gray-400 hover:text-gray-600" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4 text-gray-400 hover:text-gray-600" }) |
| 6514 |
} |
| 6515 |
) |
| 6516 |
] }), |
| 6517 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6518 |
Button, |
| 6519 |
{ |
| 6520 |
type: "button", |
| 6521 |
variant: "outline", |
| 6522 |
size: "sm", |
| 6523 |
onClick: validateMailchimpApiKey, |
| 6524 |
disabled: !formData.mailchimp_api_key || validatingApiKey, |
| 6525 |
className: "whitespace-nowrap", |
| 6526 |
children: validatingApiKey ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6527 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "h-4 w-4 animate-spin mr-2" }), |
| 6528 |
__("Validating...", "yatra") |
| 6529 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6530 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-4 w-4 mr-2" }), |
| 6531 |
__("Validate", "yatra") |
| 6532 |
] }) |
| 6533 |
} |
| 6534 |
) |
| 6535 |
] }), |
| 6536 |
formData.mailchimp_api_key && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6537 |
"div", |
| 6538 |
{ |
| 6539 |
className: `mt-2 text-sm ${((_u = (_t = (_s = window.yatraAdmin) == null ? void 0 : _s.mailchimp) == null ? void 0 : _t.connectionStatus) == null ? void 0 : _u.connected) ? "text-green-600 dark:text-green-400" : "text-orange-600 dark:text-orange-400"}`, |
| 6540 |
children: ((_x = (_w = (_v = window.yatraAdmin) == null ? void 0 : _v.mailchimp) == null ? void 0 : _w.connectionStatus) == null ? void 0 : _x.connected) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6541 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "h-4 w-4 inline mr-1" }), |
| 6542 |
__("Connected successfully!", "yatra") |
| 6543 |
] }) : ((_A = (_z = (_y = window.yatraAdmin) == null ? void 0 : _y.mailchimp) == null ? void 0 : _z.connectionStatus) == null ? void 0 : _A.error) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6544 |
/* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "h-4 w-4 inline mr-1" }), |
| 6545 |
(_D = (_C = (_B = window.yatraAdmin) == null ? void 0 : _B.mailchimp) == null ? void 0 : _C.connectionStatus) == null ? void 0 : _D.error |
| 6546 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6547 |
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "h-4 w-4 inline mr-1" }), |
| 6548 |
__( |
| 6549 |
"API key entered. Click 'Validate' to test connection.", |
| 6550 |
"yatra" |
| 6551 |
) |
| 6552 |
] }) |
| 6553 |
} |
| 6554 |
) |
| 6555 |
] |
| 6556 |
} |
| 6557 |
), |
| 6558 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6559 |
FormField, |
| 6560 |
{ |
| 6561 |
id: "mailchimp_list_id", |
| 6562 |
label: __("Audience/List", "yatra"), |
| 6563 |
description: __( |
| 6564 |
"Select the Mailchimp audience to sync subscribers to.", |
| 6565 |
"yatra" |
| 6566 |
), |
| 6567 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 6568 |
Select, |
| 6569 |
{ |
| 6570 |
id: "mailchimp_list_id", |
| 6571 |
value: formData.mailchimp_list_id || "", |
| 6572 |
name: "mailchimp_list_id", |
| 6573 |
onChange: handleFieldChange, |
| 6574 |
disabled: !((_G = (_F = (_E = window.yatraAdmin) == null ? void 0 : _E.mailchimp) == null ? void 0 : _F.connectionStatus) == null ? void 0 : _G.connected), |
| 6575 |
children: [ |
| 6576 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: !((_J = (_I = (_H = window.yatraAdmin) == null ? void 0 : _H.mailchimp) == null ? void 0 : _I.connectionStatus) == null ? void 0 : _J.connected) ? __("Please validate API key first", "yatra") : __("Select an audience", "yatra") }), |
| 6577 |
(_M = (_L = (_K = window.yatraAdmin) == null ? void 0 : _K.mailchimp) == null ? void 0 : _L.availableLists) == null ? void 0 : _M.map( |
| 6578 |
(list) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: list.id, children: list.name }, list.id) |
| 6579 |
) |
| 6580 |
] |
| 6581 |
} |
| 6582 |
) |
| 6583 |
} |
| 6584 |
), |
| 6585 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 6586 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6587 |
"input", |
| 6588 |
{ |
| 6589 |
type: "checkbox", |
| 6590 |
id: "mailchimp_sync_on_booking", |
| 6591 |
checked: formData.mailchimp_sync_on_booking ?? true, |
| 6592 |
name: "mailchimp_sync_on_booking", |
| 6593 |
onChange: handleFieldChange, |
| 6594 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 6595 |
} |
| 6596 |
), |
| 6597 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 6598 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6599 |
Label, |
| 6600 |
{ |
| 6601 |
htmlFor: "mailchimp_sync_on_booking", |
| 6602 |
className: "font-medium cursor-pointer", |
| 6603 |
children: __("Sync on Booking", "yatra") |
| 6604 |
} |
| 6605 |
), |
| 6606 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 6607 |
"Automatically add customers to Mailchimp when they make a booking", |
| 6608 |
"yatra" |
| 6609 |
) }) |
| 6610 |
] }) |
| 6611 |
] }), |
| 6612 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 6613 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6614 |
"input", |
| 6615 |
{ |
| 6616 |
type: "checkbox", |
| 6617 |
id: "mailchimp_double_optin", |
| 6618 |
checked: formData.mailchimp_double_optin ?? false, |
| 6619 |
name: "mailchimp_double_optin", |
| 6620 |
onChange: handleFieldChange, |
| 6621 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 6622 |
} |
| 6623 |
), |
| 6624 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 6625 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6626 |
Label, |
| 6627 |
{ |
| 6628 |
htmlFor: "mailchimp_double_optin", |
| 6629 |
className: "font-medium cursor-pointer", |
| 6630 |
children: __("Double Opt-in", "yatra") |
| 6631 |
} |
| 6632 |
), |
| 6633 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 6634 |
"Require email confirmation before adding to list (recommended for GDPR)", |
| 6635 |
"yatra" |
| 6636 |
) }) |
| 6637 |
] }) |
| 6638 |
] }), |
| 6639 |
formData.mailchimp_api_key && formData.mailchimp_list_id && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6 pt-4 border-t border-gray-200 dark:border-gray-700", children: [ |
| 6640 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-3 flex items-center gap-2", children: [ |
| 6641 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ClipboardList, { className: "w-4 h-4" }), |
| 6642 |
__("Field Mapping", "yatra") |
| 6643 |
] }), |
| 6644 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __( |
| 6645 |
"Map Yatra customer fields to Mailchimp merge fields. This controls what data is synced when a customer is added to your list.", |
| 6646 |
"yatra" |
| 6647 |
) }), |
| 6648 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-3", children: ((_P = (_O = (_N = window.yatraAdmin) == null ? void 0 : _N.mailchimp) == null ? void 0 : _O.mergeFields) == null ? void 0 : _P.length) > 0 ? (_R = (_Q = window.yatraAdmin) == null ? void 0 : _Q.mailchimp) == null ? void 0 : _R.mergeFields.map( |
| 6649 |
(field) => { |
| 6650 |
var _a3, _b3; |
| 6651 |
const currentMapping = formData.mailchimp_field_mapping || {}; |
| 6652 |
const yatraFields = ((_b3 = (_a3 = window.yatraAdmin) == null ? void 0 : _a3.mailchimp) == null ? void 0 : _b3.yatraFields) || {}; |
| 6653 |
const yatraFieldOptions = yatraFields[field.type] || yatraFields["text"] || []; |
| 6654 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 6655 |
"div", |
| 6656 |
{ |
| 6657 |
className: "grid grid-cols-2 gap-3 items-center", |
| 6658 |
children: [ |
| 6659 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-800 px-3 py-2 rounded", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 6660 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: field.name }), |
| 6661 |
field.required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-red-500", children: "*" }), |
| 6662 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-gray-400", children: [ |
| 6663 |
"(", |
| 6664 |
field.tag, |
| 6665 |
")" |
| 6666 |
] }) |
| 6667 |
] }) }), |
| 6668 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 6669 |
Select, |
| 6670 |
{ |
| 6671 |
value: currentMapping[field.tag] || "", |
| 6672 |
onChange: (e) => { |
| 6673 |
const newMapping = { |
| 6674 |
...formData.mailchimp_field_mapping || {} |
| 6675 |
}; |
| 6676 |
if (e.target.value) { |
| 6677 |
newMapping[field.tag] = e.target.value; |
| 6678 |
} else { |
| 6679 |
delete newMapping[field.tag]; |
| 6680 |
} |
| 6681 |
setFormData((prev) => ({ |
| 6682 |
...prev, |
| 6683 |
mailchimp_field_mapping: newMapping |
| 6684 |
})); |
| 6685 |
}, |
| 6686 |
children: [ |
| 6687 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: __("Do not sync", "yatra") }), |
| 6688 |
Object.entries(yatraFieldOptions).map( |
| 6689 |
([value, label]) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value, children: String(label) }, value) |
| 6690 |
) |
| 6691 |
] |
| 6692 |
} |
| 6693 |
) |
| 6694 |
] |
| 6695 |
}, |
| 6696 |
field.tag |
| 6697 |
); |
| 6698 |
} |
| 6699 |
) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center py-4 text-sm text-gray-500 dark:text-gray-400", children: __( |
| 6700 |
"No merge fields available. Please select a list first.", |
| 6701 |
"yatra" |
| 6702 |
) }) }), |
| 6703 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 pt-4 border-t border-gray-200 dark:border-gray-700", children: [ |
| 6704 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 6705 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6706 |
"input", |
| 6707 |
{ |
| 6708 |
type: "checkbox", |
| 6709 |
id: "mailchimp_add_tags", |
| 6710 |
checked: formData.mailchimp_add_tags ?? true, |
| 6711 |
onChange: (e) => setFormData((prev) => ({ |
| 6712 |
...prev, |
| 6713 |
mailchimp_add_tags: e.target.checked |
| 6714 |
})), |
| 6715 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 6716 |
} |
| 6717 |
), |
| 6718 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 6719 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6720 |
Label, |
| 6721 |
{ |
| 6722 |
htmlFor: "mailchimp_add_tags", |
| 6723 |
className: "font-medium cursor-pointer", |
| 6724 |
children: __("Add Trip Tags", "yatra") |
| 6725 |
} |
| 6726 |
), |
| 6727 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 6728 |
"Automatically tag subscribers with the trip name they booked", |
| 6729 |
"yatra" |
| 6730 |
) }) |
| 6731 |
] }) |
| 6732 |
] }), |
| 6733 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6734 |
FormField, |
| 6735 |
{ |
| 6736 |
id: "mailchimp_default_tags", |
| 6737 |
label: __("Default Tags", "yatra"), |
| 6738 |
description: __( |
| 6739 |
'Comma-separated tags to add to all synced subscribers (e.g., "yatra, booking")', |
| 6740 |
"yatra" |
| 6741 |
), |
| 6742 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6743 |
Input, |
| 6744 |
{ |
| 6745 |
id: "mailchimp_default_tags", |
| 6746 |
value: formData.mailchimp_default_tags || "", |
| 6747 |
onChange: (e) => setFormData((prev) => ({ |
| 6748 |
...prev, |
| 6749 |
mailchimp_default_tags: e.target.value |
| 6750 |
})), |
| 6751 |
placeholder: "yatra, booking" |
| 6752 |
} |
| 6753 |
) |
| 6754 |
} |
| 6755 |
) |
| 6756 |
] }) |
| 6757 |
] }) |
| 6758 |
] }) |
| 6759 |
} |
| 6760 |
) |
| 6761 |
] }) |
| 6762 |
] }), |
| 6763 |
/* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Facebook Pixel", "yatra") }), |
| 6764 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 6765 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [ |
| 6766 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-lg flex items-center gap-2", children: [ |
| 6767 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6768 |
"svg", |
| 6769 |
{ |
| 6770 |
className: "w-5 h-5 text-blue-600", |
| 6771 |
viewBox: "0 0 24 24", |
| 6772 |
fill: "currentColor", |
| 6773 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z" }) |
| 6774 |
} |
| 6775 |
), |
| 6776 |
__("Facebook Pixel", "yatra"), |
| 6777 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ProBadge, { isProActive: (_S = window.yatraAdmin) == null ? void 0 : _S.isPro }) |
| 6778 |
] }), |
| 6779 |
((_V = (_U = (_T = window.yatraAdmin) == null ? void 0 : _T.facebookPixel) == null ? void 0 : _U.connectionStatus) == null ? void 0 : _V.pixelConnected) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-green-600 dark:text-green-400", children: [ |
| 6780 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-4 h-4" }), |
| 6781 |
__("Connected", "yatra") |
| 6782 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-sm text-gray-500 dark:text-gray-400", children: [ |
| 6783 |
/* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-4 h-4" }), |
| 6784 |
__("Not Connected", "yatra") |
| 6785 |
] }) |
| 6786 |
] }), |
| 6787 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-4", children: [ |
| 6788 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300", children: __( |
| 6789 |
"Track booking conversions with Facebook Pixel. Retarget visitors who viewed trips and optimize ad campaigns with accurate conversion data.", |
| 6790 |
"yatra" |
| 6791 |
) }), |
| 6792 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6793 |
ProFeature, |
| 6794 |
{ |
| 6795 |
title: __("Facebook Pixel", "yatra"), |
| 6796 |
description: __( |
| 6797 |
"access advanced conversion tracking features", |
| 6798 |
"yatra" |
| 6799 |
), |
| 6800 |
moduleName: "Facebook Pixel", |
| 6801 |
pricingUrl: "https://wpyatra.com/pricing?module=facebook-pixel", |
| 6802 |
isProActive: (_W = window.yatraAdmin) == null ? void 0 : _W.isPro, |
| 6803 |
isModuleEnabled: (_X = window.yatraAdmin) == null ? void 0 : _X.showFacebookPixelSettingsUI, |
| 6804 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 6805 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 6806 |
FormField, |
| 6807 |
{ |
| 6808 |
id: "facebook_pixel_id", |
| 6809 |
label: __("Pixel ID", "yatra"), |
| 6810 |
description: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 6811 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __( |
| 6812 |
"Your Facebook Pixel ID (e.g., 123456789012345).", |
| 6813 |
"yatra" |
| 6814 |
) }), |
| 6815 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("details", { className: "text-sm", children: [ |
| 6816 |
/* @__PURE__ */ jsxRuntimeExports.jsx("summary", { className: "cursor-pointer text-blue-600 hover:text-blue-500 dark:text-blue-400 font-medium", children: __("How to get your Pixel ID:", "yatra") }), |
| 6817 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: "mt-2 ml-4 list-decimal space-y-1 text-gray-600 dark:text-gray-400", children: [ |
| 6818 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 6819 |
"Go to Facebook Business Manager: business.facebook.com", |
| 6820 |
"yatra" |
| 6821 |
) }), |
| 6822 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Select your Business Account", "yatra") }), |
| 6823 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 6824 |
"Click 'All tools' and select 'Pixels'", |
| 6825 |
"yatra" |
| 6826 |
) }), |
| 6827 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 6828 |
"Click 'Add Pixel' if you don't have one", |
| 6829 |
"yatra" |
| 6830 |
) }), |
| 6831 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 6832 |
"Enter a Pixel name and enter your website URL", |
| 6833 |
"yatra" |
| 6834 |
) }), |
| 6835 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Click 'Create Pixel'", "yatra") }), |
| 6836 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 6837 |
"Your Pixel ID will be displayed (e.g., 123456789012345)", |
| 6838 |
"yatra" |
| 6839 |
) }), |
| 6840 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 6841 |
"Copy this Pixel ID and paste it in the field above", |
| 6842 |
"yatra" |
| 6843 |
) }) |
| 6844 |
] }) |
| 6845 |
] }), |
| 6846 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6847 |
"a", |
| 6848 |
{ |
| 6849 |
href: "https://business.facebook.com/events_manager", |
| 6850 |
target: "_blank", |
| 6851 |
rel: "noopener noreferrer", |
| 6852 |
className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline text-sm", |
| 6853 |
children: __("Open Facebook Events Manager →", "yatra") |
| 6854 |
} |
| 6855 |
) }) |
| 6856 |
] }), |
| 6857 |
children: [ |
| 6858 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [ |
| 6859 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6860 |
Input, |
| 6861 |
{ |
| 6862 |
id: "facebook_pixel_id", |
| 6863 |
value: formData.facebook_pixel_id || "", |
| 6864 |
name: "facebook_pixel_id", |
| 6865 |
onChange: handleFieldChange, |
| 6866 |
placeholder: "123456789012345" |
| 6867 |
} |
| 6868 |
) }), |
| 6869 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6870 |
Button, |
| 6871 |
{ |
| 6872 |
type: "button", |
| 6873 |
onClick: validateFacebookPixel, |
| 6874 |
disabled: !formData.facebook_pixel_id || validatingPixel, |
| 6875 |
variant: "outline", |
| 6876 |
size: "sm", |
| 6877 |
className: "whitespace-nowrap", |
| 6878 |
children: validatingPixel ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6879 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }), |
| 6880 |
__("Validating...", "yatra") |
| 6881 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6882 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-4 w-4 mr-2" }), |
| 6883 |
__("Validate", "yatra") |
| 6884 |
] }) |
| 6885 |
} |
| 6886 |
) |
| 6887 |
] }), |
| 6888 |
formData.facebook_pixel_id && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6889 |
"div", |
| 6890 |
{ |
| 6891 |
className: `mt-2 text-sm ${((__2 = (_Z = (_Y = window.yatraAdmin) == null ? void 0 : _Y.facebookPixel) == null ? void 0 : _Z.connectionStatus) == null ? void 0 : __2.pixelConnected) ? "text-green-600 dark:text-green-400" : "text-orange-600 dark:text-orange-400"}`, |
| 6892 |
children: ((_ba = (_aa = (_$ = window.yatraAdmin) == null ? void 0 : _$.facebookPixel) == null ? void 0 : _aa.connectionStatus) == null ? void 0 : _ba.pixelConnected) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6893 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "h-4 w-4 inline mr-1" }), |
| 6894 |
__("Pixel ID is valid!", "yatra") |
| 6895 |
] }) : ((_ea = (_da = (_ca = window.yatraAdmin) == null ? void 0 : _ca.facebookPixel) == null ? void 0 : _da.connectionStatus) == null ? void 0 : _ea.pixelError) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6896 |
/* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "h-4 w-4 inline mr-1" }), |
| 6897 |
(_ha = (_ga = (_fa = window.yatraAdmin) == null ? void 0 : _fa.facebookPixel) == null ? void 0 : _ga.connectionStatus) == null ? void 0 : _ha.pixelError |
| 6898 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 6899 |
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "h-4 w-4 inline mr-1" }), |
| 6900 |
__( |
| 6901 |
"Click 'Validate' to test Pixel ID.", |
| 6902 |
"yatra" |
| 6903 |
) |
| 6904 |
] }) |
| 6905 |
} |
| 6906 |
) |
| 6907 |
] |
| 6908 |
} |
| 6909 |
), |
| 6910 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-3", children: [ |
| 6911 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 6912 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6913 |
"input", |
| 6914 |
{ |
| 6915 |
type: "checkbox", |
| 6916 |
id: "fb_track_view_content", |
| 6917 |
checked: formData.fb_track_view_content ?? true, |
| 6918 |
name: "fb_track_view_content", |
| 6919 |
onChange: handleFieldChange, |
| 6920 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 6921 |
} |
| 6922 |
), |
| 6923 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6924 |
Label, |
| 6925 |
{ |
| 6926 |
htmlFor: "fb_track_view_content", |
| 6927 |
className: "text-sm cursor-pointer", |
| 6928 |
children: __("Track ViewContent", "yatra") |
| 6929 |
} |
| 6930 |
) |
| 6931 |
] }), |
| 6932 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 6933 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6934 |
"input", |
| 6935 |
{ |
| 6936 |
type: "checkbox", |
| 6937 |
id: "fb_track_initiate_checkout", |
| 6938 |
checked: formData.fb_track_initiate_checkout ?? true, |
| 6939 |
name: "fb_track_initiate_checkout", |
| 6940 |
onChange: handleFieldChange, |
| 6941 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 6942 |
} |
| 6943 |
), |
| 6944 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6945 |
Label, |
| 6946 |
{ |
| 6947 |
htmlFor: "fb_track_initiate_checkout", |
| 6948 |
className: "text-sm cursor-pointer", |
| 6949 |
children: __("Track InitiateCheckout", "yatra") |
| 6950 |
} |
| 6951 |
) |
| 6952 |
] }), |
| 6953 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 6954 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6955 |
"input", |
| 6956 |
{ |
| 6957 |
type: "checkbox", |
| 6958 |
id: "fb_track_purchase", |
| 6959 |
checked: formData.fb_track_purchase ?? true, |
| 6960 |
name: "fb_track_purchase", |
| 6961 |
onChange: handleFieldChange, |
| 6962 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 6963 |
} |
| 6964 |
), |
| 6965 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6966 |
Label, |
| 6967 |
{ |
| 6968 |
htmlFor: "fb_track_purchase", |
| 6969 |
className: "text-sm cursor-pointer", |
| 6970 |
children: __("Track Purchase", "yatra") |
| 6971 |
} |
| 6972 |
) |
| 6973 |
] }), |
| 6974 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 6975 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6976 |
"input", |
| 6977 |
{ |
| 6978 |
type: "checkbox", |
| 6979 |
id: "fb_use_conversions_api", |
| 6980 |
checked: formData.fb_use_conversions_api ?? false, |
| 6981 |
name: "fb_use_conversions_api", |
| 6982 |
onChange: handleFieldChange, |
| 6983 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 6984 |
} |
| 6985 |
), |
| 6986 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6987 |
Label, |
| 6988 |
{ |
| 6989 |
htmlFor: "fb_use_conversions_api", |
| 6990 |
className: "text-sm cursor-pointer", |
| 6991 |
children: __("Use Conversions API", "yatra") |
| 6992 |
} |
| 6993 |
) |
| 6994 |
] }) |
| 6995 |
] }), |
| 6996 |
formData.fb_use_conversions_api && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 6997 |
FormField, |
| 6998 |
{ |
| 6999 |
id: "facebook_access_token", |
| 7000 |
label: __("Access Token", "yatra"), |
| 7001 |
description: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 7002 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __( |
| 7003 |
"Required for Conversions API. Enables server-side tracking for better accuracy.", |
| 7004 |
"yatra" |
| 7005 |
) }), |
| 7006 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("details", { className: "text-sm", children: [ |
| 7007 |
/* @__PURE__ */ jsxRuntimeExports.jsx("summary", { className: "cursor-pointer text-blue-600 hover:text-blue-500 dark:text-blue-400 font-medium", children: __("How to get Access Token:", "yatra") }), |
| 7008 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: "mt-2 ml-4 list-decimal space-y-1 text-gray-600 dark:text-gray-400", children: [ |
| 7009 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7010 |
"Go to Facebook Business Manager: business.facebook.com", |
| 7011 |
"yatra" |
| 7012 |
) }), |
| 7013 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Select your Business Account", "yatra") }), |
| 7014 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7015 |
"Click 'All tools' and select 'Events Manager'", |
| 7016 |
"yatra" |
| 7017 |
) }), |
| 7018 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7019 |
"Find your Pixel ID in the data sources list (it should match the Pixel ID you entered above)", |
| 7020 |
"yatra" |
| 7021 |
) }), |
| 7022 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7023 |
"Click on your Pixel name to open its settings", |
| 7024 |
"yatra" |
| 7025 |
) }), |
| 7026 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7027 |
"Click 'Settings' (gear icon ⚙️) in the top right", |
| 7028 |
"yatra" |
| 7029 |
) }), |
| 7030 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7031 |
"Scroll down to 'Conversions API' section", |
| 7032 |
"yatra" |
| 7033 |
) }), |
| 7034 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Click 'Generate access token'", "yatra") }), |
| 7035 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7036 |
"Choose permissions: 'ads_management' and 'business_management'", |
| 7037 |
"yatra" |
| 7038 |
) }), |
| 7039 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Click 'Generate token'", "yatra") }), |
| 7040 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7041 |
"Copy the generated access token", |
| 7042 |
"yatra" |
| 7043 |
) }), |
| 7044 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __("Paste it in the field above", "yatra") }) |
| 7045 |
] }), |
| 7046 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-3 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-blue-800 dark:text-blue-300", children: [ |
| 7047 |
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: __("💡 Tip:", "yatra") }), |
| 7048 |
" ", |
| 7049 |
__( |
| 7050 |
"If you have multiple Pixels, look for the one that matches the Pixel ID you entered above. The Pixel ID is displayed next to each Pixel name in the list.", |
| 7051 |
"yatra" |
| 7052 |
) |
| 7053 |
] }) }), |
| 7054 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 p-2 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-yellow-800 dark:text-yellow-300", children: __( |
| 7055 |
"⚠️ Keep your access token secure and never share it publicly.", |
| 7056 |
"yatra" |
| 7057 |
) }) }) |
| 7058 |
] }), |
| 7059 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7060 |
"a", |
| 7061 |
{ |
| 7062 |
href: "https://business.facebook.com/settings/conversions-api", |
| 7063 |
target: "_blank", |
| 7064 |
rel: "noopener noreferrer", |
| 7065 |
className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline text-sm", |
| 7066 |
children: __("Open Conversions API Settings →", "yatra") |
| 7067 |
} |
| 7068 |
) }) |
| 7069 |
] }), |
| 7070 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 7071 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [ |
| 7072 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 relative", children: [ |
| 7073 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7074 |
Input, |
| 7075 |
{ |
| 7076 |
id: "facebook_access_token", |
| 7077 |
type: showFacebookToken ? "text" : "password", |
| 7078 |
value: formData.facebook_access_token || "", |
| 7079 |
name: "facebook_access_token", |
| 7080 |
onChange: handleFieldChange, |
| 7081 |
placeholder: "EAAC...", |
| 7082 |
className: "pr-10" |
| 7083 |
} |
| 7084 |
), |
| 7085 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7086 |
"button", |
| 7087 |
{ |
| 7088 |
type: "button", |
| 7089 |
onClick: () => setShowFacebookToken(!showFacebookToken), |
| 7090 |
className: "absolute inset-y-0 right-0 pr-3 flex items-center", |
| 7091 |
tabIndex: -1, |
| 7092 |
children: showFacebookToken ? /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4 text-gray-400 hover:text-gray-600" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4 text-gray-400 hover:text-gray-600" }) |
| 7093 |
} |
| 7094 |
) |
| 7095 |
] }), |
| 7096 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7097 |
Button, |
| 7098 |
{ |
| 7099 |
type: "button", |
| 7100 |
onClick: validateFacebookToken, |
| 7101 |
disabled: !formData.facebook_access_token || validatingToken, |
| 7102 |
variant: "outline", |
| 7103 |
size: "sm", |
| 7104 |
className: "whitespace-nowrap", |
| 7105 |
children: validatingToken ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 7106 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }), |
| 7107 |
__("Validating...", "yatra") |
| 7108 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 7109 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-4 w-4 mr-2" }), |
| 7110 |
__("Validate", "yatra") |
| 7111 |
] }) |
| 7112 |
} |
| 7113 |
) |
| 7114 |
] }), |
| 7115 |
formData.facebook_access_token && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7116 |
"div", |
| 7117 |
{ |
| 7118 |
className: `text-sm ${((_ka = (_ja = (_ia = window.yatraAdmin) == null ? void 0 : _ia.facebookPixel) == null ? void 0 : _ja.connectionStatus) == null ? void 0 : _ka.tokenConnected) ? "text-green-600 dark:text-green-400" : "text-orange-600 dark:text-orange-400"}`, |
| 7119 |
children: ((_na = (_ma = (_la = window.yatraAdmin) == null ? void 0 : _la.facebookPixel) == null ? void 0 : _ma.connectionStatus) == null ? void 0 : _na.tokenConnected) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 7120 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "h-4 w-4 inline mr-1" }), |
| 7121 |
__("Access token is valid!", "yatra") |
| 7122 |
] }) : ((_qa = (_pa = (_oa = window.yatraAdmin) == null ? void 0 : _oa.facebookPixel) == null ? void 0 : _pa.connectionStatus) == null ? void 0 : _qa.tokenError) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 7123 |
/* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "h-4 w-4 inline mr-1" }), |
| 7124 |
(_ta = (_sa = (_ra = window.yatraAdmin) == null ? void 0 : _ra.facebookPixel) == null ? void 0 : _sa.connectionStatus) == null ? void 0 : _ta.tokenError |
| 7125 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 7126 |
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertCircle, { className: "h-4 w-4 inline mr-1" }), |
| 7127 |
__( |
| 7128 |
"Click 'Validate' to test access token.", |
| 7129 |
"yatra" |
| 7130 |
) |
| 7131 |
] }) |
| 7132 |
} |
| 7133 |
) |
| 7134 |
] }) |
| 7135 |
} |
| 7136 |
) |
| 7137 |
] }) |
| 7138 |
} |
| 7139 |
), |
| 7140 |
((_va = (_ua = window.yatraAdmin) == null ? void 0 : _ua.facebookPixel) == null ? void 0 : _va.pixelId) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 7141 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7142 |
"svg", |
| 7143 |
{ |
| 7144 |
className: "w-4 h-4 text-blue-600 dark:text-blue-400", |
| 7145 |
fill: "none", |
| 7146 |
stroke: "currentColor", |
| 7147 |
viewBox: "0 0 24 24", |
| 7148 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7149 |
"path", |
| 7150 |
{ |
| 7151 |
strokeLinecap: "round", |
| 7152 |
strokeLinejoin: "round", |
| 7153 |
strokeWidth: 2, |
| 7154 |
d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" |
| 7155 |
} |
| 7156 |
) |
| 7157 |
} |
| 7158 |
), |
| 7159 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm", children: [ |
| 7160 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-blue-800 dark:text-blue-300 font-medium", children: __("Facebook Pixel Monitoring:", "yatra") }), |
| 7161 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-blue-700 dark:text-blue-400 ml-1", children: [ |
| 7162 |
__( |
| 7163 |
"View event statistics and activity in the ", |
| 7164 |
"yatra" |
| 7165 |
), |
| 7166 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7167 |
"a", |
| 7168 |
{ |
| 7169 |
href: `${((_wa = window.yatraAdmin) == null ? void 0 : _wa.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=reports`, |
| 7170 |
className: "underline hover:text-blue-600 dark:hover:text-blue-300 font-medium", |
| 7171 |
children: __("Reports page", "yatra") |
| 7172 |
} |
| 7173 |
), |
| 7174 |
__(" → Facebook Pixel tab.", "yatra") |
| 7175 |
] }) |
| 7176 |
] }) |
| 7177 |
] }) }) |
| 7178 |
] }) |
| 7179 |
] }), |
| 7180 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7181 |
SectionDivider, |
| 7182 |
{ |
| 7183 |
title: __("Google Analytics 4 Enhanced", "yatra") |
| 7184 |
} |
| 7185 |
), |
| 7186 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "overflow-hidden border-gray-200 dark:border-gray-700 shadow-sm", children: [ |
| 7187 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { className: "flex flex-row flex-wrap items-start gap-3 justify-between border-b border-gray-100 dark:border-gray-800 bg-gray-50/80 dark:bg-gray-900/40 pb-4", children: [ |
| 7188 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-lg flex items-center gap-2.5 text-gray-900 dark:text-white", children: [ |
| 7189 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex h-9 w-9 items-center justify-center rounded-lg bg-orange-500/10 dark:bg-orange-500/15", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7190 |
BarChart3, |
| 7191 |
{ |
| 7192 |
className: "w-5 h-5 text-orange-600 dark:text-orange-400", |
| 7193 |
"aria-hidden": true |
| 7194 |
} |
| 7195 |
) }), |
| 7196 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex flex-wrap items-center gap-2 leading-tight", children: [ |
| 7197 |
__("Google Analytics 4 Enhanced", "yatra"), |
| 7198 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ProBadge, { isProActive: (_xa = window.yatraAdmin) == null ? void 0 : _xa.isPro }) |
| 7199 |
] }) |
| 7200 |
] }), |
| 7201 |
(() => { |
| 7202 |
var _a3, _b3, _c2; |
| 7203 |
const ga4HasId = Boolean((_a3 = formData.ga4_measurement_id) == null ? void 0 : _a3.trim()); |
| 7204 |
const ga4Connected = ga4HasId || Boolean( |
| 7205 |
(_c2 = (_b3 = window.yatraAdmin) == null ? void 0 : _b3.googleAnalytics) == null ? void 0 : _c2.connected |
| 7206 |
); |
| 7207 |
return ga4Connected ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "inline-flex items-center gap-1.5 rounded-full border border-green-200 bg-green-50 px-2.5 py-1 text-xs font-medium text-green-800 dark:border-green-800 dark:bg-green-950/40 dark:text-green-300", children: [ |
| 7208 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CheckCircle, { className: "w-3.5 h-3.5 shrink-0" }), |
| 7209 |
__("Measurement ID set", "yatra") |
| 7210 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "inline-flex items-center gap-1.5 rounded-full border border-gray-200 bg-gray-100 px-2.5 py-1 text-xs font-medium text-gray-600 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400", children: [ |
| 7211 |
/* @__PURE__ */ jsxRuntimeExports.jsx(XCircle, { className: "w-3.5 h-3.5 shrink-0" }), |
| 7212 |
__("Not configured", "yatra") |
| 7213 |
] }); |
| 7214 |
})() |
| 7215 |
] }), |
| 7216 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-6 pt-6", children: [ |
| 7217 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm leading-relaxed text-gray-600 dark:text-gray-300", children: __( |
| 7218 |
"Connect GA4 for ecommerce events (view item, add to cart, checkout, purchase). Optional Measurement Protocol sends verified server-side events for more reliable attribution.", |
| 7219 |
"yatra" |
| 7220 |
) }), |
| 7221 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7222 |
ProFeature, |
| 7223 |
{ |
| 7224 |
title: __("Google Analytics 4 Enhanced", "yatra"), |
| 7225 |
description: __( |
| 7226 |
"access enhanced e-commerce tracking features", |
| 7227 |
"yatra" |
| 7228 |
), |
| 7229 |
moduleName: "Google Analytics", |
| 7230 |
pricingUrl: "https://wpyatra.com/pricing?module=google-analytics", |
| 7231 |
isProActive: (_ya = window.yatraAdmin) == null ? void 0 : _ya.isPro, |
| 7232 |
isModuleEnabled: (_za = window.yatraAdmin) == null ? void 0 : _za.showGoogleAnalyticsSettingsUI, |
| 7233 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-8", children: [ |
| 7234 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-950/30 sm:p-5", children: [ |
| 7235 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4", children: [ |
| 7236 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: __("Connection", "yatra") }), |
| 7237 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-xs leading-relaxed text-gray-500 dark:text-gray-400", children: __( |
| 7238 |
"Use your GA4 web data stream Measurement ID (format G-XXXXXXXXXX). Find it under Admin → Data streams → your stream.", |
| 7239 |
"yatra" |
| 7240 |
) }) |
| 7241 |
] }), |
| 7242 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7243 |
FormField, |
| 7244 |
{ |
| 7245 |
id: "ga4_measurement_id", |
| 7246 |
label: __("Measurement ID", "yatra"), |
| 7247 |
description: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 7248 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __( |
| 7249 |
"Your GA4 web data stream Measurement ID (format G-XXXXXXXXXX). The Validate button checks the format only — confirm the stream is live in your GA4 Admin.", |
| 7250 |
"yatra" |
| 7251 |
) }), |
| 7252 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("details", { className: "text-sm", children: [ |
| 7253 |
/* @__PURE__ */ jsxRuntimeExports.jsx("summary", { className: "cursor-pointer font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400", children: __("How to get your Measurement ID:", "yatra") }), |
| 7254 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: "mt-2 ml-4 list-decimal space-y-1 text-gray-600 dark:text-gray-400", children: [ |
| 7255 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7256 |
"Go to Google Analytics: analytics.google.com", |
| 7257 |
"yatra" |
| 7258 |
) }), |
| 7259 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7260 |
"Sign in and select the property you want to track this site with (or create one: Admin → Create → Property → choose your business details).", |
| 7261 |
"yatra" |
| 7262 |
) }), |
| 7263 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7264 |
"In the bottom-left corner click the gear icon (Admin).", |
| 7265 |
"yatra" |
| 7266 |
) }), |
| 7267 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7268 |
"In the Property column click Data Streams.", |
| 7269 |
"yatra" |
| 7270 |
) }), |
| 7271 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7272 |
"Click your existing Web stream — or click Add stream → Web, enter your site URL and a stream name, then Create stream.", |
| 7273 |
"yatra" |
| 7274 |
) }), |
| 7275 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7276 |
"On the stream details panel, copy the Measurement ID at the top right (format G-XXXXXXXXXX).", |
| 7277 |
"yatra" |
| 7278 |
) }), |
| 7279 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7280 |
"Paste it in the field above and click Validate.", |
| 7281 |
"yatra" |
| 7282 |
) }) |
| 7283 |
] }) |
| 7284 |
] }), |
| 7285 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7286 |
"a", |
| 7287 |
{ |
| 7288 |
href: "https://analytics.google.com/analytics/web/", |
| 7289 |
target: "_blank", |
| 7290 |
rel: "noopener noreferrer", |
| 7291 |
className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline text-sm", |
| 7292 |
children: __("Open Google Analytics →", "yatra") |
| 7293 |
} |
| 7294 |
) }) |
| 7295 |
] }), |
| 7296 |
actionButton: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7297 |
Button, |
| 7298 |
{ |
| 7299 |
type: "button", |
| 7300 |
variant: "outline", |
| 7301 |
size: "sm", |
| 7302 |
onClick: () => validateMeasurementId(), |
| 7303 |
disabled: !((_Aa = formData.ga4_measurement_id) == null ? void 0 : _Aa.trim()) || validatingMeasurementId, |
| 7304 |
className: "shrink-0", |
| 7305 |
children: validatingMeasurementId ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 7306 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), |
| 7307 |
__("Validating...", "yatra") |
| 7308 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 7309 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "mr-2 h-4 w-4" }), |
| 7310 |
__("Validate", "yatra") |
| 7311 |
] }) |
| 7312 |
} |
| 7313 |
), |
| 7314 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7315 |
Input, |
| 7316 |
{ |
| 7317 |
id: "ga4_measurement_id", |
| 7318 |
value: formData.ga4_measurement_id || "", |
| 7319 |
name: "ga4_measurement_id", |
| 7320 |
onChange: handleFieldChange, |
| 7321 |
placeholder: "G-XXXXXXXXXX", |
| 7322 |
className: "font-mono text-sm", |
| 7323 |
spellCheck: false, |
| 7324 |
autoComplete: "off" |
| 7325 |
} |
| 7326 |
) |
| 7327 |
} |
| 7328 |
) |
| 7329 |
] }), |
| 7330 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-950/30 sm:p-5", children: [ |
| 7331 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4", children: [ |
| 7332 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: __("Events", "yatra") }), |
| 7333 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-xs leading-relaxed text-gray-500 dark:text-gray-400", children: __( |
| 7334 |
"Choose which standard ecommerce events Yatra should emit to GA4 on the storefront and booking flow.", |
| 7335 |
"yatra" |
| 7336 |
) }) |
| 7337 |
] }), |
| 7338 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 gap-3 md:grid-cols-2", children: [ |
| 7339 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-gray-100 bg-gray-50/80 p-3 dark:border-gray-700 dark:bg-gray-900/50", children: [ |
| 7340 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7341 |
"input", |
| 7342 |
{ |
| 7343 |
type: "checkbox", |
| 7344 |
id: "ga4_track_view_item", |
| 7345 |
checked: formData.ga4_track_view_item ?? true, |
| 7346 |
name: "ga4_track_view_item", |
| 7347 |
onChange: handleFieldChange, |
| 7348 |
className: "mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 7349 |
} |
| 7350 |
), |
| 7351 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [ |
| 7352 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7353 |
Label, |
| 7354 |
{ |
| 7355 |
htmlFor: "ga4_track_view_item", |
| 7356 |
className: "cursor-pointer text-sm font-medium text-gray-900 dark:text-white", |
| 7357 |
children: __("View item", "yatra") |
| 7358 |
} |
| 7359 |
), |
| 7360 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: __( |
| 7361 |
"Trip detail pages (recommended for remarketing).", |
| 7362 |
"yatra" |
| 7363 |
) }) |
| 7364 |
] }) |
| 7365 |
] }), |
| 7366 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-gray-100 bg-gray-50/80 p-3 dark:border-gray-700 dark:bg-gray-900/50", children: [ |
| 7367 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7368 |
"input", |
| 7369 |
{ |
| 7370 |
type: "checkbox", |
| 7371 |
id: "ga4_track_add_to_cart", |
| 7372 |
checked: formData.ga4_track_add_to_cart ?? true, |
| 7373 |
name: "ga4_track_add_to_cart", |
| 7374 |
onChange: handleFieldChange, |
| 7375 |
className: "mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 7376 |
} |
| 7377 |
), |
| 7378 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [ |
| 7379 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7380 |
Label, |
| 7381 |
{ |
| 7382 |
htmlFor: "ga4_track_add_to_cart", |
| 7383 |
className: "cursor-pointer text-sm font-medium text-gray-900 dark:text-white", |
| 7384 |
children: __("Add to cart", "yatra") |
| 7385 |
} |
| 7386 |
), |
| 7387 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: __( |
| 7388 |
"When a trip is added to the booking session / checkout.", |
| 7389 |
"yatra" |
| 7390 |
) }) |
| 7391 |
] }) |
| 7392 |
] }), |
| 7393 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-gray-100 bg-gray-50/80 p-3 dark:border-gray-700 dark:bg-gray-900/50", children: [ |
| 7394 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7395 |
"input", |
| 7396 |
{ |
| 7397 |
type: "checkbox", |
| 7398 |
id: "ga4_track_begin_checkout", |
| 7399 |
checked: formData.ga4_track_begin_checkout ?? true, |
| 7400 |
name: "ga4_track_begin_checkout", |
| 7401 |
onChange: handleFieldChange, |
| 7402 |
className: "mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 7403 |
} |
| 7404 |
), |
| 7405 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [ |
| 7406 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7407 |
Label, |
| 7408 |
{ |
| 7409 |
htmlFor: "ga4_track_begin_checkout", |
| 7410 |
className: "cursor-pointer text-sm font-medium text-gray-900 dark:text-white", |
| 7411 |
children: __("Begin checkout", "yatra") |
| 7412 |
} |
| 7413 |
), |
| 7414 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: __( |
| 7415 |
"When a booking is created (checkout started).", |
| 7416 |
"yatra" |
| 7417 |
) }) |
| 7418 |
] }) |
| 7419 |
] }), |
| 7420 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-gray-100 bg-gray-50/80 p-3 dark:border-gray-700 dark:bg-gray-900/50", children: [ |
| 7421 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7422 |
"input", |
| 7423 |
{ |
| 7424 |
type: "checkbox", |
| 7425 |
id: "ga4_track_purchase", |
| 7426 |
checked: formData.ga4_track_purchase ?? true, |
| 7427 |
name: "ga4_track_purchase", |
| 7428 |
onChange: handleFieldChange, |
| 7429 |
className: "mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 7430 |
} |
| 7431 |
), |
| 7432 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [ |
| 7433 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7434 |
Label, |
| 7435 |
{ |
| 7436 |
htmlFor: "ga4_track_purchase", |
| 7437 |
className: "cursor-pointer text-sm font-medium text-gray-900 dark:text-white", |
| 7438 |
children: __("Purchase", "yatra") |
| 7439 |
} |
| 7440 |
), |
| 7441 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: __( |
| 7442 |
"When payment completes (and on confirmation page).", |
| 7443 |
"yatra" |
| 7444 |
) }) |
| 7445 |
] }) |
| 7446 |
] }) |
| 7447 |
] }) |
| 7448 |
] }), |
| 7449 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-950/30 sm:p-5", children: [ |
| 7450 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4", children: [ |
| 7451 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: __("Server-side (Measurement Protocol)", "yatra") }), |
| 7452 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-xs leading-relaxed text-gray-500 dark:text-gray-400", children: __( |
| 7453 |
"Send duplicate events from your server with an API secret—useful when ad blockers affect the browser tag or for reconciliation.", |
| 7454 |
"yatra" |
| 7455 |
) }) |
| 7456 |
] }), |
| 7457 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-gray-100 bg-gray-50/80 p-3 dark:border-gray-700 dark:bg-gray-900/50", children: [ |
| 7458 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7459 |
"input", |
| 7460 |
{ |
| 7461 |
type: "checkbox", |
| 7462 |
id: "ga4_use_measurement_protocol", |
| 7463 |
checked: formData.ga4_use_measurement_protocol ?? false, |
| 7464 |
name: "ga4_use_measurement_protocol", |
| 7465 |
onChange: handleFieldChange, |
| 7466 |
className: "mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 7467 |
} |
| 7468 |
), |
| 7469 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [ |
| 7470 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7471 |
Label, |
| 7472 |
{ |
| 7473 |
htmlFor: "ga4_use_measurement_protocol", |
| 7474 |
className: "cursor-pointer text-sm font-medium text-gray-900 dark:text-white", |
| 7475 |
children: __("Enable Measurement Protocol", "yatra") |
| 7476 |
} |
| 7477 |
), |
| 7478 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: __( |
| 7479 |
"Requires an API secret from the same GA4 data stream.", |
| 7480 |
"yatra" |
| 7481 |
) }) |
| 7482 |
] }) |
| 7483 |
] }), |
| 7484 |
formData.ga4_use_measurement_protocol && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 space-y-4 border-t border-gray-100 pt-4 dark:border-gray-800", children: [ |
| 7485 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-amber-100 bg-amber-50/60 p-3 dark:border-amber-900/40 dark:bg-amber-950/20", children: [ |
| 7486 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7487 |
"input", |
| 7488 |
{ |
| 7489 |
type: "checkbox", |
| 7490 |
id: "ga4_debug_mode", |
| 7491 |
checked: formData.ga4_debug_mode ?? false, |
| 7492 |
name: "ga4_debug_mode", |
| 7493 |
onChange: handleFieldChange, |
| 7494 |
className: "mt-0.5 h-4 w-4 shrink-0 rounded border-amber-300 text-amber-600 focus:ring-amber-500" |
| 7495 |
} |
| 7496 |
), |
| 7497 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [ |
| 7498 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7499 |
Label, |
| 7500 |
{ |
| 7501 |
htmlFor: "ga4_debug_mode", |
| 7502 |
className: "cursor-pointer text-sm font-medium text-amber-950 dark:text-amber-100", |
| 7503 |
children: __( |
| 7504 |
"Validation mode (debug endpoint)", |
| 7505 |
"yatra" |
| 7506 |
) |
| 7507 |
} |
| 7508 |
), |
| 7509 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-amber-900/90 dark:text-amber-200/90", children: __( |
| 7510 |
"Send Measurement Protocol hits to Google’s validation URL for troubleshooting. Events won’t appear in standard reports.", |
| 7511 |
"yatra" |
| 7512 |
) }) |
| 7513 |
] }) |
| 7514 |
] }), |
| 7515 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7516 |
FormField, |
| 7517 |
{ |
| 7518 |
id: "ga4_api_secret", |
| 7519 |
label: __( |
| 7520 |
"Measurement Protocol API secret", |
| 7521 |
"yatra" |
| 7522 |
), |
| 7523 |
description: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 7524 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: __( |
| 7525 |
"Treat this like a password — anyone with it can send fake events to your GA4 property. Restrict who can view Yatra settings.", |
| 7526 |
"yatra" |
| 7527 |
) }), |
| 7528 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("details", { className: "text-sm", children: [ |
| 7529 |
/* @__PURE__ */ jsxRuntimeExports.jsx("summary", { className: "cursor-pointer font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400", children: __("How to get your API secret:", "yatra") }), |
| 7530 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: "mt-2 ml-4 list-decimal space-y-1 text-gray-600 dark:text-gray-400", children: [ |
| 7531 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7532 |
"Go to Google Analytics: analytics.google.com", |
| 7533 |
"yatra" |
| 7534 |
) }), |
| 7535 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7536 |
"Sign in and select the same property you used for the Measurement ID above.", |
| 7537 |
"yatra" |
| 7538 |
) }), |
| 7539 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7540 |
"Click the gear icon (Admin) in the bottom-left corner.", |
| 7541 |
"yatra" |
| 7542 |
) }), |
| 7543 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7544 |
"In the Property column click Data Streams, then click your Web stream.", |
| 7545 |
"yatra" |
| 7546 |
) }), |
| 7547 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7548 |
"Scroll to Events → Measurement Protocol API secrets → Create.", |
| 7549 |
"yatra" |
| 7550 |
) }), |
| 7551 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7552 |
"Give the secret a nickname (e.g. “Yatra server”) and click Create.", |
| 7553 |
"yatra" |
| 7554 |
) }), |
| 7555 |
/* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: __( |
| 7556 |
"Copy the Secret value (not the nickname) and paste it in the field above.", |
| 7557 |
"yatra" |
| 7558 |
) }) |
| 7559 |
] }) |
| 7560 |
] }), |
| 7561 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7562 |
"a", |
| 7563 |
{ |
| 7564 |
href: "https://analytics.google.com/analytics/web/", |
| 7565 |
target: "_blank", |
| 7566 |
rel: "noopener noreferrer", |
| 7567 |
className: "text-blue-600 hover:text-blue-500 dark:text-blue-400 underline text-sm", |
| 7568 |
children: __("Open Google Analytics →", "yatra") |
| 7569 |
} |
| 7570 |
) }) |
| 7571 |
] }), |
| 7572 |
actionButton: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7573 |
Button, |
| 7574 |
{ |
| 7575 |
type: "button", |
| 7576 |
variant: "outline", |
| 7577 |
size: "sm", |
| 7578 |
onClick: () => validateApiSecret(), |
| 7579 |
disabled: !formData.ga4_api_secret || !formData.ga4_measurement_id || validatingApiSecret, |
| 7580 |
className: "shrink-0", |
| 7581 |
children: validatingApiSecret ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 7582 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), |
| 7583 |
__("Validating...", "yatra") |
| 7584 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 7585 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "mr-2 h-4 w-4" }), |
| 7586 |
__("Validate", "yatra") |
| 7587 |
] }) |
| 7588 |
} |
| 7589 |
), |
| 7590 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [ |
| 7591 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7592 |
Input, |
| 7593 |
{ |
| 7594 |
id: "ga4_api_secret", |
| 7595 |
type: showGa4ApiSecret ? "text" : "password", |
| 7596 |
value: formData.ga4_api_secret || "", |
| 7597 |
name: "ga4_api_secret", |
| 7598 |
onChange: handleFieldChange, |
| 7599 |
placeholder: __( |
| 7600 |
"Paste secret from GA4", |
| 7601 |
"yatra" |
| 7602 |
), |
| 7603 |
className: "pr-10 font-mono text-sm", |
| 7604 |
spellCheck: false, |
| 7605 |
autoComplete: "new-password" |
| 7606 |
} |
| 7607 |
), |
| 7608 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7609 |
"button", |
| 7610 |
{ |
| 7611 |
type: "button", |
| 7612 |
onClick: () => setShowGa4ApiSecret(!showGa4ApiSecret), |
| 7613 |
className: "absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300", |
| 7614 |
tabIndex: -1, |
| 7615 |
"aria-label": showGa4ApiSecret ? __("Hide secret", "yatra") : __("Show secret", "yatra"), |
| 7616 |
children: showGa4ApiSecret ? /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" }) |
| 7617 |
} |
| 7618 |
) |
| 7619 |
] }) |
| 7620 |
} |
| 7621 |
) |
| 7622 |
] }) |
| 7623 |
] }) |
| 7624 |
] }) |
| 7625 |
} |
| 7626 |
), |
| 7627 |
(Boolean((_Ba = formData.ga4_measurement_id) == null ? void 0 : _Ba.trim()) || Boolean( |
| 7628 |
(_Da = (_Ca = window.yatraAdmin) == null ? void 0 : _Ca.googleAnalytics) == null ? void 0 : _Da.measurementId |
| 7629 |
)) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 rounded-lg border border-blue-200 bg-blue-50/90 p-4 dark:border-blue-800 dark:bg-blue-950/30", children: [ |
| 7630 |
/* @__PURE__ */ jsxRuntimeExports.jsx(BarChart3, { className: "mt-0.5 h-5 w-5 shrink-0 text-blue-600 dark:text-blue-400" }), |
| 7631 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 text-sm leading-relaxed", children: [ |
| 7632 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-medium text-blue-900 dark:text-blue-100", children: __("Reports & event log", "yatra") }), |
| 7633 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1 text-blue-800/90 dark:text-blue-200/90", children: [ |
| 7634 |
__( |
| 7635 |
"Review connection status and recent Measurement Protocol activity under", |
| 7636 |
"yatra" |
| 7637 |
), |
| 7638 |
" ", |
| 7639 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7640 |
"a", |
| 7641 |
{ |
| 7642 |
href: `${((_Ea = window.yatraAdmin) == null ? void 0 : _Ea.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=reports`, |
| 7643 |
className: "font-medium underline decoration-blue-600/40 underline-offset-2 hover:text-blue-950 dark:hover:text-white", |
| 7644 |
children: __("Reports", "yatra") |
| 7645 |
} |
| 7646 |
), |
| 7647 |
" → ", |
| 7648 |
__("Google Analytics 4.", "yatra") |
| 7649 |
] }) |
| 7650 |
] }) |
| 7651 |
] }) |
| 7652 |
] }) |
| 7653 |
] }), |
| 7654 |
/* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("Maps", "yatra") }), |
| 7655 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-3", children: [ |
| 7656 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-6 h-6 text-blue-600 dark:text-blue-400 mt-0.5", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7657 |
"path", |
| 7658 |
{ |
| 7659 |
strokeLinecap: "round", |
| 7660 |
strokeLinejoin: "round", |
| 7661 |
strokeWidth: 2, |
| 7662 |
d: "M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7" |
| 7663 |
} |
| 7664 |
) }) }), |
| 7665 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 7666 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-medium text-blue-900 dark:text-blue-100 mb-1", children: __("OpenStreetMap Integration", "yatra") }), |
| 7667 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-blue-700 dark:text-blue-300", children: __( |
| 7668 |
"Maps are powered by OpenStreetMap - a free, open-source mapping service. No API key required! Maps will automatically display trip starting locations with custom markers.", |
| 7669 |
"yatra" |
| 7670 |
) }) |
| 7671 |
] }) |
| 7672 |
] }) }) }), |
| 7673 |
/* @__PURE__ */ jsxRuntimeExports.jsx(SectionDivider, { title: __("reCAPTCHA Settings", "yatra") }), |
| 7674 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 7675 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 7676 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7677 |
"input", |
| 7678 |
{ |
| 7679 |
type: "checkbox", |
| 7680 |
id: "recaptcha_enabled", |
| 7681 |
checked: formData.recaptcha_enabled, |
| 7682 |
name: "recaptcha_enabled", |
| 7683 |
onChange: handleFieldChange, |
| 7684 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 7685 |
} |
| 7686 |
), |
| 7687 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 7688 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7689 |
Label, |
| 7690 |
{ |
| 7691 |
htmlFor: "recaptcha_enabled", |
| 7692 |
className: "font-medium cursor-pointer", |
| 7693 |
children: __("Enable reCAPTCHA", "yatra") |
| 7694 |
} |
| 7695 |
), |
| 7696 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __("Protect forms from spam and bots", "yatra") }) |
| 7697 |
] }) |
| 7698 |
] }), |
| 7699 |
formData.recaptcha_enabled && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 7700 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7701 |
FormField, |
| 7702 |
{ |
| 7703 |
id: "recaptcha_site_key", |
| 7704 |
label: __("Site Key", "yatra"), |
| 7705 |
description: __("Your reCAPTCHA site key", "yatra"), |
| 7706 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7707 |
Input, |
| 7708 |
{ |
| 7709 |
id: "recaptcha_site_key", |
| 7710 |
value: formData.recaptcha_site_key, |
| 7711 |
name: "recaptcha_site_key", |
| 7712 |
onChange: handleFieldChange, |
| 7713 |
placeholder: __("Enter site key", "yatra") |
| 7714 |
} |
| 7715 |
) |
| 7716 |
} |
| 7717 |
), |
| 7718 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7719 |
FormField, |
| 7720 |
{ |
| 7721 |
id: "recaptcha_secret_key", |
| 7722 |
label: __("Secret Key", "yatra"), |
| 7723 |
description: __( |
| 7724 |
"Your reCAPTCHA secret key (keep this secure)", |
| 7725 |
"yatra" |
| 7726 |
), |
| 7727 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7728 |
Input, |
| 7729 |
{ |
| 7730 |
id: "recaptcha_secret_key", |
| 7731 |
type: "password", |
| 7732 |
value: formData.recaptcha_secret_key, |
| 7733 |
name: "recaptcha_secret_key", |
| 7734 |
onChange: handleFieldChange, |
| 7735 |
placeholder: __("Enter secret key", "yatra") |
| 7736 |
} |
| 7737 |
) |
| 7738 |
} |
| 7739 |
), |
| 7740 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: __( |
| 7741 |
"Uses reCAPTCHA v3 (invisible, score-based). Create v3 keys at google.com/recaptcha and paste them above.", |
| 7742 |
"yatra" |
| 7743 |
) }), |
| 7744 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7745 |
FormField, |
| 7746 |
{ |
| 7747 |
id: "recaptcha_score_threshold", |
| 7748 |
label: __("Score Threshold", "yatra"), |
| 7749 |
description: __( |
| 7750 |
"Minimum v3 score (0.0–1.0) to accept a submission. Lower is more lenient, higher is stricter. Default 0.5.", |
| 7751 |
"yatra" |
| 7752 |
), |
| 7753 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7754 |
Input, |
| 7755 |
{ |
| 7756 |
id: "recaptcha_score_threshold", |
| 7757 |
type: "number", |
| 7758 |
min: "0", |
| 7759 |
max: "1", |
| 7760 |
step: "0.1", |
| 7761 |
value: String(formData.recaptcha_score_threshold ?? 0.5), |
| 7762 |
name: "recaptcha_score_threshold", |
| 7763 |
onChange: (e) => setFormData( |
| 7764 |
(prev) => prev ? { |
| 7765 |
...prev, |
| 7766 |
recaptcha_score_threshold: parseFloat( |
| 7767 |
e.target.value |
| 7768 |
) |
| 7769 |
} : prev |
| 7770 |
) |
| 7771 |
} |
| 7772 |
) |
| 7773 |
} |
| 7774 |
), |
| 7775 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pt-2", children: [ |
| 7776 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "font-medium", children: __("Protect these forms", "yatra") }), |
| 7777 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5 mb-2", children: __( |
| 7778 |
"Choose which forms reCAPTCHA should verify. Booking protection is off by default to avoid blocking a legitimate payment on a low score.", |
| 7779 |
"yatra" |
| 7780 |
) }), |
| 7781 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: [ |
| 7782 |
{ |
| 7783 |
key: "recaptcha_protect_enquiry", |
| 7784 |
label: __("Enquiry form", "yatra") |
| 7785 |
}, |
| 7786 |
{ |
| 7787 |
key: "recaptcha_protect_booking", |
| 7788 |
label: __("Booking / checkout form", "yatra") |
| 7789 |
}, |
| 7790 |
{ |
| 7791 |
key: "recaptcha_protect_registration", |
| 7792 |
label: __("Customer registration", "yatra") |
| 7793 |
} |
| 7794 |
].map((f) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 7795 |
"label", |
| 7796 |
{ |
| 7797 |
className: "flex items-center gap-2 cursor-pointer", |
| 7798 |
children: [ |
| 7799 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7800 |
"input", |
| 7801 |
{ |
| 7802 |
type: "checkbox", |
| 7803 |
id: f.key, |
| 7804 |
name: f.key, |
| 7805 |
checked: Boolean( |
| 7806 |
formData[f.key] |
| 7807 |
), |
| 7808 |
onChange: handleFieldChange, |
| 7809 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 7810 |
} |
| 7811 |
), |
| 7812 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm", children: f.label }) |
| 7813 |
] |
| 7814 |
}, |
| 7815 |
f.key |
| 7816 |
)) }) |
| 7817 |
] }) |
| 7818 |
] }) |
| 7819 |
] }) |
| 7820 |
] }); |
| 7821 |
case "permalink": { |
| 7822 |
const listingSite = (((_Fa = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _Fa.siteUrl) || "").replace(/\/$/, ""); |
| 7823 |
const listingHref = (segment) => buildYatraListingPublicUrl(segment, listingSite || void 0); |
| 7824 |
const bookingConfirmationPreviewUrl = (bookingBase) => { |
| 7825 |
const bb = bookingBase.replace(/^\/|\/$/g, ""); |
| 7826 |
const site = listingSite || ""; |
| 7827 |
if (isWordPressPlainPermalink()) { |
| 7828 |
return site ? `${site}/?yatra_booking_confirmation=` : "/?yatra_booking_confirmation="; |
| 7829 |
} |
| 7830 |
return site ? `${site}/${bb}/confirmation/` : `/${bb}/confirmation/`; |
| 7831 |
}; |
| 7832 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 7833 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 7834 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Permalink Settings", "yatra") }), |
| 7835 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mb-6", children: __( |
| 7836 |
"Configure URL slugs for your Yatra content types. These settings control how your trips, destinations, and activities appear in URLs.", |
| 7837 |
"yatra" |
| 7838 |
) }) |
| 7839 |
] }), |
| 7840 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 7841 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 7842 |
FormField, |
| 7843 |
{ |
| 7844 |
id: "trip_base", |
| 7845 |
label: __("Trip Base", "yatra"), |
| 7846 |
description: __( |
| 7847 |
'URL slug for trip single pages (e.g., "trip" will create URLs like /trip/everest-base-camp)', |
| 7848 |
"yatra" |
| 7849 |
), |
| 7850 |
children: [ |
| 7851 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7852 |
Input, |
| 7853 |
{ |
| 7854 |
id: "trip_base", |
| 7855 |
name: "trip_base", |
| 7856 |
value: formData.trip_base || "trip", |
| 7857 |
onChange: handleFieldChange, |
| 7858 |
placeholder: "trip", |
| 7859 |
className: "font-mono" |
| 7860 |
} |
| 7861 |
), |
| 7862 |
formData.trip_base && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2", children: [ |
| 7863 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [ |
| 7864 |
__("Listing URL:", "yatra"), |
| 7865 |
" ", |
| 7866 |
/* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: listingHref(formData.trip_base || "trip") }) |
| 7867 |
] }), |
| 7868 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 7869 |
"a", |
| 7870 |
{ |
| 7871 |
href: listingHref(formData.trip_base || "trip"), |
| 7872 |
target: "_blank", |
| 7873 |
rel: "noreferrer", |
| 7874 |
className: "inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline shrink-0", |
| 7875 |
children: [ |
| 7876 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }), |
| 7877 |
" ", |
| 7878 |
__("View", "yatra") |
| 7879 |
] |
| 7880 |
} |
| 7881 |
) |
| 7882 |
] }) |
| 7883 |
] |
| 7884 |
} |
| 7885 |
), |
| 7886 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 7887 |
FormField, |
| 7888 |
{ |
| 7889 |
id: "destination_base", |
| 7890 |
label: __("Destination Base", "yatra"), |
| 7891 |
description: __( |
| 7892 |
'URL slug for destination archive pages (e.g., "destination" will create URLs like /destination/nepal)', |
| 7893 |
"yatra" |
| 7894 |
), |
| 7895 |
children: [ |
| 7896 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7897 |
Input, |
| 7898 |
{ |
| 7899 |
id: "destination_base", |
| 7900 |
name: "destination_base", |
| 7901 |
value: formData.destination_base || "destination", |
| 7902 |
onChange: handleFieldChange, |
| 7903 |
placeholder: "destination", |
| 7904 |
className: "font-mono" |
| 7905 |
} |
| 7906 |
), |
| 7907 |
formData.destination_base && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2", children: [ |
| 7908 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [ |
| 7909 |
__("Listing URL:", "yatra"), |
| 7910 |
" ", |
| 7911 |
/* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: listingHref( |
| 7912 |
formData.destination_base || "destination" |
| 7913 |
) }) |
| 7914 |
] }), |
| 7915 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 7916 |
"a", |
| 7917 |
{ |
| 7918 |
href: listingHref( |
| 7919 |
formData.destination_base || "destination" |
| 7920 |
), |
| 7921 |
target: "_blank", |
| 7922 |
rel: "noreferrer", |
| 7923 |
className: "inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline shrink-0", |
| 7924 |
children: [ |
| 7925 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }), |
| 7926 |
" ", |
| 7927 |
__("View", "yatra") |
| 7928 |
] |
| 7929 |
} |
| 7930 |
) |
| 7931 |
] }) |
| 7932 |
] |
| 7933 |
} |
| 7934 |
), |
| 7935 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 7936 |
FormField, |
| 7937 |
{ |
| 7938 |
id: "activity_base", |
| 7939 |
label: __("Activity Base", "yatra"), |
| 7940 |
description: __( |
| 7941 |
'URL slug for activity archive pages (e.g., "activity" will create URLs like /activity/trekking)', |
| 7942 |
"yatra" |
| 7943 |
), |
| 7944 |
children: [ |
| 7945 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7946 |
Input, |
| 7947 |
{ |
| 7948 |
id: "activity_base", |
| 7949 |
name: "activity_base", |
| 7950 |
value: formData.activity_base || "activity", |
| 7951 |
onChange: handleFieldChange, |
| 7952 |
placeholder: "activity", |
| 7953 |
className: "font-mono" |
| 7954 |
} |
| 7955 |
), |
| 7956 |
formData.activity_base && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2", children: [ |
| 7957 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [ |
| 7958 |
__("Listing URL:", "yatra"), |
| 7959 |
" ", |
| 7960 |
/* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: listingHref(formData.activity_base || "activity") }) |
| 7961 |
] }), |
| 7962 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 7963 |
"a", |
| 7964 |
{ |
| 7965 |
href: listingHref(formData.activity_base || "activity"), |
| 7966 |
target: "_blank", |
| 7967 |
rel: "noreferrer", |
| 7968 |
className: "inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline shrink-0", |
| 7969 |
children: [ |
| 7970 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }), |
| 7971 |
" ", |
| 7972 |
__("View", "yatra") |
| 7973 |
] |
| 7974 |
} |
| 7975 |
) |
| 7976 |
] }) |
| 7977 |
] |
| 7978 |
} |
| 7979 |
), |
| 7980 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 7981 |
FormField, |
| 7982 |
{ |
| 7983 |
id: "trip_category_base", |
| 7984 |
label: __("Trip Category Base", "yatra"), |
| 7985 |
description: __( |
| 7986 |
'URL slug for trip category archive pages (e.g., "trip-category" will create URLs like /trip-category/adventure)', |
| 7987 |
"yatra" |
| 7988 |
), |
| 7989 |
children: [ |
| 7990 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 7991 |
Input, |
| 7992 |
{ |
| 7993 |
id: "trip_category_base", |
| 7994 |
name: "trip_category_base", |
| 7995 |
value: formData.trip_category_base || "trip-category", |
| 7996 |
onChange: handleFieldChange, |
| 7997 |
placeholder: "trip-category", |
| 7998 |
className: "font-mono" |
| 7999 |
} |
| 8000 |
), |
| 8001 |
formData.trip_category_base && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2", children: [ |
| 8002 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [ |
| 8003 |
__("Listing URL:", "yatra"), |
| 8004 |
" ", |
| 8005 |
/* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: listingHref( |
| 8006 |
formData.trip_category_base || "trip-category" |
| 8007 |
) }) |
| 8008 |
] }), |
| 8009 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8010 |
"a", |
| 8011 |
{ |
| 8012 |
href: listingHref( |
| 8013 |
formData.trip_category_base || "trip-category" |
| 8014 |
), |
| 8015 |
target: "_blank", |
| 8016 |
rel: "noreferrer", |
| 8017 |
className: "inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline shrink-0", |
| 8018 |
children: [ |
| 8019 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }), |
| 8020 |
" ", |
| 8021 |
__("View", "yatra") |
| 8022 |
] |
| 8023 |
} |
| 8024 |
) |
| 8025 |
] }) |
| 8026 |
] |
| 8027 |
} |
| 8028 |
) |
| 8029 |
] }), |
| 8030 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-8 pt-6 border-t border-gray-200 dark:border-gray-700", children: [ |
| 8031 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Booking Page Settings", "yatra") }), |
| 8032 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 mb-6", children: __( |
| 8033 |
"Configure the booking page URL. By default, bookings use /book/{trip-slug}. You can customize the URL base or use a custom WordPress page.", |
| 8034 |
"yatra" |
| 8035 |
) }), |
| 8036 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 8037 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8038 |
FormField, |
| 8039 |
{ |
| 8040 |
id: "booking_base", |
| 8041 |
label: __("Default Booking URL Base", "yatra"), |
| 8042 |
description: __( |
| 8043 |
'URL slug for the booking page (e.g., "book" will create URLs like /book/trip-name)', |
| 8044 |
"yatra" |
| 8045 |
), |
| 8046 |
children: [ |
| 8047 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8048 |
Input, |
| 8049 |
{ |
| 8050 |
id: "booking_base", |
| 8051 |
name: "booking_base", |
| 8052 |
value: formData.booking_base || "book", |
| 8053 |
onChange: handleFieldChange, |
| 8054 |
placeholder: "book", |
| 8055 |
className: "font-mono" |
| 8056 |
} |
| 8057 |
), |
| 8058 |
formData.booking_base && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 8059 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1 flex items-center gap-2", children: [ |
| 8060 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [ |
| 8061 |
__("Booking hub URL:", "yatra"), |
| 8062 |
" ", |
| 8063 |
/* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: listingHref(formData.booking_base || "book") }) |
| 8064 |
] }), |
| 8065 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8066 |
"a", |
| 8067 |
{ |
| 8068 |
href: listingHref(formData.booking_base || "book"), |
| 8069 |
target: "_blank", |
| 8070 |
rel: "noreferrer", |
| 8071 |
className: "inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline shrink-0", |
| 8072 |
children: [ |
| 8073 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3" }), |
| 8074 |
" ", |
| 8075 |
__("View", "yatra") |
| 8076 |
] |
| 8077 |
} |
| 8078 |
) |
| 8079 |
] }), |
| 8080 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "min-w-0", children: [ |
| 8081 |
__( |
| 8082 |
"Booking confirmation base (pageless, same slug as above):", |
| 8083 |
"yatra" |
| 8084 |
), |
| 8085 |
" ", |
| 8086 |
/* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded break-all", children: bookingConfirmationPreviewUrl( |
| 8087 |
formData.booking_base || "book" |
| 8088 |
) }), |
| 8089 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-400 dark:text-gray-500 ml-1", children: __( |
| 8090 |
"append booking reference after checkout", |
| 8091 |
"yatra" |
| 8092 |
) }) |
| 8093 |
] }) }) |
| 8094 |
] }) |
| 8095 |
] |
| 8096 |
} |
| 8097 |
), |
| 8098 |
formData.use_booking_page && /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8099 |
FormField, |
| 8100 |
{ |
| 8101 |
id: "booking_page_id", |
| 8102 |
label: __("Select Booking Page", "yatra"), |
| 8103 |
description: __( |
| 8104 |
"Choose a page that contains the [yatra_booking] shortcode. If the page doesn't have the shortcode, you'll be prompted to add it.", |
| 8105 |
"Choose a page that contains the [yatra_booking] shortcode. If the page doesn't have the shortcode, you'll be prompted to add it." |
| 8106 |
), |
| 8107 |
children: [ |
| 8108 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [ |
| 8109 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8110 |
"select", |
| 8111 |
{ |
| 8112 |
id: "booking_page_id", |
| 8113 |
name: "booking_page_id", |
| 8114 |
value: formData.booking_page_id || 0, |
| 8115 |
onChange: (e) => handleBookingPageChange(parseInt(e.target.value)), |
| 8116 |
disabled: isCheckingShortcode, |
| 8117 |
className: "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:opacity-50 disabled:cursor-wait", |
| 8118 |
children: [ |
| 8119 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: 0, children: __("-- Select a page --", "yatra") }), |
| 8120 |
pagesData == null ? void 0 : pagesData.map((page) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: page.id, children: page.title }, page.id)) |
| 8121 |
] |
| 8122 |
} |
| 8123 |
), |
| 8124 |
isCheckingShortcode && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute right-8 top-1/2 -translate-y-1/2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin text-blue-500" }) }) |
| 8125 |
] }), |
| 8126 |
formData.booking_page_id > 0 && pagesData && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: [ |
| 8127 |
__("Booking URL:", "yatra"), |
| 8128 |
" ", |
| 8129 |
/* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-800 px-1 rounded", children: ((_Ga = pagesData.find( |
| 8130 |
(p) => p.id === formData.booking_page_id |
| 8131 |
)) == null ? void 0 : _Ga.url) || "" }) |
| 8132 |
] }) |
| 8133 |
] |
| 8134 |
} |
| 8135 |
) |
| 8136 |
] }) |
| 8137 |
] }), |
| 8138 |
showShortcodeDialog && selectedPageForShortcode && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full mx-4 p-6", children: [ |
| 8139 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white mb-4", children: __("Shortcode Required", "yatra") }), |
| 8140 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6", children: [ |
| 8141 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm text-gray-600 dark:text-gray-300 mb-3", children: [ |
| 8142 |
__("The page", "yatra"), |
| 8143 |
" ", |
| 8144 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("strong", { children: [ |
| 8145 |
'"', |
| 8146 |
selectedPageForShortcode.title, |
| 8147 |
'"' |
| 8148 |
] }), |
| 8149 |
" ", |
| 8150 |
__("doesn't have the", "doesn't have the"), |
| 8151 |
" ", |
| 8152 |
/* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: "bg-gray-100 dark:bg-gray-700 px-1 rounded", children: "[yatra_booking]" }), |
| 8153 |
" ", |
| 8154 |
__("shortcode.", "yatra") |
| 8155 |
] }), |
| 8156 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300", children: __( |
| 8157 |
"Would you like to add it automatically, or edit the page manually to place it where you want?", |
| 8158 |
"yatra" |
| 8159 |
) }) |
| 8160 |
] }), |
| 8161 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [ |
| 8162 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8163 |
Button, |
| 8164 |
{ |
| 8165 |
onClick: handleConfirmInsertShortcode, |
| 8166 |
disabled: insertShortcodeMutation.isPending, |
| 8167 |
className: "w-full justify-center", |
| 8168 |
children: insertShortcodeMutation.isPending ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 8169 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin mr-2" }), |
| 8170 |
__("Adding...", "yatra") |
| 8171 |
] }) : __("Add Shortcode Automatically", "yatra") |
| 8172 |
} |
| 8173 |
), |
| 8174 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8175 |
Button, |
| 8176 |
{ |
| 8177 |
variant: "outline", |
| 8178 |
onClick: () => { |
| 8179 |
var _a3; |
| 8180 |
const editUrl = (_a3 = pagesData == null ? void 0 : pagesData.find( |
| 8181 |
(p) => p.id === selectedPageForShortcode.id |
| 8182 |
)) == null ? void 0 : _a3.url; |
| 8183 |
if (editUrl) { |
| 8184 |
window.open( |
| 8185 |
`/wp-admin/post.php?post=${selectedPageForShortcode.id}&action=edit`, |
| 8186 |
"_blank" |
| 8187 |
); |
| 8188 |
} |
| 8189 |
setShowShortcodeDialog(false); |
| 8190 |
setSelectedPageForShortcode(null); |
| 8191 |
}, |
| 8192 |
className: "w-full justify-center", |
| 8193 |
children: __("Edit Page Manually", "yatra") |
| 8194 |
} |
| 8195 |
), |
| 8196 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8197 |
Button, |
| 8198 |
{ |
| 8199 |
variant: "ghost", |
| 8200 |
onClick: () => { |
| 8201 |
setShowShortcodeDialog(false); |
| 8202 |
setSelectedPageForShortcode(null); |
| 8203 |
handleFieldChange({ |
| 8204 |
target: { name: "booking_page_id", value: 0 } |
| 8205 |
}); |
| 8206 |
}, |
| 8207 |
className: "w-full justify-center", |
| 8208 |
children: __("Skip for now", "yatra") |
| 8209 |
} |
| 8210 |
) |
| 8211 |
] }) |
| 8212 |
] }) }), |
| 8213 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-6 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2", children: [ |
| 8214 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0" }), |
| 8215 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 text-sm text-blue-800 dark:text-blue-200", children: [ |
| 8216 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-medium mb-1", children: __("Important:", "yatra") }), |
| 8217 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mb-3", children: __( |
| 8218 |
"After changing permalink settings, you must flush rewrite rules for the changes to take effect.", |
| 8219 |
"yatra" |
| 8220 |
) }), |
| 8221 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8222 |
Button, |
| 8223 |
{ |
| 8224 |
type: "button", |
| 8225 |
onClick: () => flushRewriteRulesMutation.mutate(), |
| 8226 |
disabled: flushRewriteRulesMutation.isPending, |
| 8227 |
variant: "outline", |
| 8228 |
size: "sm", |
| 8229 |
className: "flex items-center gap-2", |
| 8230 |
children: flushRewriteRulesMutation.isPending ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 8231 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin" }), |
| 8232 |
__("Flushing...", "yatra") |
| 8233 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 8234 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Globe, { className: "w-4 h-4" }), |
| 8235 |
__("Flush Rewrite Rules", "yatra") |
| 8236 |
] }) |
| 8237 |
} |
| 8238 |
) |
| 8239 |
] }) |
| 8240 |
] }) }) |
| 8241 |
] }); |
| 8242 |
} |
| 8243 |
case "seo": |
| 8244 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 8245 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 8246 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Trip Archive SEO Settings", "yatra") }), |
| 8247 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __( |
| 8248 |
"Configure SEO meta tags for the trip archive page (/trip/). These meta tags will be used for the main trip listing page.", |
| 8249 |
"yatra" |
| 8250 |
) }), |
| 8251 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 8252 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8253 |
FormField, |
| 8254 |
{ |
| 8255 |
id: "seo_trip_meta_title", |
| 8256 |
label: __("Trip Archive Meta Title", "yatra"), |
| 8257 |
description: __( |
| 8258 |
"Meta title for the trip archive page. This will appear in search engine results for /trip/ page.", |
| 8259 |
"yatra" |
| 8260 |
), |
| 8261 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8262 |
Input, |
| 8263 |
{ |
| 8264 |
id: "seo_trip_meta_title", |
| 8265 |
type: "text", |
| 8266 |
value: formData.seo_trip_meta_title, |
| 8267 |
onChange: (e) => setFormData( |
| 8268 |
(prev) => prev ? { ...prev, seo_trip_meta_title: e.target.value } : null |
| 8269 |
), |
| 8270 |
placeholder: __( |
| 8271 |
"e.g., Browse All Trips - Find Your Perfect Adventure | Your Travel Agency", |
| 8272 |
"yatra" |
| 8273 |
), |
| 8274 |
className: "w-full" |
| 8275 |
} |
| 8276 |
) |
| 8277 |
} |
| 8278 |
), |
| 8279 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8280 |
FormField, |
| 8281 |
{ |
| 8282 |
id: "seo_trip_meta_description", |
| 8283 |
label: __("Trip Archive Meta Description", "yatra"), |
| 8284 |
description: __( |
| 8285 |
"Meta description for the trip archive page. Should be 150-160 characters for best SEO results.", |
| 8286 |
"yatra" |
| 8287 |
), |
| 8288 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8289 |
"textarea", |
| 8290 |
{ |
| 8291 |
id: "seo_trip_meta_description", |
| 8292 |
value: formData.seo_trip_meta_description, |
| 8293 |
onChange: (e) => setFormData( |
| 8294 |
(prev) => prev ? { |
| 8295 |
...prev, |
| 8296 |
seo_trip_meta_description: e.target.value |
| 8297 |
} : null |
| 8298 |
), |
| 8299 |
placeholder: __( |
| 8300 |
"e.g., Explore our complete collection of amazing trips and adventures. Find and book your perfect journey with us.", |
| 8301 |
"yatra" |
| 8302 |
), |
| 8303 |
rows: 3, |
| 8304 |
className: "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white" |
| 8305 |
} |
| 8306 |
) |
| 8307 |
} |
| 8308 |
), |
| 8309 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8310 |
FormField, |
| 8311 |
{ |
| 8312 |
id: "seo_trip_meta_keywords", |
| 8313 |
label: __("Trip Archive Meta Keywords", "yatra"), |
| 8314 |
description: __( |
| 8315 |
"Comma-separated keywords for the trip archive page. Include relevant travel and booking keywords.", |
| 8316 |
"yatra" |
| 8317 |
), |
| 8318 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8319 |
Input, |
| 8320 |
{ |
| 8321 |
id: "seo_trip_meta_keywords", |
| 8322 |
type: "text", |
| 8323 |
value: formData.seo_trip_meta_keywords, |
| 8324 |
onChange: (e) => setFormData( |
| 8325 |
(prev) => prev ? { ...prev, seo_trip_meta_keywords: e.target.value } : null |
| 8326 |
), |
| 8327 |
placeholder: __( |
| 8328 |
"e.g., travel, trips, adventure, booking, tours, destinations, holidays", |
| 8329 |
"yatra" |
| 8330 |
), |
| 8331 |
className: "w-full" |
| 8332 |
} |
| 8333 |
) |
| 8334 |
} |
| 8335 |
), |
| 8336 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8337 |
FormField, |
| 8338 |
{ |
| 8339 |
id: "seo_trip_meta_image", |
| 8340 |
label: __("Trip Archive SEO Image", "yatra"), |
| 8341 |
description: __( |
| 8342 |
"Image for social media sharing and SEO. Recommended size: 1200x630 pixels. This image will appear when the trip archive page is shared on Facebook, Twitter, and other platforms.", |
| 8343 |
"yatra" |
| 8344 |
), |
| 8345 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: formData.seo_trip_meta_image && formData.seo_trip_meta_image > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative group", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-4 p-4 border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-800/50", children: [ |
| 8346 |
seoImageLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-24 h-24 flex items-center justify-center border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-6 h-6 animate-spin text-gray-400" }) }) : seoImageUrl ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative w-24 h-24 overflow-hidden rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700", children: [ |
| 8347 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8348 |
"img", |
| 8349 |
{ |
| 8350 |
src: seoImageUrl, |
| 8351 |
alt: "SEO Preview", |
| 8352 |
className: "w-full h-full object-cover" |
| 8353 |
} |
| 8354 |
), |
| 8355 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors" }) |
| 8356 |
] }) : seoImageError ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-24 h-24 flex flex-col items-center justify-center border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700", children: [ |
| 8357 |
/* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "w-6 h-6 text-red-400 mb-1" }), |
| 8358 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-red-500 dark:text-red-400 text-center px-1", children: seoImageError }) |
| 8359 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-24 h-24 flex flex-col items-center justify-center border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700", children: [ |
| 8360 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Image, { className: "w-6 h-6 text-gray-400 mb-1" }), |
| 8361 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-500 dark:text-gray-400", children: "No image" }) |
| 8362 |
] }), |
| 8363 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [ |
| 8364 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-2", children: [ |
| 8365 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-medium text-gray-900 dark:text-white", children: __("SEO Image", "yatra") }), |
| 8366 |
!seoImageLoading && /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8367 |
"button", |
| 8368 |
{ |
| 8369 |
type: "button", |
| 8370 |
onClick: () => { |
| 8371 |
setFormData( |
| 8372 |
(prev) => prev ? { ...prev, seo_trip_meta_image: 0 } : null |
| 8373 |
); |
| 8374 |
}, |
| 8375 |
className: "opacity-0 group-hover:opacity-100 transition-opacity p-1 text-gray-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded", |
| 8376 |
title: __("Remove image", "yatra"), |
| 8377 |
children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "w-4 h-4" }) |
| 8378 |
} |
| 8379 |
) |
| 8380 |
] }), |
| 8381 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-3", children: __( |
| 8382 |
"Recommended size: 1200x630 pixels for optimal social media display.", |
| 8383 |
"yatra" |
| 8384 |
) }), |
| 8385 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8386 |
Button, |
| 8387 |
{ |
| 8388 |
type: "button", |
| 8389 |
onClick: () => { |
| 8390 |
if (window.wp && window.wp.media) { |
| 8391 |
const mediaUploader = window.wp.media({ |
| 8392 |
title: __("Select SEO Image", "yatra"), |
| 8393 |
button: { |
| 8394 |
text: __("Use this image", "yatra") |
| 8395 |
}, |
| 8396 |
multiple: false, |
| 8397 |
library: { type: "image" } |
| 8398 |
}); |
| 8399 |
mediaUploader.on("select", () => { |
| 8400 |
const attachment = mediaUploader.state().get("selection").first().toJSON(); |
| 8401 |
setFormData( |
| 8402 |
(prev) => prev ? { |
| 8403 |
...prev, |
| 8404 |
seo_trip_meta_image: attachment.id |
| 8405 |
} : null |
| 8406 |
); |
| 8407 |
}); |
| 8408 |
prepareWordPressMediaFrameOpen(); |
| 8409 |
mediaUploader.open(); |
| 8410 |
} |
| 8411 |
}, |
| 8412 |
variant: "outline", |
| 8413 |
size: "sm", |
| 8414 |
children: __("Change Image", "yatra") |
| 8415 |
} |
| 8416 |
) |
| 8417 |
] }) |
| 8418 |
] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-8 text-center hover:border-gray-400 dark:hover:border-gray-500 transition-colors", children: [ |
| 8419 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-16 h-16 mx-auto mb-4 flex items-center justify-center bg-gray-100 dark:bg-gray-700 rounded-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Image, { className: "w-8 h-8 text-gray-400" }) }), |
| 8420 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-medium text-gray-900 dark:text-white mb-2", children: __("Add SEO Image", "yatra") }), |
| 8421 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4 max-w-sm mx-auto", children: __( |
| 8422 |
"Upload an image that will appear when your trip archive page is shared on social media. Recommended size: 1200x630 pixels.", |
| 8423 |
"yatra" |
| 8424 |
) }), |
| 8425 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8426 |
Button, |
| 8427 |
{ |
| 8428 |
type: "button", |
| 8429 |
onClick: () => { |
| 8430 |
if (window.wp && window.wp.media) { |
| 8431 |
const mediaUploader = window.wp.media({ |
| 8432 |
title: __("Select SEO Image", "yatra"), |
| 8433 |
button: { text: __("Use this image", "yatra") }, |
| 8434 |
multiple: false, |
| 8435 |
library: { type: "image" } |
| 8436 |
}); |
| 8437 |
mediaUploader.on("select", () => { |
| 8438 |
const attachment = mediaUploader.state().get("selection").first().toJSON(); |
| 8439 |
setFormData( |
| 8440 |
(prev) => prev ? { |
| 8441 |
...prev, |
| 8442 |
seo_trip_meta_image: attachment.id |
| 8443 |
} : null |
| 8444 |
); |
| 8445 |
}); |
| 8446 |
prepareWordPressMediaFrameOpen(); |
| 8447 |
mediaUploader.open(); |
| 8448 |
} |
| 8449 |
}, |
| 8450 |
children: [ |
| 8451 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4 mr-2" }), |
| 8452 |
__("Select Image", "yatra") |
| 8453 |
] |
| 8454 |
} |
| 8455 |
) |
| 8456 |
] }) }) |
| 8457 |
} |
| 8458 |
) |
| 8459 |
] }) |
| 8460 |
] }), |
| 8461 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 8462 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-4", children: __("Sitemap", "yatra") }), |
| 8463 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __( |
| 8464 |
"Yatra publishes one sitemap of all trips, destinations, activities and categories so search engines can find them. It is advertised in robots.txt and linked into Yoast, Rank Math, AIOSEO and WordPress core sitemaps automatically.", |
| 8465 |
"yatra" |
| 8466 |
) }), |
| 8467 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 8468 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 8469 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8470 |
"input", |
| 8471 |
{ |
| 8472 |
type: "checkbox", |
| 8473 |
id: "enable_sitemap", |
| 8474 |
checked: formData.enable_sitemap, |
| 8475 |
name: "enable_sitemap", |
| 8476 |
onChange: handleFieldChange, |
| 8477 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 8478 |
} |
| 8479 |
), |
| 8480 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 8481 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8482 |
Label, |
| 8483 |
{ |
| 8484 |
htmlFor: "enable_sitemap", |
| 8485 |
className: "font-medium cursor-pointer", |
| 8486 |
children: __("Enable Sitemap", "yatra") |
| 8487 |
} |
| 8488 |
), |
| 8489 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 8490 |
"Generate /yatra-sitemap.xml and advertise it to search engines.", |
| 8491 |
"yatra" |
| 8492 |
) }) |
| 8493 |
] }) |
| 8494 |
] }), |
| 8495 |
formData.enable_sitemap && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 8496 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "font-medium", children: __("Sitemap URL", "yatra") }), |
| 8497 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex items-center gap-2", children: [ |
| 8498 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8499 |
"a", |
| 8500 |
{ |
| 8501 |
href: ((_Ha = window.yatraAdmin) == null ? void 0 : _Ha.sitemapUrl) || "#", |
| 8502 |
target: "_blank", |
| 8503 |
rel: "noopener noreferrer", |
| 8504 |
className: "flex-1 break-all text-sm text-blue-600 dark:text-blue-400 underline", |
| 8505 |
children: ((_Ia = window.yatraAdmin) == null ? void 0 : _Ia.sitemapUrl) || "" |
| 8506 |
} |
| 8507 |
), |
| 8508 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8509 |
"button", |
| 8510 |
{ |
| 8511 |
type: "button", |
| 8512 |
onClick: () => { |
| 8513 |
var _a3, _b3; |
| 8514 |
return (_b3 = navigator.clipboard) == null ? void 0 : _b3.writeText( |
| 8515 |
((_a3 = window.yatraAdmin) == null ? void 0 : _a3.sitemapUrl) || "" |
| 8516 |
); |
| 8517 |
}, |
| 8518 |
className: "px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700", |
| 8519 |
children: __("Copy", "yatra") |
| 8520 |
} |
| 8521 |
) |
| 8522 |
] }), |
| 8523 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-2", children: [ |
| 8524 |
__( |
| 8525 |
"Optional: submit this URL in Google Search Console or Bing Webmaster Tools. It is already listed in robots.txt, so search engines find it automatically.", |
| 8526 |
"yatra" |
| 8527 |
), |
| 8528 |
formData.enable_sitemap && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 border border-gray-200 dark:border-gray-700 rounded-md space-y-3", children: [ |
| 8529 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 8530 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "font-medium", children: __("Content in the sitemap", "yatra") }), |
| 8531 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 8532 |
"Uncheck a type to keep it out of /yatra-sitemap.xml.", |
| 8533 |
"yatra" |
| 8534 |
) }) |
| 8535 |
] }), |
| 8536 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 sm:grid-cols-3 gap-2", children: [ |
| 8537 |
{ key: "trip", label: __("Trips", "yatra") }, |
| 8538 |
{ key: "destination", label: __("Destinations", "yatra") }, |
| 8539 |
{ key: "activity", label: __("Activities", "yatra") }, |
| 8540 |
{ key: "category", label: __("Trip categories", "yatra") }, |
| 8541 |
{ key: "archive", label: __("Listing pages", "yatra") } |
| 8542 |
].map((t) => { |
| 8543 |
const selected = formData.sitemap_types ?? []; |
| 8544 |
const checked = selected.includes(t.key); |
| 8545 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8546 |
"label", |
| 8547 |
{ |
| 8548 |
className: "flex items-center gap-2 text-sm cursor-pointer", |
| 8549 |
children: [ |
| 8550 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8551 |
"input", |
| 8552 |
{ |
| 8553 |
type: "checkbox", |
| 8554 |
checked, |
| 8555 |
onChange: () => setFormData((prev) => { |
| 8556 |
if (!prev) return prev; |
| 8557 |
return { |
| 8558 |
...prev, |
| 8559 |
sitemap_types: checked ? (prev.sitemap_types ?? []).filter( |
| 8560 |
(x) => x !== t.key |
| 8561 |
) : [...prev.sitemap_types ?? [], t.key] |
| 8562 |
}; |
| 8563 |
}), |
| 8564 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 8565 |
} |
| 8566 |
), |
| 8567 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: t.label }) |
| 8568 |
] |
| 8569 |
}, |
| 8570 |
t.key |
| 8571 |
); |
| 8572 |
}) }), |
| 8573 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 pt-2 border-t border-gray-200 dark:border-gray-700", children: [ |
| 8574 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8575 |
"input", |
| 8576 |
{ |
| 8577 |
type: "checkbox", |
| 8578 |
id: "sitemap_noindex_excluded", |
| 8579 |
name: "sitemap_noindex_excluded", |
| 8580 |
checked: formData.sitemap_noindex_excluded, |
| 8581 |
onChange: (e) => setFormData((prev) => { |
| 8582 |
if (!prev) return prev; |
| 8583 |
return { |
| 8584 |
...prev, |
| 8585 |
sitemap_noindex_excluded: e.target.checked |
| 8586 |
}; |
| 8587 |
}), |
| 8588 |
className: "mt-0.5 w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 8589 |
} |
| 8590 |
), |
| 8591 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 8592 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8593 |
Label, |
| 8594 |
{ |
| 8595 |
htmlFor: "sitemap_noindex_excluded", |
| 8596 |
className: "font-medium cursor-pointer", |
| 8597 |
children: __("Also add noindex to excluded types", "yatra") |
| 8598 |
} |
| 8599 |
), |
| 8600 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 8601 |
"Leaving a type out of the sitemap does not stop Google indexing it. Turn this on to send noindex on those pages as well — they will drop out of search results, so only do this for content you do not want found.", |
| 8602 |
"yatra" |
| 8603 |
) }) |
| 8604 |
] }) |
| 8605 |
] }) |
| 8606 |
] }) |
| 8607 |
] }) |
| 8608 |
] }) |
| 8609 |
] }) |
| 8610 |
] }) |
| 8611 |
] }); |
| 8612 |
case "advanced": |
| 8613 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [ |
| 8614 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 8615 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-600 dark:border-gray-700 dark:bg-gray-800/50 dark:text-gray-400", children: __( |
| 8616 |
"For PHP-level debug output, use WordPress wp-config.php (WP_DEBUG). The options below are implemented by the plugin.", |
| 8617 |
"yatra" |
| 8618 |
) }), |
| 8619 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 8620 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8621 |
"input", |
| 8622 |
{ |
| 8623 |
type: "checkbox", |
| 8624 |
id: "enable_logging", |
| 8625 |
checked: formData.enable_logging, |
| 8626 |
name: "enable_logging", |
| 8627 |
onChange: handleFieldChange, |
| 8628 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 8629 |
} |
| 8630 |
), |
| 8631 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 8632 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8633 |
Label, |
| 8634 |
{ |
| 8635 |
htmlFor: "enable_logging", |
| 8636 |
className: "font-medium cursor-pointer", |
| 8637 |
children: __("Enable Logging", "yatra") |
| 8638 |
} |
| 8639 |
), |
| 8640 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 8641 |
"Log system events and errors for troubleshooting", |
| 8642 |
"yatra" |
| 8643 |
) }) |
| 8644 |
] }) |
| 8645 |
] }), |
| 8646 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 8647 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8648 |
"input", |
| 8649 |
{ |
| 8650 |
type: "checkbox", |
| 8651 |
id: "debug_mode", |
| 8652 |
checked: formData.debug_mode, |
| 8653 |
name: "debug_mode", |
| 8654 |
onChange: handleFieldChange, |
| 8655 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 8656 |
} |
| 8657 |
), |
| 8658 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 8659 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8660 |
Label, |
| 8661 |
{ |
| 8662 |
htmlFor: "debug_mode", |
| 8663 |
className: "font-medium cursor-pointer", |
| 8664 |
children: __("Debug mode", "yatra") |
| 8665 |
} |
| 8666 |
), |
| 8667 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 8668 |
"Extra plugin-side diagnostics. When on, Yatra object cache is bypassed (same as when WP_DEBUG is true in wp-config).", |
| 8669 |
"yatra" |
| 8670 |
) }) |
| 8671 |
] }) |
| 8672 |
] }), |
| 8673 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 8674 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8675 |
"input", |
| 8676 |
{ |
| 8677 |
type: "checkbox", |
| 8678 |
id: "cache_enabled", |
| 8679 |
checked: formData.cache_enabled, |
| 8680 |
name: "cache_enabled", |
| 8681 |
onChange: handleFieldChange, |
| 8682 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" |
| 8683 |
} |
| 8684 |
), |
| 8685 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 8686 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8687 |
Label, |
| 8688 |
{ |
| 8689 |
htmlFor: "cache_enabled", |
| 8690 |
className: "font-medium cursor-pointer", |
| 8691 |
children: __("Enable Cache", "yatra") |
| 8692 |
} |
| 8693 |
), |
| 8694 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: __( |
| 8695 |
"Stores frequently used data for faster loads. Stays off while WP_DEBUG or Debug mode (above) is on.", |
| 8696 |
"yatra" |
| 8697 |
) }) |
| 8698 |
] }) |
| 8699 |
] }) |
| 8700 |
] }), |
| 8701 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "border-t border-gray-200 dark:border-gray-700 pt-6", children: [ |
| 8702 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-2", children: __("Legal pages (Booking UI)", "yatra") }), |
| 8703 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: __( |
| 8704 |
"Select the pages that will be linked from the booking Terms and Privacy consent checkboxes.", |
| 8705 |
"yatra" |
| 8706 |
) }), |
| 8707 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [ |
| 8708 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 8709 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "terms_page_id", children: __("Terms & Conditions page", "yatra") }), |
| 8710 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8711 |
"select", |
| 8712 |
{ |
| 8713 |
id: "terms_page_id", |
| 8714 |
name: "terms_page_id", |
| 8715 |
value: formData.terms_page_id || 0, |
| 8716 |
onChange: handleFieldChange, |
| 8717 |
className: "mt-1 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-900", |
| 8718 |
children: [ |
| 8719 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: 0, children: __("— Select —", "yatra") }), |
| 8720 |
pagesData == null ? void 0 : pagesData.map((p) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: p.id, children: p.title }, p.id)) |
| 8721 |
] |
| 8722 |
} |
| 8723 |
) |
| 8724 |
] }), |
| 8725 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 8726 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "privacy_policy_page_id", children: __("Privacy Policy page", "yatra") }), |
| 8727 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8728 |
"select", |
| 8729 |
{ |
| 8730 |
id: "privacy_policy_page_id", |
| 8731 |
name: "privacy_policy_page_id", |
| 8732 |
value: formData.privacy_policy_page_id || 0, |
| 8733 |
onChange: handleFieldChange, |
| 8734 |
className: "mt-1 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-900", |
| 8735 |
children: [ |
| 8736 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: 0, children: __("— Select —", "yatra") }), |
| 8737 |
pagesData == null ? void 0 : pagesData.map((p) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: p.id, children: p.title }, p.id)) |
| 8738 |
] |
| 8739 |
} |
| 8740 |
), |
| 8741 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-[11px] text-gray-500 dark:text-gray-400", children: __( |
| 8742 |
"If not set here, WordPress Settings → Privacy will be used when available.", |
| 8743 |
"yatra" |
| 8744 |
) }) |
| 8745 |
] }) |
| 8746 |
] }) |
| 8747 |
] }), |
| 8748 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "border-t border-gray-200 dark:border-gray-700 pt-6 mt-6", children: [ |
| 8749 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("h3", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-2 flex items-center gap-2", children: [ |
| 8750 |
/* @__PURE__ */ jsxRuntimeExports.jsx(BarChart3, { className: "w-4 h-4" }), |
| 8751 |
__("Help us improve Yatra", "yatra") |
| 8752 |
] }), |
| 8753 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-4", children: [ |
| 8754 |
__( |
| 8755 |
"Share non-sensitive technical details so we can make Yatra better. You can turn this off anytime. See what we collect on our site:", |
| 8756 |
"yatra" |
| 8757 |
), |
| 8758 |
" ", |
| 8759 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8760 |
"a", |
| 8761 |
{ |
| 8762 |
className: "text-blue-600 hover:underline inline-flex items-center gap-0.5", |
| 8763 |
href: "https://wpyatra.com/what-we-collect/", |
| 8764 |
target: "_blank", |
| 8765 |
rel: "noopener noreferrer", |
| 8766 |
children: [ |
| 8767 |
__("What we collect", "yatra"), |
| 8768 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3", "aria-hidden": true }) |
| 8769 |
] |
| 8770 |
} |
| 8771 |
), |
| 8772 |
" · ", |
| 8773 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8774 |
"a", |
| 8775 |
{ |
| 8776 |
className: "text-blue-600 hover:underline", |
| 8777 |
href: "https://mantrabrain.com/privacy-policy/", |
| 8778 |
target: "_blank", |
| 8779 |
rel: "noopener noreferrer", |
| 8780 |
children: __("Privacy policy", "yatra") |
| 8781 |
} |
| 8782 |
) |
| 8783 |
] }), |
| 8784 |
usageLoading && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm text-gray-500 flex items-center gap-2", children: [ |
| 8785 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin" }), |
| 8786 |
__("Loading…", "yatra") |
| 8787 |
] }), |
| 8788 |
!usageLoading && !usageStatus && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [ |
| 8789 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-amber-600", children: __( |
| 8790 |
"Could not load this section. You may need permission to manage Yatra.", |
| 8791 |
"yatra" |
| 8792 |
) }), |
| 8793 |
usageError && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: usageError }) |
| 8794 |
] }), |
| 8795 |
!usageLoading && usageStatus && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md", children: [ |
| 8796 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8797 |
"input", |
| 8798 |
{ |
| 8799 |
type: "checkbox", |
| 8800 |
id: "yatra_usage_tracking_enabled", |
| 8801 |
checked: usageStatus.enabled, |
| 8802 |
disabled: usageBusy, |
| 8803 |
onChange: async (e) => { |
| 8804 |
setUsageBusy(true); |
| 8805 |
try { |
| 8806 |
const r = await postUsageTrackingSettings( |
| 8807 |
e.target.checked |
| 8808 |
); |
| 8809 |
setUsageStatus( |
| 8810 |
(prev) => prev ? { ...prev, enabled: r.enabled } : prev |
| 8811 |
); |
| 8812 |
showToast( |
| 8813 |
__("Preference saved.", "yatra"), |
| 8814 |
"success" |
| 8815 |
); |
| 8816 |
} catch (err) { |
| 8817 |
showToast( |
| 8818 |
(err == null ? void 0 : err.message) || __("Could not save your preference.", "yatra"), |
| 8819 |
"error" |
| 8820 |
); |
| 8821 |
} finally { |
| 8822 |
setUsageBusy(false); |
| 8823 |
} |
| 8824 |
}, |
| 8825 |
className: "w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 shrink-0" |
| 8826 |
} |
| 8827 |
), |
| 8828 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-[200px]", children: [ |
| 8829 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8830 |
Label, |
| 8831 |
{ |
| 8832 |
htmlFor: "yatra_usage_tracking_enabled", |
| 8833 |
className: "font-medium cursor-pointer", |
| 8834 |
children: __( |
| 8835 |
"Help us improve the product by sharing non-sensitive data", |
| 8836 |
"yatra" |
| 8837 |
) |
| 8838 |
} |
| 8839 |
), |
| 8840 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-0.5", children: [ |
| 8841 |
__( |
| 8842 |
"Sent periodically while enabled. Learn more: ", |
| 8843 |
"yatra" |
| 8844 |
), |
| 8845 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8846 |
"a", |
| 8847 |
{ |
| 8848 |
className: "text-blue-600 hover:underline inline-flex items-center gap-0.5", |
| 8849 |
href: "https://wpyatra.com/what-we-collect/", |
| 8850 |
target: "_blank", |
| 8851 |
rel: "noopener noreferrer", |
| 8852 |
children: [ |
| 8853 |
__("What we collect", "yatra"), |
| 8854 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ExternalLink, { className: "w-3 h-3", "aria-hidden": true }) |
| 8855 |
] |
| 8856 |
} |
| 8857 |
) |
| 8858 |
] }) |
| 8859 |
] }), |
| 8860 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8861 |
Button, |
| 8862 |
{ |
| 8863 |
type: "button", |
| 8864 |
variant: "default", |
| 8865 |
size: "sm", |
| 8866 |
disabled: usageBusy, |
| 8867 |
onClick: async () => { |
| 8868 |
setUsageBusy(true); |
| 8869 |
try { |
| 8870 |
await postUsageTrackingSend({ |
| 8871 |
force: !usageStatus.enabled |
| 8872 |
}); |
| 8873 |
const s = await fetchUsageTrackingStatus(); |
| 8874 |
setUsageStatus(s); |
| 8875 |
showToast( |
| 8876 |
__("Sent successfully.", "yatra"), |
| 8877 |
"success" |
| 8878 |
); |
| 8879 |
} catch (err) { |
| 8880 |
showToast( |
| 8881 |
(err == null ? void 0 : err.message) || __("Send failed.", "yatra"), |
| 8882 |
"error" |
| 8883 |
); |
| 8884 |
} finally { |
| 8885 |
setUsageBusy(false); |
| 8886 |
} |
| 8887 |
}, |
| 8888 |
children: [ |
| 8889 |
/* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "w-4 h-4 mr-1" }), |
| 8890 |
__("Send now", "yatra") |
| 8891 |
] |
| 8892 |
} |
| 8893 |
) |
| 8894 |
] }) }) |
| 8895 |
] }) |
| 8896 |
] }); |
| 8897 |
default: |
| 8898 |
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400", children: __("Settings section coming soon", "yatra") }); |
| 8899 |
} |
| 8900 |
}; |
| 8901 |
if (isLoading) { |
| 8902 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 8903 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [ |
| 8904 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 8905 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-8 w-48 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 8906 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-96 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 8907 |
] }), |
| 8908 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-32 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 8909 |
] }), |
| 8910 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-4 gap-3", children: [ |
| 8911 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "lg:col-span-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "p-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx("nav", { className: "space-y-1 p-2", children: [...Array(12)].map((_, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8912 |
"div", |
| 8913 |
{ |
| 8914 |
className: "w-full flex items-center gap-3 px-3 py-2.5 rounded-md", |
| 8915 |
children: [ |
| 8916 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-4 h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 8917 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-24 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 8918 |
] |
| 8919 |
}, |
| 8920 |
`skeleton-nav-${index}` |
| 8921 |
)) }) }) }) }), |
| 8922 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "lg:col-span-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 8923 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 8924 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-4 h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 8925 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-5 w-32 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 8926 |
] }) }), |
| 8927 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "pb-4 space-y-4", children: [ |
| 8928 |
[...Array(6)].map((_, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 8929 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-24 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 8930 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 8931 |
] }, `skeleton-field-${index}`)), |
| 8932 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 gap-4", children: [...Array(4)].map((_, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 8933 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 8934 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 8935 |
] }, `skeleton-grid-${index}`)) }) |
| 8936 |
] }) |
| 8937 |
] }) }) |
| 8938 |
] }) |
| 8939 |
] }); |
| 8940 |
} |
| 8941 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 8942 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8943 |
PageHeader, |
| 8944 |
{ |
| 8945 |
title: __("Settings", "yatra"), |
| 8946 |
description: __( |
| 8947 |
"Configure your travel booking plugin settings", |
| 8948 |
"yatra" |
| 8949 |
), |
| 8950 |
actions: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8951 |
Button, |
| 8952 |
{ |
| 8953 |
onClick: handleSave, |
| 8954 |
disabled: isSaving || !formData, |
| 8955 |
className: "flex items-center gap-2", |
| 8956 |
children: isSaving ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 8957 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin" }), |
| 8958 |
__("Saving...", "yatra") |
| 8959 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 8960 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Save, { className: "w-4 h-4" }), |
| 8961 |
__("Save Settings", "yatra") |
| 8962 |
] }) |
| 8963 |
} |
| 8964 |
) |
| 8965 |
} |
| 8966 |
), |
| 8967 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ConditionalRender, { capability: "yatra_manage_settings", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-4 gap-3", children: [ |
| 8968 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "lg:col-span-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "p-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx("nav", { className: "space-y-1 p-2", children: settingsSections.map((section) => { |
| 8969 |
const Icon = section.icon; |
| 8970 |
const isViewing = viewingSection === section.id; |
| 8971 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 8972 |
"button", |
| 8973 |
{ |
| 8974 |
onClick: () => setViewingSection(section.id), |
| 8975 |
className: `w-full flex items-center gap-3 px-3 py-2.5 rounded-md text-sm font-medium transition-colors ${isViewing ? "bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-400" : "text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700"}`, |
| 8976 |
children: [ |
| 8977 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { className: "w-4 h-4" }), |
| 8978 |
section.label |
| 8979 |
] |
| 8980 |
}, |
| 8981 |
section.id |
| 8982 |
); |
| 8983 |
}) }) }) }) }), |
| 8984 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "lg:col-span-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 8985 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base flex items-center gap-2", children: (() => { |
| 8986 |
const section = settingsSections.find( |
| 8987 |
(s) => s.id === viewingSection |
| 8988 |
); |
| 8989 |
const Icon = (section == null ? void 0 : section.icon) || Settings$1; |
| 8990 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 8991 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { className: "w-4 h-4" }), |
| 8992 |
(section == null ? void 0 : section.label) || __("Settings", "yatra") |
| 8993 |
] }); |
| 8994 |
})() }) }), |
| 8995 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "pb-4", children: renderSettingsContent() }), |
| 8996 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardFooter, { className: "flex justify-end pt-4 border-t border-gray-100 dark:border-gray-700/50", children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 8997 |
Button, |
| 8998 |
{ |
| 8999 |
onClick: handleSave, |
| 9000 |
disabled: isSaving || !formData, |
| 9001 |
className: "flex items-center gap-2", |
| 9002 |
children: isSaving ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 9003 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin" }), |
| 9004 |
__("Saving...", "yatra") |
| 9005 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 9006 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Save, { className: "w-4 h-4" }), |
| 9007 |
__("Save Settings", "yatra") |
| 9008 |
] }) |
| 9009 |
} |
| 9010 |
) }) |
| 9011 |
] }) }) |
| 9012 |
] }) }), |
| 9013 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 9014 |
PremiumUpgradeDialog, |
| 9015 |
{ |
| 9016 |
open: showPremiumDialog, |
| 9017 |
onClose: () => setShowPremiumDialog(false), |
| 9018 |
moduleName: selectedPremiumGateway, |
| 9019 |
moduleDescription: `Unlock ${selectedPremiumGateway} payment gateway to accept payments from your customers. This premium gateway provides secure payment processing with advanced features.`, |
| 9020 |
purchaseUrl: ((_b = window.yatraAdmin) == null ? void 0 : _b.pricingUrl) || "https://wpyatra.com/pricing" |
| 9021 |
} |
| 9022 |
) |
| 9023 |
] }); |
| 9024 |
}; |
| 9025 |
export { |
| 9026 |
Settings as default |
| 9027 |
}; |
| 9028 |
//# sourceMappingURL=Settings-BCwXvDOi.js.map |
| 9029 |
|