@wix/himalaya-cli 0.1257.0 → 0.1259.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/sdk/motion/src/index.d.ts +45 -5
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/sdk-types/src/capabilities.generated.d.ts +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/audio-record.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calendar.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calls.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/contacts.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/location.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +18 -2
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/photos.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdk-types.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/tasks.mjs +1 -1
- package/dist/cli.mjs +47 -23
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/sdk-reference.json +15 -3
- package/package.json +2 -2
- package/templates/beauty-salon/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/beauty-salon/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +41 -4
- package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +31 -7
- package/templates/beauty-salon-owner/dev/index.ts +4 -1
- package/templates/beauty-salon-owner/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/branded-lite/config.ts +14 -1
- package/templates/branded-lite/dev/index.ts +845 -2
- package/templates/branded-lite/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/branded-lite/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +41 -4
- package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +31 -7
- package/templates/branded-lite/tier5-src/himi-branded-lite-steps/index.ts +524 -0
- package/templates/community-club/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/community-club/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +31 -7
- package/templates/community-club-owner/dev/index.ts +4 -1
- package/templates/community-club-owner/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/events-meetups/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/events-meetups/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +31 -7
- package/templates/events-meetups-owner/dev/index.ts +4 -1
- package/templates/events-meetups-owner/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/gym-fitness/config.ts +14 -1
- package/templates/gym-fitness/dev/index.ts +844 -1
- package/templates/gym-fitness/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/gym-fitness/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +41 -4
- package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +31 -7
- package/templates/gym-fitness/tier5-src/himi-branded-lite-steps/index.ts +524 -0
- package/templates/gym-fitness-owner/dev/index.ts +4 -1
- package/templates/gym-fitness-owner/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/nonprofit-cause/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/nonprofit-cause/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +31 -7
- package/templates/nonprofit-cause-owner/dev/index.ts +4 -1
- package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/owner-lite/dev/index.ts +4 -1
- package/templates/owner-lite/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/podcast-creator/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/podcast-creator/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +31 -7
- package/templates/podcast-creator-owner/dev/index.ts +4 -1
- package/templates/podcast-creator-owner/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/portfolio-creative/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/portfolio-creative/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +31 -7
- package/templates/portfolio-creative-owner/dev/index.ts +4 -1
- package/templates/portfolio-creative-owner/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/restaurant/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/restaurant/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +31 -7
- package/templates/restaurant-owner/dev/index.ts +4 -1
- package/templates/restaurant-owner/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/retail-store/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/retail-store/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +31 -7
- package/templates/retail-store-owner/dev/index.ts +4 -1
- package/templates/retail-store-owner/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/yoga-studio/dev/index.ts +90 -1
- package/templates/yoga-studio/tier5-src/_shared/collection-service.ts +7 -0
- package/templates/yoga-studio/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +41 -4
- package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +31 -7
- package/templates/yoga-studio-owner/dev/index.ts +4 -1
- package/templates/yoga-studio-owner/tier5-src/_shared/collection-service.ts +7 -0
|
@@ -14,6 +14,7 @@ import { formatServicePrice } from "../_shared/wix-service-price.js";
|
|
|
14
14
|
import { cleanTitle, initials } from "../_shared/himi-text.js";
|
|
15
15
|
import { accentColor as resolveAccentColor, ACCENT_KEY, LAYOUT_KEY, type LayoutId, recommendLayout, resolveLayout } from "../_shared/himi-layouts.js";
|
|
16
16
|
import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
|
|
17
|
+
import { parseWeeklyGoal, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
|
|
17
18
|
import { isBridgeUnavailable } from "../_shared/owner-load-error.js";
|
|
18
19
|
import { formatDateMedium } from "../_shared/engine-intl.js";
|
|
19
20
|
import { readSavedProducts, type SavedProduct } from "../_shared/himi-store-saved.js";
|
|
@@ -837,7 +838,10 @@ function derive(state: State): State {
|
|
|
837
838
|
// hide them entirely, so every non-bookings layout renders unchanged.
|
|
838
839
|
noTodaysClasses: state.todaysClasses.length === 0,
|
|
839
840
|
noCoachAvatars: state.coachAvatars.length === 0,
|
|
840
|
-
|
|
841
|
+
// The weekly-goal Gauge shows only for a signed-in member of an app that provisions
|
|
842
|
+
// `goals.weeklySessions` — the label is set by refreshPersonal exactly then, and stays "" for
|
|
843
|
+
// a visitor or an app without a goal (so it shows at "0 of 2", but never as fake progress).
|
|
844
|
+
noWeeklyGoal: state.weeklyGoalLabel === "",
|
|
841
845
|
// Collapse gates for the salonLuxe / calmStudio / communityPulse blocks —
|
|
842
846
|
// the same contract: empty data hides the block entirely.
|
|
843
847
|
noServiceShowcase: state.serviceShowcase.length === 0,
|
|
@@ -1070,6 +1074,8 @@ function memberSchedule(rows: MemberBookingRow[], now = new Date()): { label: st
|
|
|
1070
1074
|
async function refreshPersonal(generation: number, arg?: unknown): Promise<void> {
|
|
1071
1075
|
const member = await memberAccess();
|
|
1072
1076
|
let rows: MemberBookingRow[] = [], progress = { label: "", fraction: 0 }, error = false;
|
|
1077
|
+
let weekly: { count: number; fraction: number; label: string } | null = null;
|
|
1078
|
+
const weeklyGoal = parseWeeklyGoal(paramValue(arg, "weeklyGoal"));
|
|
1073
1079
|
if (member.email && parseVerticals(arg).includes("bookings")) {
|
|
1074
1080
|
const now = new Date();
|
|
1075
1081
|
const [upcoming, past] = await Promise.allSettled([
|
|
@@ -1087,10 +1093,24 @@ async function refreshPersonal(generation: number, arg?: unknown): Promise<void>
|
|
|
1087
1093
|
// when either query failed.
|
|
1088
1094
|
progress = memberSchedule([...upcoming.value.items, ...past.value.items], now);
|
|
1089
1095
|
}
|
|
1096
|
+
if (weeklyGoal > 0 && past.status === "fulfilled") {
|
|
1097
|
+
// The goal counts sessions that already HAPPENED this week (_shared/weekly-goal.ts). A
|
|
1098
|
+
// failed past read leaves it hidden rather than claiming "0 of N".
|
|
1099
|
+
// Pages further back only while the first page still sits inside this week; a failing
|
|
1100
|
+
// later page hides the Gauge too.
|
|
1101
|
+
try {
|
|
1102
|
+
const readPast = (cursor: string) =>
|
|
1103
|
+
fetchMemberBookings({ query: "", filter: "value:Past", sort: "za", savedIds: [] }, cursor, now.toISOString(), member);
|
|
1104
|
+
const goal = weeklyGoalProgress(await weeklySessionsFromPages(past.value, readPast, now.getTime()), weeklyGoal);
|
|
1105
|
+
weekly = { count: goal.done, fraction: goal.fraction, label: goal.label };
|
|
1106
|
+
} catch {
|
|
1107
|
+
weekly = null;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1090
1110
|
error = upcoming.status === "rejected" || past.status === "rejected";
|
|
1091
|
-
try { await assertMemberAccess(member); } catch { rows = []; progress = { label: "", fraction: 0 }; error = false; }
|
|
1111
|
+
try { await assertMemberAccess(member); } catch { rows = []; progress = { label: "", fraction: 0 }; error = false; weekly = null; }
|
|
1092
1112
|
}
|
|
1093
|
-
if (generation === personalGeneration) svc.personalLoaded({ generation, rows, progress, error });
|
|
1113
|
+
if (generation === personalGeneration) svc.personalLoaded({ generation, rows, progress, error, weekly });
|
|
1094
1114
|
}
|
|
1095
1115
|
async function refresh(state: State, arg?: unknown): Promise<State | undefined> {
|
|
1096
1116
|
const generation = ++personalGeneration;
|
|
@@ -1102,7 +1122,9 @@ async function refresh(state: State, arg?: unknown): Promise<State | undefined>
|
|
|
1102
1122
|
const current = svc.getState();
|
|
1103
1123
|
return derive({ ...publicState, nextBooking: current.nextBooking, hideNextBooking: current.hideNextBooking,
|
|
1104
1124
|
memberProgressLabel: current.memberProgressLabel, memberProgressFraction: current.memberProgressFraction,
|
|
1105
|
-
hideMemberProgress: current.hideMemberProgress, personalError: current.personalError, hidePersonalError: current.hidePersonalError
|
|
1125
|
+
hideMemberProgress: current.hideMemberProgress, personalError: current.personalError, hidePersonalError: current.hidePersonalError,
|
|
1126
|
+
// The weekly goal is PERSONAL (member bookings); the public refresh resets it, so keep it.
|
|
1127
|
+
weeklyClassCount: current.weeklyClassCount, weeklyClassGoalFraction: current.weeklyClassGoalFraction, weeklyGoalLabel: current.weeklyGoalLabel });
|
|
1106
1128
|
}
|
|
1107
1129
|
|
|
1108
1130
|
const svc = defineService<State, {
|
|
@@ -1113,15 +1135,17 @@ const svc = defineService<State, {
|
|
|
1113
1135
|
refresh: (state: State, arg?: unknown) => Promise<State | undefined>;
|
|
1114
1136
|
dismissOnboarding: (state: State) => State;
|
|
1115
1137
|
clearPersonal: (state: State) => State;
|
|
1116
|
-
personalLoaded: (state: State, arg: { generation: number; rows: MemberBookingRow[]; progress: { label: string; fraction: number }; error: boolean }) => State;
|
|
1138
|
+
personalLoaded: (state: State, arg: { generation: number; rows: MemberBookingRow[]; progress: { label: string; fraction: number }; error: boolean; weekly: { count: number; fraction: number; label: string } | null }) => State;
|
|
1117
1139
|
}>("himiBrandedHome", {
|
|
1118
1140
|
state: baseState(),
|
|
1119
1141
|
actions: {
|
|
1120
|
-
clearPersonal: state => ({ ...state, nextBooking: [], hideNextBooking: true, memberProgressLabel: "", memberProgressFraction: 0, hideMemberProgress: true, personalError: false, hidePersonalError: true
|
|
1142
|
+
clearPersonal: state => derive({ ...state, nextBooking: [], hideNextBooking: true, memberProgressLabel: "", memberProgressFraction: 0, hideMemberProgress: true, personalError: false, hidePersonalError: true,
|
|
1143
|
+
weeklyClassCount: 0, weeklyClassGoalFraction: 0, weeklyGoalLabel: "" }),
|
|
1121
1144
|
personalLoaded: (state, arg) => arg.generation !== personalGeneration ? state : derive({ ...state,
|
|
1122
1145
|
nextBooking: arg.rows, hideNextBooking: !arg.rows.length,
|
|
1123
1146
|
memberProgressLabel: arg.progress.label, memberProgressFraction: arg.progress.fraction, hideMemberProgress: !arg.progress.label,
|
|
1124
|
-
personalError: arg.error, hidePersonalError: !arg.error
|
|
1147
|
+
personalError: arg.error, hidePersonalError: !arg.error,
|
|
1148
|
+
weeklyClassCount: arg.weekly?.count ?? 0, weeklyClassGoalFraction: arg.weekly?.fraction ?? 0, weeklyGoalLabel: arg.weekly?.label ?? "" }),
|
|
1125
1149
|
refresh,
|
|
1126
1150
|
// "Got it" on the first-run card: persist + hide. Persistence is
|
|
1127
1151
|
// best-effort — the UI hides either way for this session.
|
|
@@ -52391,7 +52391,10 @@ const SCREENS = runtimeSetting({
|
|
|
52391
52391
|
}
|
|
52392
52392
|
},
|
|
52393
52393
|
"modifiers": {
|
|
52394
|
-
"accessibilityRole": "decorative"
|
|
52394
|
+
"accessibilityRole": "decorative",
|
|
52395
|
+
"padding": {
|
|
52396
|
+
"leading": 12
|
|
52397
|
+
}
|
|
52395
52398
|
}
|
|
52396
52399
|
},
|
|
52397
52400
|
{
|
|
@@ -11,6 +11,8 @@ export interface CollectionSaving {
|
|
|
11
11
|
type State = Record<string, unknown>;
|
|
12
12
|
interface BackendCollection {
|
|
13
13
|
restorePagesOnLoad?: boolean;
|
|
14
|
+
/** Sees the load action's argument (the screen's onAppear params) BEFORE the query runs. */
|
|
15
|
+
onLoad?(arg: unknown): void;
|
|
14
16
|
controller: ReturnType<typeof createCollectionQuery<CollectionRow>>;
|
|
15
17
|
apply(state: State, page: CollectionQueryState<CollectionRow>): State;
|
|
16
18
|
}
|
|
@@ -294,6 +296,7 @@ export function decorateCollection(name: string, def: { state: State; actions?:
|
|
|
294
296
|
actions.collectionDataChanged = s => derive(backend.apply(s, backend.controller.getState()));
|
|
295
297
|
actions.load = (_s, arg) => {
|
|
296
298
|
stashCopy(arg); syncSaved(); applyNavigationCriteria(arg, _s);
|
|
299
|
+
backend.onLoad?.(arg);
|
|
297
300
|
return backend.controller.query(criteria(), backend.restorePagesOnLoad).then(() => undefined);
|
|
298
301
|
};
|
|
299
302
|
actions.refresh = (_s, arg) => {
|
|
@@ -320,6 +323,9 @@ export function decorateCollection(name: string, def: { state: State; actions?:
|
|
|
320
323
|
export function defineBackendCollection<S extends object, Row extends object>(name: string, options: {
|
|
321
324
|
/** Revalidate already opened pages on navigation return; explicit refresh resets. */
|
|
322
325
|
restorePagesOnLoad?: boolean;
|
|
326
|
+
/** The load action's argument (onAppear params beyond `copy`), before the query runs — for a
|
|
327
|
+
* domain setting that rides the descriptor, e.g. My Bookings' `weeklyGoal`. */
|
|
328
|
+
onLoad?(arg: unknown): void;
|
|
323
329
|
state: S;
|
|
324
330
|
source: CollectionQuerySource<Row>;
|
|
325
331
|
apply(state: S, page: CollectionQueryState<Row>): S;
|
|
@@ -330,6 +336,7 @@ export function defineBackendCollection<S extends object, Row extends object>(na
|
|
|
330
336
|
const controller = createCollectionQuery(options.source, () => { publish?.(); });
|
|
331
337
|
const definition = decorateCollection(name, { state: options.state as State, actions: options.actions as Record<string, Reducer> | undefined }, options.saving, {
|
|
332
338
|
restorePagesOnLoad: options.restorePagesOnLoad,
|
|
339
|
+
onLoad: options.onLoad,
|
|
333
340
|
controller: controller as unknown as BackendCollection['controller'],
|
|
334
341
|
apply: (state, page) => options.apply(state as S, page as unknown as CollectionQueryState<Row>) as State,
|
|
335
342
|
});
|
|
@@ -11,6 +11,8 @@ export interface CollectionSaving {
|
|
|
11
11
|
type State = Record<string, unknown>;
|
|
12
12
|
interface BackendCollection {
|
|
13
13
|
restorePagesOnLoad?: boolean;
|
|
14
|
+
/** Sees the load action's argument (the screen's onAppear params) BEFORE the query runs. */
|
|
15
|
+
onLoad?(arg: unknown): void;
|
|
14
16
|
controller: ReturnType<typeof createCollectionQuery<CollectionRow>>;
|
|
15
17
|
apply(state: State, page: CollectionQueryState<CollectionRow>): State;
|
|
16
18
|
}
|
|
@@ -294,6 +296,7 @@ export function decorateCollection(name: string, def: { state: State; actions?:
|
|
|
294
296
|
actions.collectionDataChanged = s => derive(backend.apply(s, backend.controller.getState()));
|
|
295
297
|
actions.load = (_s, arg) => {
|
|
296
298
|
stashCopy(arg); syncSaved(); applyNavigationCriteria(arg, _s);
|
|
299
|
+
backend.onLoad?.(arg);
|
|
297
300
|
return backend.controller.query(criteria(), backend.restorePagesOnLoad).then(() => undefined);
|
|
298
301
|
};
|
|
299
302
|
actions.refresh = (_s, arg) => {
|
|
@@ -320,6 +323,9 @@ export function decorateCollection(name: string, def: { state: State; actions?:
|
|
|
320
323
|
export function defineBackendCollection<S extends object, Row extends object>(name: string, options: {
|
|
321
324
|
/** Revalidate already opened pages on navigation return; explicit refresh resets. */
|
|
322
325
|
restorePagesOnLoad?: boolean;
|
|
326
|
+
/** The load action's argument (onAppear params beyond `copy`), before the query runs — for a
|
|
327
|
+
* domain setting that rides the descriptor, e.g. My Bookings' `weeklyGoal`. */
|
|
328
|
+
onLoad?(arg: unknown): void;
|
|
323
329
|
state: S;
|
|
324
330
|
source: CollectionQuerySource<Row>;
|
|
325
331
|
apply(state: S, page: CollectionQueryState<Row>): S;
|
|
@@ -330,6 +336,7 @@ export function defineBackendCollection<S extends object, Row extends object>(na
|
|
|
330
336
|
const controller = createCollectionQuery(options.source, () => { publish?.(); });
|
|
331
337
|
const definition = decorateCollection(name, { state: options.state as State, actions: options.actions as Record<string, Reducer> | undefined }, options.saving, {
|
|
332
338
|
restorePagesOnLoad: options.restorePagesOnLoad,
|
|
339
|
+
onLoad: options.onLoad,
|
|
333
340
|
controller: controller as unknown as BackendCollection['controller'],
|
|
334
341
|
apply: (state, page) => options.apply(state as S, page as unknown as CollectionQueryState<Row>) as State,
|
|
335
342
|
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// The weekly session goal (`provisioning.goals.weeklySessions`) over a member's own bookings —
|
|
2
|
+
// shared by the home weekly-goal Gauge (himi-branded-lite-home) and the My Bookings "This week"
|
|
3
|
+
// card (himi-booking-bookings), so the two can never count differently.
|
|
4
|
+
//
|
|
5
|
+
// WHAT COUNTS as a session toward the goal: a CONFIRMED booking whose start falls in the CURRENT
|
|
6
|
+
// calendar week (Monday 00:00 local → now) and is already in the past. An allow-list, not a
|
|
7
|
+
// deny-list: CREATED (checkout never completed), PENDING / PENDING_APPROVAL / PENDING_CHECKOUT,
|
|
8
|
+
// WAITING_LIST, CANCELED and DECLINED — and any status Wix adds later — do not count. That is
|
|
9
|
+
// "booked and it happened", not verified
|
|
10
|
+
// attendance: the member-scoped queryBookings row carries no attendance/check-in field (the Wix
|
|
11
|
+
// Attendance API is owner-scoped), so a no-show still counts. Future bookings this week do not
|
|
12
|
+
// count — they have not happened yet.
|
|
13
|
+
//
|
|
14
|
+
// DETERMINISM: nothing here runs at worker boot; every clock read is an argument. PURE (no network,
|
|
15
|
+
// no bridge) so the rules are unit-tested directly; the read lives with its caller.
|
|
16
|
+
|
|
17
|
+
import type { MemberBookingRow } from "./member-bookings.js";
|
|
18
|
+
import { copyParam, copyTemplate } from "./himi-copy.js";
|
|
19
|
+
|
|
20
|
+
export const MAX_WEEKLY_SESSION_GOAL = 21;
|
|
21
|
+
|
|
22
|
+
/** The one status that means the session was booked and held (as memberBookingRow normalizes
|
|
23
|
+
* it: upper-case, `_` → space). */
|
|
24
|
+
const COUNTS_AS_SESSION = /^CONFIRMED$/;
|
|
25
|
+
|
|
26
|
+
/** At most this many pages of past bookings are read for one week's count. */
|
|
27
|
+
export const MAX_WEEKLY_PAGES = 4;
|
|
28
|
+
|
|
29
|
+
/** The onAppear `weeklyGoal` param → a goal in [1, 21], or 0 = no goal provisioned. */
|
|
30
|
+
export function parseWeeklyGoal(raw: unknown): number {
|
|
31
|
+
const n = typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : NaN;
|
|
32
|
+
return Number.isInteger(n) && n >= 1 ? Math.min(n, MAX_WEEKLY_SESSION_GOAL) : 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Monday 00:00 local of `now`'s week, epoch ms. */
|
|
36
|
+
export function weekStartMs(now: number): number {
|
|
37
|
+
const d = new Date(now);
|
|
38
|
+
d.setHours(0, 0, 0, 0);
|
|
39
|
+
d.setDate(d.getDate() - ((d.getDay() + 6) % 7));
|
|
40
|
+
return d.getTime();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Sessions toward the goal among `rows` — see the file header for what counts. */
|
|
44
|
+
export function weeklySessionsDone(rows: readonly MemberBookingRow[], now: number): number {
|
|
45
|
+
const from = weekStartMs(now);
|
|
46
|
+
const seen = new Set<string>();
|
|
47
|
+
for (const row of rows) {
|
|
48
|
+
const start = Date.parse(row.start);
|
|
49
|
+
if (!Number.isFinite(start) || start < from || start >= now) continue;
|
|
50
|
+
if (!COUNTS_AS_SESSION.test((row.status || "").trim().toUpperCase())) continue;
|
|
51
|
+
seen.add(row.id || `${row.start}|${row.title}`);
|
|
52
|
+
}
|
|
53
|
+
return seen.size;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface BookingsPage {
|
|
57
|
+
items: MemberBookingRow[];
|
|
58
|
+
nextCursor?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Sessions toward the goal from PAST bookings read newest-first: `first` is the first page, and
|
|
62
|
+
* `next(cursor)` reads more only while the oldest row so far is still inside this week (a page of
|
|
63
|
+
* 50 almost always reaches back before Monday). Bounded to MAX_WEEKLY_PAGES reads; a failing
|
|
64
|
+
* read rejects, so the caller hides the count rather than under-counting. */
|
|
65
|
+
export async function weeklySessionsFromPages(
|
|
66
|
+
first: BookingsPage,
|
|
67
|
+
next: (cursor: string) => Promise<BookingsPage>,
|
|
68
|
+
now: number,
|
|
69
|
+
): Promise<number> {
|
|
70
|
+
const from = weekStartMs(now);
|
|
71
|
+
const rows = [...first.items];
|
|
72
|
+
let page = first;
|
|
73
|
+
for (let read = 1; read < MAX_WEEKLY_PAGES && page.nextCursor; read++) {
|
|
74
|
+
const oldest = page.items[page.items.length - 1];
|
|
75
|
+
if (oldest && Date.parse(oldest.start) < from) break;
|
|
76
|
+
page = await next(page.nextCursor);
|
|
77
|
+
rows.push(...page.items);
|
|
78
|
+
}
|
|
79
|
+
return weeklySessionsDone(rows, now);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface WeeklyGoalProgress {
|
|
83
|
+
done: number;
|
|
84
|
+
goal: number;
|
|
85
|
+
/** 0..1 — the Gauge / ProgressBar fill. */
|
|
86
|
+
fraction: number;
|
|
87
|
+
met: boolean;
|
|
88
|
+
/** "1 of 2 sessions this week" */
|
|
89
|
+
label: string;
|
|
90
|
+
/** "1 more to reach your weekly goal" / "Weekly goal reached. Great consistency." */
|
|
91
|
+
remainingLabel: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function weeklyGoalProgress(done: number, goal: number): WeeklyGoalProgress {
|
|
95
|
+
const safeGoal = Math.max(1, goal);
|
|
96
|
+
const met = done >= safeGoal;
|
|
97
|
+
return {
|
|
98
|
+
done,
|
|
99
|
+
goal: safeGoal,
|
|
100
|
+
fraction: Math.min(done / safeGoal, 1),
|
|
101
|
+
met,
|
|
102
|
+
label: copyTemplate("weeklyGoal.progress", "{done} of {goal} sessions this week", { done, goal: safeGoal }),
|
|
103
|
+
remainingLabel: met
|
|
104
|
+
? copyParam("weeklyGoal.met", "Weekly goal reached. Great consistency.")
|
|
105
|
+
: copyTemplate("weeklyGoal.remaining", "{count} more to reach your weekly goal", { count: safeGoal - done }),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -14,6 +14,7 @@ import { formatServicePrice } from "../_shared/wix-service-price.js";
|
|
|
14
14
|
import { cleanTitle, initials } from "../_shared/himi-text.js";
|
|
15
15
|
import { accentColor as resolveAccentColor, ACCENT_KEY, LAYOUT_KEY, type LayoutId, recommendLayout, resolveLayout } from "../_shared/himi-layouts.js";
|
|
16
16
|
import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
|
|
17
|
+
import { parseWeeklyGoal, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
|
|
17
18
|
import { isBridgeUnavailable } from "../_shared/owner-load-error.js";
|
|
18
19
|
import { formatDateMedium } from "../_shared/engine-intl.js";
|
|
19
20
|
import { readSavedProducts, type SavedProduct } from "../_shared/himi-store-saved.js";
|
|
@@ -837,7 +838,10 @@ function derive(state: State): State {
|
|
|
837
838
|
// hide them entirely, so every non-bookings layout renders unchanged.
|
|
838
839
|
noTodaysClasses: state.todaysClasses.length === 0,
|
|
839
840
|
noCoachAvatars: state.coachAvatars.length === 0,
|
|
840
|
-
|
|
841
|
+
// The weekly-goal Gauge shows only for a signed-in member of an app that provisions
|
|
842
|
+
// `goals.weeklySessions` — the label is set by refreshPersonal exactly then, and stays "" for
|
|
843
|
+
// a visitor or an app without a goal (so it shows at "0 of 2", but never as fake progress).
|
|
844
|
+
noWeeklyGoal: state.weeklyGoalLabel === "",
|
|
841
845
|
// Collapse gates for the salonLuxe / calmStudio / communityPulse blocks —
|
|
842
846
|
// the same contract: empty data hides the block entirely.
|
|
843
847
|
noServiceShowcase: state.serviceShowcase.length === 0,
|
|
@@ -1070,6 +1074,8 @@ function memberSchedule(rows: MemberBookingRow[], now = new Date()): { label: st
|
|
|
1070
1074
|
async function refreshPersonal(generation: number, arg?: unknown): Promise<void> {
|
|
1071
1075
|
const member = await memberAccess();
|
|
1072
1076
|
let rows: MemberBookingRow[] = [], progress = { label: "", fraction: 0 }, error = false;
|
|
1077
|
+
let weekly: { count: number; fraction: number; label: string } | null = null;
|
|
1078
|
+
const weeklyGoal = parseWeeklyGoal(paramValue(arg, "weeklyGoal"));
|
|
1073
1079
|
if (member.email && parseVerticals(arg).includes("bookings")) {
|
|
1074
1080
|
const now = new Date();
|
|
1075
1081
|
const [upcoming, past] = await Promise.allSettled([
|
|
@@ -1087,10 +1093,24 @@ async function refreshPersonal(generation: number, arg?: unknown): Promise<void>
|
|
|
1087
1093
|
// when either query failed.
|
|
1088
1094
|
progress = memberSchedule([...upcoming.value.items, ...past.value.items], now);
|
|
1089
1095
|
}
|
|
1096
|
+
if (weeklyGoal > 0 && past.status === "fulfilled") {
|
|
1097
|
+
// The goal counts sessions that already HAPPENED this week (_shared/weekly-goal.ts). A
|
|
1098
|
+
// failed past read leaves it hidden rather than claiming "0 of N".
|
|
1099
|
+
// Pages further back only while the first page still sits inside this week; a failing
|
|
1100
|
+
// later page hides the Gauge too.
|
|
1101
|
+
try {
|
|
1102
|
+
const readPast = (cursor: string) =>
|
|
1103
|
+
fetchMemberBookings({ query: "", filter: "value:Past", sort: "za", savedIds: [] }, cursor, now.toISOString(), member);
|
|
1104
|
+
const goal = weeklyGoalProgress(await weeklySessionsFromPages(past.value, readPast, now.getTime()), weeklyGoal);
|
|
1105
|
+
weekly = { count: goal.done, fraction: goal.fraction, label: goal.label };
|
|
1106
|
+
} catch {
|
|
1107
|
+
weekly = null;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1090
1110
|
error = upcoming.status === "rejected" || past.status === "rejected";
|
|
1091
|
-
try { await assertMemberAccess(member); } catch { rows = []; progress = { label: "", fraction: 0 }; error = false; }
|
|
1111
|
+
try { await assertMemberAccess(member); } catch { rows = []; progress = { label: "", fraction: 0 }; error = false; weekly = null; }
|
|
1092
1112
|
}
|
|
1093
|
-
if (generation === personalGeneration) svc.personalLoaded({ generation, rows, progress, error });
|
|
1113
|
+
if (generation === personalGeneration) svc.personalLoaded({ generation, rows, progress, error, weekly });
|
|
1094
1114
|
}
|
|
1095
1115
|
async function refresh(state: State, arg?: unknown): Promise<State | undefined> {
|
|
1096
1116
|
const generation = ++personalGeneration;
|
|
@@ -1102,7 +1122,9 @@ async function refresh(state: State, arg?: unknown): Promise<State | undefined>
|
|
|
1102
1122
|
const current = svc.getState();
|
|
1103
1123
|
return derive({ ...publicState, nextBooking: current.nextBooking, hideNextBooking: current.hideNextBooking,
|
|
1104
1124
|
memberProgressLabel: current.memberProgressLabel, memberProgressFraction: current.memberProgressFraction,
|
|
1105
|
-
hideMemberProgress: current.hideMemberProgress, personalError: current.personalError, hidePersonalError: current.hidePersonalError
|
|
1125
|
+
hideMemberProgress: current.hideMemberProgress, personalError: current.personalError, hidePersonalError: current.hidePersonalError,
|
|
1126
|
+
// The weekly goal is PERSONAL (member bookings); the public refresh resets it, so keep it.
|
|
1127
|
+
weeklyClassCount: current.weeklyClassCount, weeklyClassGoalFraction: current.weeklyClassGoalFraction, weeklyGoalLabel: current.weeklyGoalLabel });
|
|
1106
1128
|
}
|
|
1107
1129
|
|
|
1108
1130
|
const svc = defineService<State, {
|
|
@@ -1113,15 +1135,17 @@ const svc = defineService<State, {
|
|
|
1113
1135
|
refresh: (state: State, arg?: unknown) => Promise<State | undefined>;
|
|
1114
1136
|
dismissOnboarding: (state: State) => State;
|
|
1115
1137
|
clearPersonal: (state: State) => State;
|
|
1116
|
-
personalLoaded: (state: State, arg: { generation: number; rows: MemberBookingRow[]; progress: { label: string; fraction: number }; error: boolean }) => State;
|
|
1138
|
+
personalLoaded: (state: State, arg: { generation: number; rows: MemberBookingRow[]; progress: { label: string; fraction: number }; error: boolean; weekly: { count: number; fraction: number; label: string } | null }) => State;
|
|
1117
1139
|
}>("himiBrandedHome", {
|
|
1118
1140
|
state: baseState(),
|
|
1119
1141
|
actions: {
|
|
1120
|
-
clearPersonal: state => ({ ...state, nextBooking: [], hideNextBooking: true, memberProgressLabel: "", memberProgressFraction: 0, hideMemberProgress: true, personalError: false, hidePersonalError: true
|
|
1142
|
+
clearPersonal: state => derive({ ...state, nextBooking: [], hideNextBooking: true, memberProgressLabel: "", memberProgressFraction: 0, hideMemberProgress: true, personalError: false, hidePersonalError: true,
|
|
1143
|
+
weeklyClassCount: 0, weeklyClassGoalFraction: 0, weeklyGoalLabel: "" }),
|
|
1121
1144
|
personalLoaded: (state, arg) => arg.generation !== personalGeneration ? state : derive({ ...state,
|
|
1122
1145
|
nextBooking: arg.rows, hideNextBooking: !arg.rows.length,
|
|
1123
1146
|
memberProgressLabel: arg.progress.label, memberProgressFraction: arg.progress.fraction, hideMemberProgress: !arg.progress.label,
|
|
1124
|
-
personalError: arg.error, hidePersonalError: !arg.error
|
|
1147
|
+
personalError: arg.error, hidePersonalError: !arg.error,
|
|
1148
|
+
weeklyClassCount: arg.weekly?.count ?? 0, weeklyClassGoalFraction: arg.weekly?.fraction ?? 0, weeklyGoalLabel: arg.weekly?.label ?? "" }),
|
|
1125
1149
|
refresh,
|
|
1126
1150
|
// "Got it" on the first-run card: persist + hide. Persistence is
|
|
1127
1151
|
// best-effort — the UI hides either way for this session.
|
|
@@ -52023,7 +52023,10 @@ const SCREENS = runtimeSetting({
|
|
|
52023
52023
|
}
|
|
52024
52024
|
},
|
|
52025
52025
|
"modifiers": {
|
|
52026
|
-
"accessibilityRole": "decorative"
|
|
52026
|
+
"accessibilityRole": "decorative",
|
|
52027
|
+
"padding": {
|
|
52028
|
+
"leading": 12
|
|
52029
|
+
}
|
|
52027
52030
|
}
|
|
52028
52031
|
},
|
|
52029
52032
|
{
|
|
@@ -11,6 +11,8 @@ export interface CollectionSaving {
|
|
|
11
11
|
type State = Record<string, unknown>;
|
|
12
12
|
interface BackendCollection {
|
|
13
13
|
restorePagesOnLoad?: boolean;
|
|
14
|
+
/** Sees the load action's argument (the screen's onAppear params) BEFORE the query runs. */
|
|
15
|
+
onLoad?(arg: unknown): void;
|
|
14
16
|
controller: ReturnType<typeof createCollectionQuery<CollectionRow>>;
|
|
15
17
|
apply(state: State, page: CollectionQueryState<CollectionRow>): State;
|
|
16
18
|
}
|
|
@@ -294,6 +296,7 @@ export function decorateCollection(name: string, def: { state: State; actions?:
|
|
|
294
296
|
actions.collectionDataChanged = s => derive(backend.apply(s, backend.controller.getState()));
|
|
295
297
|
actions.load = (_s, arg) => {
|
|
296
298
|
stashCopy(arg); syncSaved(); applyNavigationCriteria(arg, _s);
|
|
299
|
+
backend.onLoad?.(arg);
|
|
297
300
|
return backend.controller.query(criteria(), backend.restorePagesOnLoad).then(() => undefined);
|
|
298
301
|
};
|
|
299
302
|
actions.refresh = (_s, arg) => {
|
|
@@ -320,6 +323,9 @@ export function decorateCollection(name: string, def: { state: State; actions?:
|
|
|
320
323
|
export function defineBackendCollection<S extends object, Row extends object>(name: string, options: {
|
|
321
324
|
/** Revalidate already opened pages on navigation return; explicit refresh resets. */
|
|
322
325
|
restorePagesOnLoad?: boolean;
|
|
326
|
+
/** The load action's argument (onAppear params beyond `copy`), before the query runs — for a
|
|
327
|
+
* domain setting that rides the descriptor, e.g. My Bookings' `weeklyGoal`. */
|
|
328
|
+
onLoad?(arg: unknown): void;
|
|
323
329
|
state: S;
|
|
324
330
|
source: CollectionQuerySource<Row>;
|
|
325
331
|
apply(state: S, page: CollectionQueryState<Row>): S;
|
|
@@ -330,6 +336,7 @@ export function defineBackendCollection<S extends object, Row extends object>(na
|
|
|
330
336
|
const controller = createCollectionQuery(options.source, () => { publish?.(); });
|
|
331
337
|
const definition = decorateCollection(name, { state: options.state as State, actions: options.actions as Record<string, Reducer> | undefined }, options.saving, {
|
|
332
338
|
restorePagesOnLoad: options.restorePagesOnLoad,
|
|
339
|
+
onLoad: options.onLoad,
|
|
333
340
|
controller: controller as unknown as BackendCollection['controller'],
|
|
334
341
|
apply: (state, page) => options.apply(state as S, page as unknown as CollectionQueryState<Row>) as State,
|
|
335
342
|
});
|
|
@@ -37,7 +37,7 @@ export default defineApp({
|
|
|
37
37
|
actions: "http://localhost:8190/v1/actions",
|
|
38
38
|
sync: "http://localhost:8190/v1/sync",
|
|
39
39
|
},
|
|
40
|
-
capabilities: ["live_activity","push","share","secure_storage","open_url","calendar","local_database","wix_api","wix_platform","app_info","release_control","clipboard"],
|
|
40
|
+
capabilities: ["live_activity","push","share","secure_storage","open_url","calendar","local_database","wix_api","wix_platform","app_info","release_control","clipboard","motion"],
|
|
41
41
|
designTokensPath: "./tokens.json",
|
|
42
42
|
navigation: {
|
|
43
43
|
"navKind": "responsive",
|
|
@@ -281,6 +281,13 @@ export default defineApp({
|
|
|
281
281
|
"parentScreenId": "himi_account",
|
|
282
282
|
"tabId": "profile"
|
|
283
283
|
},
|
|
284
|
+
{
|
|
285
|
+
"screenId": "himi_steps",
|
|
286
|
+
"isPublic": true,
|
|
287
|
+
"paramKeys": [],
|
|
288
|
+
"parentScreenId": "",
|
|
289
|
+
"tabId": ""
|
|
290
|
+
},
|
|
284
291
|
{
|
|
285
292
|
"screenId": "himi_account",
|
|
286
293
|
"isPublic": true,
|
|
@@ -365,6 +372,12 @@ export default defineApp({
|
|
|
365
372
|
"label": "Events",
|
|
366
373
|
"icon": "ticket"
|
|
367
374
|
},
|
|
375
|
+
{
|
|
376
|
+
"id": "drawer_steps",
|
|
377
|
+
"screenId": "himi_steps",
|
|
378
|
+
"label": "Steps",
|
|
379
|
+
"icon": "heart"
|
|
380
|
+
},
|
|
368
381
|
{
|
|
369
382
|
"id": "drawer_profile",
|
|
370
383
|
"screenId": "himi_account",
|