@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.js CHANGED
@@ -2241,21 +2241,16 @@ function AdventureSection({
2241
2241
  onRemoveTraveller,
2242
2242
  onAddSuggestedTraveller,
2243
2243
  onAddTraveller,
2244
- onUnassignFromAdventure
2244
+ onUnassignFromAdventure,
2245
+ hasSubmitAddTraveller,
2246
+ hasSubmitEditTraveller,
2247
+ hasConfirmRemoveTraveller,
2248
+ onRequestOpenAddModal,
2249
+ onRequestOpenEditModal,
2250
+ onRequestOpenDeleteModal
2245
2251
  }) {
2246
2252
  var _a, _b, _c, _d;
2247
2253
  const [detailsOpen, setDetailsOpen] = React22.useState(false);
2248
- const [addModalOpen, setAddModalOpen] = React22.useState(false);
2249
- const [newTraveller, setNewTraveller] = React22.useState({
2250
- firstName: "",
2251
- lastName: "",
2252
- passport: "",
2253
- type: "adult",
2254
- email: "",
2255
- dateOfBirth: "",
2256
- phone: ""
2257
- });
2258
- const setField = (k, v) => setNewTraveller((p) => __spreadProps(__spreadValues({}, p), { [k]: v }));
2259
2254
  const handleCopyUrl = (url) => {
2260
2255
  navigator.clipboard.writeText(url);
2261
2256
  };
@@ -2413,11 +2408,17 @@ function AdventureSection({
2413
2408
  ]
2414
2409
  }
2415
2410
  ),
