@planetaexo/design-system 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +444 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -3
- package/dist/index.d.ts +72 -3
- package/dist/index.js +444 -113
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2262,21 +2262,16 @@ function AdventureSection({
|
|
|
2262
2262
|
onRemoveTraveller,
|
|
2263
2263
|
onAddSuggestedTraveller,
|
|
2264
2264
|
onAddTraveller,
|
|
2265
|
-
onUnassignFromAdventure
|
|
2265
|
+
onUnassignFromAdventure,
|
|
2266
|
+
hasSubmitAddTraveller,
|
|
2267
|
+
hasSubmitEditTraveller,
|
|
2268
|
+
hasConfirmRemoveTraveller,
|
|
2269
|
+
onRequestOpenAddModal,
|
|
2270
|
+
onRequestOpenEditModal,
|
|
2271
|
+
onRequestOpenDeleteModal
|
|
2266
2272
|
}) {
|
|
2267
2273
|
var _a, _b, _c, _d;
|
|
2268
2274
|
const [detailsOpen, setDetailsOpen] = React22__namespace.useState(false);
|
|
2269
|
-
const [addModalOpen, setAddModalOpen] = React22__namespace.useState(false);
|
|
2270
|
-
const [newTraveller, setNewTraveller] = React22__namespace.useState({
|
|
2271
|
-
firstName: "",
|
|
2272
|
-
lastName: "",
|
|
2273
|
-
passport: "",
|
|
2274
|
-
type: "adult",
|
|
2275
|
-
email: "",
|
|
2276
|
-
dateOfBirth: "",
|
|
2277
|
-
phone: ""
|
|
2278
|
-
});
|
|
2279
|
-
const setField = (k, v) => setNewTraveller((p) => __spreadProps(__spreadValues({}, p), { [k]: v }));
|
|
2280
2275
|
const handleCopyUrl = (url) => {
|
|
2281
2276
|
navigator.clipboard.writeText(url);
|
|
2282
2277
|
};
|
|
@@ -2434,11 +2429,17 @@ function AdventureSection({
|
|
|
2434
2429
|
]
|
|
2435
2430
|
}
|
|
2436
2431
|
),
|
|
2437
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2432
|
+
(onAddTraveller || hasSubmitAddTraveller) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2438
2433
|
"button",
|
|
2439
2434
|
{
|
|
2440
2435
|
type: "button",
|
|
2441
|
-
onClick: () =>
|
|
2436
|
+
onClick: () => {
|
|
2437
|
+
if (onAddTraveller) {
|
|
2438
|
+
onAddTraveller(adventure.id);
|
|
2439
|
+
} else {
|
|
2440
|
+
onRequestOpenAddModal == null ? void 0 : onRequestOpenAddModal(adventure.id);
|
|
2441
|
+
}
|
|
2442
|
+
},
|
|
2442
2443
|
className: "flex items-center gap-1.5 rounded-full border border-border px-3 py-1.5 text-xs font-ui text-primary hover:border-primary hover:bg-primary/5 transition-colors",
|
|
2443
2444
|
children: [
|
|
2444
2445
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.PlusIcon, { className: "w-3 h-3" }),
|
|
@@ -2501,31 +2502,51 @@ function AdventureSection({
|
|
|
2501
2502
|
}
|
|
2502
2503
|
),
|
|
2503
2504
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-0.5 shrink-0", children: [
|
|
2504
|
-
onEditTraveller && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2505
|
+
(onEditTraveller || hasSubmitEditTraveller) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2505
2506
|
"button",
|
|
2506
2507
|
{
|
|
2507
2508
|
type: "button",
|
|
2508
|
-
onClick: () =>
|
|
2509
|
+
onClick: () => {
|
|
2510
|
+
if (onEditTraveller) {
|
|
2511
|
+
onEditTraveller(adventure.id, t.id);
|
|
2512
|
+
} else {
|
|
2513
|
+
onRequestOpenEditModal == null ? void 0 : onRequestOpenEditModal(adventure.id, t);
|
|
2514
|
+
}
|
|
2515
|
+
},
|
|
2509
2516
|
className: "flex h-8 w-8 sm:h-7 sm:w-7 items-center justify-center rounded-lg text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors",
|
|
2510
2517
|
"aria-label": `Edit ${t.firstName}`,
|
|
2511
2518
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PencilIcon, { className: "w-3.5 h-3.5" })
|
|
2512
2519
|
}
|
|
2513
2520
|
),
|
|
2514
|
-
onRemoveTraveller && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2521
|
+
(onRemoveTraveller || hasConfirmRemoveTraveller) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2515
2522
|
"button",
|
|
2516
2523
|
{
|
|
2517
2524
|
type: "button",
|
|
2518
|
-
onClick: () =>
|
|
2525
|
+
onClick: () => {
|
|
2526
|
+
if (onRemoveTraveller) {
|
|
2527
|
+
onRemoveTraveller(adventure.id, t.id);
|
|
2528
|
+
} else {
|
|
2529
|
+
onRequestOpenDeleteModal == null ? void 0 : onRequestOpenDeleteModal(adventure.id, t);
|
|
2530
|
+
}
|
|
2531
|
+
},
|
|
2519
2532
|
className: "flex h-8 w-8 sm:h-7 sm:w-7 items-center justify-center rounded-lg text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",
|
|
2520
2533
|
"aria-label": `Delete ${t.firstName}`,
|
|
2521
2534
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2Icon, { className: "w-3.5 h-3.5" })
|
|
2522
2535
|
}
|
|
2523
2536
|
),
|
|
2524
|
-
(onUnassignFromAdventure || onRemoveTraveller) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2537
|
+
(onUnassignFromAdventure || onRemoveTraveller || hasConfirmRemoveTraveller) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2525
2538
|
"button",
|
|
2526
2539
|
{
|
|
2527
2540
|
type: "button",
|
|
2528
|
-
onClick: () =>
|
|
2541
|
+
onClick: () => {
|
|
2542
|
+
if (onUnassignFromAdventure) {
|
|
2543
|
+
onUnassignFromAdventure(adventure.id, t.id);
|
|
2544
|
+
} else if (onRemoveTraveller) {
|
|
2545
|
+
onRemoveTraveller(adventure.id, t.id);
|
|
2546
|
+
} else {
|
|
2547
|
+
onRequestOpenDeleteModal == null ? void 0 : onRequestOpenDeleteModal(adventure.id, t);
|
|
2548
|
+
}
|
|
2549
|
+
},
|
|
2529
2550
|
className: "flex h-8 w-8 sm:h-7 sm:w-7 items-center justify-center rounded-lg text-muted-foreground hover:text-amber-500 hover:bg-amber-500/10 transition-colors",
|
|
2530
2551
|
"aria-label": `Remove ${t.firstName} from adventure`,
|
|
2531
2552
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.UserMinusIcon, { className: "w-3.5 h-3.5" })
|
|
@@ -2582,111 +2603,303 @@ function AdventureSection({
|
|
|
2582
2603
|
] })
|
|
2583
2604
|
] });
|
|
2584
2605
|
})()
|
|
2585
|
-
] })
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
)
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2606
|
+
] })
|
|
2607
|
+
] });
|
|
2608
|
+
}
|
|
2609
|
+
function TravellerFormFields({ value, onChange, config }) {
|
|
2610
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
2611
|
+
const labels = (_a = config == null ? void 0 : config.labels) != null ? _a : {};
|
|
2612
|
+
const disabledTypes = new Set((_b = config == null ? void 0 : config.disabledPersonTypes) != null ? _b : []);
|
|
2613
|
+
const documentLabel = (config == null ? void 0 : config.requireCpf) ? (_c = labels.documentCpf) != null ? _c : "CPF" : (_d = labels.documentPassport) != null ? _d : "Passport (optional)";
|
|
2614
|
+
const documentPlaceholder = (config == null ? void 0 : config.requireCpf) ? "000.000.000-00" : void 0;
|
|
2615
|
+
const isChild = value.personType === "CHILD";
|
|
2616
|
+
const childEmail = config == null ? void 0 : config.childEmailFromContact;
|
|
2617
|
+
const emailRequired = value.personType === "ADULT" || value.personType === "SENIOR";
|
|
2618
|
+
const emailLabel = `${(_e = labels.email) != null ? _e : "Email"}${emailRequired ? " *" : ""}`;
|
|
2619
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2620
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2621
|
+
FloatingInput,
|
|
2622
|
+
{
|
|
2623
|
+
label: (_f = labels.firstName) != null ? _f : "First name *",
|
|
2624
|
+
required: true,
|
|
2625
|
+
value: value.firstName,
|
|
2626
|
+
onChange: (e) => onChange({ firstName: e.target.value })
|
|
2627
|
+
}
|
|
2628
|
+
),
|
|
2629
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2630
|
+
FloatingInput,
|
|
2631
|
+
{
|
|
2632
|
+
label: (_g = labels.lastName) != null ? _g : "Last name *",
|
|
2633
|
+
required: true,
|
|
2634
|
+
value: value.lastName,
|
|
2635
|
+
onChange: (e) => onChange({ lastName: e.target.value })
|
|
2636
|
+
}
|
|
2637
|
+
),
|
|
2638
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2639
|
+
FloatingInput,
|
|
2640
|
+
{
|
|
2641
|
+
label: documentLabel,
|
|
2642
|
+
placeholder: documentPlaceholder,
|
|
2643
|
+
value: (_h = value.documentNumber) != null ? _h : "",
|
|
2644
|
+
onChange: (e) => onChange({ documentNumber: e.target.value })
|
|
2645
|
+
}
|
|
2646
|
+
),
|
|
2647
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2648
|
+
FloatingSelect,
|
|
2649
|
+
{
|
|
2650
|
+
label: (_i = labels.personTypeLabel) != null ? _i : "Type (adult/child/senior)",
|
|
2651
|
+
value: value.personType,
|
|
2652
|
+
onChange: (e) => onChange({ personType: e.target.value }),
|
|
2653
|
+
children: [
|
|
2654
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "ADULT", disabled: disabledTypes.has("ADULT"), children: (_j = labels.personTypeAdult) != null ? _j : "Adult" }),
|
|
2655
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "CHILD", disabled: disabledTypes.has("CHILD"), children: (_k = labels.personTypeChild) != null ? _k : "Child" }),
|
|
2656
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "SENIOR", disabled: disabledTypes.has("SENIOR"), children: (_l = labels.personTypeSenior) != null ? _l : "Senior" })
|
|
2657
|
+
]
|
|
2658
|
+
}
|
|
2659
|
+
),
|
|
2660
|
+
isChild && childEmail ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2661
|
+
FloatingInput,
|
|
2662
|
+
{
|
|
2663
|
+
label: (_m = labels.email) != null ? _m : "Email",
|
|
2664
|
+
type: "email",
|
|
2665
|
+
value: childEmail,
|
|
2666
|
+
readOnly: true,
|
|
2667
|
+
disabled: true
|
|
2668
|
+
}
|
|
2669
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2670
|
+
FloatingInput,
|
|
2671
|
+
{
|
|
2672
|
+
label: emailLabel,
|
|
2673
|
+
type: "email",
|
|
2674
|
+
value: (_n = value.email) != null ? _n : "",
|
|
2675
|
+
onChange: (e) => onChange({ email: e.target.value }),
|
|
2676
|
+
required: emailRequired
|
|
2677
|
+
}
|
|
2678
|
+
),
|
|
2679
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2680
|
+
FloatingInput,
|
|
2681
|
+
{
|
|
2682
|
+
label: (_o = labels.birthDate) != null ? _o : "Date of birth",
|
|
2683
|
+
type: "date",
|
|
2684
|
+
value: (_p = value.birthDate) != null ? _p : "",
|
|
2685
|
+
onChange: (e) => onChange({ birthDate: e.target.value })
|
|
2686
|
+
}
|
|
2687
|
+
),
|
|
2688
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2689
|
+
FloatingInput,
|
|
2690
|
+
{
|
|
2691
|
+
label: (_q = labels.phone) != null ? _q : "Phone (optional)",
|
|
2692
|
+
type: "tel",
|
|
2693
|
+
value: (_r = value.phone) != null ? _r : "",
|
|
2694
|
+
onChange: (e) => onChange({ phone: e.target.value }),
|
|
2695
|
+
placeholder: "+5511987654321"
|
|
2696
|
+
}
|
|
2697
|
+
)
|
|
2698
|
+
] });
|
|
2699
|
+
}
|
|
2700
|
+
function createInitialAddFormData(config) {
|
|
2701
|
+
var _a;
|
|
2702
|
+
const disabled = new Set((_a = config == null ? void 0 : config.disabledPersonTypes) != null ? _a : []);
|
|
2703
|
+
const personType = !disabled.has("ADULT") ? "ADULT" : !disabled.has("CHILD") ? "CHILD" : "SENIOR";
|
|
2704
|
+
return {
|
|
2705
|
+
firstName: "",
|
|
2706
|
+
lastName: "",
|
|
2707
|
+
email: "",
|
|
2708
|
+
documentNumber: "",
|
|
2709
|
+
phone: "",
|
|
2710
|
+
birthDate: "",
|
|
2711
|
+
personType
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
function AddTravellerDialog({
|
|
2715
|
+
open,
|
|
2716
|
+
adventureId,
|
|
2717
|
+
onClose,
|
|
2718
|
+
onSubmit,
|
|
2719
|
+
config,
|
|
2720
|
+
saving,
|
|
2721
|
+
errorMessage
|
|
2722
|
+
}) {
|
|
2723
|
+
var _a, _b, _c, _d, _e;
|
|
2724
|
+
const [form, setForm] = React22__namespace.useState(() => createInitialAddFormData(config));
|
|
2725
|
+
React22__namespace.useEffect(() => {
|
|
2726
|
+
if (open) {
|
|
2727
|
+
setForm(createInitialAddFormData(config));
|
|
2728
|
+
}
|
|
2729
|
+
}, [open, config]);
|
|
2730
|
+
const childEmailFromContact = config == null ? void 0 : config.childEmailFromContact;
|
|
2731
|
+
const labels = (_a = config == null ? void 0 : config.labels) != null ? _a : {};
|
|
2732
|
+
const handleSubmit = async (e) => {
|
|
2733
|
+
var _a2, _b2, _c2;
|
|
2734
|
+
e.preventDefault();
|
|
2735
|
+
if (!adventureId) return;
|
|
2736
|
+
const data = __spreadProps(__spreadValues({}, form), {
|
|
2737
|
+
firstName: form.firstName.trim(),
|
|
2738
|
+
lastName: form.lastName.trim(),
|
|
2739
|
+
email: form.personType === "CHILD" && childEmailFromContact ? childEmailFromContact : ((_a2 = form.email) == null ? void 0 : _a2.trim()) || void 0,
|
|
2740
|
+
documentNumber: ((_b2 = form.documentNumber) == null ? void 0 : _b2.trim()) || void 0,
|
|
2741
|
+
phone: ((_c2 = form.phone) == null ? void 0 : _c2.trim()) || void 0,
|
|
2742
|
+
birthDate: form.birthDate || void 0
|
|
2743
|
+
});
|
|
2744
|
+
await onSubmit(adventureId, data);
|
|
2745
|
+
};
|
|
2746
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2747
|
+
Dialog,
|
|
2748
|
+
{
|
|
2749
|
+
open,
|
|
2750
|
+
onOpenChange: (o) => {
|
|
2751
|
+
if (!o) onClose();
|
|
2752
|
+
},
|
|
2753
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "sm:max-w-lg", children: [
|
|
2754
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "font-heading text-xl", children: (_b = labels.modalAddTitle) != null ? _b : "Add traveller" }) }),
|
|
2755
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "space-y-3", children: [
|
|
2657
2756
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2658
|
-
|
|
2757
|
+
TravellerFormFields,
|
|
2659
2758
|
{
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
children: "Cancel"
|
|
2759
|
+
value: form,
|
|
2760
|
+
onChange: (patch) => setForm((prev) => __spreadValues(__spreadValues({}, prev), patch)),
|
|
2761
|
+
config
|
|
2664
2762
|
}
|
|
2665
2763
|
),
|
|
2764
|
+
errorMessage && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-destructive font-sans", children: errorMessage }),
|
|
2765
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { children: [
|
|
2766
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onClose, children: (_c = labels.cancel) != null ? _c : "Cancel" }),
|
|
2767
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", size: "sm", disabled: saving, children: saving ? (_d = labels.saving) != null ? _d : "Saving..." : (_e = labels.add) != null ? _e : "Add" })
|
|
2768
|
+
] })
|
|
2769
|
+
] })
|
|
2770
|
+
] })
|
|
2771
|
+
}
|
|
2772
|
+
);
|
|
2773
|
+
}
|
|
2774
|
+
function EditTravellerDialog({
|
|
2775
|
+
open,
|
|
2776
|
+
adventureId,
|
|
2777
|
+
traveller,
|
|
2778
|
+
onClose,
|
|
2779
|
+
onSubmit,
|
|
2780
|
+
config,
|
|
2781
|
+
saving,
|
|
2782
|
+
errorMessage
|
|
2783
|
+
}) {
|
|
2784
|
+
var _a, _b, _c, _d, _e;
|
|
2785
|
+
const [form, setForm] = React22__namespace.useState(() => ({
|
|
2786
|
+
firstName: "",
|
|
2787
|
+
lastName: "",
|
|
2788
|
+
email: "",
|
|
2789
|
+
documentNumber: "",
|
|
2790
|
+
phone: "",
|
|
2791
|
+
birthDate: "",
|
|
2792
|
+
personType: "ADULT"
|
|
2793
|
+
}));
|
|
2794
|
+
React22__namespace.useEffect(() => {
|
|
2795
|
+
var _a2, _b2, _c2, _d2, _e2, _f;
|
|
2796
|
+
if (open && traveller) {
|
|
2797
|
+
setForm({
|
|
2798
|
+
firstName: (_a2 = traveller.firstName) != null ? _a2 : "",
|
|
2799
|
+
lastName: (_b2 = traveller.lastName) != null ? _b2 : "",
|
|
2800
|
+
email: (_c2 = traveller.email) != null ? _c2 : "",
|
|
2801
|
+
documentNumber: (_d2 = traveller.documentNumber) != null ? _d2 : "",
|
|
2802
|
+
phone: (_e2 = traveller.phone) != null ? _e2 : "",
|
|
2803
|
+
birthDate: traveller.birthDate ? traveller.birthDate.slice(0, 10) : "",
|
|
2804
|
+
personType: (_f = traveller.personType) != null ? _f : traveller.isChild ? "CHILD" : "ADULT"
|
|
2805
|
+
});
|
|
2806
|
+
}
|
|
2807
|
+
}, [open, traveller]);
|
|
2808
|
+
const childEmailFromContact = config == null ? void 0 : config.childEmailFromContact;
|
|
2809
|
+
const labels = (_a = config == null ? void 0 : config.labels) != null ? _a : {};
|
|
2810
|
+
const handleSubmit = async (e) => {
|
|
2811
|
+
var _a2, _b2, _c2;
|
|
2812
|
+
e.preventDefault();
|
|
2813
|
+
if (!adventureId || !traveller) return;
|
|
2814
|
+
const data = __spreadProps(__spreadValues({}, form), {
|
|
2815
|
+
firstName: form.firstName.trim(),
|
|
2816
|
+
lastName: form.lastName.trim(),
|
|
2817
|
+
email: form.personType === "CHILD" && childEmailFromContact ? childEmailFromContact : ((_a2 = form.email) == null ? void 0 : _a2.trim()) || void 0,
|
|
2818
|
+
documentNumber: ((_b2 = form.documentNumber) == null ? void 0 : _b2.trim()) || void 0,
|
|
2819
|
+
phone: ((_c2 = form.phone) == null ? void 0 : _c2.trim()) || void 0,
|
|
2820
|
+
birthDate: form.birthDate || void 0
|
|
2821
|
+
});
|
|
2822
|
+
await onSubmit(adventureId, traveller.id, data);
|
|
2823
|
+
};
|
|
2824
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2825
|
+
Dialog,
|
|
2826
|
+
{
|
|
2827
|
+
open,
|
|
2828
|
+
onOpenChange: (o) => {
|
|
2829
|
+
if (!o) onClose();
|
|
2830
|
+
},
|
|
2831
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "sm:max-w-lg", children: [
|
|
2832
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "font-heading text-xl", children: (_b = labels.modalEditTitle) != null ? _b : "Edit traveller" }) }),
|
|
2833
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "space-y-3", children: [
|
|
2666
2834
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2667
|
-
|
|
2835
|
+
TravellerFormFields,
|
|
2836
|
+
{
|
|
2837
|
+
value: form,
|
|
2838
|
+
onChange: (patch) => setForm((prev) => __spreadValues(__spreadValues({}, prev), patch)),
|
|
2839
|
+
config
|
|
2840
|
+
}
|
|
2841
|
+
),
|
|
2842
|
+
errorMessage && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-destructive font-sans", children: errorMessage }),
|
|
2843
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { children: [
|
|
2844
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onClose, children: (_c = labels.cancel) != null ? _c : "Cancel" }),
|
|
2845
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", size: "sm", disabled: saving, children: saving ? (_d = labels.saving) != null ? _d : "Saving..." : (_e = labels.save) != null ? _e : "Save" })
|
|
2846
|
+
] })
|
|
2847
|
+
] })
|
|
2848
|
+
] })
|
|
2849
|
+
}
|
|
2850
|
+
);
|
|
2851
|
+
}
|
|
2852
|
+
function DeleteTravellerDialog({
|
|
2853
|
+
open,
|
|
2854
|
+
adventureId,
|
|
2855
|
+
traveller,
|
|
2856
|
+
onClose,
|
|
2857
|
+
onConfirm,
|
|
2858
|
+
config,
|
|
2859
|
+
saving,
|
|
2860
|
+
errorMessage
|
|
2861
|
+
}) {
|
|
2862
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2863
|
+
const labels = (_a = config == null ? void 0 : config.labels) != null ? _a : {};
|
|
2864
|
+
const name = traveller ? `${(_b = traveller.firstName) != null ? _b : ""} ${(_c = traveller.lastName) != null ? _c : ""}`.trim() : "";
|
|
2865
|
+
const description = ((_d = labels.modalDeleteConfirm) != null ? _d : 'Delete traveller "{name}"?').replace(
|
|
2866
|
+
"{name}",
|
|
2867
|
+
name
|
|
2868
|
+
);
|
|
2869
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2870
|
+
Dialog,
|
|
2871
|
+
{
|
|
2872
|
+
open,
|
|
2873
|
+
onOpenChange: (o) => {
|
|
2874
|
+
if (!o) onClose();
|
|
2875
|
+
},
|
|
2876
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "sm:max-w-sm", children: [
|
|
2877
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
|
|
2878
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: (_e = labels.modalDeleteTitle) != null ? _e : "Delete traveller?" }),
|
|
2879
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { children: description })
|
|
2880
|
+
] }),
|
|
2881
|
+
errorMessage && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-destructive font-sans", children: errorMessage }),
|
|
2882
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { children: [
|
|
2883
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onClose, children: (_f = labels.cancel) != null ? _f : "Cancel" }),
|
|
2884
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2885
|
+
Button,
|
|
2668
2886
|
{
|
|
2669
2887
|
type: "button",
|
|
2888
|
+
variant: "destructive",
|
|
2889
|
+
size: "sm",
|
|
2890
|
+
disabled: saving,
|
|
2670
2891
|
onClick: () => {
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
lastName: "",
|
|
2675
|
-
passport: "",
|
|
2676
|
-
type: "adult",
|
|
2677
|
-
email: "",
|
|
2678
|
-
dateOfBirth: "",
|
|
2679
|
-
phone: ""
|
|
2680
|
-
});
|
|
2892
|
+
if (adventureId && traveller) {
|
|
2893
|
+
void onConfirm(adventureId, traveller.id);
|
|
2894
|
+
}
|
|
2681
2895
|
},
|
|
2682
|
-
|
|
2683
|
-
children: "Add"
|
|
2896
|
+
children: saving ? (_h = (_g = labels.deleting) != null ? _g : labels.saving) != null ? _h : "Deleting..." : (_i = labels.delete) != null ? _i : "Delete"
|
|
2684
2897
|
}
|
|
2685
2898
|
)
|
|
2686
2899
|
] })
|
|
2687
2900
|
] })
|
|
2688
|
-
|
|
2689
|
-
|
|
2901
|
+
}
|
|
2902
|
+
);
|
|
2690
2903
|
}
|
|
2691
2904
|
function OrderSummary({
|
|
2692
2905
|
adventures,
|
|
@@ -2813,6 +3026,14 @@ function BookingDetails({
|
|
|
2813
3026
|
onAddSuggestedTraveller,
|
|
2814
3027
|
onAddTraveller,
|
|
2815
3028
|
onUnassignFromAdventure,
|
|
3029
|
+
onSubmitAddTraveller,
|
|
3030
|
+
onSubmitEditTraveller,
|
|
3031
|
+
onConfirmRemoveTraveller,
|
|
3032
|
+
travellerFormConfig,
|
|
3033
|
+
addTravellerSaving,
|
|
3034
|
+
editTravellerSaving,
|
|
3035
|
+
removeTravellerSaving,
|
|
3036
|
+
travellerFormError,
|
|
2816
3037
|
onPayBalance,
|
|
2817
3038
|
onCancelRequest,
|
|
2818
3039
|
logoSrc,
|
|
@@ -2823,6 +3044,72 @@ function BookingDetails({
|
|
|
2823
3044
|
}) {
|
|
2824
3045
|
var _a, _b, _c;
|
|
2825
3046
|
const people = totalPeople(adventures);
|
|
3047
|
+
const hasSubmitAddTraveller = !!onSubmitAddTraveller;
|
|
3048
|
+
const hasSubmitEditTraveller = !!onSubmitEditTraveller;
|
|
3049
|
+
const hasConfirmRemoveTraveller = !!onConfirmRemoveTraveller;
|
|
3050
|
+
const [addModalState, setAddModalState] = React22__namespace.useState({
|
|
3051
|
+
open: false,
|
|
3052
|
+
adventureId: null
|
|
3053
|
+
});
|
|
3054
|
+
const [editModalState, setEditModalState] = React22__namespace.useState({ open: false, adventureId: null, traveller: null });
|
|
3055
|
+
const [deleteModalState, setDeleteModalState] = React22__namespace.useState({ open: false, adventureId: null, traveller: null });
|
|
3056
|
+
const handleRequestOpenAddModal = React22__namespace.useCallback((adventureId) => {
|
|
3057
|
+
setAddModalState({ open: true, adventureId });
|
|
3058
|
+
}, []);
|
|
3059
|
+
const handleRequestOpenEditModal = React22__namespace.useCallback(
|
|
3060
|
+
(adventureId, traveller) => {
|
|
3061
|
+
setEditModalState({ open: true, adventureId, traveller });
|
|
3062
|
+
},
|
|
3063
|
+
[]
|
|
3064
|
+
);
|
|
3065
|
+
const handleRequestOpenDeleteModal = React22__namespace.useCallback(
|
|
3066
|
+
(adventureId, traveller) => {
|
|
3067
|
+
setDeleteModalState({ open: true, adventureId, traveller });
|
|
3068
|
+
},
|
|
3069
|
+
[]
|
|
3070
|
+
);
|
|
3071
|
+
const closeAddModal = React22__namespace.useCallback(() => {
|
|
3072
|
+
setAddModalState({ open: false, adventureId: null });
|
|
3073
|
+
}, []);
|
|
3074
|
+
const closeEditModal = React22__namespace.useCallback(() => {
|
|
3075
|
+
setEditModalState({ open: false, adventureId: null, traveller: null });
|
|
3076
|
+
}, []);
|
|
3077
|
+
const closeDeleteModal = React22__namespace.useCallback(() => {
|
|
3078
|
+
setDeleteModalState({ open: false, adventureId: null, traveller: null });
|
|
3079
|
+
}, []);
|
|
3080
|
+
const handleAddSubmit = React22__namespace.useCallback(
|
|
3081
|
+
async (adventureId, data) => {
|
|
3082
|
+
if (!onSubmitAddTraveller) return;
|
|
3083
|
+
try {
|
|
3084
|
+
await onSubmitAddTraveller(adventureId, data);
|
|
3085
|
+
closeAddModal();
|
|
3086
|
+
} catch (e) {
|
|
3087
|
+
}
|
|
3088
|
+
},
|
|
3089
|
+
[onSubmitAddTraveller, closeAddModal]
|
|
3090
|
+
);
|
|
3091
|
+
const handleEditSubmit = React22__namespace.useCallback(
|
|
3092
|
+
async (adventureId, travellerId, data) => {
|
|
3093
|
+
if (!onSubmitEditTraveller) return;
|
|
3094
|
+
try {
|
|
3095
|
+
await onSubmitEditTraveller(adventureId, travellerId, data);
|
|
3096
|
+
closeEditModal();
|
|
3097
|
+
} catch (e) {
|
|
3098
|
+
}
|
|
3099
|
+
},
|
|
3100
|
+
[onSubmitEditTraveller, closeEditModal]
|
|
3101
|
+
);
|
|
3102
|
+
const handleDeleteConfirm = React22__namespace.useCallback(
|
|
3103
|
+
async (adventureId, travellerId) => {
|
|
3104
|
+
if (!onConfirmRemoveTraveller) return;
|
|
3105
|
+
try {
|
|
3106
|
+
await onConfirmRemoveTraveller(adventureId, travellerId);
|
|
3107
|
+
closeDeleteModal();
|
|
3108
|
+
} catch (e) {
|
|
3109
|
+
}
|
|
3110
|
+
},
|
|
3111
|
+
[onConfirmRemoveTraveller, closeDeleteModal]
|
|
3112
|
+
);
|
|
2826
3113
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2827
3114
|
(logoSrc || onSignOut) && /* @__PURE__ */ jsxRuntime.jsx("header", { className: "w-full border-b border-border bg-card/50 backdrop-blur-sm sticky top-0 z-30", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full max-w-5xl mx-auto px-4 sm:px-6 lg:px-0 h-14 flex items-center justify-between gap-4", children: [
|
|
2828
3115
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1" }),
|
|
@@ -2927,7 +3214,13 @@ function BookingDetails({
|
|
|
2927
3214
|
onRemoveTraveller,
|
|
2928
3215
|
onAddSuggestedTraveller,
|
|
2929
3216
|
onAddTraveller,
|
|
2930
|
-
onUnassignFromAdventure
|
|
3217
|
+
onUnassignFromAdventure,
|
|
3218
|
+
hasSubmitAddTraveller,
|
|
3219
|
+
hasSubmitEditTraveller,
|
|
3220
|
+
hasConfirmRemoveTraveller,
|
|
3221
|
+
onRequestOpenAddModal: handleRequestOpenAddModal,
|
|
3222
|
+
onRequestOpenEditModal: handleRequestOpenEditModal,
|
|
3223
|
+
onRequestOpenDeleteModal: handleRequestOpenDeleteModal
|
|
2931
3224
|
},
|
|
2932
3225
|
adventure.id
|
|
2933
3226
|
))
|
|
@@ -3003,6 +3296,44 @@ function BookingDetails({
|
|
|
3003
3296
|
] })
|
|
3004
3297
|
]
|
|
3005
3298
|
}
|
|
3299
|
+
),
|
|
3300
|
+
hasSubmitAddTraveller && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3301
|
+
AddTravellerDialog,
|
|
3302
|
+
{
|
|
3303
|
+
open: addModalState.open,
|
|
3304
|
+
adventureId: addModalState.adventureId,
|
|
3305
|
+
onClose: closeAddModal,
|
|
3306
|
+
onSubmit: handleAddSubmit,
|
|
3307
|
+
config: travellerFormConfig,
|
|
3308
|
+
saving: addTravellerSaving,
|
|
3309
|
+
errorMessage: addModalState.open ? travellerFormError : null
|
|
3310
|
+
}
|
|
3311
|
+
),
|
|
3312
|
+
hasSubmitEditTraveller && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3313
|
+
EditTravellerDialog,
|
|
3314
|
+
{
|
|
3315
|
+
open: editModalState.open,
|
|
3316
|
+
adventureId: editModalState.adventureId,
|
|
3317
|
+
traveller: editModalState.traveller,
|
|
3318
|
+
onClose: closeEditModal,
|
|
3319
|
+
onSubmit: handleEditSubmit,
|
|
3320
|
+
config: travellerFormConfig,
|
|
3321
|
+
saving: editTravellerSaving,
|
|
3322
|
+
errorMessage: editModalState.open ? travellerFormError : null
|
|
3323
|
+
}
|
|
3324
|
+
),
|
|
3325
|
+
hasConfirmRemoveTraveller && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3326
|
+
DeleteTravellerDialog,
|
|
3327
|
+
{
|
|
3328
|
+
open: deleteModalState.open,
|
|
3329
|
+
adventureId: deleteModalState.adventureId,
|
|
3330
|
+
traveller: deleteModalState.traveller,
|
|
3331
|
+
onClose: closeDeleteModal,
|
|
3332
|
+
onConfirm: handleDeleteConfirm,
|
|
3333
|
+
config: travellerFormConfig,
|
|
3334
|
+
saving: removeTravellerSaving,
|
|
3335
|
+
errorMessage: deleteModalState.open ? travellerFormError : null
|
|
3336
|
+
}
|
|
3006
3337
|
)
|
|
3007
3338
|
] });
|
|
3008
3339
|
}
|