@wix/himalaya-cli 0.1479.0 → 0.1481.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.
Files changed (70) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +1 -1
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +3 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/state/src/index.d.ts +47 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/app-services-gate.d.ts +86 -0
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/bindings.d.ts +22 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/define-app.d.ts +10 -0
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/index.d.ts +1 -0
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +35 -0
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +87 -0
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +148 -3
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +34 -4
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/state.mjs +95 -0
  13. package/dist/cli.mjs +2153 -1411
  14. package/dist/preview-assets.generated.bin +0 -0
  15. package/guides/component-reference.json +3 -26
  16. package/guides/component-reference.md +7 -9
  17. package/guides/sdk-reference.json +32 -2
  18. package/guides/tier-5-add-a-screen.md +50 -2
  19. package/package.json +2 -2
  20. package/templates/beauty-salon/dev/index.ts +29 -229
  21. package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +69 -9
  22. package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +6 -1
  23. package/templates/beauty-salon/tier5-src/wix-spaces-my-subscriptions/index.ts +2 -2
  24. package/templates/beauty-salon-owner/dev/index.ts +624 -59
  25. package/templates/branded-lite/dev/index.ts +58 -364
  26. package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +69 -9
  27. package/templates/branded-lite/tier5-src/himi-events-rsvp/index.ts +5 -0
  28. package/templates/branded-lite/tier5-src/himi-store-account/index.ts +6 -1
  29. package/templates/branded-lite/tier5-src/wix-spaces-my-subscriptions/index.ts +2 -2
  30. package/templates/community-club/dev/index.ts +26 -134
  31. package/templates/community-club/tier5-src/himi-events-rsvp/index.ts +5 -0
  32. package/templates/community-club/tier5-src/himi-store-account/index.ts +6 -1
  33. package/templates/community-club-owner/dev/index.ts +599 -57
  34. package/templates/events-meetups/dev/index.ts +26 -134
  35. package/templates/events-meetups/tier5-src/himi-events-rsvp/index.ts +5 -0
  36. package/templates/events-meetups/tier5-src/himi-store-account/index.ts +6 -1
  37. package/templates/events-meetups-owner/dev/index.ts +543 -52
  38. package/templates/gym-fitness/dev/index.ts +55 -363
  39. package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +69 -9
  40. package/templates/gym-fitness/tier5-src/himi-events-rsvp/index.ts +5 -0
  41. package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +6 -1
  42. package/templates/gym-fitness/tier5-src/wix-spaces-my-subscriptions/index.ts +2 -2
  43. package/templates/gym-fitness-owner/dev/index.ts +649 -61
  44. package/templates/nonprofit-cause/dev/index.ts +29 -136
  45. package/templates/nonprofit-cause/tier5-src/himi-events-rsvp/index.ts +5 -0
  46. package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +6 -1
  47. package/templates/nonprofit-cause/tier5-src/wix-spaces-my-subscriptions/index.ts +2 -2
  48. package/templates/nonprofit-cause-owner/dev/index.ts +593 -56
  49. package/templates/owner-lite/dev/index.ts +698 -67
  50. package/templates/podcast-creator/dev/index.ts +29 -136
  51. package/templates/podcast-creator/tier5-src/himi-events-rsvp/index.ts +5 -0
  52. package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +6 -1
  53. package/templates/podcast-creator/tier5-src/wix-spaces-my-subscriptions/index.ts +2 -2
  54. package/templates/podcast-creator-owner/dev/index.ts +599 -57
  55. package/templates/portfolio-creative/dev/index.ts +26 -134
  56. package/templates/portfolio-creative/tier5-src/himi-events-rsvp/index.ts +5 -0
  57. package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +6 -1
  58. package/templates/portfolio-creative-owner/dev/index.ts +624 -59
  59. package/templates/restaurant/dev/index.ts +26 -134
  60. package/templates/restaurant/tier5-src/himi-events-rsvp/index.ts +5 -0
  61. package/templates/restaurant/tier5-src/himi-store-account/index.ts +6 -1
  62. package/templates/restaurant-owner/dev/index.ts +649 -61
  63. package/templates/retail-store/tier5-src/himi-store-account/index.ts +6 -1
  64. package/templates/retail-store-owner/dev/index.ts +574 -55
  65. package/templates/yoga-studio/dev/index.ts +55 -363
  66. package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +69 -9
  67. package/templates/yoga-studio/tier5-src/himi-events-rsvp/index.ts +5 -0
  68. package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +6 -1
  69. package/templates/yoga-studio/tier5-src/wix-spaces-my-subscriptions/index.ts +2 -2
  70. package/templates/yoga-studio-owner/dev/index.ts +593 -56