2416
- /* @__PURE__ */ jsxs(
2411
+ (onAddTraveller || hasSubmitAddTraveller) && /* @__PURE__ */ jsxs(
2417
2412
  "button",
2418
2413
  {
2419
2414
  type: "button",
2420
- onClick: () => onAddTraveller ? onAddTraveller(adventure.id) : setAddModalOpen(true),
2415
+ onClick: () => {
2416
+ if (onAddTraveller) {
2417
+ onAddTraveller(adventure.id);
2418
+ } else {
2419
+ onRequestOpenAddModal == null ? void 0 : onRequestOpenAddModal(adventure.id);
2420
+ }
2421
+ },
2421
2422
  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",
2422
2423
  children: [
2423
2424
  /* @__PURE__ */ jsx(PlusIcon, { className: "w-3 h-3" }),
@@ -2480,31 +2481,51 @@ function AdventureSection({
2480
2481
  }
2481
2482
  ),
2482
2483
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5 shrink-0", children: [
2483
- onEditTraveller && /* @__PURE__ */ jsx(
2484
+ (onEditTraveller || hasSubmitEditTraveller) && /* @__PURE__ */ jsx(
2484
2485
  "button",
2485
2486
  {
2486
2487
  type: "button",
2487
- onClick: () => onEditTraveller(adventure.id, t.id),
2488
+ onClick: () => {
2489
+ if (onEditTraveller) {
2490
+ onEditTraveller(adventure.id, t.id);
2491
+ } else {
2492
+ onRequestOpenEditModal == null ? void 0 : onRequestOpenEditModal(adventure.id, t);
2493
+ }
2494
+ },
2488
2495
  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",
2489
2496
  "aria-label": `Edit ${t.firstName}`,
2490
2497
  children: /* @__PURE__ */ jsx(PencilIcon, { className: "w-3.5 h-3.5" })
2491
2498
  }
2492
2499
  ),
2493
- onRemoveTraveller && /* @__PURE__ */ jsx(
2500
+ (onRemoveTraveller || hasConfirmRemoveTraveller) && /* @__PURE__ */ jsx(
2494
2501
  "button",
2495
2502
  {
2496
2503
  type: "button",
2497
- onClick: () => onRemoveTraveller(adventure.id, t.id),
2504
+ onClick: () => {
2505
+ if (onRemoveTraveller) {
2506
+ onRemoveTraveller(adventure.id, t.id);
2507
+ } else {
2508
+ onRequestOpenDeleteModal == null ? void 0 : onRequestOpenDeleteModal(adventure.id, t);
2509
+ }
2510
+ },
2498
2511
  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",
2499
2512
  "aria-label": `Delete ${t.firstName}`,
2500
2513
  children: /* @__PURE__ */ jsx(Trash2Icon, { className: "w-3.5 h-3.5" })
2501
2514
  }
2502
2515
  ),
2503
- (onUnassignFromAdventure || onRemoveTraveller) && /* @__PURE__ */ jsx(
2516
+ (onUnassignFromAdventure || onRemoveTraveller || hasConfirmRemoveTraveller) && /* @__PURE__ */ jsx(
2504
2517
  "button",
2505
2518
  {
2506
2519
  type: "button",
2507
- onClick: () => onUnassignFromAdventure ? onUnassignFromAdventure(adventure.id, t.id) : onRemoveTraveller(adventure.id, t.id),
2520
+ onClick: () => {
2521
+ if (onUnassignFromAdventure) {
2522
+ onUnassignFromAdventure(adventure.id, t.id);
2523
+ } else if (onRemoveTraveller) {
2524
+ onRemoveTraveller(adventure.id, t.id);
2525
+ } else {
2526
+ onRequestOpenDeleteModal == null ? void 0 : onRequestOpenDeleteModal(adventure.id, t);
2527
+ }
2528
+ },
2508
2529
  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",
2509
2530
  "aria-label": `Remove ${t.firstName} from adventure`,
2510
2531
  children: /* @__PURE__ */ jsx(UserMinusIcon, { className: "w-3.5 h-3.5" })
@@ -2561,111 +2582,303 @@ function AdventureSection({
2561
2582
  ] })
2562
2583
  ] });
2563
2584
  })()
2564
- ] }),
2565
- /* @__PURE__ */ jsx(Dialog, { open: addModalOpen, onOpenChange: setAddModalOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-md", children: [
2566
- /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { className: "font-heading text-xl", children: "Add traveller" }) }),
2567
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 pt-2", children: [
2568
- /* @__PURE__ */ jsx(
2569
- FloatingInput,
2570
- {
2571
- label: "First name",
2572
- required: true,
2573
- value: newTraveller.firstName,
2574
- onChange: (e) => setField("firstName", e.target.value)
2575
- }
2576
- ),
2577
- /* @__PURE__ */ jsx(
2578
- FloatingInput,
2579
- {
2580
- label: "Last name",
2581
- required: true,
2582
- value: newTraveller.lastName,
2583
- onChange: (e) => setField("lastName", e.target.value)
2584
- }
2585
- ),
2586
- /* @__PURE__ */ jsx(
2587
- FloatingInput,
2588
- {
2589
- label: "Passport (optional)",
2590
- value: newTraveller.passport,
2591
- onChange: (e) => setField("passport", e.target.value)
2592
- }
2593
- ),
2594
- /* @__PURE__ */ jsxs(
2595
- FloatingSelect,
2596
- {
2597
- label: "Type (adult/child/senior)",
2598
- value: newTraveller.type,
2599
- onChange: (e) => setField("type", e.target.value),
2600
- children: [
2601
- /* @__PURE__ */ jsx("option", { value: "adult", children: "Adult" }),
2602
- /* @__PURE__ */ jsx("option", { value: "child", children: "Child" }),
2603
- /* @__PURE__ */ jsx("option", { value: "senior", children: "Senior" })
2604
- ]
2605
- }
2606
- ),
2607
- /* @__PURE__ */ jsx(
2608
- FloatingInput,
2609
- {
2610
- label: "Email",
2611
- type: "email",
2612
- required: true,
2613
- value: newTraveller.email,
2614
- onChange: (e) => setField("email", e.target.value)
2615
- }
2616
- ),
2617
- /* @__PURE__ */ jsx(
2618
- FloatingInput,
2619
- {
2620
- label: "Date of birth",
2621
- type: "date",
2622
- value: newTraveller.dateOfBirth,
2623
- onChange: (e) => setField("dateOfBirth", e.target.value)
2624
- }
2625
- ),
2626
- /* @__PURE__ */ jsx(
2627
- FloatingInput,
2628
- {
2629
- label: "Phone (optional)",
2630
- type: "tel",
2631
- value: newTraveller.phone,
2632
- onChange: (e) => setField("phone", e.target.value)
2633
- }
2634
- ),
2635
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-3 pt-2", children: [
2585
+ ] })
2586
+ ] });
2587
+ }
2588
+ function TravellerFormFields({ value, onChange, config }) {
2589
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
2590
+ const labels = (_a = config == null ? void 0 : config.labels) != null ? _a : {};
2591
+ const disabledTypes = new Set((_b = config == null ? void 0 : config.disabledPersonTypes) != null ? _b : []);
2592
+ const documentLabel = (config == null ? void 0 : config.requireCpf) ? (_c = labels.documentCpf) != null ? _c : "CPF" : (_d = labels.documentPassport) != null ? _d : "Passport (optional)";
2593
+ const documentPlaceholder = (config == null ? void 0 : config.requireCpf) ? "000.000.000-00" : void 0;
2594
+ const isChild = value.personType === "CHILD";
2595
+ const childEmail = config == null ? void 0 : config.childEmailFromContact;
2596
+ const emailRequired = value.personType === "ADULT" || value.personType === "SENIOR";
2597
+ const emailLabel = `${(_e = labels.email) != null ? _e : "Email"}${emailRequired ? " *" : ""}`;
2598
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2599
+ /* @__PURE__ */ jsx(
2600
+ FloatingInput,
2601
+ {
2602
+ label: (_f = labels.firstName) != null ? _f : "First name *",
2603
+ required: true,
2604
+ value: value.firstName,
2605
+ onChange: (e) => onChange({ firstName: e.target.value })
2606
+ }
2607
+ ),
2608
+ /* @__PURE__ */ jsx(
2609
+ FloatingInput,
2610
+ {
2611
+ label: (_g = labels.lastName) != null ? _g : "Last name *",
2612
+ required: true,
2613
+ value: value.lastName,
2614
+ onChange: (e) => onChange({ lastName: e.target.value })
2615
+ }
2616
+ ),
2617
+ /* @__PURE__ */ jsx(
2618
+ FloatingInput,
2619
+ {
2620
+ label: documentLabel,
2621
+ placeholder: documentPlaceholder,
2622
+ value: (_h = value.documentNumber) != null ? _h : "",
2623
+ onChange: (e) => onChange({ documentNumber: e.target.value })
2624
+ }
2625
+ ),
2626
+ /* @__PURE__ */ jsxs(
2627
+ FloatingSelect,
2628
+ {
2629
+ label: (_i = labels.personTypeLabel) != null ? _i : "Type (adult/child/senior)",
2630
+ value: value.personType,
2631
+ onChange: (e) => onChange({ personType: e.target.value }),
2632
+ children: [
2633
+ /* @__PURE__ */ jsx("option", { value: "ADULT", disabled: disabledTypes.has("ADULT"), children: (_j = labels.personTypeAdult) != null ? _j : "Adult" }),
2634
+ /* @__PURE__ */ jsx("option", { value: "CHILD", disabled: disabledTypes.has("CHILD"), children: (_k = labels.personTypeChild) != null ? _k : "Child" }),
2635
+ /* @__PURE__ */ jsx("option", { value: "SENIOR", disabled: disabledTypes.has("SENIOR"), children: (_l = labels.personTypeSenior) != null ? _l : "Senior" })
2636
+ ]
2637
+ }
2638
+ ),
2639
+ isChild && childEmail ? /* @__PURE__ */ jsx(
2640
+ FloatingInput,
2641
+ {
2642
+ label: (_m = labels.email) != null ? _m : "Email",
2643
+ type: "email",
2644
+ value: childEmail,
2645
+ readOnly: true,
2646
+ disabled: true
2647
+ }
2648
+ ) : /* @__PURE__ */ jsx(
2649
+ FloatingInput,
2650
+ {
2651
+ label: emailLabel,
2652
+ type: "email",
2653
+ value: (_n = value.email) != null ? _n : "",
2654
+ onChange: (e) => onChange({ email: e.target.value }),
2655
+ required: emailRequired
2656
+ }
2657
+ ),
2658
+ /* @__PURE__ */ jsx(
2659
+ FloatingInput,
2660
+ {
2661
+ label: (_o = labels.birthDate) != null ? _o : "Date of birth",
2662
+ type: "date",
2663
+ value: (_p = value.birthDate) != null ? _p : "",
2664
+ onChange: (e) => onChange({ birthDate: e.target.value })
2665
+ }
2666
+ ),
2667
+ /* @__PURE__ */ jsx(
2668
+ FloatingInput,
2669
+ {
2670
+ label: (_q = labels.phone) != null ? _q : "Phone (optional)",
2671
+ type: "tel",
2672
+ value: (_r = value.phone) != null ? _r : "",
2673
+ onChange: (e) => onChange({ phone: e.target.value }),
2674
+ placeholder: "+5511987654321"
2675
+ }
2676
+ )
2677
+ ] });
2678
+ }
2679
+ function createInitialAddFormData(config) {
2680
+ var _a;
2681
+ const disabled = new Set((_a = config == null ? void 0 : config.disabledPersonTypes) != null ? _a : []);
2682
+ const personType = !disabled.has("ADULT") ? "ADULT" : !disabled.has("CHILD") ? "CHILD" : "SENIOR";
2683
+ return {
2684
+ firstName: "",
2685
+ lastName: "",
2686
+ email: "",
2687
+ documentNumber: "",
2688
+ phone: "",
2689
+ birthDate: "",
2690
+ personType
2691
+ };
2692
+ }
2693
+ function AddTravellerDialog({
2694
+ open,
2695
+ adventureId,
2696
+ onClose,
2697
+ onSubmit,
2698
+ config,
2699
+ saving,
2700
+ errorMessage
2701
+ }) {
2702
+ var _a, _b, _c, _d, _e;
2703
+ const [form, setForm] = React22.useState(() => createInitialAddFormData(config));
2704
+ React22.useEffect(() => {
2705
+ if (open) {
2706
+ setForm(createInitialAddFormData(config));
2707
+ }
2708
+ }, [open, config]);
2709
+ const childEmailFromContact = config == null ? void 0 : config.childEmailFromContact;
2710
+ const labels = (_a = config == null ? void 0 : config.labels) != null ? _a : {};
2711
+ const handleSubmit = async (e) => {
2712
+ var _a2, _b2, _c2;
2713
+ e.preventDefault();
2714
+ if (!adventureId) return;
2715
+ const data = __spreadProps(__spreadValues({}, form), {
2716
+ firstName: form.firstName.trim(),
2717
+ lastName: form.lastName.trim(),
2718
+ email: form.personType === "CHILD" && childEmailFromContact ? childEmailFromContact : ((_a2 = form.email) == null ? void 0 : _a2.trim()) || void 0,
2719
+ documentNumber: ((_b2 = form.documentNumber) == null ? void 0 : _b2.trim()) || void 0,
2720
+ phone: ((_c2 = form.phone) == null ? void 0 : _c2.trim()) || void 0,
2721
+ birthDate: form.birthDate || void 0
2722
+ });
2723
+ await onSubmit(adventureId, data);
2724
+ };
2725
+ return /* @__PURE__ */ jsx(
2726
+ Dialog,
2727
+ {
2728
+ open,
2729
+ onOpenChange: (o) => {
2730
+ if (!o) onClose();
2731
+ },
2732
+ children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-lg", children: [
2733
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { className: "font-heading text-xl", children: (_b = labels.modalAddTitle) != null ? _b : "Add traveller" }) }),
2734
+ /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "space-y-3", children: [
2636
2735
  /* @__PURE__ */ jsx(
2637
- "button",
2736
+ TravellerFormFields,
2638
2737
  {
2639
- type: "button",
2640
- onClick: () => setAddModalOpen(false),
2641
- className: "text-sm font-ui text-muted-foreground hover:text-foreground transition-colors",
2642
- children: "Cancel"
2738
+ value: form,
2739
+ onChange: (patch) => setForm((prev) => __spreadValues(__spreadValues({}, prev), patch)),
2740
+ config
2643
2741
  }
2644
2742
  ),
2743
+ errorMessage && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive font-sans", children: errorMessage }),
2744
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
2745
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onClose, children: (_c = labels.cancel) != null ? _c : "Cancel" }),
2746
+ /* @__PURE__ */ jsx(Button, { type: "submit", size: "sm", disabled: saving, children: saving ? (_d = labels.saving) != null ? _d : "Saving..." : (_e = labels.add) != null ? _e : "Add" })
2747
+ ] })
2748
+ ] })
2749
+ ] })
2750
+ }
2751
+ );
2752
+ }
2753
+ function EditTravellerDialog({
2754
+ open,
2755
+ adventureId,
2756
+ traveller,
2757
+ onClose,
2758
+ onSubmit,
2759
+ config,
2760
+ saving,
2761
+ errorMessage
2762
+ }) {
2763
+ var _a, _b, _c, _d, _e;
2764
+ const [form, setForm] = React22.useState(() => ({
2765
+ firstName: "",
2766
+ lastName: "",
2767
+ email: "",
2768
+ documentNumber: "",
2769
+ phone: "",
2770
+ birthDate: "",
2771
+ personType: "ADULT"
2772
+ }));
2773
+ React22.useEffect(() => {
2774
+ var _a2, _b2, _c2, _d2, _e2, _f;
2775
+ if (open && traveller) {
2776
+ setForm({
2777
+ firstName: (_a2 = traveller.firstName) != null ? _a2 : "",
2778
+ lastName: (_b2 = traveller.lastName) != null ? _b2 : "",
2779
+ email: (_c2 = traveller.email) != null ? _c2 : "",
2780
+ documentNumber: (_d2 = traveller.documentNumber) != null ? _d2 : "",
2781
+ phone: (_e2 = traveller.phone) != null ? _e2 : "",
2782
+ birthDate: traveller.birthDate ? traveller.birthDate.slice(0, 10) : "",
2783
+ personType: (_f = traveller.personType) != null ? _f : traveller.isChild ? "CHILD" : "ADULT"
2784
+ });
2785
+ }
2786
+ }, [open, traveller]);
2787
+ const childEmailFromContact = config == null ? void 0 : config.childEmailFromContact;
2788
+ const labels = (_a = config == null ? void 0 : config.labels) != null ? _a : {};
2789
+ const handleSubmit = async (e) => {
2790
+ var _a2, _b2, _c2;
2791
+ e.preventDefault();
2792
+ if (!adventureId || !traveller) return;
2793
+ const data = __spreadProps(__spreadValues({}, form), {
2794
+ firstName: form.firstName.trim(),
2795
+ lastName: form.lastName.trim(),
2796
+ email: form.personType === "CHILD" && childEmailFromContact ? childEmailFromContact : ((_a2 = form.email) == null ? void 0 : _a2.trim()) || void 0,
2797
+ documentNumber: ((_b2 = form.documentNumber) == null ? void 0 : _b2.trim()) || void 0,
2798
+ phone: ((_c2 = form.phone) == null ? void 0 : _c2.trim()) || void 0,
2799
+ birthDate: form.birthDate || void 0
2800
+ });
2801
+ await onSubmit(adventureId, traveller.id, data);
2802
+ };
2803
+ return /* @__PURE__ */ jsx(
2804
+ Dialog,
2805
+ {
2806
+ open,
2807
+ onOpenChange: (o) => {
2808
+ if (!o) onClose();
2809
+ },
2810
+ children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-lg", children: [
2811
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { className: "font-heading text-xl", children: (_b = labels.modalEditTitle) != null ? _b : "Edit traveller" }) }),
2812
+ /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "space-y-3", children: [
2645
2813
  /* @__PURE__ */ jsx(
2646
- "button",
2814
+ TravellerFormFields,
2815
+ {
2816
+ value: form,
2817
+ onChange: (patch) => setForm((prev) => __spreadValues(__spreadValues({}, prev), patch)),
2818
+ config
2819
+ }
2820
+ ),
2821
+ errorMessage && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive font-sans", children: errorMessage }),
2822
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
2823
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onClose, children: (_c = labels.cancel) != null ? _c : "Cancel" }),
2824
+ /* @__PURE__ */ jsx(Button, { type: "submit", size: "sm", disabled: saving, children: saving ? (_d = labels.saving) != null ? _d : "Saving..." : (_e = labels.save) != null ? _e : "Save" })
2825
+ ] })
2826
+ ] })
2827
+ ] })
2828
+ }
2829
+ );
2830
+ }
2831
+ function DeleteTravellerDialog({
2832
+ open,
2833
+ adventureId,
2834
+ traveller,
2835
+ onClose,
2836
+ onConfirm,
2837
+ config,
2838
+ saving,
2839
+ errorMessage
2840
+ }) {
2841
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2842
+ const labels = (_a = config == null ? void 0 : config.labels) != null ? _a : {};
2843
+ const name = traveller ? `${(_b = traveller.firstName) != null ? _b : ""} ${(_c = traveller.lastName) != null ? _c : ""}`.trim() : "";
2844
+ const description = ((_d = labels.modalDeleteConfirm) != null ? _d : 'Delete traveller "{name}"?').replace(
2845
+ "{name}",
2846
+ name
2847
+ );
2848
+ return /* @__PURE__ */ jsx(
2849
+ Dialog,
2850
+ {
2851
+ open,
2852
+ onOpenChange: (o) => {
2853
+ if (!o) onClose();
2854
+ },
2855
+ children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-sm", children: [
2856
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
2857
+ /* @__PURE__ */ jsx(DialogTitle, { children: (_e = labels.modalDeleteTitle) != null ? _e : "Delete traveller?" }),
2858
+ /* @__PURE__ */ jsx(DialogDescription, { children: description })
2859
+ ] }),
2860
+ errorMessage && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive font-sans", children: errorMessage }),
2861
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
2862
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onClose, children: (_f = labels.cancel) != null ? _f : "Cancel" }),
2863
+ /* @__PURE__ */ jsx(
2864
+ Button,
2647
2865
  {
2648
2866
  type: "button",
2867
+ variant: "destructive",
2868
+ size: "sm",
2869
+ disabled: saving,
2649
2870
  onClick: () => {
2650
- setAddModalOpen(false);
2651
- setNewTraveller({
2652
- firstName: "",
2653
- lastName: "",
2654
- passport: "",
2655
- type: "adult",
2656
- email: "",
2657
- dateOfBirth: "",
2658
- phone: ""
2659
- });
2871
+ if (adventureId && traveller) {
2872
+ void onConfirm(adventureId, traveller.id);
2873
+ }
2660
2874
  },
2661
- className: "rounded-full bg-primary px-6 py-2.5 text-sm font-bold text-primary-foreground font-heading hover:bg-primary/90 transition-colors",
2662
- children: "Add"
2875
+ children: saving ? (_h = (_g = labels.deleting) != null ? _g : labels.saving) != null ? _h : "Deleting..." : (_i = labels.delete) != null ? _i : "Delete"
2663
2876
  }
2664
2877
  )
