| 1 |
import { t as useQueryClient, r as reactExports, u as useQuery, v as useMutation, j as jsxRuntimeExports, z as ArrowLeft, aF as Info, U as Users, aw as Plus, aN as Trash2, D as Loader2, aV as Save } from "./react-vendor-xzSqHjRF.js"; |
| 2 |
import { u as useToast, h as getCurrencySymbol, n as normalizeCurrencyPosition, r as readYatraCurrencyPositionFromWindow, _ as __, I as Input, t as toDateValue, a as apiClient } from "./index-CbMRo6lO.js"; |
| 3 |
import { u as usePermissions, C as Card, d as CardContent, f as CardHeader, P as PageHeader, B as Button, r as ConditionalRender, g as CardTitle, H as HelpText, S as Select, D as DatePicker, t as PremiumUpgradeDialog } from "../../admin/dist/js/app.js"; |
| 4 |
import { A as ApplicableTripSelector } from "./ApplicableTripSelector-BYZjxt18.js"; |
| 5 |
const DiscountForm = () => { |
| 6 |
var _a; |
| 7 |
const queryClient = useQueryClient(); |
| 8 |
const { can } = usePermissions(); |
| 9 |
const { showToast } = useToast(); |
| 10 |
const currencySymbol = getCurrencySymbol( |
| 11 |
((_a = window == null ? void 0 : window.yatraAdmin) == null ? void 0 : _a.currency) || "USD" |
| 12 |
); |
| 13 |
const currencyOnRight = (() => { |
| 14 |
const pos = normalizeCurrencyPosition(readYatraCurrencyPositionFromWindow()); |
| 15 |
return pos === "right" || pos === "right_space"; |
| 16 |
})(); |
| 17 |
const currencyPad = currencyOnRight ? currencySymbol.length > 1 ? "pr-10" : "pr-7" : currencySymbol.length > 1 ? "pl-10" : "pl-7"; |
| 18 |
const [showPremiumModal, setShowPremiumModal] = reactExports.useState(false); |
| 19 |
const getInitialState = () => { |
| 20 |
const params = new URLSearchParams(window.location.search); |
| 21 |
const urlDiscountMode = params.get("discount_mode") || "both"; |
| 22 |
const isGroupOnly = urlDiscountMode === "group"; |
| 23 |
return { |
| 24 |
code: "", |
| 25 |
description: "", |
| 26 |
type: "percentage", |
| 27 |
amount: isGroupOnly ? "0" : "", |
| 28 |
max_discount_amount: "", |
| 29 |
usage_limit: "0", |
| 30 |
usage_limit_per_customer: "0", |
| 31 |
valid_from: "", |
| 32 |
expiry_date: "", |
| 33 |
status: "draft", |
| 34 |
applicable_to: "all", |
| 35 |
trip_ids: [], |
| 36 |
min_amount: "", |
| 37 |
first_time_customer_only: false, |
| 38 |
is_group_discount: isGroupOnly, |
| 39 |
discount_mode: urlDiscountMode, |
| 40 |
group_discount_mode: "total", |
| 41 |
group_discount_ranges: [ |
| 42 |
{ |
| 43 |
id: String(Date.now()), |
| 44 |
min_group_size: "", |
| 45 |
max_group_size: "", |
| 46 |
discount_type: "percentage", |
| 47 |
discount_amount: "", |
| 48 |
categories: [] |
| 49 |
} |
| 50 |
], |
| 51 |
category_discounts: [] |
| 52 |
}; |
| 53 |
}; |
| 54 |
const [formData, setFormData] = reactExports.useState(getInitialState); |
| 55 |
const [errors, setErrors] = reactExports.useState({}); |
| 56 |
const [isSubmitting, setIsSubmitting] = reactExports.useState(false); |
| 57 |
const [showCategoryDropdown, setShowCategoryDropdown] = reactExports.useState(false); |
| 58 |
const action = reactExports.useMemo(() => { |
| 59 |
const params = new URLSearchParams(window.location.search); |
| 60 |
return params.get("action") || "create"; |
| 61 |
}, []); |
| 62 |
const discountId = reactExports.useMemo(() => { |
| 63 |
const params = new URLSearchParams(window.location.search); |
| 64 |
return params.get("id") ? parseInt(params.get("id") || "0") : null; |
| 65 |
}, []); |
| 66 |
const duplicateId = reactExports.useMemo(() => { |
| 67 |
const params = new URLSearchParams(window.location.search); |
| 68 |
return params.get("duplicate") ? parseInt(params.get("duplicate") || "0") : null; |
| 69 |
}, []); |
| 70 |
const discountMode = reactExports.useMemo(() => { |
| 71 |
const params = new URLSearchParams(window.location.search); |
| 72 |
return params.get("discount_mode") || "both"; |
| 73 |
}, []); |
| 74 |
const isEditMode = action === "edit" && discountId !== null; |
| 75 |
const isDuplicateMode = action === "create" && duplicateId !== null; |
| 76 |
const isGroupOnlyMode = discountMode === "group"; |
| 77 |
const isPromoOnlyMode = discountMode === "promo"; |
| 78 |
const effectiveDiscountMode = isEditMode ? formData.discount_mode : discountMode; |
| 79 |
const isEffectiveGroupOnly = effectiveDiscountMode === "group"; |
| 80 |
const isEffectivePromoOnly = effectiveDiscountMode === "promo"; |
| 81 |
const { data: discountData, isLoading: isLoadingDiscount } = useQuery({ |
| 82 |
queryKey: ["discount", discountId || duplicateId], |
| 83 |
queryFn: async () => { |
| 84 |
const id = discountId || duplicateId; |
| 85 |
if (!id) return null; |
| 86 |
try { |
| 87 |
const response = await apiClient.get(`/discounts/${id}`); |
| 88 |
return response; |
| 89 |
} catch (error) { |
| 90 |
showToast( |
| 91 |
(error == null ? void 0 : error.message) || __("Failed to load discount", "yatra"), |
| 92 |
"error" |
| 93 |
); |
| 94 |
throw error; |
| 95 |
} |
| 96 |
}, |
| 97 |
enabled: (isEditMode || isDuplicateMode) && can("yatra_manage_discounts") |
| 98 |
}); |
| 99 |
reactExports.useEffect(() => { |
| 100 |
var _a2, _b, _c, _d, _e, _f, _g, _h, _i; |
| 101 |
if (discountData && (isEditMode || isDuplicateMode)) { |
| 102 |
setFormData({ |
| 103 |
code: isDuplicateMode ? `${discountData.code}_COPY` : discountData.code || "", |
| 104 |
description: discountData.description || "", |
| 105 |
type: discountData.type || "percentage", |
| 106 |
amount: ((_a2 = discountData.amount) == null ? void 0 : _a2.toString()) || "", |
| 107 |
max_discount_amount: ((_b = discountData.max_discount_amount) == null ? void 0 : _b.toString()) || "", |
| 108 |
usage_limit: ((_c = discountData.usage_limit) == null ? void 0 : _c.toString()) || "0", |
| 109 |
usage_limit_per_customer: ((_d = discountData.usage_limit_per_customer) == null ? void 0 : _d.toString()) || "0", |
| 110 |
valid_from: discountData.valid_from || "", |
| 111 |
expiry_date: discountData.expiry_date || "", |
| 112 |
status: isDuplicateMode ? "draft" : discountData.status || "draft", |
| 113 |
applicable_to: discountData.applicable_to || "all", |
| 114 |
trip_ids: discountData.trip_ids || [], |
| 115 |
min_amount: ((_e = discountData.min_amount) == null ? void 0 : _e.toString()) || "", |
| 116 |
first_time_customer_only: discountData.first_time_customer_only || false, |
| 117 |
is_group_discount: discountData.is_group_discount || false, |
| 118 |
discount_mode: discountData.discount_mode || "both", |
| 119 |
group_discount_mode: discountData.group_discount_mode || "total", |
| 120 |
group_discount_ranges: Array.isArray(discountData.group_discount_ranges) && discountData.group_discount_ranges.length ? discountData.group_discount_ranges : [ |
| 121 |
{ |
| 122 |
id: String(Date.now()), |
| 123 |
min_group_size: ((_f = discountData.min_group_size) == null ? void 0 : _f.toString()) || "", |
| 124 |
max_group_size: ((_g = discountData.max_group_size) == null ? void 0 : _g.toString()) || "", |
| 125 |
discount_type: discountData.group_discount_type || "percentage", |
| 126 |
discount_amount: ((_h = discountData.group_discount_amount) == null ? void 0 : _h.toString()) || "", |
| 127 |
categories: [] |
| 128 |
} |
| 129 |
], |
| 130 |
category_discounts: Array.isArray(discountData.category_discounts) && ((_i = discountData.category_discounts) == null ? void 0 : _i.length) ? discountData.category_discounts : [] |
| 131 |
}); |
| 132 |
} |
| 133 |
}, [discountData, isEditMode, isDuplicateMode]); |
| 134 |
reactExports.useEffect(() => { |
| 135 |
if (!isEditMode && !isDuplicateMode && !discountData) { |
| 136 |
if (isGroupOnlyMode) { |
| 137 |
setFormData((prev) => ({ |
| 138 |
...prev, |
| 139 |
is_group_discount: true, |
| 140 |
discount_mode: "group", |
| 141 |
amount: "0", |
| 142 |
type: "percentage" |
| 143 |
})); |
| 144 |
} else if (isPromoOnlyMode) { |
| 145 |
setFormData((prev) => ({ |
| 146 |
...prev, |
| 147 |
is_group_discount: false, |
| 148 |
discount_mode: "promo" |
| 149 |
})); |
| 150 |
} else { |
| 151 |
setFormData((prev) => ({ |
| 152 |
...prev, |
| 153 |
discount_mode: "both" |
| 154 |
})); |
| 155 |
} |
| 156 |
} |
| 157 |
}, [ |
| 158 |
isGroupOnlyMode, |
| 159 |
isPromoOnlyMode, |
| 160 |
isEditMode, |
| 161 |
isDuplicateMode, |
| 162 |
discountData |
| 163 |
]); |
| 164 |
const handleFieldChange = (field, value) => { |
| 165 |
setFormData((prev) => ({ ...prev, [field]: value })); |
| 166 |
if (errors[field]) { |
| 167 |
setErrors((prev) => ({ ...prev, [field]: "" })); |
| 168 |
} |
| 169 |
if (field === "group_discount_mode") { |
| 170 |
if (value === "category_based") { |
| 171 |
setFormData((prev) => ({ |
| 172 |
...prev, |
| 173 |
group_discount_mode: "category_based", |
| 174 |
group_discount_ranges: [], |
| 175 |
category_discounts: [] |
| 176 |
// Ensure empty categories array |
| 177 |
})); |
| 178 |
} else { |
| 179 |
setFormData((prev) => ({ |
| 180 |
...prev, |
| 181 |
group_discount_mode: "total", |
| 182 |
group_discount_ranges: [ |
| 183 |
{ |
| 184 |
id: String(Date.now()), |
| 185 |
min_group_size: "", |
| 186 |
max_group_size: "", |
| 187 |
discount_type: "percentage", |
| 188 |
discount_amount: "", |
| 189 |
categories: [] |
| 190 |
} |
| 191 |
], |
| 192 |
category_discounts: [] |
| 193 |
// Ensure empty categories array |
| 194 |
})); |
| 195 |
} |
| 196 |
} |
| 197 |
}; |
| 198 |
const handleGroupDiscountToggle = (checked) => { |
| 199 |
handleFieldChange("is_group_discount", checked); |
| 200 |
}; |
| 201 |
const travelerCategoriesQuery = useQuery({ |
| 202 |
queryKey: ["traveler-categories"], |
| 203 |
queryFn: async () => { |
| 204 |
var _a2; |
| 205 |
try { |
| 206 |
const response = await apiClient.get("/traveler-categories", { |
| 207 |
params: { |
| 208 |
per_page: 100, |
| 209 |
status: "publish" |
| 210 |
} |
| 211 |
}); |
| 212 |
const categories = ((_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.data) || (response == null ? void 0 : response.data) || response || []; |
| 213 |
return Array.isArray(categories) ? categories : []; |
| 214 |
} catch (error) { |
| 215 |
console.error("Failed to load traveler categories:", error); |
| 216 |
return []; |
| 217 |
} |
| 218 |
}, |
| 219 |
staleTime: 5 * 60 * 1e3 |
| 220 |
}); |
| 221 |
const travelerCategoryOptions = reactExports.useMemo(() => { |
| 222 |
const items = travelerCategoriesQuery.data || []; |
| 223 |
return items.filter( |
| 224 |
(c) => !!c && (typeof c.id === "number" || typeof c.id === "string") && (c.status === "publish" || c.status === "active") |
| 225 |
).map((c) => ({ |
| 226 |
value: String(c.id), |
| 227 |
label: c.label || c.slug || String(c.id), |
| 228 |
description: c.description || "", |
| 229 |
age_min: c.age_min, |
| 230 |
age_max: c.age_max, |
| 231 |
pricing_mode: c.pricing_mode || "per_person" |
| 232 |
})); |
| 233 |
}, [travelerCategoriesQuery.data]); |
| 234 |
const addRange = () => { |
| 235 |
setFormData((prev) => ({ |
| 236 |
...prev, |
| 237 |
group_discount_ranges: [ |
| 238 |
...prev.group_discount_ranges, |
| 239 |
{ |
| 240 |
id: String(Date.now() + Math.random()), |
| 241 |
min_group_size: "", |
| 242 |
max_group_size: "", |
| 243 |
discount_type: "percentage", |
| 244 |
discount_amount: "", |
| 245 |
categories: [] |
| 246 |
} |
| 247 |
] |
| 248 |
})); |
| 249 |
}; |
| 250 |
const removeRange = (rangeId) => { |
| 251 |
setFormData((prev) => ({ |
| 252 |
...prev, |
| 253 |
group_discount_ranges: prev.group_discount_ranges.filter( |
| 254 |
(r) => r.id !== rangeId |
| 255 |
) |
| 256 |
})); |
| 257 |
}; |
| 258 |
const updateRange = (rangeId, patch) => { |
| 259 |
setFormData((prev) => ({ |
| 260 |
...prev, |
| 261 |
group_discount_ranges: prev.group_discount_ranges.map( |
| 262 |
(r) => r.id === rangeId ? { ...r, ...patch } : r |
| 263 |
) |
| 264 |
})); |
| 265 |
}; |
| 266 |
const addTravelerCategory = () => { |
| 267 |
setShowCategoryDropdown((prev) => !prev); |
| 268 |
}; |
| 269 |
const selectCategory = (categoryId, categoryLabel) => { |
| 270 |
setFormData((prev) => ({ |
| 271 |
...prev, |
| 272 |
category_discounts: [ |
| 273 |
...prev.category_discounts, |
| 274 |
{ |
| 275 |
traveler_category_id: categoryId, |
| 276 |
traveler_category_label: categoryLabel, |
| 277 |
ranges: [], |
| 278 |
isSelecting: false |
| 279 |
} |
| 280 |
] |
| 281 |
})); |
| 282 |
setShowCategoryDropdown(false); |
| 283 |
}; |
| 284 |
const removeTravelerCategory = (categoryIndex) => { |
| 285 |
setFormData((prev) => ({ |
| 286 |
...prev, |
| 287 |
category_discounts: prev.category_discounts.filter( |
| 288 |
(_, idx) => idx !== categoryIndex |
| 289 |
) |
| 290 |
})); |
| 291 |
}; |
| 292 |
const updateTravelerCategory = (categoryIndex, patch) => { |
| 293 |
setFormData((prev) => ({ |
| 294 |
...prev, |
| 295 |
category_discounts: prev.category_discounts.map( |
| 296 |
(cat, idx) => idx === categoryIndex ? { ...cat, ...patch } : cat |
| 297 |
) |
| 298 |
})); |
| 299 |
}; |
| 300 |
const addRangeToCategory = (categoryIndex) => { |
| 301 |
setFormData((prev) => ({ |
| 302 |
...prev, |
| 303 |
category_discounts: prev.category_discounts.map((cat, idx) => { |
| 304 |
if (idx !== categoryIndex) return cat; |
| 305 |
return { |
| 306 |
...cat, |
| 307 |
ranges: [ |
| 308 |
...cat.ranges, |
| 309 |
{ |
| 310 |
id: String(Date.now() + Math.random()), |
| 311 |
min_group_size: "", |
| 312 |
max_group_size: "", |
| 313 |
discount_type: "percentage", |
| 314 |
discount_amount: "" |
| 315 |
} |
| 316 |
] |
| 317 |
}; |
| 318 |
}) |
| 319 |
})); |
| 320 |
}; |
| 321 |
const removeRangeFromCategory = (categoryIndex, rangeId) => { |
| 322 |
setFormData((prev) => ({ |
| 323 |
...prev, |
| 324 |
category_discounts: prev.category_discounts.map((cat, idx) => { |
| 325 |
if (idx !== categoryIndex) return cat; |
| 326 |
return { ...cat, ranges: cat.ranges.filter((r) => r.id !== rangeId) }; |
| 327 |
}) |
| 328 |
})); |
| 329 |
}; |
| 330 |
const updateRangeInCategory = (categoryIndex, rangeId, patch) => { |
| 331 |
setFormData((prev) => ({ |
| 332 |
...prev, |
| 333 |
category_discounts: prev.category_discounts.map((cat, idx) => { |
| 334 |
if (idx !== categoryIndex) return cat; |
| 335 |
const ranges = cat.ranges.map( |
| 336 |
(r) => r.id === rangeId ? { ...r, ...patch } : r |
| 337 |
); |
| 338 |
return { ...cat, ranges }; |
| 339 |
}) |
| 340 |
})); |
| 341 |
}; |
| 342 |
const validateForm = () => { |
| 343 |
const newErrors = {}; |
| 344 |
if (!formData.code.trim()) { |
| 345 |
newErrors.code = isEffectiveGroupOnly ? __("Internal name is required", "yatra") : __("Coupon code is required", "yatra"); |
| 346 |
} else if (!/^[A-Z0-9_-]+$/.test(formData.code)) { |
| 347 |
newErrors.code = __( |
| 348 |
"Only uppercase letters, numbers, hyphens, and underscores are allowed", |
| 349 |
"yatra" |
| 350 |
); |
| 351 |
} |
| 352 |
if (!isEffectiveGroupOnly) { |
| 353 |
if (!formData.amount.trim()) { |
| 354 |
newErrors.amount = __("Discount amount is required", "yatra"); |
| 355 |
} else { |
| 356 |
const amount = parseFloat(formData.amount); |
| 357 |
if (isNaN(amount) || amount < 0) { |
| 358 |
newErrors.amount = __( |
| 359 |
"Discount amount must be a positive number", |
| 360 |
"yatra" |
| 361 |
); |
| 362 |
} else if (formData.type === "percentage" && amount > 100) { |
| 363 |
newErrors.amount = __( |
| 364 |
"Percentage discount cannot exceed 100%", |
| 365 |
"yatra" |
| 366 |
); |
| 367 |
} |
| 368 |
} |
| 369 |
if (formData.type === "percentage" && formData.max_discount_amount && formData.max_discount_amount.trim()) { |
| 370 |
const maxAmount = parseFloat(formData.max_discount_amount); |
| 371 |
if (isNaN(maxAmount) || maxAmount <= 0) { |
| 372 |
newErrors.max_discount_amount = __( |
| 373 |
"Maximum discount amount must be a positive number", |
| 374 |
"yatra" |
| 375 |
); |
| 376 |
} |
| 377 |
} |
| 378 |
} |
| 379 |
if (formData.usage_limit && formData.usage_limit !== "0") { |
| 380 |
const limit = parseInt(formData.usage_limit); |
| 381 |
if (isNaN(limit) || limit < 0) { |
| 382 |
newErrors.usage_limit = __( |
| 383 |
"Usage limit must be a positive number or 0 for unlimited", |
| 384 |
"yatra" |
| 385 |
); |
| 386 |
} |
| 387 |
} |
| 388 |
if (formData.usage_limit_per_customer && formData.usage_limit_per_customer !== "0") { |
| 389 |
const limit = parseInt(formData.usage_limit_per_customer); |
| 390 |
if (isNaN(limit) || limit < 0) { |
| 391 |
newErrors.usage_limit_per_customer = __( |
| 392 |
"Per-customer usage limit must be a positive number or 0 for unlimited", |
| 393 |
"yatra" |
| 394 |
); |
| 395 |
} |
| 396 |
} |
| 397 |
const today = /* @__PURE__ */ new Date(); |
| 398 |
today.setHours(0, 0, 0, 0); |
| 399 |
if (formData.expiry_date) { |
| 400 |
const expiryDate = toDateValue(formData.expiry_date); |
| 401 |
if (expiryDate < today) { |
| 402 |
newErrors.expiry_date = __( |
| 403 |
"Expiry date cannot be in the past", |
| 404 |
"yatra" |
| 405 |
); |
| 406 |
} |
| 407 |
} |
| 408 |
if (formData.valid_from && formData.expiry_date) { |
| 409 |
const validFrom = toDateValue(formData.valid_from); |
| 410 |
const expiryDate = toDateValue(formData.expiry_date); |
| 411 |
if (expiryDate < validFrom) { |
| 412 |
newErrors.expiry_date = __( |
| 413 |
"Expiry date must be after the valid from date", |
| 414 |
"yatra" |
| 415 |
); |
| 416 |
} |
| 417 |
} |
| 418 |
if (formData.min_amount && formData.min_amount.trim()) { |
| 419 |
const minAmount = parseFloat(formData.min_amount); |
| 420 |
if (isNaN(minAmount) || minAmount < 0) { |
| 421 |
newErrors.min_amount = __( |
| 422 |
"Minimum amount must be a positive number", |
| 423 |
"yatra" |
| 424 |
); |
| 425 |
} |
| 426 |
} |
| 427 |
if (formData.is_group_discount && formData.group_discount_mode === "total") { |
| 428 |
if (!formData.group_discount_ranges || formData.group_discount_ranges.length === 0) { |
| 429 |
newErrors.group_discount_ranges = __( |
| 430 |
"At least one group discount range is required", |
| 431 |
"yatra" |
| 432 |
); |
| 433 |
} else { |
| 434 |
formData.group_discount_ranges.forEach((range, idx) => { |
| 435 |
const prefix = `group_discount_ranges_${idx}`; |
| 436 |
const min = parseInt(range.min_group_size); |
| 437 |
const max = range.max_group_size ? parseInt(range.max_group_size) : null; |
| 438 |
if (Number.isNaN(min) || min < 1) { |
| 439 |
newErrors[`${prefix}_min`] = __( |
| 440 |
"Minimum group size must be at least 1", |
| 441 |
"yatra" |
| 442 |
); |
| 443 |
} |
| 444 |
if (max !== null) { |
| 445 |
if (Number.isNaN(max) || max < 1) { |
| 446 |
newErrors[`${prefix}_max`] = __( |
| 447 |
"Maximum group size must be a positive number", |
| 448 |
"yatra" |
| 449 |
); |
| 450 |
} else if (!Number.isNaN(min) && max <= min) { |
| 451 |
newErrors[`${prefix}_max`] = __( |
| 452 |
"Maximum group size must be greater than minimum group size", |
| 453 |
"yatra" |
| 454 |
); |
| 455 |
} |
| 456 |
} |
| 457 |
const amount = range.discount_amount ? parseFloat(range.discount_amount) : NaN; |
| 458 |
if (!range.discount_type) { |
| 459 |
newErrors[`${prefix}_type`] = __( |
| 460 |
"Discount type is required", |
| 461 |
"yatra" |
| 462 |
); |
| 463 |
} |
| 464 |
if (Number.isNaN(amount) || amount <= 0) { |
| 465 |
newErrors[`${prefix}_amount`] = __( |
| 466 |
"Discount amount must be a positive number", |
| 467 |
"yatra" |
| 468 |
); |
| 469 |
} else if (range.discount_type === "percentage" && amount > 100) { |
| 470 |
newErrors[`${prefix}_amount`] = __( |
| 471 |
"Percentage discount cannot exceed 100%", |
| 472 |
"yatra" |
| 473 |
); |
| 474 |
} |
| 475 |
}); |
| 476 |
} |
| 477 |
} |
| 478 |
if (formData.is_group_discount && formData.group_discount_mode === "category_based") { |
| 479 |
if (!formData.category_discounts || formData.category_discounts.length === 0) { |
| 480 |
newErrors.category_discounts = __( |
| 481 |
"Add at least one traveler category", |
| 482 |
"yatra" |
| 483 |
); |
| 484 |
} else { |
| 485 |
formData.category_discounts.forEach((cat, catIdx) => { |
| 486 |
const catPrefix = `category_discounts_${catIdx}`; |
| 487 |
if (!cat.traveler_category_id) { |
| 488 |
newErrors[`${catPrefix}_id`] = __( |
| 489 |
"Traveler category is required", |
| 490 |
"yatra" |
| 491 |
); |
| 492 |
} |
| 493 |
if (!cat.ranges || cat.ranges.length === 0) { |
| 494 |
newErrors[`${catPrefix}_ranges`] = __( |
| 495 |
"Add at least one discount range", |
| 496 |
"yatra" |
| 497 |
); |
| 498 |
} else { |
| 499 |
cat.ranges.forEach((range, rIdx) => { |
| 500 |
const rangePrefix = `${catPrefix}_ranges_${rIdx}`; |
| 501 |
const min = parseInt(range.min_group_size); |
| 502 |
const max = range.max_group_size ? parseInt(range.max_group_size) : null; |
| 503 |
if (Number.isNaN(min) || min < 1) { |
| 504 |
newErrors[`${rangePrefix}_min`] = __( |
| 505 |
"Minimum group size must be at least 1", |
| 506 |
"yatra" |
| 507 |
); |
| 508 |
} |
| 509 |
if (max !== null) { |
| 510 |
if (Number.isNaN(max) || max < 1) { |
| 511 |
newErrors[`${rangePrefix}_max`] = __( |
| 512 |
"Maximum group size must be a positive number", |
| 513 |
"yatra" |
| 514 |
); |
| 515 |
} else if (!Number.isNaN(min) && max <= min) { |
| 516 |
newErrors[`${rangePrefix}_max`] = __( |
| 517 |
"Maximum group size must be greater than minimum group size", |
| 518 |
"yatra" |
| 519 |
); |
| 520 |
} |
| 521 |
} |
| 522 |
const amount = range.discount_amount ? parseFloat(range.discount_amount) : NaN; |
| 523 |
if (!range.discount_type) { |
| 524 |
newErrors[`${rangePrefix}_type`] = __( |
| 525 |
"Discount type is required", |
| 526 |
"yatra" |
| 527 |
); |
| 528 |
} |
| 529 |
if (Number.isNaN(amount) || amount <= 0) { |
| 530 |
newErrors[`${rangePrefix}_amount`] = __( |
| 531 |
"Discount amount must be a positive number", |
| 532 |
"yatra" |
| 533 |
); |
| 534 |
} else if (range.discount_type === "percentage" && amount > 100) { |
| 535 |
newErrors[`${rangePrefix}_amount`] = __( |
| 536 |
"Percentage discount cannot exceed 100%", |
| 537 |
"yatra" |
| 538 |
); |
| 539 |
} |
| 540 |
}); |
| 541 |
} |
| 542 |
}); |
| 543 |
} |
| 544 |
} |
| 545 |
setErrors(newErrors); |
| 546 |
if (Object.keys(newErrors).length > 0) { |
| 547 |
const firstErrorKey = Object.keys(newErrors)[0]; |
| 548 |
const errorElement = document.querySelector( |
| 549 |
`[name="${firstErrorKey}"], #${firstErrorKey}, [data-field="${firstErrorKey}"]` |
| 550 |
); |
| 551 |
if (errorElement) { |
| 552 |
errorElement.scrollIntoView({ behavior: "smooth", block: "center" }); |
| 553 |
if (errorElement instanceof HTMLInputElement || errorElement instanceof HTMLSelectElement || errorElement instanceof HTMLTextAreaElement) { |
| 554 |
setTimeout(() => errorElement.focus(), 300); |
| 555 |
} |
| 556 |
} else { |
| 557 |
const errorMessage = document.querySelector( |
| 558 |
".text-red-500, .text-red-600" |
| 559 |
); |
| 560 |
if (errorMessage) { |
| 561 |
errorMessage.scrollIntoView({ behavior: "smooth", block: "center" }); |
| 562 |
} |
| 563 |
} |
| 564 |
} |
| 565 |
return Object.keys(newErrors).length === 0; |
| 566 |
}; |
| 567 |
const saveMutation = useMutation({ |
| 568 |
mutationFn: async (data) => { |
| 569 |
const payload = { |
| 570 |
code: data.code.trim().toUpperCase(), |
| 571 |
description: data.description.trim(), |
| 572 |
type: data.type, |
| 573 |
amount: parseFloat(data.amount) || 0, |
| 574 |
max_discount_amount: data.max_discount_amount ? parseFloat(data.max_discount_amount) : null, |
| 575 |
usage_limit: parseInt(data.usage_limit) || 0, |
| 576 |
usage_limit_per_customer: parseInt(data.usage_limit_per_customer) || 0, |
| 577 |
valid_from: data.valid_from || null, |
| 578 |
expiry_date: data.expiry_date || null, |
| 579 |
status: data.status, |
| 580 |
applicable_to: data.applicable_to, |
| 581 |
trip_ids: data.applicable_to === "specific_trips" ? data.trip_ids : [], |
| 582 |
min_amount: data.min_amount ? parseFloat(data.min_amount) : null, |
| 583 |
first_time_customer_only: data.first_time_customer_only, |
| 584 |
is_group_discount: data.is_group_discount, |
| 585 |
discount_mode: data.discount_mode, |
| 586 |
group_discount_mode: data.is_group_discount ? data.group_discount_mode : null, |
| 587 |
group_discount_ranges: data.is_group_discount ? data.group_discount_ranges : [], |
| 588 |
category_discounts: data.is_group_discount && data.group_discount_mode === "category_based" ? data.category_discounts.map((cat) => ({ |
| 589 |
traveler_category_id: cat.traveler_category_id, |
| 590 |
traveler_category_label: cat.traveler_category_label, |
| 591 |
ranges: cat.ranges.map((range) => ({ |
| 592 |
id: range.id, |
| 593 |
min_group_size: range.min_group_size, |
| 594 |
max_group_size: range.max_group_size, |
| 595 |
discount_type: range.discount_type, |
| 596 |
discount_amount: range.discount_amount |
| 597 |
})) |
| 598 |
})) : [] |
| 599 |
}; |
| 600 |
if (isEditMode && discountId) { |
| 601 |
return await apiClient.put(`/discounts/${discountId}`, payload); |
| 602 |
} else { |
| 603 |
return await apiClient.post("/discounts", payload); |
| 604 |
} |
| 605 |
}, |
| 606 |
onSuccess: () => { |
| 607 |
queryClient.invalidateQueries({ queryKey: ["discounts"] }); |
| 608 |
queryClient.invalidateQueries({ |
| 609 |
queryKey: ["discount", discountId || duplicateId] |
| 610 |
}); |
| 611 |
showToast( |
| 612 |
isEditMode ? __("Discount updated successfully", "yatra") : __("Discount created successfully", "yatra"), |
| 613 |
"success" |
| 614 |
); |
| 615 |
if (!isEditMode) { |
| 616 |
setTimeout(() => { |
| 617 |
var _a2; |
| 618 |
window.location.href = `${((_a2 = window.yatraAdmin) == null ? void 0 : _a2.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=discounts`; |
| 619 |
}, 1e3); |
| 620 |
} |
| 621 |
setIsSubmitting(false); |
| 622 |
}, |
| 623 |
onError: (error) => { |
| 624 |
const errorMessage = (error == null ? void 0 : error.message) || __("An error occurred while saving the discount", "yatra"); |
| 625 |
showToast(errorMessage, "error"); |
| 626 |
setIsSubmitting(false); |
| 627 |
} |
| 628 |
}); |
| 629 |
const handleSubmit = async (e) => { |
| 630 |
e.preventDefault(); |
| 631 |
if (!validateForm()) { |
| 632 |
return; |
| 633 |
} |
| 634 |
setIsSubmitting(true); |
| 635 |
try { |
| 636 |
await saveMutation.mutateAsync(formData); |
| 637 |
} catch (error) { |
| 638 |
} finally { |
| 639 |
setIsSubmitting(false); |
| 640 |
} |
| 641 |
}; |
| 642 |
const handleBack = () => { |
| 643 |
var _a2; |
| 644 |
window.location.href = `${((_a2 = window.yatraAdmin) == null ? void 0 : _a2.siteUrl) || ""}/wp-admin/admin.php?page=yatra&subpage=discounts`; |
| 645 |
}; |
| 646 |
if (isLoadingDiscount) { |
| 647 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 648 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [ |
| 649 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 650 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-8 w-64 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 651 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-48 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 652 |
] }), |
| 653 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-24 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 654 |
] }), |
| 655 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-3", children: [ |
| 656 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-5 h-5 bg-blue-200 dark:bg-blue-700 rounded animate-pulse" }), |
| 657 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 space-y-2", children: [ |
| 658 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-40 bg-blue-200 dark:bg-blue-700 rounded animate-pulse" }), |
| 659 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [ |
| 660 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-3 w-full bg-blue-100 dark:bg-blue-800 rounded animate-pulse" }), |
| 661 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-3 w-3/4 bg-blue-100 dark:bg-blue-800 rounded animate-pulse" }) |
| 662 |
] }) |
| 663 |
] }) |
| 664 |
] }) }) }), |
| 665 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-3 gap-3", children: [ |
| 666 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "lg:col-span-2 space-y-3", children: [ |
| 667 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 668 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-5 w-40 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) }), |
| 669 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-4", children: [ |
| 670 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 671 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-24 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 672 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 673 |
] }), |
| 674 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 675 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 676 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-20 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 677 |
] }), |
| 678 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [ |
| 679 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 680 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-24 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 681 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 682 |
] }), |
| 683 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 684 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-28 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 685 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 686 |
] }) |
| 687 |
] }) |
| 688 |
] }) |
| 689 |
] }), |
| 690 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 691 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-5 w-32 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) }), |
| 692 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-4", children: [ |
| 693 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [ |
| 694 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 695 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-24 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 696 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 697 |
] }), |
| 698 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 699 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-32 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 700 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 701 |
] }) |
| 702 |
] }), |
| 703 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [ |
| 704 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 705 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 706 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 707 |
] }), |
| 708 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 709 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-24 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 710 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 711 |
] }) |
| 712 |
] }) |
| 713 |
] }) |
| 714 |
] }), |
| 715 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 716 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-5 w-44 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) }), |
| 717 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "space-y-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [ |
| 718 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-5 w-5 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }), |
| 719 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-4 w-40 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) |
| 720 |
] }) }) |
| 721 |
] }) |
| 722 |
] }), |
| 723 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 724 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 725 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-5 w-16 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) }), |
| 726 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) }) |
| 727 |
] }), |
| 728 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Card, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-10 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse" }) }) }) |
| 729 |
] }) |
| 730 |
] }) |
| 731 |
] }); |
| 732 |
} |
| 733 |
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 734 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 735 |
PageHeader, |
| 736 |
{ |
| 737 |
title: isEditMode ? __("Edit Discount Coupon", "yatra") : __("Add New Discount Coupon", "yatra"), |
| 738 |
description: isEditMode ? __("Update discount coupon details", "yatra") : __("Create a new discount coupon for your trips", "yatra"), |
| 739 |
actions: /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 740 |
Button, |
| 741 |
{ |
| 742 |
variant: "outline", |
| 743 |
onClick: handleBack, |
| 744 |
className: "flex items-center gap-2", |
| 745 |
children: [ |
| 746 |
/* @__PURE__ */ jsxRuntimeExports.jsx(ArrowLeft, { className: "w-4 h-4" }), |
| 747 |
__("Back", "yatra") |
| 748 |
] |
| 749 |
} |
| 750 |
) |
| 751 |
} |
| 752 |
), |
| 753 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(ConditionalRender, { capability: "yatra_manage_discounts", children: [ |
| 754 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-3", children: [ |
| 755 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-5 h-5 text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5" }), |
| 756 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 757 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-blue-900 dark:text-blue-100 mb-2", children: __("How Discounts Work", "yatra") }), |
| 758 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("ul", { className: "text-xs text-blue-800 dark:text-blue-200 space-y-1.5", children: [ |
| 759 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [ |
| 760 |
"• ", |
| 761 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("strong", { children: [ |
| 762 |
__("Regular Discount", "yatra"), |
| 763 |
":" |
| 764 |
] }), |
| 765 |
" ", |
| 766 |
__( |
| 767 |
"Applied first to the booking total (trip price × travelers)", |
| 768 |
"yatra" |
| 769 |
) |
| 770 |
] }), |
| 771 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [ |
| 772 |
"• ", |
| 773 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("strong", { children: [ |
| 774 |
__("Group Discount", "yatra"), |
| 775 |
":" |
| 776 |
] }), |
| 777 |
" ", |
| 778 |
__( |
| 779 |
"Additional discount applied AFTER regular discount when group size requirement is met", |
| 780 |
"yatra" |
| 781 |
) |
| 782 |
] }), |
| 783 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [ |
| 784 |
"• ", |
| 785 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("strong", { children: [ |
| 786 |
__("Maximum Cap", "yatra"), |
| 787 |
":" |
| 788 |
] }), |
| 789 |
" ", |
| 790 |
__( |
| 791 |
"For percentage discounts, you can set a maximum dollar amount to cap the discount", |
| 792 |
"yatra" |
| 793 |
) |
| 794 |
] }), |
| 795 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [ |
| 796 |
"• ", |
| 797 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("strong", { children: [ |
| 798 |
__("Example", "yatra"), |
| 799 |
":" |
| 800 |
] }), |
| 801 |
" ", |
| 802 |
__( |
| 803 |
"$1000 booking, 15% regular discount ($150 off), then 10% group discount on $850 = $85 more off. Final: $765", |
| 804 |
"yatra" |
| 805 |
) |
| 806 |
] }) |
| 807 |
] }) |
| 808 |
] }) |
| 809 |
] }) }) }), |
| 810 |
/* @__PURE__ */ jsxRuntimeExports.jsx("form", { onSubmit: handleSubmit, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-3 gap-3", children: [ |
| 811 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "lg:col-span-2 space-y-3", children: [ |
| 812 |
(() => { |
| 813 |
const currentMode = isEditMode ? formData.discount_mode : discountMode; |
| 814 |
const isGroupOnly = currentMode === "group"; |
| 815 |
const isPromoOnly = currentMode === "promo"; |
| 816 |
return /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 817 |
"div", |
| 818 |
{ |
| 819 |
className: `p-3 rounded-lg border-2 mb-3 ${isGroupOnly ? "bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800" : isPromoOnly ? "bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800" : "bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-800"}`, |
| 820 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 821 |
isGroupOnly ? /* @__PURE__ */ jsxRuntimeExports.jsx(Users, { className: "w-5 h-5 text-green-600 dark:text-green-400" }) : isPromoOnly ? /* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-5 h-5 text-blue-600 dark:text-blue-400" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-5 h-5 text-purple-600 dark:text-purple-400" }), |
| 822 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 823 |
"span", |
| 824 |
{ |
| 825 |
className: `font-medium ${isGroupOnly ? "text-green-700 dark:text-green-300" : isPromoOnly ? "text-blue-700 dark:text-blue-300" : "text-purple-700 dark:text-purple-300"}`, |
| 826 |
children: isGroupOnly ? isEditMode ? __( |
| 827 |
"Group Discount (Auto-applies, no code needed)", |
| 828 |
"yatra" |
| 829 |
) : __( |
| 830 |
"Creating Group Discount (Auto-applies, no code needed)", |
| 831 |
"yatra" |
| 832 |
) : isPromoOnly ? isEditMode ? __("Promo Code Discount", "yatra") : __("Creating Promo Code Discount", "yatra") : isEditMode ? __("Promo Code + Group Discount", "yatra") : __( |
| 833 |
"Creating Promo Code + Group Discount", |
| 834 |
"yatra" |
| 835 |
) |
| 836 |
} |
| 837 |
) |
| 838 |
] }) |
| 839 |
} |
| 840 |
); |
| 841 |
})(), |
| 842 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 843 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: isEffectiveGroupOnly ? __("Group Discount Information", "yatra") : __("Basic Information", "yatra") }) }), |
| 844 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 845 |
!isEffectiveGroupOnly && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 846 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 847 |
"label", |
| 848 |
{ |
| 849 |
htmlFor: "code", |
| 850 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 851 |
children: [ |
| 852 |
__("Coupon Code", "yatra"), |
| 853 |
" ", |
| 854 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 855 |
] |
| 856 |
} |
| 857 |
), |
| 858 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 859 |
HelpText, |
| 860 |
{ |
| 861 |
text: __( |
| 862 |
"Enter a unique coupon code. Only uppercase letters, numbers, hyphens, and underscores are allowed.", |
| 863 |
"yatra" |
| 864 |
), |
| 865 |
className: "mb-2" |
| 866 |
} |
| 867 |
), |
| 868 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 869 |
Input, |
| 870 |
{ |
| 871 |
id: "code", |
| 872 |
name: "code", |
| 873 |
type: "text", |
| 874 |
value: formData.code, |
| 875 |
onChange: (e) => handleFieldChange( |
| 876 |
"code", |
| 877 |
e.target.value.toUpperCase() |
| 878 |
), |
| 879 |
placeholder: __("e.g., SUMMER2024", "yatra"), |
| 880 |
className: errors.code ? "border-red-500" : "", |
| 881 |
required: true |
| 882 |
} |
| 883 |
), |
| 884 |
errors.code && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 885 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 886 |
errors.code |
| 887 |
] }) |
| 888 |
] }), |
| 889 |
isEffectiveGroupOnly && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 890 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 891 |
"label", |
| 892 |
{ |
| 893 |
htmlFor: "code", |
| 894 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 895 |
children: [ |
| 896 |
__("Internal Name", "yatra"), |
| 897 |
" ", |
| 898 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 899 |
] |
| 900 |
} |
| 901 |
), |
| 902 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 903 |
HelpText, |
| 904 |
{ |
| 905 |
text: __( |
| 906 |
"Enter a unique internal name for this group discount. This is for your reference only and won't be shown to customers.", |
| 907 |
"Enter a unique internal name for this group discount. This is for your reference only and won't be shown to customers." |
| 908 |
), |
| 909 |
className: "mb-2" |
| 910 |
} |
| 911 |
), |
| 912 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 913 |
Input, |
| 914 |
{ |
| 915 |
id: "code", |
| 916 |
name: "code", |
| 917 |
type: "text", |
| 918 |
value: formData.code, |
| 919 |
onChange: (e) => handleFieldChange( |
| 920 |
"code", |
| 921 |
e.target.value.toUpperCase().replace(/\s+/g, "_") |
| 922 |
), |
| 923 |
placeholder: __("e.g., GROUP_DISCOUNT_2024", "yatra"), |
| 924 |
className: errors.code ? "border-red-500" : "", |
| 925 |
required: true |
| 926 |
} |
| 927 |
), |
| 928 |
errors.code && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 929 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 930 |
errors.code |
| 931 |
] }) |
| 932 |
] }), |
| 933 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 934 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 935 |
"label", |
| 936 |
{ |
| 937 |
htmlFor: "description", |
| 938 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 939 |
children: __("Description", "yatra") |
| 940 |
} |
| 941 |
), |
| 942 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 943 |
HelpText, |
| 944 |
{ |
| 945 |
text: __( |
| 946 |
"Optional description for this discount coupon. This helps you identify the purpose of the coupon.", |
| 947 |
"yatra" |
| 948 |
), |
| 949 |
className: "mb-2" |
| 950 |
} |
| 951 |
), |
| 952 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 953 |
"textarea", |
| 954 |
{ |
| 955 |
id: "description", |
| 956 |
value: formData.description, |
| 957 |
onChange: (e) => handleFieldChange("description", e.target.value), |
| 958 |
placeholder: __( |
| 959 |
"e.g., Summer discount for all trips", |
| 960 |
"yatra" |
| 961 |
), |
| 962 |
rows: 3, |
| 963 |
className: "flex w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm ring-offset-white placeholder:text-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:ring-offset-gray-900 dark:placeholder:text-gray-400 dark:focus-visible:ring-blue-400 resize-none" |
| 964 |
} |
| 965 |
) |
| 966 |
] }), |
| 967 |
!isEffectiveGroupOnly && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-3", children: [ |
| 968 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 969 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 970 |
"label", |
| 971 |
{ |
| 972 |
htmlFor: "type", |
| 973 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 974 |
children: [ |
| 975 |
__("Discount Type", "yatra"), |
| 976 |
" ", |
| 977 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 978 |
] |
| 979 |
} |
| 980 |
), |
| 981 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 982 |
Select, |
| 983 |
{ |
| 984 |
id: "type", |
| 985 |
name: "type", |
| 986 |
value: formData.type, |
| 987 |
onChange: (e) => handleFieldChange( |
| 988 |
"type", |
| 989 |
e.target.value |
| 990 |
), |
| 991 |
className: errors.type ? "border-red-500" : "", |
| 992 |
required: true, |
| 993 |
children: [ |
| 994 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "percentage", children: __("Percentage", "yatra") }), |
| 995 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "fixed", children: __("Fixed Amount", "yatra") }) |
| 996 |
] |
| 997 |
} |
| 998 |
), |
| 999 |
errors.type && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1000 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1001 |
errors.type |
| 1002 |
] }) |
| 1003 |
] }), |
| 1004 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1005 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1006 |
"label", |
| 1007 |
{ |
| 1008 |
htmlFor: "amount", |
| 1009 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 1010 |
children: [ |
| 1011 |
__("Discount Amount", "yatra"), |
| 1012 |
" ", |
| 1013 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 1014 |
] |
| 1015 |
} |
| 1016 |
), |
| 1017 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [ |
| 1018 |
formData.type === "percentage" ? /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1019 |
Input, |
| 1020 |
{ |
| 1021 |
id: "amount", |
| 1022 |
name: "amount", |
| 1023 |
type: "number", |
| 1024 |
min: "0", |
| 1025 |
max: "100", |
| 1026 |
step: "0.01", |
| 1027 |
value: formData.amount, |
| 1028 |
onChange: (e) => handleFieldChange("amount", e.target.value), |
| 1029 |
placeholder: __("e.g., 15", "yatra"), |
| 1030 |
className: errors.amount ? "border-red-500" : "", |
| 1031 |
required: true |
| 1032 |
} |
| 1033 |
) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [ |
| 1034 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `absolute ${currencyOnRight ? "right-3" : "left-3"} top-1/2 transform -translate-y-1/2 text-gray-500 text-sm`, children: [ |
| 1035 |
currencySymbol, |
| 1036 |
" " |
| 1037 |
] }), |
| 1038 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1039 |
Input, |
| 1040 |
{ |
| 1041 |
id: "amount", |
| 1042 |
name: "amount", |
| 1043 |
type: "number", |
| 1044 |
min: "0", |
| 1045 |
step: "0.01", |
| 1046 |
value: formData.amount, |
| 1047 |
onChange: (e) => handleFieldChange("amount", e.target.value), |
| 1048 |
placeholder: __("e.g., 50", "yatra"), |
| 1049 |
className: `${currencyPad} ${errors.amount ? "border-red-500" : ""}`, |
| 1050 |
required: true |
| 1051 |
} |
| 1052 |
) |
| 1053 |
] }), |
| 1054 |
formData.type === "percentage" && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 text-sm", children: "%" }) |
| 1055 |
] }), |
| 1056 |
errors.amount && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1057 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1058 |
errors.amount |
| 1059 |
] }) |
| 1060 |
] }) |
| 1061 |
] }), |
| 1062 |
!isEffectiveGroupOnly && formData.type === "percentage" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1063 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1064 |
"label", |
| 1065 |
{ |
| 1066 |
htmlFor: "max_discount_amount", |
| 1067 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 1068 |
children: __("Maximum Discount Amount", "yatra") |
| 1069 |
} |
| 1070 |
), |
| 1071 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1072 |
HelpText, |
| 1073 |
{ |
| 1074 |
text: __( |
| 1075 |
"Optional maximum discount cap. For example, if discount is 20% with max $500, a $5000 booking gets $500 off (not $1000).", |
| 1076 |
"yatra" |
| 1077 |
), |
| 1078 |
className: "mb-2" |
| 1079 |
} |
| 1080 |
), |
| 1081 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [ |
| 1082 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `absolute ${currencyOnRight ? "right-3" : "left-3"} top-1/2 transform -translate-y-1/2 text-gray-500 text-sm`, children: [ |
| 1083 |
currencySymbol, |
| 1084 |
" " |
| 1085 |
] }), |
| 1086 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1087 |
Input, |
| 1088 |
{ |
| 1089 |
id: "max_discount_amount", |
| 1090 |
type: "number", |
| 1091 |
min: "0", |
| 1092 |
step: "0.01", |
| 1093 |
value: formData.max_discount_amount, |
| 1094 |
onChange: (e) => handleFieldChange( |
| 1095 |
"max_discount_amount", |
| 1096 |
e.target.value |
| 1097 |
), |
| 1098 |
placeholder: __("e.g., 500 (optional)", "yatra"), |
| 1099 |
className: `${currencyPad} ${errors.max_discount_amount ? "border-red-500" : ""}` |
| 1100 |
} |
| 1101 |
) |
| 1102 |
] }), |
| 1103 |
errors.max_discount_amount && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1104 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1105 |
errors.max_discount_amount |
| 1106 |
] }) |
| 1107 |
] }) |
| 1108 |
] }) |
| 1109 |
] }), |
| 1110 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 1111 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Usage & Restrictions", "yatra") }) }), |
| 1112 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 1113 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1114 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1115 |
"label", |
| 1116 |
{ |
| 1117 |
htmlFor: "usage_limit", |
| 1118 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 1119 |
children: __("Total Usage Limit", "yatra") |
| 1120 |
} |
| 1121 |
), |
| 1122 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1123 |
HelpText, |
| 1124 |
{ |
| 1125 |
text: __( |
| 1126 |
"Maximum number of times this coupon can be used across all customers. Enter 0 for unlimited usage.", |
| 1127 |
"yatra" |
| 1128 |
), |
| 1129 |
className: "mb-2" |
| 1130 |
} |
| 1131 |
), |
| 1132 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1133 |
Input, |
| 1134 |
{ |
| 1135 |
id: "usage_limit", |
| 1136 |
type: "number", |
| 1137 |
min: "0", |
| 1138 |
value: formData.usage_limit, |
| 1139 |
onChange: (e) => handleFieldChange("usage_limit", e.target.value), |
| 1140 |
placeholder: __("0 for unlimited", "yatra"), |
| 1141 |
className: errors.usage_limit ? "border-red-500" : "" |
| 1142 |
} |
| 1143 |
), |
| 1144 |
errors.usage_limit && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1145 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1146 |
errors.usage_limit |
| 1147 |
] }) |
| 1148 |
] }), |
| 1149 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1150 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1151 |
"label", |
| 1152 |
{ |
| 1153 |
htmlFor: "usage_limit_per_customer", |
| 1154 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 1155 |
children: __("Usage Limit Per Customer", "yatra") |
| 1156 |
} |
| 1157 |
), |
| 1158 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1159 |
HelpText, |
| 1160 |
{ |
| 1161 |
text: __( |
| 1162 |
"Maximum number of times a single customer can use this coupon. Enter 0 for unlimited usage per customer.", |
| 1163 |
"yatra" |
| 1164 |
), |
| 1165 |
className: "mb-2" |
| 1166 |
} |
| 1167 |
), |
| 1168 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1169 |
Input, |
| 1170 |
{ |
| 1171 |
id: "usage_limit_per_customer", |
| 1172 |
type: "number", |
| 1173 |
min: "0", |
| 1174 |
value: formData.usage_limit_per_customer, |
| 1175 |
onChange: (e) => handleFieldChange( |
| 1176 |
"usage_limit_per_customer", |
| 1177 |
e.target.value |
| 1178 |
), |
| 1179 |
placeholder: __("0 for unlimited", "yatra"), |
| 1180 |
className: errors.usage_limit_per_customer ? "border-red-500" : "" |
| 1181 |
} |
| 1182 |
), |
| 1183 |
errors.usage_limit_per_customer && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1184 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1185 |
errors.usage_limit_per_customer |
| 1186 |
] }) |
| 1187 |
] }), |
| 1188 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1189 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 cursor-pointer", children: [ |
| 1190 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1191 |
"input", |
| 1192 |
{ |
| 1193 |
type: "checkbox", |
| 1194 |
checked: formData.first_time_customer_only, |
| 1195 |
onChange: (e) => handleFieldChange( |
| 1196 |
"first_time_customer_only", |
| 1197 |
e.target.checked |
| 1198 |
), |
| 1199 |
className: "w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" |
| 1200 |
} |
| 1201 |
), |
| 1202 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: __("First-Time Customers Only", "yatra") }) |
| 1203 |
] }), |
| 1204 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1205 |
HelpText, |
| 1206 |
{ |
| 1207 |
text: __( |
| 1208 |
"If enabled, only customers who have never made a booking before can use this coupon.", |
| 1209 |
"yatra" |
| 1210 |
), |
| 1211 |
className: "mb-2 mt-1" |
| 1212 |
} |
| 1213 |
) |
| 1214 |
] }), |
| 1215 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1216 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1217 |
"label", |
| 1218 |
{ |
| 1219 |
htmlFor: "min_amount", |
| 1220 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 1221 |
children: __("Minimum Booking Amount", "yatra") |
| 1222 |
} |
| 1223 |
), |
| 1224 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1225 |
HelpText, |
| 1226 |
{ |
| 1227 |
text: __( |
| 1228 |
"Minimum total booking amount required to use this coupon. This applies to the total booking value (trip price × number of travelers).", |
| 1229 |
"yatra" |
| 1230 |
), |
| 1231 |
className: "mb-2" |
| 1232 |
} |
| 1233 |
), |
| 1234 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [ |
| 1235 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `absolute ${currencyOnRight ? "right-3" : "left-3"} top-1/2 transform -translate-y-1/2 text-gray-500 text-sm`, children: [ |
| 1236 |
currencySymbol, |
| 1237 |
" " |
| 1238 |
] }), |
| 1239 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1240 |
Input, |
| 1241 |
{ |
| 1242 |
id: "min_amount", |
| 1243 |
type: "number", |
| 1244 |
min: "0", |
| 1245 |
step: "0.01", |
| 1246 |
value: formData.min_amount, |
| 1247 |
onChange: (e) => handleFieldChange("min_amount", e.target.value), |
| 1248 |
placeholder: __("e.g., 100", "yatra"), |
| 1249 |
className: `${currencyPad} ${errors.min_amount ? "border-red-500" : ""}` |
| 1250 |
} |
| 1251 |
) |
| 1252 |
] }), |
| 1253 |
errors.min_amount && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1254 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1255 |
errors.min_amount |
| 1256 |
] }) |
| 1257 |
] }), |
| 1258 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-3", children: [ |
| 1259 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1260 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1261 |
"label", |
| 1262 |
{ |
| 1263 |
htmlFor: "valid_from", |
| 1264 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 1265 |
children: __("Valid From", "yatra") |
| 1266 |
} |
| 1267 |
), |
| 1268 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1269 |
DatePicker, |
| 1270 |
{ |
| 1271 |
value: formData.valid_from, |
| 1272 |
onChange: (value) => handleFieldChange("valid_from", value), |
| 1273 |
placeholder: __("Select start date", "yatra"), |
| 1274 |
error: !!errors.valid_from, |
| 1275 |
className: errors.valid_from ? "border-red-500" : "" |
| 1276 |
} |
| 1277 |
), |
| 1278 |
errors.valid_from && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1279 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1280 |
errors.valid_from |
| 1281 |
] }) |
| 1282 |
] }), |
| 1283 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1284 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1285 |
"label", |
| 1286 |
{ |
| 1287 |
htmlFor: "expiry_date", |
| 1288 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 1289 |
children: __("Expiry Date", "yatra") |
| 1290 |
} |
| 1291 |
), |
| 1292 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1293 |
DatePicker, |
| 1294 |
{ |
| 1295 |
value: formData.expiry_date, |
| 1296 |
onChange: (value) => handleFieldChange("expiry_date", value), |
| 1297 |
placeholder: __("Select expiry date", "yatra"), |
| 1298 |
minDate: formData.valid_from ? toDateValue(formData.valid_from) : /* @__PURE__ */ new Date(), |
| 1299 |
error: !!errors.expiry_date, |
| 1300 |
className: errors.expiry_date ? "border-red-500" : "" |
| 1301 |
} |
| 1302 |
), |
| 1303 |
errors.expiry_date && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1304 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1305 |
errors.expiry_date |
| 1306 |
] }) |
| 1307 |
] }) |
| 1308 |
] }) |
| 1309 |
] }) |
| 1310 |
] }), |
| 1311 |
!isEffectivePromoOnly && /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 1312 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Group Discount Settings", "yatra") }) }), |
| 1313 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 1314 |
!isEffectiveGroupOnly && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1315 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 cursor-pointer", children: [ |
| 1316 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1317 |
"input", |
| 1318 |
{ |
| 1319 |
type: "checkbox", |
| 1320 |
checked: formData.is_group_discount, |
| 1321 |
onChange: (e) => handleGroupDiscountToggle(e.target.checked), |
| 1322 |
className: "w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" |
| 1323 |
} |
| 1324 |
), |
| 1325 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: __("Enable Group Discount", "yatra") }) |
| 1326 |
] }), |
| 1327 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1328 |
HelpText, |
| 1329 |
{ |
| 1330 |
text: __( |
| 1331 |
"Apply discounts for group bookings based on traveler count.", |
| 1332 |
"yatra" |
| 1333 |
), |
| 1334 |
className: "mb-2 mt-1" |
| 1335 |
} |
| 1336 |
) |
| 1337 |
] }), |
| 1338 |
formData.is_group_discount && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 1339 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1340 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1341 |
"label", |
| 1342 |
{ |
| 1343 |
htmlFor: "group_discount_mode", |
| 1344 |
className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", |
| 1345 |
children: [ |
| 1346 |
__("Discount Mode", "yatra"), |
| 1347 |
" ", |
| 1348 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 1349 |
] |
| 1350 |
} |
| 1351 |
), |
| 1352 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1353 |
HelpText, |
| 1354 |
{ |
| 1355 |
text: __( |
| 1356 |
"Choose how to apply the group discount: Total discount on entire booking, or category-based rates per traveler type.", |
| 1357 |
"yatra" |
| 1358 |
), |
| 1359 |
className: "mb-2" |
| 1360 |
} |
| 1361 |
), |
| 1362 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1363 |
Select, |
| 1364 |
{ |
| 1365 |
id: "group_discount_mode", |
| 1366 |
value: formData.group_discount_mode, |
| 1367 |
onChange: (e) => handleFieldChange( |
| 1368 |
"group_discount_mode", |
| 1369 |
e.target.value |
| 1370 |
), |
| 1371 |
className: errors.group_discount_mode ? "border-red-500" : "", |
| 1372 |
required: formData.is_group_discount, |
| 1373 |
children: [ |
| 1374 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "total", children: __("Total Discount", "yatra") }), |
| 1375 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "category_based", children: __("Category-Based Discount", "yatra") }) |
| 1376 |
] |
| 1377 |
} |
| 1378 |
), |
| 1379 |
errors.group_discount_mode && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1380 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1381 |
errors.group_discount_mode |
| 1382 |
] }) |
| 1383 |
] }), |
| 1384 |
formData.group_discount_mode === "total" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 1385 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [ |
| 1386 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1387 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: __("Group Size Ranges", "yatra") }), |
| 1388 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: __( |
| 1389 |
"Add one or more ranges (e.g., 1-10, 10-12, 12-15, 15+). The first matching range will be applied.", |
| 1390 |
"yatra" |
| 1391 |
) }) |
| 1392 |
] }), |
| 1393 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1394 |
Button, |
| 1395 |
{ |
| 1396 |
type: "button", |
| 1397 |
variant: "outline", |
| 1398 |
onClick: addRange, |
| 1399 |
className: "flex items-center gap-2", |
| 1400 |
children: [ |
| 1401 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4" }), |
| 1402 |
__("Add Range", "yatra") |
| 1403 |
] |
| 1404 |
} |
| 1405 |
) |
| 1406 |
] }), |
| 1407 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-3", children: formData.group_discount_ranges.map( |
| 1408 |
(range, idx) => /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1409 |
Card, |
| 1410 |
{ |
| 1411 |
className: "border border-gray-200 dark:border-gray-700", |
| 1412 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "p-4 space-y-3", children: [ |
| 1413 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-3", children: [ |
| 1414 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: [ |
| 1415 |
__("Range", "yatra"), |
| 1416 |
" #", |
| 1417 |
idx + 1 |
| 1418 |
] }), |
| 1419 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1420 |
Button, |
| 1421 |
{ |
| 1422 |
type: "button", |
| 1423 |
variant: "outline", |
| 1424 |
onClick: () => removeRange(range.id), |
| 1425 |
disabled: formData.group_discount_ranges.length === 1, |
| 1426 |
className: "flex items-center gap-2", |
| 1427 |
children: [ |
| 1428 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "w-4 h-4" }), |
| 1429 |
__("Remove", "yatra") |
| 1430 |
] |
| 1431 |
} |
| 1432 |
) |
| 1433 |
] }), |
| 1434 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-3", children: [ |
| 1435 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1436 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", children: [ |
| 1437 |
__("Minimum Group Size", "yatra"), |
| 1438 |
" ", |
| 1439 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 1440 |
] }), |
| 1441 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1442 |
Input, |
| 1443 |
{ |
| 1444 |
type: "number", |
| 1445 |
min: "1", |
| 1446 |
value: range.min_group_size, |
| 1447 |
onChange: (e) => updateRange(range.id, { |
| 1448 |
min_group_size: e.target.value |
| 1449 |
}), |
| 1450 |
placeholder: __( |
| 1451 |
"e.g., 10", |
| 1452 |
"yatra" |
| 1453 |
), |
| 1454 |
className: errors[`group_discount_ranges_${idx}_min`] ? "border-red-500" : "" |
| 1455 |
} |
| 1456 |
), |
| 1457 |
errors[`group_discount_ranges_${idx}_min`] && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1458 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1459 |
errors[`group_discount_ranges_${idx}_min`] |
| 1460 |
] }) |
| 1461 |
] }), |
| 1462 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1463 |
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", children: __("Maximum Group Size", "yatra") }), |
| 1464 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1465 |
Input, |
| 1466 |
{ |
| 1467 |
type: "number", |
| 1468 |
min: range.min_group_size ? parseInt( |
| 1469 |
range.min_group_size, |
| 1470 |
10 |
| 1471 |
) + 1 : 2, |
| 1472 |
value: range.max_group_size, |
| 1473 |
onChange: (e) => updateRange(range.id, { |
| 1474 |
max_group_size: e.target.value |
| 1475 |
}), |
| 1476 |
placeholder: __( |
| 1477 |
"Leave empty for unlimited", |
| 1478 |
"yatra" |
| 1479 |
), |
| 1480 |
className: errors[`group_discount_ranges_${idx}_max`] ? "border-red-500" : "" |
| 1481 |
} |
| 1482 |
), |
| 1483 |
errors[`group_discount_ranges_${idx}_max`] && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1484 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1485 |
errors[`group_discount_ranges_${idx}_max`] |
| 1486 |
] }) |
| 1487 |
] }) |
| 1488 |
] }), |
| 1489 |
formData.group_discount_mode === "total" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-3", children: [ |
| 1490 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1491 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", children: [ |
| 1492 |
__("Discount Type", "yatra"), |
| 1493 |
" ", |
| 1494 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 1495 |
] }), |
| 1496 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1497 |
Select, |
| 1498 |
{ |
| 1499 |
value: range.discount_type || "percentage", |
| 1500 |
onChange: (e) => updateRange(range.id, { |
| 1501 |
discount_type: e.target.value |
| 1502 |
}), |
| 1503 |
className: errors[`group_discount_ranges_${idx}_type`] ? "border-red-500" : "", |
| 1504 |
children: [ |
| 1505 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "percentage", children: __("Percentage", "yatra") }), |
| 1506 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "fixed", children: __("Fixed Amount", "yatra") }), |
| 1507 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "percentage_of_total", children: __( |
| 1508 |
"Percentage of Total", |
| 1509 |
"yatra" |
| 1510 |
) }) |
| 1511 |
] |
| 1512 |
} |
| 1513 |
), |
| 1514 |
errors[`group_discount_ranges_${idx}_type`] && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1515 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1516 |
errors[`group_discount_ranges_${idx}_type`] |
| 1517 |
] }) |
| 1518 |
] }), |
| 1519 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1520 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", children: [ |
| 1521 |
__("Discount Amount", "yatra"), |
| 1522 |
" ", |
| 1523 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 1524 |
] }), |
| 1525 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [ |
| 1526 |
range.discount_type === "fixed" && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `absolute ${currencyOnRight ? "right-3" : "left-3"} top-1/2 transform -translate-y-1/2 text-gray-500 text-sm`, children: [ |
| 1527 |
currencySymbol, |
| 1528 |
" " |
| 1529 |
] }), |
| 1530 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1531 |
Input, |
| 1532 |
{ |
| 1533 |
type: "number", |
| 1534 |
min: "0", |
| 1535 |
max: range.discount_type === "percentage" ? 100 : void 0, |
| 1536 |
step: "0.01", |
| 1537 |
value: range.discount_amount || "", |
| 1538 |
onChange: (e) => updateRange(range.id, { |
| 1539 |
discount_amount: e.target.value |
| 1540 |
}), |
| 1541 |
placeholder: range.discount_type === "percentage" ? __("e.g., 10", "yatra") : __("e.g., 50", "yatra"), |
| 1542 |
className: `${range.discount_type === "fixed" ? currencyPad : ""} ${errors[`group_discount_ranges_${idx}_amount`] ? "border-red-500" : ""}` |
| 1543 |
} |
| 1544 |
), |
| 1545 |
range.discount_type === "percentage" && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 text-sm", children: "%" }) |
| 1546 |
] }), |
| 1547 |
errors[`group_discount_ranges_${idx}_amount`] && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1548 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1549 |
errors[`group_discount_ranges_${idx}_amount`] |
| 1550 |
] }) |
| 1551 |
] }) |
| 1552 |
] }) |
| 1553 |
] }) |
| 1554 |
}, |
| 1555 |
range.id |
| 1556 |
) |
| 1557 |
) }) |
| 1558 |
] }), |
| 1559 |
formData.group_discount_mode === "category_based" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [ |
| 1560 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [ |
| 1561 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1562 |
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: __("Traveler Categories", "yatra") }), |
| 1563 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: __( |
| 1564 |
"Add traveler categories and define discount ranges for each category.", |
| 1565 |
"yatra" |
| 1566 |
) }) |
| 1567 |
] }), |
| 1568 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [ |
| 1569 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1570 |
Button, |
| 1571 |
{ |
| 1572 |
type: "button", |
| 1573 |
onClick: addTravelerCategory, |
| 1574 |
className: "flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors", |
| 1575 |
children: [ |
| 1576 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4" }), |
| 1577 |
__("Add Category", "yatra") |
| 1578 |
] |
| 1579 |
} |
| 1580 |
), |
| 1581 |
showCategoryDropdown && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute right-0 top-full mt-2 z-50 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 shadow-lg min-w-[320px]", children: [ |
| 1582 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-3 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: __( |
| 1583 |
"Select a category to add pricing", |
| 1584 |
"yatra" |
| 1585 |
) }) }), |
| 1586 |
travelerCategoryOptions.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "divide-y divide-gray-100 dark:divide-gray-700 max-h-[300px] overflow-y-auto", children: travelerCategoryOptions.map((cat) => { |
| 1587 |
var _a2; |
| 1588 |
return /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1589 |
"div", |
| 1590 |
{ |
| 1591 |
onClick: () => selectCategory( |
| 1592 |
cat.value, |
| 1593 |
cat.label |
| 1594 |
), |
| 1595 |
className: "px-4 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors", |
| 1596 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col", children: [ |
| 1597 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [ |
| 1598 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold text-gray-900 dark:text-white", children: cat.label }), |
| 1599 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: [ |
| 1600 |
"(", |
| 1601 |
cat.age_min || "null", |
| 1602 |
"-", |
| 1603 |
cat.age_max || "null", |
| 1604 |
" ", |
| 1605 |
__("years", "yatra"), |
| 1606 |
")" |
| 1607 |
] }) |
| 1608 |
] }), |
| 1609 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm text-gray-500 dark:text-gray-400", children: [ |
| 1610 |
cat.description && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [ |
| 1611 |
cat.description, |
| 1612 |
" •", |
| 1613 |
" " |
| 1614 |
] }), |
| 1615 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "capitalize", children: ((_a2 = cat.pricing_mode) == null ? void 0 : _a2.replace( |
| 1616 |
"_", |
| 1617 |
" " |
| 1618 |
)) || "Per person" }) |
| 1619 |
] }) |
| 1620 |
] }) |
| 1621 |
}, |
| 1622 |
cat.value |
| 1623 |
); |
| 1624 |
}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 text-center text-sm text-gray-500 dark:text-gray-400", children: __( |
| 1625 |
"No traveler categories available. Please create categories first.", |
| 1626 |
"yatra" |
| 1627 |
) }) |
| 1628 |
] }) |
| 1629 |
] }) |
| 1630 |
] }), |
| 1631 |
errors.category_discounts && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1632 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1633 |
errors.category_discounts |
| 1634 |
] }), |
| 1635 |
formData.category_discounts.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center py-12 border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-800/50", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center space-y-4", children: [ |
| 1636 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-16 h-16 bg-gray-200 dark:bg-gray-700 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Users, { className: "w-8 h-8 text-gray-500 dark:text-gray-400" }) }), |
| 1637 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-gray-500 dark:text-gray-400", children: [ |
| 1638 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-lg font-medium mb-2", children: __( |
| 1639 |
"No traveler categories added yet", |
| 1640 |
"yatra" |
| 1641 |
) }), |
| 1642 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm mb-4", children: __( |
| 1643 |
"Select traveler categories to apply group-specific discounts", |
| 1644 |
"yatra" |
| 1645 |
) }) |
| 1646 |
] }), |
| 1647 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1648 |
Button, |
| 1649 |
{ |
| 1650 |
type: "button", |
| 1651 |
onClick: addTravelerCategory, |
| 1652 |
className: "flex items-center gap-2 px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors", |
| 1653 |
children: [ |
| 1654 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4" }), |
| 1655 |
__("Add Your First Category", "yatra") |
| 1656 |
] |
| 1657 |
} |
| 1658 |
) |
| 1659 |
] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-4", children: formData.category_discounts.map( |
| 1660 |
(category, catIdx) => /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1661 |
Card, |
| 1662 |
{ |
| 1663 |
className: "border border-gray-200 dark:border-gray-700", |
| 1664 |
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "p-4 space-y-3", children: [ |
| 1665 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-3", children: [ |
| 1666 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1", children: [ |
| 1667 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm font-semibold text-gray-900 dark:text-white", children: [ |
| 1668 |
__("Traveler Category", "yatra"), |
| 1669 |
" ", |
| 1670 |
"#", |
| 1671 |
catIdx + 1 |
| 1672 |
] }), |
| 1673 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: __( |
| 1674 |
"Configure discount ranges for this traveler category.", |
| 1675 |
"yatra" |
| 1676 |
) }) |
| 1677 |
] }), |
| 1678 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1679 |
Button, |
| 1680 |
{ |
| 1681 |
type: "button", |
| 1682 |
variant: "outline", |
| 1683 |
onClick: () => removeTravelerCategory(catIdx), |
| 1684 |
disabled: formData.category_discounts.length === 1, |
| 1685 |
className: "flex items-center gap-2", |
| 1686 |
children: [ |
| 1687 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "w-4 h-4" }), |
| 1688 |
__("Remove", "yatra") |
| 1689 |
] |
| 1690 |
} |
| 1691 |
) |
| 1692 |
] }), |
| 1693 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1694 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", children: [ |
| 1695 |
__( |
| 1696 |
"Select Traveler Category", |
| 1697 |
"yatra" |
| 1698 |
), |
| 1699 |
" ", |
| 1700 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 1701 |
] }), |
| 1702 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1703 |
Select, |
| 1704 |
{ |
| 1705 |
value: category.traveler_category_id, |
| 1706 |
onChange: (e) => { |
| 1707 |
const selected = travelerCategoryOptions.find( |
| 1708 |
(opt) => opt.value === e.target.value |
| 1709 |
); |
| 1710 |
updateTravelerCategory(catIdx, { |
| 1711 |
traveler_category_id: e.target.value, |
| 1712 |
traveler_category_label: (selected == null ? void 0 : selected.label) || "" |
| 1713 |
}); |
| 1714 |
}, |
| 1715 |
className: errors[`category_discounts_${catIdx}_id`] ? "border-red-500" : "", |
| 1716 |
children: travelerCategoryOptions.map( |
| 1717 |
(opt) => /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1718 |
"option", |
| 1719 |
{ |
| 1720 |
value: opt.value, |
| 1721 |
children: opt.label |
| 1722 |
}, |
| 1723 |
opt.value |
| 1724 |
) |
| 1725 |
) |
| 1726 |
} |
| 1727 |
), |
| 1728 |
errors[`category_discounts_${catIdx}_id`] && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1729 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1730 |
errors[`category_discounts_${catIdx}_id`] |
| 1731 |
] }) |
| 1732 |
] }) }), |
| 1733 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [ |
| 1734 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1735 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-medium text-gray-900 dark:text-white", children: __("Discount Ranges", "yatra") }), |
| 1736 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400", children: __( |
| 1737 |
"Add multiple group size ranges for this category (e.g., 1-10, 10-12, 12-15, 15+).", |
| 1738 |
"yatra" |
| 1739 |
) }) |
| 1740 |
] }), |
| 1741 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1742 |
Button, |
| 1743 |
{ |
| 1744 |
type: "button", |
| 1745 |
variant: "outline", |
| 1746 |
onClick: () => addRangeToCategory(catIdx), |
| 1747 |
className: "flex items-center gap-2", |
| 1748 |
children: [ |
| 1749 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "w-4 h-4" }), |
| 1750 |
__("Add Range", "yatra") |
| 1751 |
] |
| 1752 |
} |
| 1753 |
) |
| 1754 |
] }), |
| 1755 |
errors[`category_discounts_${catIdx}_ranges`] && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1756 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1757 |
errors[`category_discounts_${catIdx}_ranges`] |
| 1758 |
] }), |
| 1759 |
category.ranges.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center py-6 border-2 border-dashed border-gray-200 dark:border-gray-600 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-gray-500 dark:text-gray-400", children: [ |
| 1760 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-medium mb-1", children: __( |
| 1761 |
"No discount ranges added yet", |
| 1762 |
"yatra" |
| 1763 |
) }), |
| 1764 |
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: __( |
| 1765 |
'Click "Add Range" to create discount tiers', |
| 1766 |
"yatra" |
| 1767 |
) }) |
| 1768 |
] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-3", children: category.ranges.map( |
| 1769 |
(range, rIdx) => /* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1770 |
"div", |
| 1771 |
{ |
| 1772 |
className: "border border-gray-200 dark:border-gray-600 rounded-lg p-4 space-y-3 bg-gray-50 dark:bg-gray-800", |
| 1773 |
children: [ |
| 1774 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-3", children: [ |
| 1775 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm font-medium text-gray-900 dark:text-white", children: [ |
| 1776 |
__("Range", "yatra"), |
| 1777 |
" #", |
| 1778 |
rIdx + 1 |
| 1779 |
] }), |
| 1780 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1781 |
Button, |
| 1782 |
{ |
| 1783 |
type: "button", |
| 1784 |
variant: "outline", |
| 1785 |
size: "sm", |
| 1786 |
onClick: () => removeRangeFromCategory( |
| 1787 |
catIdx, |
| 1788 |
range.id |
| 1789 |
), |
| 1790 |
disabled: category.ranges.length === 1, |
| 1791 |
className: "flex items-center gap-1", |
| 1792 |
children: [ |
| 1793 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "w-3 h-3" }), |
| 1794 |
__("Remove", "yatra") |
| 1795 |
] |
| 1796 |
} |
| 1797 |
) |
| 1798 |
] }), |
| 1799 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-3", children: [ |
| 1800 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1801 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", children: [ |
| 1802 |
__( |
| 1803 |
"Minimum Group Size", |
| 1804 |
"yatra" |
| 1805 |
), |
| 1806 |
" ", |
| 1807 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 1808 |
] }), |
| 1809 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1810 |
Input, |
| 1811 |
{ |
| 1812 |
type: "number", |
| 1813 |
min: "1", |
| 1814 |
value: range.min_group_size, |
| 1815 |
onChange: (e) => updateRangeInCategory( |
| 1816 |
catIdx, |
| 1817 |
range.id, |
| 1818 |
{ |
| 1819 |
min_group_size: e.target.value |
| 1820 |
} |
| 1821 |
), |
| 1822 |
placeholder: __( |
| 1823 |
"e.g., 10", |
| 1824 |
"yatra" |
| 1825 |
), |
| 1826 |
className: errors[`category_discounts_${catIdx}_ranges_${rIdx}_min`] ? "border-red-500" : "" |
| 1827 |
} |
| 1828 |
), |
| 1829 |
errors[`category_discounts_${catIdx}_ranges_${rIdx}_min`] && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1830 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1831 |
errors[`category_discounts_${catIdx}_ranges_${rIdx}_min`] |
| 1832 |
] }) |
| 1833 |
] }), |
| 1834 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1835 |
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", children: __( |
| 1836 |
"Maximum Group Size", |
| 1837 |
"yatra" |
| 1838 |
) }), |
| 1839 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1840 |
Input, |
| 1841 |
{ |
| 1842 |
type: "number", |
| 1843 |
min: range.min_group_size ? parseInt( |
| 1844 |
range.min_group_size, |
| 1845 |
10 |
| 1846 |
) + 1 : 2, |
| 1847 |
value: range.max_group_size, |
| 1848 |
onChange: (e) => updateRangeInCategory( |
| 1849 |
catIdx, |
| 1850 |
range.id, |
| 1851 |
{ |
| 1852 |
max_group_size: e.target.value |
| 1853 |
} |
| 1854 |
), |
| 1855 |
placeholder: __( |
| 1856 |
"Leave empty for unlimited", |
| 1857 |
"yatra" |
| 1858 |
), |
| 1859 |
className: errors[`category_discounts_${catIdx}_ranges_${rIdx}_max`] ? "border-red-500" : "" |
| 1860 |
} |
| 1861 |
), |
| 1862 |
errors[`category_discounts_${catIdx}_ranges_${rIdx}_max`] && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1863 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1864 |
errors[`category_discounts_${catIdx}_ranges_${rIdx}_max`] |
| 1865 |
] }) |
| 1866 |
] }) |
| 1867 |
] }), |
| 1868 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-3", children: [ |
| 1869 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1870 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", children: [ |
| 1871 |
__( |
| 1872 |
"Discount Type", |
| 1873 |
"yatra" |
| 1874 |
), |
| 1875 |
" ", |
| 1876 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 1877 |
] }), |
| 1878 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1879 |
Select, |
| 1880 |
{ |
| 1881 |
value: range.discount_type || "percentage", |
| 1882 |
onChange: (e) => updateRangeInCategory( |
| 1883 |
catIdx, |
| 1884 |
range.id, |
| 1885 |
{ |
| 1886 |
discount_type: e.target.value |
| 1887 |
} |
| 1888 |
), |
| 1889 |
className: errors[`category_discounts_${catIdx}_ranges_${rIdx}_type`] ? "border-red-500" : "", |
| 1890 |
children: [ |
| 1891 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "percentage", children: __( |
| 1892 |
"Percentage", |
| 1893 |
"yatra" |
| 1894 |
) }), |
| 1895 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "fixed", children: __( |
| 1896 |
"Fixed Amount", |
| 1897 |
"yatra" |
| 1898 |
) }) |
| 1899 |
] |
| 1900 |
} |
| 1901 |
), |
| 1902 |
errors[`category_discounts_${catIdx}_ranges_${rIdx}_type`] && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1903 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1904 |
errors[`category_discounts_${catIdx}_ranges_${rIdx}_type`] |
| 1905 |
] }) |
| 1906 |
] }), |
| 1907 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [ |
| 1908 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5", children: [ |
| 1909 |
__( |
| 1910 |
"Discount Amount", |
| 1911 |
"yatra" |
| 1912 |
), |
| 1913 |
" ", |
| 1914 |
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500", children: "*" }) |
| 1915 |
] }), |
| 1916 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [ |
| 1917 |
range.discount_type === "fixed" && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `absolute ${currencyOnRight ? "right-3" : "left-3"} top-1/2 transform -translate-y-1/2 text-gray-500 text-sm`, children: [ |
| 1918 |
currencySymbol, |
| 1919 |
" " |
| 1920 |
] }), |
| 1921 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1922 |
Input, |
| 1923 |
{ |
| 1924 |
type: "number", |
| 1925 |
min: "0", |
| 1926 |
max: range.discount_type === "percentage" ? 100 : void 0, |
| 1927 |
step: "0.01", |
| 1928 |
value: range.discount_amount || "", |
| 1929 |
onChange: (e) => updateRangeInCategory( |
| 1930 |
catIdx, |
| 1931 |
range.id, |
| 1932 |
{ |
| 1933 |
discount_amount: e.target.value |
| 1934 |
} |
| 1935 |
), |
| 1936 |
placeholder: range.discount_type === "percentage" ? __( |
| 1937 |
"e.g., 10", |
| 1938 |
"yatra" |
| 1939 |
) : __( |
| 1940 |
"e.g., 50", |
| 1941 |
"yatra" |
| 1942 |
), |
| 1943 |
className: `${range.discount_type === "fixed" ? currencyPad : ""} ${errors[`category_discounts_${catIdx}_ranges_${rIdx}_amount`] ? "border-red-500" : ""}` |
| 1944 |
} |
| 1945 |
), |
| 1946 |
range.discount_type === "percentage" && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 text-sm", children: "%" }) |
| 1947 |
] }), |
| 1948 |
errors[`category_discounts_${catIdx}_ranges_${rIdx}_amount`] && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-1.5 text-sm text-red-600 dark:text-red-400 flex items-center gap-1", children: [ |
| 1949 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" }), |
| 1950 |
errors[`category_discounts_${catIdx}_ranges_${rIdx}_amount`] |
| 1951 |
] }) |
| 1952 |
] }) |
| 1953 |
] }) |
| 1954 |
] |
| 1955 |
}, |
| 1956 |
range.id |
| 1957 |
) |
| 1958 |
) }) |
| 1959 |
] }) |
| 1960 |
}, |
| 1961 |
catIdx |
| 1962 |
) |
| 1963 |
) }) |
| 1964 |
] }) |
| 1965 |
] }) |
| 1966 |
] }) |
| 1967 |
] }) |
| 1968 |
] }), |
| 1969 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [ |
| 1970 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 1971 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Status", "yatra") }) }), |
| 1972 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3", children: [ |
| 1973 |
/* @__PURE__ */ jsxRuntimeExports.jsxs( |
| 1974 |
Select, |
| 1975 |
{ |
| 1976 |
value: formData.status, |
| 1977 |
onChange: (e) => handleFieldChange( |
| 1978 |
"status", |
| 1979 |
e.target.value |
| 1980 |
), |
| 1981 |
children: [ |
| 1982 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "draft", children: __("Draft", "yatra") }), |
| 1983 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "publish", children: __("Publish", "yatra") }), |
| 1984 |
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "trash", children: __("Trash", "yatra") }) |
| 1985 |
] |
| 1986 |
} |
| 1987 |
), |
| 1988 |
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: __( |
| 1989 |
"Only published coupons can be used by customers.", |
| 1990 |
"yatra" |
| 1991 |
) }) |
| 1992 |
] }) |
| 1993 |
] }), |
| 1994 |
/* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [ |
| 1995 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: __("Applicable To", "yatra") }) }), |
| 1996 |
/* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx( |
| 1997 |
ApplicableTripSelector, |
| 1998 |
{ |
| 1999 |
value: formData.applicable_to, |
| 2000 |
onValueChange: (val) => handleFieldChange("applicable_to", val), |
| 2001 |
selectedTripIds: formData.trip_ids, |
| 2002 |
onTripIdsChange: (ids) => handleFieldChange("trip_ids", ids), |
| 2003 |
description: __( |
| 2004 |
"Choose whether this discount applies to all trips or specific ones." |
| 2005 |
), |
| 2006 |
helperText: __( |
| 2007 |
"Trips shown with ID for quick identification." |
| 2008 |
) |
| 2009 |
} |
| 2010 |
) }) |
| 2011 |
] }), |
| 2012 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Card, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [ |
| 2013 |
errors.submit && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 text-sm text-red-500 bg-red-50 dark:bg-red-900/20 rounded-md", children: errors.submit }), |
| 2014 |
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [ |
| 2015 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 2016 |
Button, |
| 2017 |
{ |
| 2018 |
type: "submit", |
| 2019 |
disabled: isSubmitting, |
| 2020 |
className: "flex-1 flex items-center justify-center gap-2", |
| 2021 |
children: isSubmitting ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 2022 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader2, { className: "w-4 h-4 animate-spin" }), |
| 2023 |
__("Saving...", "yatra") |
| 2024 |
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [ |
| 2025 |
/* @__PURE__ */ jsxRuntimeExports.jsx(Save, { className: "w-4 h-4" }), |
| 2026 |
isEditMode ? __("Update Coupon", "yatra") : __("Create Coupon", "yatra") |
| 2027 |
] }) |
| 2028 |
} |
| 2029 |
), |
| 2030 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 2031 |
Button, |
| 2032 |
{ |
| 2033 |
type: "button", |
| 2034 |
variant: "outline", |
| 2035 |
onClick: handleBack, |
| 2036 |
disabled: isSubmitting, |
| 2037 |
children: __("Cancel", "yatra") |
| 2038 |
} |
| 2039 |
) |
| 2040 |
] }) |
| 2041 |
] }) }) }) |
| 2042 |
] }) |
| 2043 |
] }) }) |
| 2044 |
] }), |
| 2045 |
/* @__PURE__ */ jsxRuntimeExports.jsx( |
| 2046 |
PremiumUpgradeDialog, |
| 2047 |
{ |
| 2048 |
open: showPremiumModal, |
| 2049 |
onClose: () => setShowPremiumModal(false), |
| 2050 |
moduleName: __("Group Discounts", "yatra"), |
| 2051 |
purchaseUrl: "https://wpyatra.com/pricing?module=group-discounts", |
| 2052 |
moduleDescription: __( |
| 2053 |
"Unlock powerful group discount features to automatically apply discounts based on group size and traveler categories.", |
| 2054 |
"yatra" |
| 2055 |
) |
| 2056 |
} |
| 2057 |
) |
| 2058 |
] }); |
| 2059 |
}; |
| 2060 |
export { |
| 2061 |
DiscountForm as default |
| 2062 |
}; |
| 2063 |
//# sourceMappingURL=DiscountForm--OXC6TLT.js.map |
| 2064 |
|