@wix/himalaya-cli 0.1950.0 → 0.1952.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/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +10 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +37 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +38 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +9 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{bb3ece9e6e814275817059f029f1b2db624dceb90d9e1a53ebae2b45fe6d36e5.bin → 15c152934a97a0d3de15946239a0037a38603f1972d2288b59945bd28a0fd237.bin} +1 -1
- package/dist/browser-plane/sw.js +9 -9
- package/dist/cli.mjs +151 -97
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/component-index.md +1 -1
- package/guides/component-reference.json +1 -1
- package/guides/component-reference.md +4 -0
- package/guides/one-app-to-himi-app.md +7 -4
- package/package.json +2 -2
- package/templates/beauty-salon/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +10 -30
- package/templates/branded-lite/recipes/blog-list-thumb-start.json +56 -5
- package/templates/branded-lite/recipes/blog-list.json +56 -5
- package/templates/branded-lite/recipes/blog-see-all.json +1 -1
- package/templates/branded-lite/recipes/plans-card.json +18 -1
- package/templates/branded-lite/recipes/upcoming-bookings.json +87 -30
- package/templates/branded-lite/tier5-src/_shared/blog-list.ts +34 -10
- package/templates/branded-lite/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/branded-lite/tier5-src/_shared/plan-facts.ts +31 -15
- package/templates/branded-lite/tier5-src/_shared/plans-section.ts +7 -3
- package/templates/branded-lite/tier5-src/_shared/upcoming-bookings-section.ts +27 -5
- package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +10 -30
- package/templates/community-club/l10n/ar.json +44 -0
- package/templates/community-club/l10n/cs.json +44 -0
- package/templates/community-club/l10n/da.json +44 -0
- package/templates/community-club/l10n/de.json +44 -0
- package/templates/community-club/l10n/el.json +44 -0
- package/templates/community-club/l10n/en.json +27 -0
- package/templates/community-club/l10n/es.json +44 -0
- package/templates/community-club/l10n/fi.json +44 -0
- package/templates/community-club/l10n/fr.json +44 -0
- package/templates/community-club/l10n/he.json +36 -0
- package/templates/community-club/l10n/hu.json +44 -0
- package/templates/community-club/l10n/id.json +44 -0
- package/templates/community-club/l10n/it.json +44 -0
- package/templates/community-club/l10n/ja.json +44 -0
- package/templates/community-club/l10n/ko.json +44 -0
- package/templates/community-club/l10n/lt.json +44 -0
- package/templates/community-club/l10n/nl.json +44 -0
- package/templates/community-club/l10n/no.json +44 -0
- package/templates/community-club/l10n/pl.json +44 -0
- package/templates/community-club/l10n/pt.json +44 -0
- package/templates/community-club/l10n/ru.json +44 -0
- package/templates/community-club/l10n/sv.json +44 -0
- package/templates/community-club/l10n/th.json +44 -0
- package/templates/community-club/l10n/tr.json +44 -0
- package/templates/community-club/l10n/uk.json +44 -0
- package/templates/community-club/l10n/vi.json +44 -0
- package/templates/community-club/l10n/zh.json +44 -0
- package/templates/community-club/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/events-meetups/l10n/ar.json +44 -0
- package/templates/events-meetups/l10n/cs.json +44 -0
- package/templates/events-meetups/l10n/da.json +44 -0
- package/templates/events-meetups/l10n/de.json +44 -0
- package/templates/events-meetups/l10n/el.json +44 -0
- package/templates/events-meetups/l10n/en.json +27 -0
- package/templates/events-meetups/l10n/es.json +44 -0
- package/templates/events-meetups/l10n/fi.json +44 -0
- package/templates/events-meetups/l10n/fr.json +44 -0
- package/templates/events-meetups/l10n/he.json +36 -0
- package/templates/events-meetups/l10n/hu.json +44 -0
- package/templates/events-meetups/l10n/id.json +44 -0
- package/templates/events-meetups/l10n/it.json +44 -0
- package/templates/events-meetups/l10n/ja.json +44 -0
- package/templates/events-meetups/l10n/ko.json +44 -0
- package/templates/events-meetups/l10n/lt.json +44 -0
- package/templates/events-meetups/l10n/nl.json +44 -0
- package/templates/events-meetups/l10n/no.json +44 -0
- package/templates/events-meetups/l10n/pl.json +44 -0
- package/templates/events-meetups/l10n/pt.json +44 -0
- package/templates/events-meetups/l10n/ru.json +44 -0
- package/templates/events-meetups/l10n/sv.json +44 -0
- package/templates/events-meetups/l10n/th.json +44 -0
- package/templates/events-meetups/l10n/tr.json +44 -0
- package/templates/events-meetups/l10n/uk.json +44 -0
- package/templates/events-meetups/l10n/vi.json +44 -0
- package/templates/events-meetups/l10n/zh.json +44 -0
- package/templates/events-meetups/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/fitness-gym/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/fitness-gym/tier5-src/himi-booking-bookings/index.ts +10 -30
- package/templates/gym-fitness/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +10 -30
- package/templates/medical-services/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/medical-services/tier5-src/himi-booking-bookings/index.ts +10 -30
- package/templates/nonprofit-cause/l10n/ar.json +38 -0
- package/templates/nonprofit-cause/l10n/cs.json +38 -0
- package/templates/nonprofit-cause/l10n/da.json +38 -0
- package/templates/nonprofit-cause/l10n/de.json +38 -0
- package/templates/nonprofit-cause/l10n/el.json +38 -0
- package/templates/nonprofit-cause/l10n/en.json +20 -0
- package/templates/nonprofit-cause/l10n/es.json +38 -0
- package/templates/nonprofit-cause/l10n/fi.json +38 -0
- package/templates/nonprofit-cause/l10n/fr.json +38 -0
- package/templates/nonprofit-cause/l10n/he.json +31 -0
- package/templates/nonprofit-cause/l10n/hu.json +38 -0
- package/templates/nonprofit-cause/l10n/id.json +38 -0
- package/templates/nonprofit-cause/l10n/it.json +38 -0
- package/templates/nonprofit-cause/l10n/ja.json +38 -0
- package/templates/nonprofit-cause/l10n/ko.json +38 -0
- package/templates/nonprofit-cause/l10n/lt.json +38 -0
- package/templates/nonprofit-cause/l10n/nl.json +38 -0
- package/templates/nonprofit-cause/l10n/no.json +38 -0
- package/templates/nonprofit-cause/l10n/pl.json +38 -0
- package/templates/nonprofit-cause/l10n/pt.json +38 -0
- package/templates/nonprofit-cause/l10n/ru.json +38 -0
- package/templates/nonprofit-cause/l10n/sv.json +38 -0
- package/templates/nonprofit-cause/l10n/th.json +38 -0
- package/templates/nonprofit-cause/l10n/tr.json +38 -0
- package/templates/nonprofit-cause/l10n/uk.json +38 -0
- package/templates/nonprofit-cause/l10n/vi.json +38 -0
- package/templates/nonprofit-cause/l10n/zh.json +38 -0
- package/templates/nonprofit-cause/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/personal-fitness-trainer/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/personal-fitness-trainer/tier5-src/himi-booking-bookings/index.ts +10 -30
- package/templates/podcast-creator/l10n/ar.json +38 -0
- package/templates/podcast-creator/l10n/cs.json +38 -0
- package/templates/podcast-creator/l10n/da.json +38 -0
- package/templates/podcast-creator/l10n/de.json +38 -0
- package/templates/podcast-creator/l10n/el.json +38 -0
- package/templates/podcast-creator/l10n/en.json +20 -0
- package/templates/podcast-creator/l10n/es.json +38 -0
- package/templates/podcast-creator/l10n/fi.json +38 -0
- package/templates/podcast-creator/l10n/fr.json +38 -0
- package/templates/podcast-creator/l10n/he.json +31 -0
- package/templates/podcast-creator/l10n/hu.json +38 -0
- package/templates/podcast-creator/l10n/id.json +38 -0
- package/templates/podcast-creator/l10n/it.json +38 -0
- package/templates/podcast-creator/l10n/ja.json +38 -0
- package/templates/podcast-creator/l10n/ko.json +38 -0
- package/templates/podcast-creator/l10n/lt.json +38 -0
- package/templates/podcast-creator/l10n/nl.json +38 -0
- package/templates/podcast-creator/l10n/no.json +38 -0
- package/templates/podcast-creator/l10n/pl.json +38 -0
- package/templates/podcast-creator/l10n/pt.json +38 -0
- package/templates/podcast-creator/l10n/ru.json +38 -0
- package/templates/podcast-creator/l10n/sv.json +38 -0
- package/templates/podcast-creator/l10n/th.json +38 -0
- package/templates/podcast-creator/l10n/tr.json +38 -0
- package/templates/podcast-creator/l10n/uk.json +38 -0
- package/templates/podcast-creator/l10n/vi.json +38 -0
- package/templates/podcast-creator/l10n/zh.json +38 -0
- package/templates/podcast-creator/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/portfolio-creative/l10n/ar.json +38 -0
- package/templates/portfolio-creative/l10n/cs.json +38 -0
- package/templates/portfolio-creative/l10n/da.json +38 -0
- package/templates/portfolio-creative/l10n/de.json +38 -0
- package/templates/portfolio-creative/l10n/el.json +38 -0
- package/templates/portfolio-creative/l10n/en.json +20 -0
- package/templates/portfolio-creative/l10n/es.json +38 -0
- package/templates/portfolio-creative/l10n/fi.json +38 -0
- package/templates/portfolio-creative/l10n/fr.json +38 -0
- package/templates/portfolio-creative/l10n/he.json +31 -0
- package/templates/portfolio-creative/l10n/hu.json +38 -0
- package/templates/portfolio-creative/l10n/id.json +38 -0
- package/templates/portfolio-creative/l10n/it.json +38 -0
- package/templates/portfolio-creative/l10n/ja.json +38 -0
- package/templates/portfolio-creative/l10n/ko.json +38 -0
- package/templates/portfolio-creative/l10n/lt.json +38 -0
- package/templates/portfolio-creative/l10n/nl.json +38 -0
- package/templates/portfolio-creative/l10n/no.json +38 -0
- package/templates/portfolio-creative/l10n/pl.json +38 -0
- package/templates/portfolio-creative/l10n/pt.json +38 -0
- package/templates/portfolio-creative/l10n/ru.json +38 -0
- package/templates/portfolio-creative/l10n/sv.json +38 -0
- package/templates/portfolio-creative/l10n/th.json +38 -0
- package/templates/portfolio-creative/l10n/tr.json +38 -0
- package/templates/portfolio-creative/l10n/uk.json +38 -0
- package/templates/portfolio-creative/l10n/vi.json +38 -0
- package/templates/portfolio-creative/l10n/zh.json +38 -0
- package/templates/portfolio-creative/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/professional-services/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/professional-services/tier5-src/himi-booking-bookings/index.ts +10 -30
- package/templates/restaurant/l10n/ar.json +38 -0
- package/templates/restaurant/l10n/cs.json +38 -0
- package/templates/restaurant/l10n/da.json +38 -0
- package/templates/restaurant/l10n/de.json +38 -0
- package/templates/restaurant/l10n/el.json +38 -0
- package/templates/restaurant/l10n/en.json +20 -0
- package/templates/restaurant/l10n/es.json +38 -0
- package/templates/restaurant/l10n/fi.json +38 -0
- package/templates/restaurant/l10n/fr.json +38 -0
- package/templates/restaurant/l10n/he.json +31 -0
- package/templates/restaurant/l10n/hu.json +38 -0
- package/templates/restaurant/l10n/id.json +38 -0
- package/templates/restaurant/l10n/it.json +38 -0
- package/templates/restaurant/l10n/ja.json +38 -0
- package/templates/restaurant/l10n/ko.json +38 -0
- package/templates/restaurant/l10n/lt.json +38 -0
- package/templates/restaurant/l10n/nl.json +38 -0
- package/templates/restaurant/l10n/no.json +38 -0
- package/templates/restaurant/l10n/pl.json +38 -0
- package/templates/restaurant/l10n/pt.json +38 -0
- package/templates/restaurant/l10n/ru.json +38 -0
- package/templates/restaurant/l10n/sv.json +38 -0
- package/templates/restaurant/l10n/th.json +38 -0
- package/templates/restaurant/l10n/tr.json +38 -0
- package/templates/restaurant/l10n/uk.json +38 -0
- package/templates/restaurant/l10n/vi.json +38 -0
- package/templates/restaurant/l10n/zh.json +38 -0
- package/templates/restaurant/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/retail-store/l10n/ar.json +38 -0
- package/templates/retail-store/l10n/cs.json +38 -0
- package/templates/retail-store/l10n/da.json +38 -0
- package/templates/retail-store/l10n/de.json +38 -0
- package/templates/retail-store/l10n/el.json +38 -0
- package/templates/retail-store/l10n/en.json +20 -0
- package/templates/retail-store/l10n/es.json +38 -0
- package/templates/retail-store/l10n/fi.json +38 -0
- package/templates/retail-store/l10n/fr.json +38 -0
- package/templates/retail-store/l10n/he.json +31 -0
- package/templates/retail-store/l10n/hu.json +38 -0
- package/templates/retail-store/l10n/id.json +38 -0
- package/templates/retail-store/l10n/it.json +38 -0
- package/templates/retail-store/l10n/ja.json +38 -0
- package/templates/retail-store/l10n/ko.json +38 -0
- package/templates/retail-store/l10n/lt.json +38 -0
- package/templates/retail-store/l10n/nl.json +38 -0
- package/templates/retail-store/l10n/no.json +38 -0
- package/templates/retail-store/l10n/pl.json +38 -0
- package/templates/retail-store/l10n/pt.json +38 -0
- package/templates/retail-store/l10n/ru.json +38 -0
- package/templates/retail-store/l10n/sv.json +38 -0
- package/templates/retail-store/l10n/th.json +38 -0
- package/templates/retail-store/l10n/tr.json +38 -0
- package/templates/retail-store/l10n/uk.json +38 -0
- package/templates/retail-store/l10n/vi.json +38 -0
- package/templates/retail-store/l10n/zh.json +38 -0
- package/templates/retail-store/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/salon-spa/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/salon-spa/tier5-src/himi-booking-bookings/index.ts +10 -30
- package/templates/yoga-studio/tier5-src/_shared/member-bookings.ts +48 -1
- package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +10 -30
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_recipe": "A page's upcoming bookings: the signed-in member's next bookings as rows (what, when, staff and place; a tap opens that booking on My Bookings), the section's See All button when there are more upcoming ones, the source's empty text, and a sign-in state for a guest. When the source shows previous bookings, a History block under them, as the source's does: a \"History\" heading with a Show All link to My Bookings, the member's latest past booking (what, when, staff and place) with a Book Again button (opens the service), or the source's empty state when the member has none. `{{id}}.past.again` is removed when the scaffold has no service screen. ONE node, always mounted. Service: registerUpcomingBookingsSection(svc, { limit, showPast, pastLimit, emptyText }).",
|
|
2
|
+
"_recipe": "A page's upcoming bookings: the signed-in member's next bookings as rows (what, when with the session's length, staff and place, and a status badge such as Booked; a tap opens that booking on My Bookings), each with a More actions button (•••) that opens the booking's action sheet on My Bookings, shown only when that sheet offers the booking an action, the section's See All button when there are more upcoming ones, the source's empty text, and a sign-in state for a guest. When the source shows previous bookings, a History block under them, as the source's does: a \"History\" heading with a Show All link to My Bookings, the member's latest past booking (what, when with the session's length, staff and place) with a Book Again button (opens the service), or the source's empty state when the member has none. `{{id}}.past.again` is removed when the scaffold has no service screen. ONE node, always mounted. Service: registerUpcomingBookingsSection(svc, { limit, showPast, pastLimit, emptyText }).",
|
|
3
3
|
"_placeholders": {
|
|
4
4
|
"svc": "service name the page worker registered with registerUpcomingBookingsSection",
|
|
5
5
|
"id": "unique node id prefix for this section",
|
|
@@ -114,51 +114,108 @@
|
|
|
114
114
|
"id": "{{id}}.upcoming.row",
|
|
115
115
|
"body": {
|
|
116
116
|
"package": "himalaya",
|
|
117
|
-
"type": "
|
|
117
|
+
"type": "HStack",
|
|
118
118
|
"props": {
|
|
119
|
-
"spacing":
|
|
120
|
-
"alignment": "
|
|
119
|
+
"spacing": 8,
|
|
120
|
+
"alignment": "center",
|
|
121
121
|
"children": [
|
|
122
122
|
{
|
|
123
|
-
"id": "{{id}}.upcoming.
|
|
123
|
+
"id": "{{id}}.upcoming.info",
|
|
124
124
|
"body": {
|
|
125
125
|
"package": "himalaya",
|
|
126
|
-
"type": "
|
|
127
|
-
"props": {
|
|
128
|
-
"text": "$item.title",
|
|
129
|
-
"style": "bodyEmphasis",
|
|
130
|
-
"maxLines": 2
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
"id": "{{id}}.upcoming.when",
|
|
136
|
-
"body": {
|
|
137
|
-
"package": "himalaya",
|
|
138
|
-
"type": "Text",
|
|
126
|
+
"type": "VStack",
|
|
139
127
|
"props": {
|
|
140
|
-
"
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
|
|
128
|
+
"spacing": 2,
|
|
129
|
+
"alignment": "leading",
|
|
130
|
+
"children": [
|
|
131
|
+
{
|
|
132
|
+
"id": "{{id}}.upcoming.title",
|
|
133
|
+
"body": {
|
|
134
|
+
"package": "himalaya",
|
|
135
|
+
"type": "Text",
|
|
136
|
+
"props": {
|
|
137
|
+
"text": "$item.title",
|
|
138
|
+
"style": "bodyEmphasis",
|
|
139
|
+
"maxLines": 2
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"id": "{{id}}.upcoming.when",
|
|
145
|
+
"body": {
|
|
146
|
+
"package": "himalaya",
|
|
147
|
+
"type": "Text",
|
|
148
|
+
"props": {
|
|
149
|
+
"text": "$item.when",
|
|
150
|
+
"style": "footnote",
|
|
151
|
+
"maxLines": 2,
|
|
152
|
+
"color": "textSecondary"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"id": "{{id}}.upcoming.detail",
|
|
158
|
+
"body": {
|
|
159
|
+
"package": "himalaya",
|
|
160
|
+
"type": "Text",
|
|
161
|
+
"props": {
|
|
162
|
+
"text": "$item.detail",
|
|
163
|
+
"style": "caption",
|
|
164
|
+
"maxLines": 1,
|
|
165
|
+
"color": "textSecondary",
|
|
166
|
+
"collapseWhenEmpty": true
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"modifiers": {
|
|
170
|
+
"hiddenPath": "$item.noDetail"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"id": "{{id}}.upcoming.badge",
|
|
175
|
+
"body": {
|
|
176
|
+
"package": "himalaya",
|
|
177
|
+
"type": "Tag",
|
|
178
|
+
"props": {
|
|
179
|
+
"text": "$item.badge",
|
|
180
|
+
"tokenPath": "$item.badgeToken"
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"modifiers": {
|
|
184
|
+
"hiddenPath": "$item.noBadge",
|
|
185
|
+
"padding": {
|
|
186
|
+
"top": 6
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
]
|
|
144
191
|
}
|
|
192
|
+
},
|
|
193
|
+
"modifiers": {
|
|
194
|
+
"weight": 1
|
|
145
195
|
}
|
|
146
196
|
},
|
|
147
197
|
{
|
|
148
|
-
"id": "{{id}}.upcoming.
|
|
198
|
+
"id": "{{id}}.upcoming.actions",
|
|
149
199
|
"body": {
|
|
150
200
|
"package": "himalaya",
|
|
151
|
-
"type": "
|
|
201
|
+
"type": "Button",
|
|
152
202
|
"props": {
|
|
153
|
-
"
|
|
154
|
-
"style": "
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
203
|
+
"title": "More actions",
|
|
204
|
+
"style": "tertiary",
|
|
205
|
+
"size": "md",
|
|
206
|
+
"leadingIcon": "ellipsis",
|
|
207
|
+
"iconOnly": true,
|
|
208
|
+
"action": {
|
|
209
|
+
"actionId": "himi.open",
|
|
210
|
+
"params": {
|
|
211
|
+
"screenId": "{{seeAllScreen}}",
|
|
212
|
+
"bookingId": "$item.id"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
158
215
|
}
|
|
159
216
|
},
|
|
160
217
|
"modifiers": {
|
|
161
|
-
"hiddenPath": "$item.
|
|
218
|
+
"hiddenPath": "$item.noActions"
|
|
162
219
|
}
|
|
163
220
|
}
|
|
164
221
|
]
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// A blog post list as a registrable service: the One App compact post list, driven by the source section's settings.
|
|
2
2
|
// limit unset -> follow the page cursor to the last post; limit N -> N posts and a "See All" for the same category,
|
|
3
|
-
// show.{author,date,readingTime,likes,views,comments} -> exactly what the section's displayOptions enable,
|
|
3
|
+
// show.{author,avatar,excerpt,date,readingTime,likes,views,comments} -> exactly what the section's displayOptions enable,
|
|
4
4
|
// relativeTime -> "2 hours ago" instead of the date,
|
|
5
5
|
// countOrder -> the icon counts in the source's order (default likes, views, comments),
|
|
6
6
|
// featuredOnly -> only the posts the owner marked featured (the Blog API's `featured` filter),
|
|
7
|
+
// seeAll -> a limited list whose section has a See All Posts footer: shown whenever the list has posts, even when
|
|
8
|
+
// they all fit the limit (the source shows it then too); unset keeps "only when there are more posts",
|
|
7
9
|
// search -> a search section: no posts until the reader types, then the latest posts whose title or excerpt hold the text.
|
|
8
10
|
// A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipe blog-post-row.json).
|
|
9
11
|
import { defineService as register } from "@himalaya/state";
|
|
@@ -12,7 +14,7 @@ import { getPublicMember } from "@himalaya/wix-members";
|
|
|
12
14
|
import { stashCopy, copyParam, copyPlural } from "./himi-copy.js";
|
|
13
15
|
import { formatDateMedium, formatNumber } from "./engine-intl.js";
|
|
14
16
|
import { relativeTime } from "./relative-time.js";
|
|
15
|
-
import { coverOf } from "./himi-blog-post-row.js";
|
|
17
|
+
import { coverOf, profilePhoto } from "./himi-blog-post-row.js";
|
|
16
18
|
|
|
17
19
|
export type CountKey = "likes" | "views" | "comments";
|
|
18
20
|
const COUNT_KEYS: readonly CountKey[] = ["likes", "views", "comments"];
|
|
@@ -22,13 +24,19 @@ export interface BlogListOptions {
|
|
|
22
24
|
categoryId?: string;
|
|
23
25
|
/** Posts shown; unset follows the cursor to the last post. */
|
|
24
26
|
limit?: number;
|
|
25
|
-
|
|
27
|
+
/** `avatar`: the author's public photo; `excerpt`: the post's summary under its title. Unset is hidden, like the other facts. */
|
|
28
|
+
show: { author?: boolean; avatar?: boolean; excerpt?: boolean; cover?: boolean; date?: boolean; readingTime?: boolean; likes?: boolean; views?: boolean; comments?: boolean };
|
|
26
29
|
relativeTime?: boolean;
|
|
27
30
|
countOrder?: CountKey[];
|
|
28
31
|
/** The post screen a row opens. */
|
|
29
32
|
detailScreenId?: string;
|
|
30
33
|
/** Only the posts the owner marked featured. */
|
|
31
34
|
featuredOnly?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The section has a See All Posts footer (a limited list): it shows whenever the list has posts, also when they all fit the limit.
|
|
37
|
+
* Unset keeps the earlier rule, See All only while there are more posts than shown. An unlimited list never shows it.
|
|
38
|
+
*/
|
|
39
|
+
seeAll?: boolean;
|
|
32
40
|
/**
|
|
33
41
|
* A search section instead of a list: nothing is shown (or read) until the reader types. The latest posts are read once, up to the API's
|
|
34
42
|
* per-query cap, and each keystroke filters them by title and excerpt; `limit` and paging do not apply.
|
|
@@ -44,6 +52,12 @@ export interface BlogRow {
|
|
|
44
52
|
/** Time and reading time ("2 hours ago · 4 min read"). */
|
|
45
53
|
meta: string; hasMeta: boolean; noMeta: boolean;
|
|
46
54
|
authorName: string; hasAuthor: boolean; noAuthor: boolean;
|
|
55
|
+
/** The author's public photo (the avatar setting); the byline row shows when it has the name or the photo. */
|
|
56
|
+
authorPhoto: string; hasAvatar: boolean;
|
|
57
|
+
/** The photo's accessible label: the author's name whenever the photo shows, also when the name itself is off. */
|
|
58
|
+
avatarLabel: string; noAvatar: boolean; hasByline: boolean; noByline: boolean;
|
|
59
|
+
/** The post's summary (the excerpt setting), "" when off or empty. */
|
|
60
|
+
excerpt: string; hasExcerpt: boolean; noExcerpt: boolean;
|
|
47
61
|
counts: Count[]; hasCounts: boolean; noCounts: boolean;
|
|
48
62
|
count1Icon: string; count1Text: string; count1Num: string; hasCount1: boolean; noCount1: boolean;
|
|
49
63
|
count2Icon: string; count2Text: string; count2Num: string; hasCount2: boolean; noCount2: boolean;
|
|
@@ -107,14 +121,18 @@ export function registerBlogList(serviceName: string, options: BlogListOptions)
|
|
|
107
121
|
const searching = options.search === true;
|
|
108
122
|
const limited = !searching && typeof options.limit === "number" && options.limit > 0;
|
|
109
123
|
const detailScreenId = options.detailScreenId ?? "himi_blog_post";
|
|
110
|
-
// Author names by member id, for this service only. A failed lookup stays unknown: no placeholder name.
|
|
111
|
-
const authors = new Map<string, string>();
|
|
124
|
+
// Author names and photos by member id, for this service only. A failed lookup stays unknown: no placeholder name or photo.
|
|
125
|
+
const authors = new Map<string, { name: string; photo: string }>();
|
|
126
|
+
const needsAuthor = options.show.author === true || options.show.avatar === true;
|
|
112
127
|
|
|
113
128
|
async function resolveAuthors(posts: Post[]): Promise<void> {
|
|
114
129
|
const ids = [...new Set(posts.map((p) => p.memberId).filter((id): id is string => !!id && !authors.has(id)))];
|
|
115
130
|
await Promise.all(ids.map(async (id) => {
|
|
116
131
|
// The PUBLIC profile only: a visitor can read it, and it carries the nickname without the login email or contact data.
|
|
117
|
-
try {
|
|
132
|
+
try {
|
|
133
|
+
const profile = (await getPublicMember(id)).member.profile;
|
|
134
|
+
authors.set(id, { name: profile?.nickname ?? "", photo: profilePhoto(profile?.photo) });
|
|
135
|
+
} catch { authors.set(id, { name: "", photo: "" }); }
|
|
118
136
|
}));
|
|
119
137
|
}
|
|
120
138
|
|
|
@@ -129,13 +147,19 @@ export function registerBlogList(serviceName: string, options: BlogListOptions)
|
|
|
129
147
|
const [one, two, three] = [slotOf(counts, 0), slotOf(counts, 1), slotOf(counts, 2)];
|
|
130
148
|
// A Wix media reference becomes a fetchable, list-sized URL; the owner turning the cover off (media.displayed) leaves none.
|
|
131
149
|
const cover = show.cover === false ? "" : coverOf(post);
|
|
132
|
-
const
|
|
150
|
+
const author = post.memberId ? authors.get(post.memberId) : undefined;
|
|
151
|
+
const authorName = show.author ? author?.name ?? "" : "";
|
|
152
|
+
const authorPhoto = show.avatar ? author?.photo ?? "" : "";
|
|
153
|
+
const avatarLabel = authorPhoto ? author?.name ?? "" : "";
|
|
154
|
+
const excerpt = show.excerpt ? (post.excerpt ?? "").trim() : "";
|
|
133
155
|
const title = post.title || copyParam("blogList.untitled", "Untitled post");
|
|
134
156
|
const meta = bits.filter(Boolean).join(" · ");
|
|
135
157
|
return {
|
|
136
158
|
id: post.id, title, cover, hasCover: !!cover, noCover: !cover, initial: (title[0] ?? "#").toUpperCase(),
|
|
137
159
|
meta, hasMeta: !!meta, noMeta: !meta,
|
|
138
160
|
authorName, hasAuthor: !!authorName, noAuthor: !authorName,
|
|
161
|
+
authorPhoto, avatarLabel, hasAvatar: !!authorPhoto, noAvatar: !authorPhoto, hasByline: !!(authorName || authorPhoto), noByline: !(authorName || authorPhoto),
|
|
162
|
+
excerpt, hasExcerpt: !!excerpt, noExcerpt: !excerpt,
|
|
139
163
|
counts, hasCounts: counts.length > 0, noCounts: counts.length === 0,
|
|
140
164
|
count1Icon: one.Icon, count1Text: one.Text, count1Num: one.Num, hasCount1: one.has, noCount1: one.no,
|
|
141
165
|
count2Icon: two.Icon, count2Text: two.Text, count2Num: two.Num, hasCount2: two.has, noCount2: two.no,
|
|
@@ -154,8 +178,8 @@ export function registerBlogList(serviceName: string, options: BlogListOptions)
|
|
|
154
178
|
// A search has its own "no matching posts" line; the list's "no posts yet" must not show before anything is typed.
|
|
155
179
|
noRows: !rows.length, notEmpty: searching || !(status === "ready" && !rows.length),
|
|
156
180
|
hasMatches: !searching || !typed || status !== "ready" || rows.length > 0,
|
|
157
|
-
// See All only for a LIMITED list
|
|
158
|
-
noSeeAll: !(limited && more),
|
|
181
|
+
// See All only for a LIMITED list: with the section's footer, whenever it has posts; without, while it has more than it shows.
|
|
182
|
+
noSeeAll: !(limited && (options.seeAll === true ? rows.length > 0 : more)),
|
|
159
183
|
};
|
|
160
184
|
}
|
|
161
185
|
|
|
@@ -173,7 +197,7 @@ export function registerBlogList(serviceName: string, options: BlogListOptions)
|
|
|
173
197
|
},
|
|
174
198
|
} as WixQueryPostsRequest & { fieldsets: string[] });
|
|
175
199
|
const posts = (result.posts ?? []) as Post[];
|
|
176
|
-
if (
|
|
200
|
+
if (needsAuthor) await resolveAuthors(posts);
|
|
177
201
|
return { posts, total: result.pagingMetadata?.total };
|
|
178
202
|
}
|
|
179
203
|
|
|
@@ -2,7 +2,7 @@ import { queryBookings, type WixBooking } from "@himalaya/wix-bookings";
|
|
|
2
2
|
import { memberAccess, assertMemberAccess, type MemberAccess } from "./member-access.js";
|
|
3
3
|
import { offsetPage } from "./offset-page.js";
|
|
4
4
|
import type { CollectionQuery } from "./collection-query.js";
|
|
5
|
-
import { copyParam } from "./himi-copy.js";
|
|
5
|
+
import { copyParam, copyTemplate } from "./himi-copy.js";
|
|
6
6
|
import { formatWeekdayDateTime } from "./engine-intl.js";
|
|
7
7
|
import { dayKey } from "@himalaya/time";
|
|
8
8
|
|
|
@@ -81,6 +81,53 @@ export function memberBookingRow(booking: WixBooking): MemberBookingRow {
|
|
|
81
81
|
courseStart: instant(schedule?.firstSessionStart),
|
|
82
82
|
courseEnd: instant(schedule?.lastSessionEnd) };
|
|
83
83
|
}
|
|
84
|
+
// ---- Labels and eligible actions -------------------------------------------------
|
|
85
|
+
// One answer for My Bookings (its rows and booking sheet) and a page's upcoming-bookings section, so a
|
|
86
|
+
// booking that is not plainly confirmed carries the same status label and length on both, and the
|
|
87
|
+
// section offers More actions only where the sheet has an action. (A confirmed booking is "Booked" on
|
|
88
|
+
// the section, as the source's card says; My Bookings shows no tag for it, or "Course" for a course.)
|
|
89
|
+
|
|
90
|
+
/** A booking that is not a plain confirmed one, as a short label: "Pending approval", "Waitlist",
|
|
91
|
+
* "Canceled", "Declined" or "Not confirmed". "" for a confirmed booking (and any other status). */
|
|
92
|
+
export function bookingStatusLabel(row: Pick<MemberBookingRow, "statusKey">): string {
|
|
93
|
+
switch (row.statusKey) {
|
|
94
|
+
// Wix answers PENDING_APPROVAL; PENDING is kept for older records.
|
|
95
|
+
case "PENDING": case "PENDING_APPROVAL": return copyParam("bookings.statusPending", "Pending approval");
|
|
96
|
+
case "WAITING_LIST": return copyParam("bookings.statusWaitlist", "Waitlist");
|
|
97
|
+
case "CANCELED": case "CANCELLED": return copyParam("bookings.statusCancelled", "Canceled");
|
|
98
|
+
case "DECLINED": return copyParam("bookings.statusDeclined", "Declined");
|
|
99
|
+
}
|
|
100
|
+
return UNCONFIRMED_STATUSES.includes(row.statusKey) ? copyParam("bookings.statusUnconfirmed", "Not confirmed") : "";
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** "40 min", "1 hr", "1 hr 15 min". */
|
|
104
|
+
export function bookingDurationText(minutes: number): string {
|
|
105
|
+
const h = Math.floor(minutes / 60), m = minutes % 60;
|
|
106
|
+
const hours = h ? copyTemplate("bookings.durationHours", "{n} hr", { n: h }) : "";
|
|
107
|
+
const mins = m ? copyTemplate("bookings.durationMinutes", "{n} min", { n: m }) : "";
|
|
108
|
+
return [hours, mins].filter(Boolean).join(" ");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A session's length in whole minutes; 0 for a course (it books a schedule), or when the record has no
|
|
112
|
+
* usable end after its start. */
|
|
113
|
+
export function bookingMinutes(row: Pick<MemberBookingRow, "isCourse" | "start" | "end">): number {
|
|
114
|
+
if (row.isCourse || !row.start || !row.end) return 0;
|
|
115
|
+
const start = Date.parse(row.start), end = Date.parse(row.end);
|
|
116
|
+
return Number.isFinite(start) && Number.isFinite(end) && end > start ? Math.round((end - start) / 60000) : 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Add to calendar: a session (not a course) that is still to come and not canceled. */
|
|
120
|
+
export const canAddBookingToCalendar = (row: MemberBookingRow, now = Date.now()) =>
|
|
121
|
+
!row.isCourse && !!row.start && Date.parse(row.start) > now && !CANCELLED_STATUSES.includes(row.statusKey);
|
|
122
|
+
/** Directions: a place with an address that is not the client's own. */
|
|
123
|
+
export const hasBookingDirections = (row: MemberBookingRow) => !!row.placeAddress && row.placeType !== "CUSTOMER";
|
|
124
|
+
/** Cancel: Wix lets the member cancel it, and it has not started yet. */
|
|
125
|
+
export const canCancelBooking = (row: MemberBookingRow, now = Date.now()) => row.canCancel && Date.parse(row.start) > now;
|
|
126
|
+
/** The booking sheet on My Bookings offers at least one action for this booking: add to calendar,
|
|
127
|
+
* directions, Book Again or Cancel. */
|
|
128
|
+
export const hasBookingActions = (row: MemberBookingRow, now = Date.now()) =>
|
|
129
|
+
canAddBookingToCalendar(row, now) || hasBookingDirections(row) || !!row.serviceId || canCancelBooking(row, now);
|
|
130
|
+
|
|
84
131
|
export async function fetchMemberBookings(criteria: CollectionQuery, cursor: string, now: string, expected?: MemberAccess, options: FetchMemberBookingsOptions = {}) {
|
|
85
132
|
const member = expected ?? await memberAccess();
|
|
86
133
|
const metadata = { email: member.email, scope: member.scope, needsSignIn: !member.email };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
// What a pricing plan says about itself, in the viewer's language: the
|
|
2
|
-
// plan-detail facts (terms, cancellation, purchase limit, start date).
|
|
3
|
-
//
|
|
1
|
+
// What a pricing plan says about itself, in the viewer's language: the billing cadence line, the validity line and the
|
|
2
|
+
// plan-detail facts (terms, cancellation, purchase limit, start date). The inline plans section (plans-section.ts) reads
|
|
3
|
+
// it; the plans list and detail worker (himi-branded-lite-plans) still has its own period() and planDuration wording.
|
|
4
4
|
//
|
|
5
5
|
// Each duration phrase is ONE plural key per unit, so a translation fits the whole phrase ("por 10 años") instead of
|
|
6
|
-
// gluing translated words around English ones. Its English fallback is the wording the workers always had.
|
|
6
|
+
// gluing translated words around English ones. Its English fallback is the wording the workers always had. The cadence
|
|
7
|
+
// ("one-time", "per month") and the validity ("for 10 years", "Unlimited duration") are separate lines: "one-time" says
|
|
8
|
+
// how the plan is paid, never how long it lasts.
|
|
7
9
|
import type { WixPlan } from "@himalaya/wix-pricing-plans";
|
|
8
10
|
import { copyParam, copyPlural, copyTemplate } from "./himi-copy.js";
|
|
9
11
|
|
|
@@ -31,7 +33,7 @@ function singularUnit(unit?: string): string {
|
|
|
31
33
|
return (unit || "").toLowerCase().replace(/s$/, "");
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
/** "for 10 years" — a
|
|
36
|
+
/** "for 10 years" — how long a plan with a fixed span lasts. */
|
|
35
37
|
function validFor(count: number, unit: string): string {
|
|
36
38
|
const known = UNITS.find((candidate) => candidate === unit);
|
|
37
39
|
if (!known) return `for ${count} ${unit}${count === 1 ? "" : "s"}`;
|
|
@@ -45,23 +47,37 @@ export function every(count: number, unit: string): string {
|
|
|
45
47
|
return copyPlural(`plans.every${unitKey(known)}`, EVERY[known], count);
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
/**
|
|
50
|
+
/** How the plan is paid, under its price: "per month" / "every 3 months" for a subscription, "one-time" for a single
|
|
51
|
+
* payment; "" when the plan names neither. How long access lasts is `planValidityLine`, never this line. */
|
|
49
52
|
export function planPeriodLine(plan: WixPlan): string {
|
|
50
53
|
const pricing = plan.pricing;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
// A single payment wins over a stray `subscription` stub: the pricing kinds are exclusive, and "recurring" beside
|
|
55
|
+
// "Unlimited duration" would contradict itself.
|
|
56
|
+
if (pricing?.singlePaymentForDuration || pricing?.singlePaymentUnlimited) return copyParam("plans.oneTimeFact", "one-time");
|
|
57
|
+
if (pricing?.subscription) {
|
|
58
|
+
const count = pricing.subscription.cycleDuration?.count ?? 0;
|
|
59
|
+
const unit = singularUnit(pricing.subscription.cycleDuration?.unit);
|
|
54
60
|
return count && unit ? every(count, unit) : copyParam("plans.periodRecurring", "recurring");
|
|
55
61
|
}
|
|
56
|
-
if (pricing?.singlePaymentForDuration) {
|
|
57
|
-
const count = pricing.singlePaymentForDuration.count ?? 0;
|
|
58
|
-
const unit = singularUnit(pricing.singlePaymentForDuration.unit);
|
|
59
|
-
return count && unit ? validFor(count, unit) : copyParam("plans.oneTimeFact", "one-time");
|
|
60
|
-
}
|
|
61
|
-
if (pricing?.singlePaymentUnlimited) return copyParam("plans.oneTimeFact", "one-time");
|
|
62
62
|
return "";
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/** How long the plan's access lasts: "Unlimited duration" (paid once, never ends), "Until canceled" (renews with no end),
|
|
66
|
+
* "for 10 years" (a fixed span, or a subscription's cycles × cycle length); "" when the plan does not say. The open-ended
|
|
67
|
+
* wording is the plans screen's (`planDuration`); a fixed span keeps the per-unit plural keys. */
|
|
68
|
+
export function planValidityLine(plan: WixPlan): string {
|
|
69
|
+
const pricing = plan.pricing;
|
|
70
|
+
if (pricing?.singlePaymentUnlimited) return copyParam("plans.unlimited", "Unlimited duration");
|
|
71
|
+
const single = pricing?.singlePaymentForDuration;
|
|
72
|
+
const cycle = single ? undefined : pricing?.subscription;
|
|
73
|
+
if (cycle && !cycle.cycleCount) return copyParam("plans.untilCanceled", "Until canceled");
|
|
74
|
+
const span = cycle ? cycle.cycleDuration : single;
|
|
75
|
+
const count = (span?.count ?? 0) * (cycle ? cycle.cycleCount ?? 0 : 1);
|
|
76
|
+
// Only a unit the plural keys know: an unknown one ("UNDEFINED", a future enum value) is never spelled out in English.
|
|
77
|
+
const unit = UNITS.find((known) => known === singularUnit(span?.unit));
|
|
78
|
+
return count && unit ? validFor(count, unit) : "";
|
|
79
|
+
}
|
|
80
|
+
|
|
65
81
|
export interface PlanFacts {
|
|
66
82
|
/** The owner's terms and conditions; collapses when the plan has none. */
|
|
67
83
|
terms: string; noTerms: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The INLINE plans section: the site's pricing plans as cards (name, pitch, price, validity, the whole benefits list), hosted by
|
|
1
|
+
// The INLINE plans section: the site's pricing plans as cards (name, pitch, price, cadence, validity, the whole benefits list), hosted by
|
|
2
2
|
// any worker that wants them next to other sections. It is data only and read-only: a card opens the plan's own screen
|
|
3
3
|
// (`himi_plan`), which is where joining and paying live. The `plans-card` recipe is the card that reads it,
|
|
4
4
|
// bound as `$service:<serviceName>.*`.
|
|
@@ -7,7 +7,7 @@ import { listPublicPlans, type WixPlan } from "@himalaya/wix-pricing-plans";
|
|
|
7
7
|
import { descriptionBody } from "./rich-body.js";
|
|
8
8
|
import { formatCurrency } from "./engine-intl.js";
|
|
9
9
|
import { copyParam, stashCopy } from "./himi-copy.js";
|
|
10
|
-
import { planPeriodLine } from "./plan-facts.js";
|
|
10
|
+
import { planPeriodLine, planValidityLine } from "./plan-facts.js";
|
|
11
11
|
|
|
12
12
|
/** The recipe binds `perk1…perkN`, so the list has a fixed ceiling. */
|
|
13
13
|
export const PLANS_SECTION_MAX_PERKS = 12;
|
|
@@ -26,7 +26,10 @@ export interface PlansSectionRow {
|
|
|
26
26
|
name: string;
|
|
27
27
|
description: string; noDescription: boolean;
|
|
28
28
|
priceLine: string; noPrice: boolean;
|
|
29
|
+
/** How the plan is paid ("per month", "one-time"). */
|
|
29
30
|
periodLine: string; noPeriod: boolean;
|
|
31
|
+
/** How long access lasts ("Unlimited duration", "for 10 years"), apart from the cadence. */
|
|
32
|
+
validityLine: string; noValidity: boolean;
|
|
30
33
|
badge: string; noBadge: boolean;
|
|
31
34
|
perks: string[];
|
|
32
35
|
[perk: `perk${number}`]: string;
|
|
@@ -55,10 +58,11 @@ export function plansSectionRow(plan: WixPlan, showBenefits = true): PlansSectio
|
|
|
55
58
|
const description = descriptionBody(plan.description).bodyText;
|
|
56
59
|
const priceLine = money(plan);
|
|
57
60
|
const periodLine = planPeriodLine(plan);
|
|
61
|
+
const validityLine = planValidityLine(plan);
|
|
58
62
|
const badge = plan.primary ? copyParam("plans.popularBadge", "Popular") : "";
|
|
59
63
|
return {
|
|
60
64
|
id: plan.id || "", name: (plan.name || copyParam("plans.planFallbackName", "Plan")).trim(),
|
|
61
|
-
description, noDescription: !description, priceLine, noPrice: !priceLine, periodLine, noPeriod: !periodLine, badge, noBadge: !badge, perks,
|
|
65
|
+
description, noDescription: !description, priceLine, noPrice: !priceLine, periodLine, noPeriod: !periodLine, validityLine, noValidity: !validityLine, badge, noBadge: !badge, perks,
|
|
62
66
|
...planPerkFields(perks),
|
|
63
67
|
};
|
|
64
68
|
}
|
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
// the latest past bookings (`pastLimit`) with Book Again, or the source's empty state when the member has none,
|
|
7
7
|
// pastLimit-> at most N past bookings in History (the source's section shows 1; default: `limit`),
|
|
8
8
|
// emptyText-> the source's own empty line (unset: the stock one).
|
|
9
|
+
// An upcoming card carries the session's length and its status badge ("Booked", or My Bookings' "Pending approval" / "Waitlist"),
|
|
10
|
+
// and its More actions button opens that booking's sheet on My Bookings, which owns every action (add to calendar, directions,
|
|
11
|
+
// Book Again, Cancel with its confirm step). The button shows only when that sheet offers the booking an action (member-bookings).
|
|
9
12
|
// A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipe upcoming-bookings.json).
|
|
10
13
|
import { defineService } from "@himalaya/state";
|
|
11
14
|
import { hostSessionFromGlobal } from "@himalaya/iap";
|
|
12
15
|
import { copyParam, stashCopy } from "./himi-copy.js";
|
|
13
|
-
import { fetchMemberBookings, type MemberBookingRow } from "./member-bookings.js";
|
|
16
|
+
import { bookingDurationText, bookingMinutes, bookingStatusLabel, fetchMemberBookings, hasBookingActions, type MemberBookingRow } from "./member-bookings.js";
|
|
14
17
|
import { memberAccess, memberAccessDenied, memberChanged } from "./member-access.js";
|
|
15
18
|
|
|
16
19
|
export interface UpcomingBookingsOptions {
|
|
@@ -26,12 +29,21 @@ export interface UpcomingBookingsOptions {
|
|
|
26
29
|
|
|
27
30
|
export interface BookingCard {
|
|
28
31
|
id: string; title: string;
|
|
29
|
-
/** "Mon, Nov 17, 2:00 PM". */
|
|
32
|
+
/** "Mon, Nov 17, 2:00 PM · 40 min" (the length only when the record has an end after its start). */
|
|
30
33
|
when: string;
|
|
31
34
|
/** The staff member and the place, "" when the booking names neither. */
|
|
32
35
|
detail: string; noDetail: boolean;
|
|
33
36
|
/** The service a past booking can be booked again from; "" (and no Book Again button) when the record names none. */
|
|
34
37
|
serviceId: string; noBookAgain: boolean;
|
|
38
|
+
/** An upcoming booking's status, as My Bookings names it: "Booked" for a confirmed one, else "Pending approval" or
|
|
39
|
+
* "Waitlist". "" on a past booking (its card has no badge) and for any other status. */
|
|
40
|
+
badge: string; noBadge: boolean;
|
|
41
|
+
/** The badge's colour token: `success` for Booked, `warning` for a booking still waiting on the business or a spot,
|
|
42
|
+
* `danger` for any other status (the upcoming read leaves those out today). "" with no badge. */
|
|
43
|
+
badgeToken: string;
|
|
44
|
+
/** false when My Bookings' booking sheet offers this upcoming booking an action (add to calendar, directions, Book
|
|
45
|
+
* Again, Cancel): the card's More actions button opens that sheet. Always true on a past booking. */
|
|
46
|
+
noActions: boolean;
|
|
35
47
|
a11y: string;
|
|
36
48
|
}
|
|
37
49
|
|
|
@@ -54,9 +66,19 @@ export interface UpcomingBookingsState {
|
|
|
54
66
|
noMore: boolean;
|
|
55
67
|
}
|
|
56
68
|
|
|
57
|
-
const
|
|
69
|
+
const WAITING_STATUSES = ["PENDING", "PENDING_APPROVAL", "WAITING_LIST"];
|
|
70
|
+
const badgeTokenOf = (status: string) => status === "CONFIRMED" ? "success" : WAITING_STATUSES.includes(status) ? "warning" : "danger";
|
|
71
|
+
|
|
72
|
+
const card = (upcoming: boolean) => (row: MemberBookingRow): BookingCard => {
|
|
58
73
|
const detail = [row.staff, row.placeName].filter(Boolean).join(" · ");
|
|
59
|
-
|
|
74
|
+
const minutes = bookingMinutes(row);
|
|
75
|
+
const when = minutes ? `${row.subtitle} · ${bookingDurationText(minutes)}` : row.subtitle;
|
|
76
|
+
// The Agenda's own "Booked" key: the same meaning (the member's confirmed place), already translated in every catalog. A second key
|
|
77
|
+
// with the same English would make the catalog row ambiguous and drop the key its semantic translations hang on.
|
|
78
|
+
const badge = !upcoming ? "" : row.statusKey === "CONFIRMED" ? copyParam("agenda.bookedLabel", "Booked") : bookingStatusLabel(row);
|
|
79
|
+
return { id: row.id, title: row.title, when, detail, noDetail: !detail, serviceId: row.serviceId, noBookAgain: !row.serviceId,
|
|
80
|
+
badge, noBadge: !badge, badgeToken: badge ? badgeTokenOf(row.statusKey) : "", noActions: !(upcoming && hasBookingActions(row)),
|
|
81
|
+
a11y: [row.title, when, detail, badge].filter(Boolean).join(", ") };
|
|
60
82
|
};
|
|
61
83
|
|
|
62
84
|
export function registerUpcomingBookingsSection(serviceName: string, options: UpcomingBookingsOptions) {
|
|
@@ -93,7 +115,7 @@ export function registerUpcomingBookingsSection(serviceName: string, options: Up
|
|
|
93
115
|
const read = (filter: string, sort: "default" | "za") => fetchMemberBookings({ query: "", filter, sort, savedIds: [] }, "", now, member);
|
|
94
116
|
const [next, previous] = await Promise.all([read("value:Upcoming", "default"), options.showPast ? read("value:Past", "za") : undefined]);
|
|
95
117
|
if (seq !== sequence) return undefined;
|
|
96
|
-
return view("ready", false, next.items.slice(0, options.limit).map(card), (previous?.items ?? []).slice(0, options.pastLimit ?? options.limit).map(card),
|
|
118
|
+
return view("ready", false, next.items.slice(0, options.limit).map(card(true)), (previous?.items ?? []).slice(0, options.pastLimit ?? options.limit).map(card(false)),
|
|
97
119
|
next.items.length > options.limit || !!next.nextCursor);
|
|
98
120
|
} catch (error) {
|
|
99
121
|
if (seq !== sequence) return undefined;
|
|
@@ -7,7 +7,7 @@ import { navigate } from "@himalaya/state";
|
|
|
7
7
|
import { copyParam, copyTemplate } from "../_shared/himi-copy.js";
|
|
8
8
|
import { readResultSnackbar, resultSnackbarOn, showResultSnackbar } from "../_shared/result-snackbar.js";
|
|
9
9
|
import { memberAccess, assertMemberAccess, memberAccessChanged, memberAccessDenied, type MemberAccess } from "../_shared/member-access.js";
|
|
10
|
-
import { fetchMemberBookings,
|
|
10
|
+
import { fetchMemberBookings, UNCONFIRMED_STATUSES, bookingDurationText, bookingMinutes, bookingStatusLabel, canAddBookingToCalendar, canCancelBooking, hasBookingDirections, type MemberBookingRow } from "../_shared/member-bookings.js";
|
|
11
11
|
import { emitHostEvent } from "../_shared/host-events.js";
|
|
12
12
|
import { formatClock, formatClockRange, formatDateMedium, formatMonthDay, formatWeekdayMonthDay, formatWeekdayMonthDayLong } from "../_shared/engine-intl.js";
|
|
13
13
|
import { parseWeeklyGoal, resolveFirstWeekday, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
|
|
@@ -126,19 +126,10 @@ function loadPhotos(rows: MemberBookingRow[]): void {
|
|
|
126
126
|
|
|
127
127
|
// ---- Projection -------------------------------------------------------------------
|
|
128
128
|
|
|
129
|
-
const cancelledStatus = (row: MemberBookingRow) => CANCELLED_STATUSES.includes(row.statusKey);
|
|
130
129
|
const date = (iso: string) => new Date(iso);
|
|
131
130
|
|
|
132
131
|
function tagOf(row: MemberBookingRow): string {
|
|
133
|
-
|
|
134
|
-
// Wix answers PENDING_APPROVAL; PENDING is kept for older records.
|
|
135
|
-
case "PENDING": case "PENDING_APPROVAL": return copyParam("bookings.statusPending", "Pending approval");
|
|
136
|
-
case "WAITING_LIST": return copyParam("bookings.statusWaitlist", "Waitlist");
|
|
137
|
-
case "CANCELED": case "CANCELLED": return copyParam("bookings.statusCancelled", "Canceled");
|
|
138
|
-
case "DECLINED": return copyParam("bookings.statusDeclined", "Declined");
|
|
139
|
-
}
|
|
140
|
-
if (UNCONFIRMED_STATUSES.includes(row.statusKey)) return copyParam("bookings.statusUnconfirmed", "Not confirmed");
|
|
141
|
-
return row.isCourse ? copyParam("bookings.coursePrefix", "Course") : "";
|
|
132
|
+
return bookingStatusLabel(row) || (row.isCourse ? copyParam("bookings.coursePrefix", "Course") : "");
|
|
142
133
|
}
|
|
143
134
|
|
|
144
135
|
function placeOf(row: MemberBookingRow): string {
|
|
@@ -165,20 +156,11 @@ function timeRange(start: Date, end: Date): string {
|
|
|
165
156
|
return formatClockRange(start, end);
|
|
166
157
|
}
|
|
167
158
|
|
|
168
|
-
function durationText(minutes: number): string {
|
|
169
|
-
const h = Math.floor(minutes / 60), m = minutes % 60;
|
|
170
|
-
const hours = h ? copyTemplate("bookings.durationHours", "{n} hr", { n: h }) : "";
|
|
171
|
-
const mins = m ? copyTemplate("bookings.durationMinutes", "{n} min", { n: m }) : "";
|
|
172
|
-
return [hours, mins].filter(Boolean).join(" ");
|
|
173
|
-
}
|
|
174
|
-
|
|
175
159
|
/** The sheet's second date line: "10:00 – 11:15 AM · 1 hr 15 min". */
|
|
176
160
|
function timeLine(row: MemberBookingRow): string {
|
|
177
161
|
if (row.isCourse || !row.start) return "";
|
|
178
|
-
const start = date(row.start),
|
|
179
|
-
|
|
180
|
-
const minutes = Math.round((end.getTime() - start.getTime()) / 60000);
|
|
181
|
-
return `${timeRange(start, end)} · ${durationText(minutes)}`;
|
|
162
|
+
const start = date(row.start), minutes = bookingMinutes(row);
|
|
163
|
+
return minutes ? `${timeRange(start, date(row.end))} · ${bookingDurationText(minutes)}` : formatClock(start);
|
|
182
164
|
}
|
|
183
165
|
|
|
184
166
|
function dateLine(row: MemberBookingRow): string {
|
|
@@ -234,8 +216,6 @@ interface S {
|
|
|
234
216
|
}
|
|
235
217
|
|
|
236
218
|
const openRow = (s: Pick<S, "rows">): MemberBookingRow | undefined => openId ? s.rows.find(row => row.id === openId) : undefined;
|
|
237
|
-
const canAddToCalendar = (row: MemberBookingRow) => !row.isCourse && !!row.start && Date.parse(row.start) > Date.now() && !cancelledStatus(row);
|
|
238
|
-
const hasDirections = (row: MemberBookingRow) => !!row.placeAddress && row.placeType !== "CUSTOMER";
|
|
239
219
|
|
|
240
220
|
function derive(s: S): S {
|
|
241
221
|
const loading = s.status === "loading", errored = s.status === "error";
|
|
@@ -252,7 +232,7 @@ function derive(s: S): S {
|
|
|
252
232
|
const weekly = weeklyGoal > 0 && memberShown && weeklyDone !== null ? weeklyGoalProgress(weeklyDone, weeklyGoal) : null;
|
|
253
233
|
const participants = row && row.participants > 1 ? copyTemplate("bookings.participants", "{count} participants", { count: row.participants }) : "";
|
|
254
234
|
const payment = row ? paymentOf(row) : "", notice = row ? noticeOf(row) : "";
|
|
255
|
-
const canCancel = !!row &&
|
|
235
|
+
const canCancel = !!row && canCancelBooking(row);
|
|
256
236
|
return { ...s, tab, bookingRows: s.rows.map(listRow),
|
|
257
237
|
isLoading: loading, notLoading: !(loading && !rowsShown), errored, notErrored: !(errored && !lastErrorDenied && !rowsShown), noEmpty: true,
|
|
258
238
|
hideTabs: !memberShown, noRows: !rowsShown, hideSignIn: !showSignIn,
|
|
@@ -262,13 +242,13 @@ function derive(s: S): S {
|
|
|
262
242
|
sheetTitle: row?.title ?? "", sheetImage: listed?.image ?? "", sheetHasImage: !!listed?.hasImage, sheetNoImage: !listed?.hasImage,
|
|
263
243
|
sheetTag: listed?.tag ?? "", sheetNoTag: !listed?.tag,
|
|
264
244
|
sheetDate: row ? dateLine(row) : "", sheetTime: row ? timeLine(row) : "",
|
|
265
|
-
sheetCanAddToCalendar: !!row &&
|
|
245
|
+
sheetCanAddToCalendar: !!row && canAddBookingToCalendar(row), sheetCannotAddToCalendar: !row || !canAddBookingToCalendar(row),
|
|
266
246
|
sheetStaff: row ? staffLine(row) : "", sheetNoStaff: !row?.staff,
|
|
267
247
|
sheetPlace: place, sheetNoPlace: !place,
|
|
268
248
|
// The address under the name only when the row shows a name of its own (never the client's place).
|
|
269
249
|
sheetAddress: row && row.placeType !== "CUSTOMER" && row.placeName !== row.placeAddress ? row.placeAddress : "",
|
|
270
|
-
sheetHasDirections: !!row &&
|
|
271
|
-
sheetHidePlainPlace: !place || (!!row &&
|
|
250
|
+
sheetHasDirections: !!row && hasBookingDirections(row), sheetNoDirections: !row || !hasBookingDirections(row),
|
|
251
|
+
sheetHidePlainPlace: !place || (!!row && hasBookingDirections(row)),
|
|
272
252
|
sheetDirectionsLabel: place ? copyTemplate("bookings.directionsLabel", "Get directions to {place}", { place }) : "",
|
|
273
253
|
sheetParticipants: participants, sheetNoParticipants: !participants,
|
|
274
254
|
sheetPayment: payment, sheetNoPayment: !payment, sheetNotice: notice, sheetNoNotice: !notice,
|
|
@@ -425,7 +405,7 @@ const svc = defineBackendCollection<S, MemberBookingRow>("himiBookingBookings",
|
|
|
425
405
|
},
|
|
426
406
|
async addToCalendar(s): Promise<S> {
|
|
427
407
|
const row = openRow(s);
|
|
428
|
-
if (!row || !
|
|
408
|
+
if (!row || !canAddBookingToCalendar(row)) return s;
|
|
429
409
|
const start = Date.parse(row.start);
|
|
430
410
|
const endAt = Date.parse(row.end);
|
|
431
411
|
const end = Number.isFinite(endAt) && endAt > start ? endAt : start + 60 * 60 * 1000;
|
|
@@ -448,7 +428,7 @@ const svc = defineBackendCollection<S, MemberBookingRow>("himiBookingBookings",
|
|
|
448
428
|
},
|
|
449
429
|
async openDirections(s): Promise<S> {
|
|
450
430
|
const row = openRow(s);
|
|
451
|
-
if (!row || !
|
|
431
|
+
if (!row || !hasBookingDirections(row)) return s;
|
|
452
432
|
try {
|
|
453
433
|
if ((await open(directionsUrl(row.placeAddress), "in_app_browser")).opened) return s;
|
|
454
434
|
} catch { /* the result sheet says so below */ }
|