2665
2878
  ] })
2666
2879
  ] })
2667
- ] }) })
2668
- ] });
2880
+ }
2881
+ );
2669
2882
  }
2670
2883
  function OrderSummary({
2671
2884
  adventures,
@@ -2792,6 +3005,14 @@ function BookingDetails({
2792
3005
  onAddSuggestedTraveller,
2793
3006
  onAddTraveller,
2794
3007
  onUnassignFromAdventure,
3008
+ onSubmitAddTraveller,
3009
+ onSubmitEditTraveller,
3010
+ onConfirmRemoveTraveller,
3011
+ travellerFormConfig,
3012
+ addTravellerSaving,
3013
+ editTravellerSaving,
3014
+ removeTravellerSaving,
3015
+ travellerFormError,
2795
3016
  onPayBalance,
2796
3017
  onCancelRequest,
2797
3018
  logoSrc,
@@ -2802,6 +3023,72 @@ function BookingDetails({
2802
3023
  }) {
2803
3024
  var _a, _b, _c;
2804
3025
  const people = totalPeople(adventures);
3026
+ const hasSubmitAddTraveller = !!onSubmitAddTraveller;
3027
+ const hasSubmitEditTraveller = !!onSubmitEditTraveller;
3028
+ const hasConfirmRemoveTraveller = !!onConfirmRemoveTraveller;
3029
+ const [addModalState, setAddModalState] = React22.useState({
3030
+ open: false,
3031
+ adventureId: null
3032
+ });
3033
+ const [editModalState, setEditModalState] = React22.useState({ open: false, adventureId: null, traveller: null });
3034
+ const [deleteModalState, setDeleteModalState] = React22.useState({ open: false, adventureId: null, traveller: null });
3035
+ const handleRequestOpenAddModal = React22.useCallback((adventureId) => {
3036
+ setAddModalState({ open: true, adventureId });
3037
+ }, []);
3038
+ const handleRequestOpenEditModal = React22.useCallback(
3039
+ (adventureId, traveller) => {
3040
+ setEditModalState({ open: true, adventureId, traveller });
3041
+ },
3042
+ []
3043
+ );
3044
+ const handleRequestOpenDeleteModal = React22.useCallback(
3045
+ (adventureId, traveller) => {
3046
+ setDeleteModalState({ open: true, adventureId, traveller });
3047
+ },
3048
+ []
3049
+ );
3050
+ const closeAddModal = React22.useCallback(() => {
3051
+ setAddModalState({ open: false, adventureId: null });
3052
+ }, []);
3053
+ const closeEditModal = React22.useCallback(() => {
3054
+ setEditModalState({ open: false, adventureId: null, traveller: null });
3055
+ }, []);
3056
+ const closeDeleteModal = React22.useCallback(() => {
3057
+ setDeleteModalState({ open: false, adventureId: null, traveller: null });
3058
+ }, []);
3059
+ const handleAddSubmit = React22.useCallback(
3060
+ async (adventureId, data) => {
3061
+ if (!onSubmitAddTraveller) return;
3062
+ try {
3063
+ await onSubmitAddTraveller(adventureId, data);
3064
+ closeAddModal();
3065
+ } catch (e) {
3066
+ }
3067
+ },
3068
+ [onSubmitAddTraveller, closeAddModal]
3069
+ );
3070
+ const handleEditSubmit = React22.useCallback(
3071
+ async (adventureId, travellerId, data) => {
3072
+ if (!onSubmitEditTraveller) return;
3073
+ try {
3074
+ await onSubmitEditTraveller(adventureId, travellerId, data);
3075
+ closeEditModal();
3076
+ } catch (e) {
3077
+ }
3078
+ },
3079
+ [onSubmitEditTraveller, closeEditModal]
3080
+ );
3081
+ const handleDeleteConfirm = React22.useCallback(
3082
+ async (adventureId, travellerId) => {
3083
+ if (!onConfirmRemoveTraveller) return;
3084
+ try {
3085
+ await onConfirmRemoveTraveller(adventureId, travellerId);
3086
+ closeDeleteModal();
3087
+ } catch (e) {
3088
+ }
3089
+ },
3090
+ [onConfirmRemoveTraveller, closeDeleteModal]
3091
+ );
2805
3092
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2806
3093
  (logoSrc || onSignOut) && /* @__PURE__ */ jsx("header", { className: "w-full border-b border-border bg-card/50 backdrop-blur-sm sticky top-0 z-30", children: /* @__PURE__ */ 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: [
2807
3094
  /* @__PURE__ */ jsx("div", { className: "flex-1" }),
@@ -2906,7 +3193,13 @@ function BookingDetails({
2906
3193
  onRemoveTraveller,
2907
3194
  onAddSuggestedTraveller,
2908
3195
  onAddTraveller,
2909
- onUnassignFromAdventure
3196
+ onUnassignFromAdventure,
3197
+ hasSubmitAddTraveller,
3198
+ hasSubmitEditTraveller,
3199
+ hasConfirmRemoveTraveller,
3200
+ onRequestOpenAddModal: handleRequestOpenAddModal,
3201
+ onRequestOpenEditModal: handleRequestOpenEditModal,
3202
+ onRequestOpenDeleteModal: handleRequestOpenDeleteModal
2910
3203
  },
2911
3204
  adventure.id
2912
3205
  ))
@@ -2982,6 +3275,44 @@ function BookingDetails({
2982
3275
  ] })
2983
3276
  ]
2984
3277
  }
3278
+ ),
3279
+ hasSubmitAddTraveller && /* @__PURE__ */ jsx(
3280
+ AddTravellerDialog,
3281
+ {
3282
+ open: addModalState.open,
3283
+ adventureId: addModalState.adventureId,
3284
+ onClose: closeAddModal,
3285
+ onSubmit: handleAddSubmit,
3286
+ config: travellerFormConfig,
3287
+ saving: addTravellerSaving,
3288
+ errorMessage: addModalState.open ? travellerFormError : null
3289
+ }
3290
+ ),
3291
+ hasSubmitEditTraveller && /* @__PURE__ */ jsx(
3292
+ EditTravellerDialog,
3293
+ {
3294
+ open: editModalState.open,
3295
+ adventureId: editModalState.adventureId,
3296
+ traveller: editModalState.traveller,
3297
+ onClose: closeEditModal,
3298
+ onSubmit: handleEditSubmit,
3299
+ config: travellerFormConfig,
3300
+ saving: editTravellerSaving,
3301
+ errorMessage: editModalState.open ? travellerFormError : null
3302
+ }
3303
+ ),
3304
+ hasConfirmRemoveTraveller && /* @__PURE__ */ jsx(
3305
+ DeleteTravellerDialog,
3306
+ {
3307
+ open: deleteModalState.open,
3308
+ adventureId: deleteModalState.adventureId,
3309
+ traveller: deleteModalState.traveller,
3310
+ onClose: closeDeleteModal,
3311
+ onConfirm: handleDeleteConfirm,
3312
+ config: travellerFormConfig,
3313
+ saving: removeTravellerSaving,
3314
+ errorMessage: deleteModalState.open ? travellerFormError : null
3315
+ }
2985
3316
  )
2986
3317
  ] });
2987
3318
  }