@@ -32815,14 +32815,15 @@ const SCREENS = runtimeSetting({
32815
32815
  "package": "himalaya",
32816
32816
  "type": "Button",
32817
32817
  "props": {
32818
- "title": "Go to Account",
32818
+ "title": "Sign in",
32819
32819
  "style": "secondary",
32820
32820
  "fullWidth": true,
32821
32821
  "leadingIcon": "person",
32822
32822
  "action": {
32823
32823
  "actionId": "himi.open",
32824
32824
  "params": {
32825
- "screenId": "himi_account"
32825
+ "screenId": "himi_sign_in",
32826
+ "mode": "signin"
32826
32827
  }
32827
32828
  }
32828
32829
  }
@@ -86437,7 +86438,9 @@ const SCREENS = runtimeSetting({
86437
86438
  "action": {
86438
86439
  "actionId": "himi.open",
86439
86440
  "params": {
86440
- "screenId": "himi_account"
86441
+ "screenId": "himi_sign_in",
86442
+ "mode": "signin",
86443
+ "returnScreenId": "himi_business_chat"
86441
86444
  }
86442
86445
  }
86443
86446
  }
@@ -91686,233 +91689,6 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
91686
91689
  "props": {
91687
91690
  "spacing": 12,
91688
91691
  "children": [
91689
- {
91690
- "id": "himi_time.signin_card",
91691
- "body": {
91692
- "package": "himalaya",
91693
- "type": "VStack",
91694
- "props": {
91695
- "spacing": 12,
91696
- "alignment": "leading",
91697
- "children": [
91698
- {
91699
- "id": "",
91700
- "body": {
91701
- "package": "himalaya",
91702
- "type": "HStack",
91703
- "props": {
91704
- "spacing": 10,
91705
- "children": [
91706
- {
91707
- "id": "",
91708
- "body": {
91709
- "package": "himalaya",
91710
- "type": "Icon",
91711
- "props": {
91712
- "name": "person",
91713
- "size": 18,
91714
- "tint": "accentPrimary"
91715
- }
91716
- },
91717
- "modifiers": {
91718
- "accessibilityRole": "decorative"
91719
- }
91720
- },
91721
- {
91722
- "id": "",
91723
- "body": {
91724
- "package": "himalaya",
91725
- "type": "Text",
91726
- "props": {
91727
- "text": "$service:himiBookingTime.authTitle",
91728
- "style": "bodyEmphasis",
91729
- "collapseWhenEmpty": true
91730
- }
91731
- }
91732
- }
91733
- ]
91734
- }
91735
- }
91736
- },
91737
- {
91738
- "id": "",
91739
- "body": {
91740
- "package": "himalaya",
91741
- "type": "Text",
91742
- "props": {
91743
- "text": "$service:himiBookingTime.authBody",
91744
- "style": "body",
91745
- "color": "textSecondary",
91746
- "collapseWhenEmpty": true
91747
- }
91748
- }
91749
- },
91750
- {
91751
- "id": "himi_time.signin.first_name",
91752
- "body": {
91753
- "package": "himalaya",
91754
- "type": "TextField",
91755
- "props": {
91756
- "placeholder": "First name",
91757
- "autoCapitalization": "words",
91758
- "onChange": {
91759
- "actionId": "tier5.himiBookingTime.setFirstName"
91760
- }
91761
- }
91762
- },
91763
- "modifiers": {
91764
- "hiddenPath": "$service:himiBookingTime.notRegistering"
91765
- }
91766
- },
91767
- {
91768
- "id": "himi_time.signin.last_name",
91769
- "body": {
91770
- "package": "himalaya",
91771
- "type": "TextField",
91772
- "props": {
91773
- "placeholder": "Last name",
91774
- "autoCapitalization": "words",
91775
- "onChange": {
91776
- "actionId": "tier5.himiBookingTime.setLastName"
91777
- }
91778
- }
91779
- },
91780
- "modifiers": {
91781
- "hiddenPath": "$service:himiBookingTime.notRegistering"
91782
- }
91783
- },
91784
- {
91785
- "id": "himi_time.signin.email",
91786
- "body": {
91787
- "package": "himalaya",
91788
- "type": "TextField",
91789
- "props": {
91790
- "placeholder": "Email",
91791
- "keyboard": "email",
91792
- "autoCapitalization": "none",
91793
- "onChange": {
91794
- "actionId": "tier5.himiBookingTime.setEmail"
91795
- }
91796
- }
91797
- }
91798
- },
91799
- {
91800
- "id": "himi_time.signin.password",
91801
- "body": {
91802
- "package": "himalaya",
91803
- "type": "TextField",
91804
- "props": {
91805
- "placeholder": "Password",
91806
- "valuePath": "$service:himiBookingTime.password",
91807
- "secure": true,
91808
- "autoCapitalization": "none",
91809
- "onChange": {
91810
- "actionId": "tier5.himiBookingTime.setPassword"
91811
- }
91812
- }
91813
- }
91814
- },
91815
- {
91816
- "id": "himi_time.signin",
91817
- "body": {
91818
- "package": "himalaya",
91819
- "type": "Button",
91820
- "props": {
91821
- "title": "Sign in",
91822
- "style": "primary",
91823
- "fullWidth": true,
91824
- "action": {
91825
- "actionId": "tier5.himiBookingTime.signIn"
91826
- }
91827
- }
91828
- },
91829
- "modifiers": {
91830
- "cornerRadius": 8,
91831
- "pressFeedback": "scale",
91832
- "haptic": "medium",
91833
- "hiddenPath": "$service:himiBookingTime.isRegistering"
91834
- }
91835
- },
91836
- {
91837
- "id": "himi_time.show_register",
91838
- "body": {
91839
- "package": "himalaya",
91840
- "type": "Button",
91841
- "props": {
91842
- "title": "Create account",
91843
- "style": "secondary",
91844
- "fullWidth": true,
91845
- "action": {
91846
- "actionId": "tier5.himiBookingTime.showRegister"
91847
- }
91848
- }
91849
- },
91850
- "modifiers": {
91851
- "hiddenPath": "$service:himiBookingTime.isRegistering"
91852
- }
91853
- },
91854
- {
91855
- "id": "himi_time.register",
91856
- "body": {
91857
- "package": "himalaya",
91858
- "type": "Button",
91859
- "props": {
91860
- "title": "Create account",
91861
- "style": "primary",
91862
- "fullWidth": true,
91863
- "action": {
91864
- "actionId": "tier5.himiBookingTime.register"
91865
- }
91866
- }
91867
- },
91868
- "modifiers": {
91869
- "cornerRadius": 8,
91870
- "pressFeedback": "scale",
91871
- "haptic": "medium",
91872
- "hiddenPath": "$service:himiBookingTime.notRegistering"
91873
- }
91874
- },
91875
- {
91876
- "id": "himi_time.show_signin",
91877
- "body": {
91878
- "package": "himalaya",
91879
- "type": "Button",
91880
- "props": {
91881
- "title": "I already have an account",
91882
- "style": "secondary",
91883
- "fullWidth": true,
91884
- "action": {
91885
- "actionId": "tier5.himiBookingTime.showSignIn"
91886
- }
91887
- }
91888
- },
91889
- "modifiers": {
91890
- "hiddenPath": "$service:himiBookingTime.notRegistering"
91891
- }
91892
- }
91893
- ]
91894
- }
91895
- },
91896
- "modifiers": {
91897
- "background": {
91898
- "token": "surfaceElevated"
91899
- },
91900
- "border": {
91901
- "width": 1,
91902
- "color": {
91903
- "token": "border"
91904
- }
91905
- },
91906
- "cornerRadius": 8,
91907
- "padding": {
91908
- "leading": 14,
91909
- "trailing": 14,
91910
- "top": 14,
91911
- "bottom": 14
91912
- },
91913
- "hiddenPath": "$service:himiBookingTime.hideSignIn"
91914
- }
91915
- },
91916
91692
  {
91917
91693
  "id": "himi_time.member_card",
91918
91694
  "body": {
@@ -92061,6 +91837,32 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
92061
91837
  "hiddenPath": "$service:himiBookingTime.notBooking"
92062
91838
  }
92063
91839
  },
91840
+ {
91841
+ "id": "himi_time.book_sign_in",
91842
+ "body": {
91843
+ "package": "himalaya",
91844
+ "type": "Button",
91845
+ "props": {
91846
+ "title": "Book selected time",
91847
+ "style": "primary",
91848
+ "fullWidth": true,
91849
+ "action": {
91850
+ "actionId": "himi.open",
91851
+ "params": {
91852
+ "screenId": "himi_sign_in",
91853
+ "mode": "signin",
91854
+ "intent": "book"
91855
+ }
91856
+ }
91857
+ }
91858
+ },
91859
+ "modifiers": {
91860
+ "cornerRadius": 8,
91861
+ "pressFeedback": "scale",
91862
+ "haptic": "medium",
91863
+ "hiddenPath": "$service:himiBookingTime.hideSignIn"
91864
+ }
91865
+ },
92064
91866
  {
92065
91867
  "id": "himi_time.book",
92066
91868
  "body": {
@@ -94706,140 +94508,6 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
94706
94508
  }
94707
94509
  }
94708
94510
  },
94709
- {
94710
- "id": "himi_rsvp.signin_card",
94711
- "body": {
94712
- "package": "himalaya",
94713
- "type": "VStack",
94714
- "props": {
94715
- "spacing": 12,
94716
- "alignment": "leading",
94717
- "children": [
94718
- {
94719
- "id": "",
94720
- "body": {
94721
- "package": "himalaya",
94722
- "type": "HStack",
94723
- "props": {
94724
- "spacing": 10,
94725
- "children": [
94726
- {
94727
- "id": "",
94728
- "body": {
94729
- "package": "himalaya",
94730
- "type": "Icon",
94731
- "props": {
94732
- "name": "person",
94733
- "size": 18,
94734
- "tint": "accentPrimary"
94735
- }
94736
- },
94737
- "modifiers": {
94738
- "accessibilityRole": "decorative"
94739
- }
94740
- },
94741
- {
94742
- "id": "",
94743
- "body": {
94744
- "package": "himalaya",
94745
- "type": "Text",
94746
- "props": {
94747
- "text": "Sign in to RSVP",
94748
- "style": "bodyEmphasis"
94749
- }
94750
- }
94751
- }
94752
- ]
94753
- }
94754
- }
94755
- },
94756
- {
94757
- "id": "",
94758
- "body": {
94759
- "package": "himalaya",
94760
- "type": "Text",
94761
- "props": {
94762
- "text": "Events can be browsed as a guest. RSVP is saved to your member identity.",
94763
- "style": "body",
94764
- "color": "textSecondary"
94765
- }
94766
- }
94767
- },
94768
- {
94769
- "id": "himi_rsvp.email",
94770
- "body": {
94771
- "package": "himalaya",
94772
- "type": "TextField",
94773
- "props": {
94774
- "placeholder": "Email",
94775
- "value": "",
94776
- "keyboard": "email",
94777
- "autoCapitalization": "none",
94778
- "onChange": {
94779
- "actionId": "tier5.himiEventsRsvp.setEmail"
94780
- }
94781
- }
94782
- }
94783
- },
94784
- {
94785
- "id": "himi_rsvp.password",
94786
- "body": {
94787
- "package": "himalaya",
94788
- "type": "TextField",
94789
- "props": {
94790
- "placeholder": "Password",
94791
- "valuePath": "$service:himiEventsRsvp.password",
94792
- "secure": true,
94793
- "autoCapitalization": "none",
94794
- "onChange": {
94795
- "actionId": "tier5.himiEventsRsvp.setPassword"
94796
- }
94797
- }
94798
- }
94799
- },
94800
- {
94801
- "id": "himi_rsvp.signin",
94802
- "body": {
94803
- "package": "himalaya",
94804
- "type": "Button",
94805
- "props": {
94806
- "title": "Sign in",
94807
- "style": "primary",
94808
- "fullWidth": true,
94809
- "action": {
94810
- "actionId": "tier5.himiEventsRsvp.signIn"
94811
- }
94812
- }
94813
- },
94814
- "modifiers": {
94815
- "cornerRadius": 8,
94816
- "pressFeedback": "scale",
94817
- "haptic": "medium"
94818
- }
94819
- }
94820
- ]
94821
- }
94822
- },
94823
- "modifiers": {
94824
- "background": {
94825
- "token": "surfaceElevated"
94826
- },
94827
- "border": {
94828
- "width": 1,
94829
- "color": {
94830
- "token": "border"
94831
- }
94832
- },
94833
- "cornerRadius": 8,
94834
- "padding": {
94835
- "leading": 14,
94836
- "trailing": 14,
94837
- "top": 14,
94838
- "bottom": 14
94839
- },
94840
- "hiddenPath": "$service:himiEventsRsvp.isMember"
94841
- }
94842
- },
94843
94511
  {
94844
94512
  "id": "himi_rsvp.member_card",
94845
94513
  "body": {
@@ -94955,6 +94623,32 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
94955
94623
  "hiddenPath": "$service:himiEventsRsvp.noSuccess"
94956
94624
  }
94957
94625
  },
94626
+ {
94627
+ "id": "himi_rsvp.confirm_sign_in",
94628
+ "body": {
94629
+ "package": "himalaya",
94630
+ "type": "Button",
94631
+ "props": {
94632
+ "title": "Confirm RSVP",
94633
+ "style": "primary",
94634
+ "fullWidth": true,
94635
+ "action": {
94636
+ "actionId": "himi.open",
94637
+ "params": {
94638
+ "screenId": "himi_sign_in",
94639
+ "mode": "signin",
94640
+ "intent": "rsvp"
94641
+ }
94642
+ }
94643
+ }
94644
+ },
94645
+ "modifiers": {
94646
+ "cornerRadius": 8,
94647
+ "pressFeedback": "scale",
94648
+ "haptic": "medium",
94649
+ "hiddenPath": "$service:himiEventsRsvp.hideGuestRsvp"
94650
+ }
94651
+ },
94958
94652
  {
94959
94653
  "id": "himi_rsvp.confirm",
94960
94654
  "body": {
@@ -160,6 +160,9 @@ function inputId(): string {
160
160
  /** The time a host opened this screen at (`himalaya.input.start`, ISO 8601), or "". Every load
161
161
  * preselects that slot (or opens on its day) until the member picks a day or a time themselves —
162
162
  * not just the first, because the boot load and the screen's own `load` can overlap. */
163
+ /** Counts the customer's picks. A load that sees it move ran while they picked a time. */
164
+ let selectionRevision = 0;
165
+
163
166
  let pendingStart = (() => {
164
167
  const start = (globalThis as { himalaya?: { input?: { start?: unknown } } }).himalaya?.input?.start;
165
168
  return typeof start === "string" && Number.isFinite(Date.parse(start)) ? start : "";
@@ -420,6 +423,48 @@ async function signedInEmail(): Promise<string> {
420
423
  }
421
424
  }
422
425
 
426
+ // A guest's picked time, kept for the sign-in it needs. Hosts key workers by account, so
427
+ // signing in can start a new worker for this screen, with no selection. `himalaya.storage`
428
+ // is shared by every worker of the app on every host, so a member's load of the same
429
+ // service with nothing selected takes the pick back. Reading never clears it: a new worker's
430
+ // boot load and appear load can run at once, and both must restore the same time. It goes
431
+ // when the member picks a time or books, or after 30 minutes.
432
+ const PENDING_PICK_KEY = "himi.booking.pendingPick.v1";
433
+ const PENDING_PICK_TTL_MS = 30 * 60 * 1000;
434
+ type StorageLike = { getItem(key: string): string | null; setItem(key: string, value: string): void };
435
+
436
+ function appStorage(): StorageLike | undefined {
437
+ return (globalThis as { himalaya?: { storage?: StorageLike } }).himalaya?.storage;
438
+ }
439
+
440
+ function writePick(value: string): void {
441
+ try {
442
+ appStorage()?.setItem(PENDING_PICK_KEY, value);
443
+ } catch {
444
+ // No storage on this host: the pick lives only as long as this worker.
445
+ }
446
+ }
447
+
448
+ function rememberPick(serviceId: string, slotId: string): void {
449
+ writePick(JSON.stringify({ serviceId, slotId, at: Date.now() }));
450
+ }
451
+
452
+ function clearPick(): void {
453
+ writePick("");
454
+ }
455
+
456
+ /** The slot a guest picked for `serviceId` in the last 30 minutes, or "". */
457
+ function readPick(serviceId: string): string {
458
+ let pick: { serviceId?: unknown; slotId?: unknown; at?: unknown } | null = null;
459
+ try {
460
+ pick = JSON.parse(appStorage()?.getItem(PENDING_PICK_KEY) || "null");
461
+ } catch {
462
+ // No storage, or a damaged entry: there is no pick to restore.
463
+ }
464
+ const fresh = typeof pick?.at === "number" && Date.now() - pick.at < PENDING_PICK_TTL_MS;
465
+ return fresh && pick?.serviceId === serviceId && typeof pick?.slotId === "string" ? pick.slotId : "";
466
+ }
467
+
423
468
  // Wix Bookings appDefId — the catalogReference.appId that wraps a booking as an
424
469
  // ecom checkout line item, and the payment appId the native cashier settles under.
425
470
  const WIX_BOOKINGS_APP_ID = "13d21c63-b5ec-5912-8397-c3a5ddb27a97";
@@ -507,7 +552,8 @@ const svc = defineService<S, {
507
552
  bookingsScreenId: "himi_bookings",
508
553
  }),
509
554
  actions: {
510
- load: async (s, arg) => {
555
+ load: async (s, arg): Promise<S> => {
556
+ const revisionAtStart = selectionRevision;
511
557
  stashCopy(arg);
512
558
  if (!s.id) return derive({ ...s, status: "ready", errored: true });
513
559
  let next = derive({ ...s, status: "loading", errored: false, message: "", successMessage: "" });
@@ -544,22 +590,29 @@ const svc = defineService<S, {
544
590
  }
545
591
  allRows = rows;
546
592
  const days = daysOf(rows);
547
- // Keep the customer's day across a reload when it still has times;
548
- // otherwise open on the first day that has any.
593
+ // A reload runs in the background when the screen shows again. A time the customer
594
+ // picked while it ran wins over the selection this load started from.
595
+ const chosen: S = selectionRevision !== revisionAtStart ? (svc.getState?.() ?? next) : next;
549
596
  // A host's `start` (deep entry): that slot preselected, or — taken since — its day.
550
597
  const wantedStart = pendingStart;
551
598
  const startRow = wantedStart ? rows.find((r) => r.id === slotIdAt(slotsById, wantedStart)) : undefined;
552
599
  // The requested day even with no time left on it: "taken since" opens there, nothing selected.
553
600
  const startDay = wantedStart ? days.find((d) => d.id === dayKey(wantedStart)) : undefined;
554
- const keep = days.find((d) => d.id === next.selectedDay && d.hasSlots);
555
- const initialDay = startRow?.dayKey ?? startDay?.id ?? keep?.id ?? days.find((d) => d.hasSlots)?.id ?? days[0]?.id ?? "";
556
- const selectionAlive = !!startRow || slotsById.has(next.selectedSlotId);
601
+ const selectionAlive = !!startRow || slotsById.has(chosen.selectedSlotId);
602
+ // A member with no live selection, and no host start, gets back the time they picked as a guest.
603
+ const picked = selectionAlive || wantedStart || !next.isMember ? undefined : rows.find((row) => row.id === readPick(s.id));
604
+ // Keep the customer's day across a reload when it still has times;
605
+ // otherwise open on the first day that has any.
606
+ const keep = days.find((d) => d.id === chosen.selectedDay && d.hasSlots);
607
+ const initialDay = startRow?.dayKey ?? startDay?.id ?? picked?.dayKey ?? keep?.id ?? days.find((d) => d.hasSlots)?.id ?? days[0]?.id ?? "";
557
608
  const header = serviceHeaderFields(serviceRes.service);
558
609
  return derive(withDay({
559
610
  ...next,
560
611
  days,
561
- selectedSlotId: startRow ? startRow.id : selectionAlive ? next.selectedSlotId : "",
562
- selectedLine: startRow ? [startRow.day, startRow.title, startRow.subtitle].filter(Boolean).join(" · ") : selectionAlive ? next.selectedLine : "",
612
+ selectedSlotId: startRow ? startRow.id : selectionAlive ? chosen.selectedSlotId : picked?.id ?? "",
613
+ selectedLine: startRow ? [startRow.day, startRow.title, startRow.subtitle].filter(Boolean).join(" · ")
614
+ : selectionAlive ? chosen.selectedLine
615
+ : picked ? [picked.day, picked.title, picked.subtitle].filter(Boolean).join(" · ") : "",
563
616
  status: "ready",
564
617
  errored: false,
565
618
  serviceName: serviceRes.service?.name || copyParam("time.serviceNameFallback", "Choose a time"),
@@ -593,7 +646,12 @@ const svc = defineService<S, {
593
646
  ? arg
594
647
  : ((arg as { id?: string; slotId?: string })?.slotId ?? (arg as { id?: string })?.id ?? "");
595
648
  const selected = allRows.find((slot) => slot.id === slotId);
596
- if (selected) pendingStart = "";
649
+ if (selected) {
650
+ selectionRevision++;
651
+ pendingStart = "";
652
+ if (s.isMember) clearPick();
653
+ else rememberPick(s.id, slotId);
654
+ }
597
655
  return derive({
598
656
  ...s,
599
657
  selectedSlotId: selected ? slotId : s.selectedSlotId,
@@ -666,6 +724,8 @@ const svc = defineService<S, {
666
724
  start: hostEventInstant(booking?.startDate) || slot.startDate,
667
725
  end: hostEventInstant(booking?.endDate) || slot.endDate,
668
726
  });
727
+ // The member acts on the pick now; a later visit must not restore it.
728
+ clearPick();
669
729
  // PAID service — FULLY NATIVE in-app payment (mirrors Wix's RN apps): NO
670
730
  // hosted-checkout WebView / browser redirect. The chain is
671
731
  // createBooking → ecom.createCheckout(booking line item) → ecom.createOrder
@@ -35,6 +35,9 @@ interface S {
35
35
  noSuccess: boolean;
36
36
  canRsvp: boolean;
37
37
  cannotRsvp: boolean;
38
+ /** Hides a guest's RSVP button, which opens a sign-in screen: shown only for a guest with
39
+ * an event to RSVP to, as `cannotRsvp` requires an event for a member's. */
40
+ hideGuestRsvp: boolean;
38
41
  errored: boolean;
39
42
  notErrored: boolean;
40
43
  isLoading: boolean;
@@ -74,6 +77,7 @@ function derive(s: S): S {
74
77
  notMember: !s.isMember,
75
78
  canRsvp,
76
79
  cannotRsvp: !canRsvp,
80
+ hideGuestRsvp: s.isMember || !hasEvent,
77
81
  noSuccess: !hasSuccess,
78
82
  notErrored: !s.errored,
79
83
  noEmpty: s.status === "loading" || s.errored || hasEvent,
@@ -144,6 +148,7 @@ const svc = defineService<S, {
144
148
  noSuccess: true,
145
149
  canRsvp: false,
146
150
  cannotRsvp: true,
151
+ hideGuestRsvp: true,
147
152
  errored: false,
148
153
  notErrored: true,
149
154
  isLoading: true,
@@ -365,6 +365,11 @@ function authHeadline(s: S, isRegistering: boolean, isRecovering: boolean): { au
365
365
  authTitle: copyParam("storeAccount.authTitleRsvp", "Sign in to RSVP"),
366
366
  authBody: copyParam("storeAccount.authBodyRsvp", "Sign in to RSVP, then we’ll bring you back."),
367
367
  };
368
+ case "book":
369
+ return {
370
+ authTitle: copyParam("storeAccount.authTitleBook", "Sign in to book"),
371
+ authBody: copyParam("storeAccount.authBodyBook", "Sign in to book this time, then we’ll bring you back."),
372
+ };
368
373
  case "post":
369
374
  return {
370
375
  authTitle: copyParam("storeAccount.authTitlePost", "Sign in to post"),
@@ -392,7 +397,7 @@ interface S extends IapRestoreFields {
392
397
  noMemberImage: boolean;
393
398
  authTitle: string;
394
399
  authBody: string;
395
- /** Mid-flow gate intent (`join_group` | `rsvp` | `post` | ""). */
400
+ /** Mid-flow gate intent (`join_group` | `rsvp` | `book` | `post` | ""). */
396
401
  authIntent: string;
397
402
  authContextName: string;
398
403
  returnScreenId: string;