@wix/himalaya-cli 0.1777.0 → 0.1778.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/cli.mjs +394 -61
- package/guides/one-app-section-mappings.md +5 -8
- package/guides/one-app-to-himi-app.md +21 -7
- package/package.json +2 -2
- package/templates/beauty-salon/l10n/ar.json +5 -0
- package/templates/beauty-salon/l10n/cs.json +5 -0
- package/templates/beauty-salon/l10n/da.json +5 -0
- package/templates/beauty-salon/l10n/de.json +5 -0
- package/templates/beauty-salon/l10n/el.json +5 -0
- package/templates/beauty-salon/l10n/es.json +5 -0
- package/templates/beauty-salon/l10n/fi.json +5 -0
- package/templates/beauty-salon/l10n/fr.json +5 -0
- package/templates/beauty-salon/l10n/he.json +4 -0
- package/templates/beauty-salon/l10n/hu.json +5 -0
- package/templates/beauty-salon/l10n/id.json +5 -0
- package/templates/beauty-salon/l10n/it.json +5 -0
- package/templates/beauty-salon/l10n/ja.json +5 -0
- package/templates/beauty-salon/l10n/ko.json +5 -0
- package/templates/beauty-salon/l10n/lt.json +5 -0
- package/templates/beauty-salon/l10n/nl.json +5 -0
- package/templates/beauty-salon/l10n/no.json +5 -0
- package/templates/beauty-salon/l10n/pl.json +5 -0
- package/templates/beauty-salon/l10n/pt.json +5 -0
- package/templates/beauty-salon/l10n/ru.json +5 -0
- package/templates/beauty-salon/l10n/sv.json +5 -0
- package/templates/beauty-salon/l10n/th.json +5 -0
- package/templates/beauty-salon/l10n/tr.json +5 -0
- package/templates/beauty-salon/l10n/uk.json +5 -0
- package/templates/beauty-salon/l10n/vi.json +5 -0
- package/templates/beauty-salon/l10n/zh.json +5 -0
- package/templates/beauty-salon/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/branded-lite/l10n/ar.json +15 -0
- package/templates/branded-lite/l10n/cs.json +15 -0
- package/templates/branded-lite/l10n/da.json +15 -0
- package/templates/branded-lite/l10n/de.json +15 -0
- package/templates/branded-lite/l10n/el.json +15 -0
- package/templates/branded-lite/l10n/es.json +15 -0
- package/templates/branded-lite/l10n/fi.json +15 -0
- package/templates/branded-lite/l10n/fr.json +15 -0
- package/templates/branded-lite/l10n/he.json +12 -0
- package/templates/branded-lite/l10n/hu.json +15 -0
- package/templates/branded-lite/l10n/id.json +15 -0
- package/templates/branded-lite/l10n/it.json +15 -0
- package/templates/branded-lite/l10n/ja.json +15 -0
- package/templates/branded-lite/l10n/ko.json +15 -0
- package/templates/branded-lite/l10n/lt.json +15 -0
- package/templates/branded-lite/l10n/nl.json +15 -0
- package/templates/branded-lite/l10n/no.json +15 -0
- package/templates/branded-lite/l10n/pl.json +15 -0
- package/templates/branded-lite/l10n/pt.json +15 -0
- package/templates/branded-lite/l10n/ru.json +15 -0
- package/templates/branded-lite/l10n/sv.json +15 -0
- package/templates/branded-lite/l10n/th.json +15 -0
- package/templates/branded-lite/l10n/tr.json +15 -0
- package/templates/branded-lite/l10n/uk.json +15 -0
- package/templates/branded-lite/l10n/vi.json +15 -0
- package/templates/branded-lite/l10n/zh.json +15 -0
- package/templates/branded-lite/recipes/blog-categories.json +115 -0
- package/templates/branded-lite/recipes/event-schedule.json +114 -0
- package/templates/branded-lite/recipes/groups-newsfeed.json +245 -0
- package/templates/branded-lite/recipes/loyalty-offering.json +241 -0
- package/templates/branded-lite/recipes/loyalty-status.json +173 -0
- package/templates/branded-lite/recipes/members-carousel.json +144 -0
- package/templates/branded-lite/recipes/performance-tracker.json +325 -0
- package/templates/branded-lite/recipes/podcasts-widget.json +280 -0
- package/templates/branded-lite/recipes/products-search-bar.json +139 -0
- package/templates/branded-lite/recipes/wishlist-grid.json +236 -0
- package/templates/branded-lite/tier5-src/_shared/blog-categories.ts +62 -0
- package/templates/branded-lite/tier5-src/_shared/event-agenda.ts +122 -0
- package/templates/branded-lite/tier5-src/_shared/event-schedule-section.ts +91 -0
- package/templates/branded-lite/tier5-src/_shared/group-feed-section.ts +2 -2
- package/templates/branded-lite/tier5-src/_shared/groups-newsfeed-section.ts +105 -0
- package/templates/branded-lite/tier5-src/_shared/loyalty-offering-section.ts +88 -0
- package/templates/branded-lite/tier5-src/_shared/loyalty-status-section.ts +88 -0
- package/templates/branded-lite/tier5-src/_shared/members-directory.ts +9 -3
- package/templates/branded-lite/tier5-src/_shared/performance-tracker-section.ts +120 -0
- package/templates/branded-lite/tier5-src/_shared/performance-tracker-weeks.ts +71 -0
- package/templates/branded-lite/tier5-src/_shared/podcast-section.ts +131 -0
- package/templates/branded-lite/tier5-src/_shared/saved-products-section.ts +64 -0
- package/templates/branded-lite/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/community-club/l10n/ar.json +5 -0
- package/templates/community-club/l10n/cs.json +5 -0
- package/templates/community-club/l10n/da.json +5 -0
- package/templates/community-club/l10n/de.json +5 -0
- package/templates/community-club/l10n/el.json +5 -0
- package/templates/community-club/l10n/es.json +5 -0
- package/templates/community-club/l10n/fi.json +5 -0
- package/templates/community-club/l10n/fr.json +5 -0
- package/templates/community-club/l10n/he.json +4 -0
- package/templates/community-club/l10n/hu.json +5 -0
- package/templates/community-club/l10n/id.json +5 -0
- package/templates/community-club/l10n/it.json +5 -0
- package/templates/community-club/l10n/ja.json +5 -0
- package/templates/community-club/l10n/ko.json +5 -0
- package/templates/community-club/l10n/lt.json +5 -0
- package/templates/community-club/l10n/nl.json +5 -0
- package/templates/community-club/l10n/no.json +5 -0
- package/templates/community-club/l10n/pl.json +5 -0
- package/templates/community-club/l10n/pt.json +5 -0
- package/templates/community-club/l10n/ru.json +5 -0
- package/templates/community-club/l10n/sv.json +5 -0
- package/templates/community-club/l10n/th.json +5 -0
- package/templates/community-club/l10n/tr.json +5 -0
- package/templates/community-club/l10n/uk.json +5 -0
- package/templates/community-club/l10n/vi.json +5 -0
- package/templates/community-club/l10n/zh.json +5 -0
- package/templates/community-club/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/events-meetups/l10n/ar.json +5 -0
- package/templates/events-meetups/l10n/cs.json +5 -0
- package/templates/events-meetups/l10n/da.json +5 -0
- package/templates/events-meetups/l10n/de.json +5 -0
- package/templates/events-meetups/l10n/el.json +5 -0
- package/templates/events-meetups/l10n/es.json +5 -0
- package/templates/events-meetups/l10n/fi.json +5 -0
- package/templates/events-meetups/l10n/fr.json +5 -0
- package/templates/events-meetups/l10n/he.json +4 -0
- package/templates/events-meetups/l10n/hu.json +5 -0
- package/templates/events-meetups/l10n/id.json +5 -0
- package/templates/events-meetups/l10n/it.json +5 -0
- package/templates/events-meetups/l10n/ja.json +5 -0
- package/templates/events-meetups/l10n/ko.json +5 -0
- package/templates/events-meetups/l10n/lt.json +5 -0
- package/templates/events-meetups/l10n/nl.json +5 -0
- package/templates/events-meetups/l10n/no.json +5 -0
- package/templates/events-meetups/l10n/pl.json +5 -0
- package/templates/events-meetups/l10n/pt.json +5 -0
- package/templates/events-meetups/l10n/ru.json +5 -0
- package/templates/events-meetups/l10n/sv.json +5 -0
- package/templates/events-meetups/l10n/th.json +5 -0
- package/templates/events-meetups/l10n/tr.json +5 -0
- package/templates/events-meetups/l10n/uk.json +5 -0
- package/templates/events-meetups/l10n/vi.json +5 -0
- package/templates/events-meetups/l10n/zh.json +5 -0
- package/templates/events-meetups/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/fitness-gym/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/gym-fitness/l10n/ar.json +5 -0
- package/templates/gym-fitness/l10n/cs.json +5 -0
- package/templates/gym-fitness/l10n/da.json +5 -0
- package/templates/gym-fitness/l10n/de.json +5 -0
- package/templates/gym-fitness/l10n/el.json +5 -0
- package/templates/gym-fitness/l10n/es.json +5 -0
- package/templates/gym-fitness/l10n/fi.json +5 -0
- package/templates/gym-fitness/l10n/fr.json +5 -0
- package/templates/gym-fitness/l10n/he.json +4 -0
- package/templates/gym-fitness/l10n/hu.json +5 -0
- package/templates/gym-fitness/l10n/id.json +5 -0
- package/templates/gym-fitness/l10n/it.json +5 -0
- package/templates/gym-fitness/l10n/ja.json +5 -0
- package/templates/gym-fitness/l10n/ko.json +5 -0
- package/templates/gym-fitness/l10n/lt.json +5 -0
- package/templates/gym-fitness/l10n/nl.json +5 -0
- package/templates/gym-fitness/l10n/no.json +5 -0
- package/templates/gym-fitness/l10n/pl.json +5 -0
- package/templates/gym-fitness/l10n/pt.json +5 -0
- package/templates/gym-fitness/l10n/ru.json +5 -0
- package/templates/gym-fitness/l10n/sv.json +5 -0
- package/templates/gym-fitness/l10n/th.json +5 -0
- package/templates/gym-fitness/l10n/tr.json +5 -0
- package/templates/gym-fitness/l10n/uk.json +5 -0
- package/templates/gym-fitness/l10n/vi.json +5 -0
- package/templates/gym-fitness/l10n/zh.json +5 -0
- package/templates/gym-fitness/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/medical-services/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/nonprofit-cause/l10n/ar.json +5 -0
- package/templates/nonprofit-cause/l10n/cs.json +5 -0
- package/templates/nonprofit-cause/l10n/da.json +5 -0
- package/templates/nonprofit-cause/l10n/de.json +5 -0
- package/templates/nonprofit-cause/l10n/el.json +5 -0
- package/templates/nonprofit-cause/l10n/es.json +5 -0
- package/templates/nonprofit-cause/l10n/fi.json +5 -0
- package/templates/nonprofit-cause/l10n/fr.json +5 -0
- package/templates/nonprofit-cause/l10n/he.json +4 -0
- package/templates/nonprofit-cause/l10n/hu.json +5 -0
- package/templates/nonprofit-cause/l10n/id.json +5 -0
- package/templates/nonprofit-cause/l10n/it.json +5 -0
- package/templates/nonprofit-cause/l10n/ja.json +5 -0
- package/templates/nonprofit-cause/l10n/ko.json +5 -0
- package/templates/nonprofit-cause/l10n/lt.json +5 -0
- package/templates/nonprofit-cause/l10n/nl.json +5 -0
- package/templates/nonprofit-cause/l10n/no.json +5 -0
- package/templates/nonprofit-cause/l10n/pl.json +5 -0
- package/templates/nonprofit-cause/l10n/pt.json +5 -0
- package/templates/nonprofit-cause/l10n/ru.json +5 -0
- package/templates/nonprofit-cause/l10n/sv.json +5 -0
- package/templates/nonprofit-cause/l10n/th.json +5 -0
- package/templates/nonprofit-cause/l10n/tr.json +5 -0
- package/templates/nonprofit-cause/l10n/uk.json +5 -0
- package/templates/nonprofit-cause/l10n/vi.json +5 -0
- package/templates/nonprofit-cause/l10n/zh.json +5 -0
- package/templates/nonprofit-cause/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/personal-fitness-trainer/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/podcast-creator/l10n/ar.json +5 -0
- package/templates/podcast-creator/l10n/cs.json +5 -0
- package/templates/podcast-creator/l10n/da.json +5 -0
- package/templates/podcast-creator/l10n/de.json +5 -0
- package/templates/podcast-creator/l10n/el.json +5 -0
- package/templates/podcast-creator/l10n/es.json +5 -0
- package/templates/podcast-creator/l10n/fi.json +5 -0
- package/templates/podcast-creator/l10n/fr.json +5 -0
- package/templates/podcast-creator/l10n/he.json +4 -0
- package/templates/podcast-creator/l10n/hu.json +5 -0
- package/templates/podcast-creator/l10n/id.json +5 -0
- package/templates/podcast-creator/l10n/it.json +5 -0
- package/templates/podcast-creator/l10n/ja.json +5 -0
- package/templates/podcast-creator/l10n/ko.json +5 -0
- package/templates/podcast-creator/l10n/lt.json +5 -0
- package/templates/podcast-creator/l10n/nl.json +5 -0
- package/templates/podcast-creator/l10n/no.json +5 -0
- package/templates/podcast-creator/l10n/pl.json +5 -0
- package/templates/podcast-creator/l10n/pt.json +5 -0
- package/templates/podcast-creator/l10n/ru.json +5 -0
- package/templates/podcast-creator/l10n/sv.json +5 -0
- package/templates/podcast-creator/l10n/th.json +5 -0
- package/templates/podcast-creator/l10n/tr.json +5 -0
- package/templates/podcast-creator/l10n/uk.json +5 -0
- package/templates/podcast-creator/l10n/vi.json +5 -0
- package/templates/podcast-creator/l10n/zh.json +5 -0
- package/templates/podcast-creator/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/portfolio-creative/l10n/ar.json +5 -0
- package/templates/portfolio-creative/l10n/cs.json +5 -0
- package/templates/portfolio-creative/l10n/da.json +5 -0
- package/templates/portfolio-creative/l10n/de.json +5 -0
- package/templates/portfolio-creative/l10n/el.json +5 -0
- package/templates/portfolio-creative/l10n/es.json +5 -0
- package/templates/portfolio-creative/l10n/fi.json +5 -0
- package/templates/portfolio-creative/l10n/fr.json +5 -0
- package/templates/portfolio-creative/l10n/he.json +4 -0
- package/templates/portfolio-creative/l10n/hu.json +5 -0
- package/templates/portfolio-creative/l10n/id.json +5 -0
- package/templates/portfolio-creative/l10n/it.json +5 -0
- package/templates/portfolio-creative/l10n/ja.json +5 -0
- package/templates/portfolio-creative/l10n/ko.json +5 -0
- package/templates/portfolio-creative/l10n/lt.json +5 -0
- package/templates/portfolio-creative/l10n/nl.json +5 -0
- package/templates/portfolio-creative/l10n/no.json +5 -0
- package/templates/portfolio-creative/l10n/pl.json +5 -0
- package/templates/portfolio-creative/l10n/pt.json +5 -0
- package/templates/portfolio-creative/l10n/ru.json +5 -0
- package/templates/portfolio-creative/l10n/sv.json +5 -0
- package/templates/portfolio-creative/l10n/th.json +5 -0
- package/templates/portfolio-creative/l10n/tr.json +5 -0
- package/templates/portfolio-creative/l10n/uk.json +5 -0
- package/templates/portfolio-creative/l10n/vi.json +5 -0
- package/templates/portfolio-creative/l10n/zh.json +5 -0
- package/templates/portfolio-creative/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/restaurant/l10n/ar.json +5 -0
- package/templates/restaurant/l10n/cs.json +5 -0
- package/templates/restaurant/l10n/da.json +5 -0
- package/templates/restaurant/l10n/de.json +5 -0
- package/templates/restaurant/l10n/el.json +5 -0
- package/templates/restaurant/l10n/es.json +5 -0
- package/templates/restaurant/l10n/fi.json +5 -0
- package/templates/restaurant/l10n/fr.json +5 -0
- package/templates/restaurant/l10n/he.json +4 -0
- package/templates/restaurant/l10n/hu.json +5 -0
- package/templates/restaurant/l10n/id.json +5 -0
- package/templates/restaurant/l10n/it.json +5 -0
- package/templates/restaurant/l10n/ja.json +5 -0
- package/templates/restaurant/l10n/ko.json +5 -0
- package/templates/restaurant/l10n/lt.json +5 -0
- package/templates/restaurant/l10n/nl.json +5 -0
- package/templates/restaurant/l10n/no.json +5 -0
- package/templates/restaurant/l10n/pl.json +5 -0
- package/templates/restaurant/l10n/pt.json +5 -0
- package/templates/restaurant/l10n/ru.json +5 -0
- package/templates/restaurant/l10n/sv.json +5 -0
- package/templates/restaurant/l10n/th.json +5 -0
- package/templates/restaurant/l10n/tr.json +5 -0
- package/templates/restaurant/l10n/uk.json +5 -0
- package/templates/restaurant/l10n/vi.json +5 -0
- package/templates/restaurant/l10n/zh.json +5 -0
- package/templates/restaurant/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/retail-store/l10n/ar.json +5 -0
- package/templates/retail-store/l10n/cs.json +5 -0
- package/templates/retail-store/l10n/da.json +5 -0
- package/templates/retail-store/l10n/de.json +5 -0
- package/templates/retail-store/l10n/el.json +5 -0
- package/templates/retail-store/l10n/es.json +5 -0
- package/templates/retail-store/l10n/fi.json +5 -0
- package/templates/retail-store/l10n/fr.json +5 -0
- package/templates/retail-store/l10n/he.json +4 -0
- package/templates/retail-store/l10n/hu.json +5 -0
- package/templates/retail-store/l10n/id.json +5 -0
- package/templates/retail-store/l10n/it.json +5 -0
- package/templates/retail-store/l10n/ja.json +5 -0
- package/templates/retail-store/l10n/ko.json +5 -0
- package/templates/retail-store/l10n/lt.json +5 -0
- package/templates/retail-store/l10n/nl.json +5 -0
- package/templates/retail-store/l10n/no.json +5 -0
- package/templates/retail-store/l10n/pl.json +5 -0
- package/templates/retail-store/l10n/pt.json +5 -0
- package/templates/retail-store/l10n/ru.json +5 -0
- package/templates/retail-store/l10n/sv.json +5 -0
- package/templates/retail-store/l10n/th.json +5 -0
- package/templates/retail-store/l10n/tr.json +5 -0
- package/templates/retail-store/l10n/uk.json +5 -0
- package/templates/retail-store/l10n/vi.json +5 -0
- package/templates/retail-store/l10n/zh.json +5 -0
- package/templates/retail-store/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/salon-spa/tier5-src/_shared/weekly-goal.ts +7 -3
- package/templates/yoga-studio/l10n/ar.json +5 -0
- package/templates/yoga-studio/l10n/cs.json +5 -0
- package/templates/yoga-studio/l10n/da.json +5 -0
- package/templates/yoga-studio/l10n/de.json +5 -0
- package/templates/yoga-studio/l10n/el.json +5 -0
- package/templates/yoga-studio/l10n/es.json +5 -0
- package/templates/yoga-studio/l10n/fi.json +5 -0
- package/templates/yoga-studio/l10n/fr.json +5 -0
- package/templates/yoga-studio/l10n/he.json +4 -0
- package/templates/yoga-studio/l10n/hu.json +5 -0
- package/templates/yoga-studio/l10n/id.json +5 -0
- package/templates/yoga-studio/l10n/it.json +5 -0
- package/templates/yoga-studio/l10n/ja.json +5 -0
- package/templates/yoga-studio/l10n/ko.json +5 -0
- package/templates/yoga-studio/l10n/lt.json +5 -0
- package/templates/yoga-studio/l10n/nl.json +5 -0
- package/templates/yoga-studio/l10n/no.json +5 -0
- package/templates/yoga-studio/l10n/pl.json +5 -0
- package/templates/yoga-studio/l10n/pt.json +5 -0
- package/templates/yoga-studio/l10n/ru.json +5 -0
- package/templates/yoga-studio/l10n/sv.json +5 -0
- package/templates/yoga-studio/l10n/th.json +5 -0
- package/templates/yoga-studio/l10n/tr.json +5 -0
- package/templates/yoga-studio/l10n/uk.json +5 -0
- package/templates/yoga-studio/l10n/vi.json +5 -0
- package/templates/yoga-studio/l10n/zh.json +5 -0
- package/templates/yoga-studio/tier5-src/_shared/weekly-goal.ts +7 -3
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// A page's performance-tracker section as a registrable service: the signed-in member's progress against a weekly session goal
|
|
2
|
+
// (this week's range, "N of G sessions this week", a progress ring), their weekly streak and their all-time sessions. The source
|
|
3
|
+
// reads a private fitness service; this reads the same member-scoped bookings as My Bookings (himi_bookings) and counts with the
|
|
4
|
+
// same rule as its "This week" card (`weekly-goal.ts`: a CONFIRMED booking that already took place; Wix attendance is owner-scoped,
|
|
5
|
+
// so a no-show still counts), so a guest or a refused member gets the sign-in state instead of a read.
|
|
6
|
+
// goal -> the weekly goal (the source's `defaultWeeklyGoal`; its members may set their own, which a visitor cannot read),
|
|
7
|
+
// showTotal -> the all-time row (the source's `totalNumberOfSessions.show`).
|
|
8
|
+
// A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipe performance-tracker.json).
|
|
9
|
+
import { defineService } from "@himalaya/state";
|
|
10
|
+
import { hostSessionFromGlobal } from "@himalaya/iap";
|
|
11
|
+
import { copyParam, stashCopy } from "./himi-copy.js";
|
|
12
|
+
import { formatNumber } from "./engine-intl.js";
|
|
13
|
+
import { fetchMemberBookings } from "./member-bookings.js";
|
|
14
|
+
import { memberAccess, memberAccessDenied, memberChanged } from "./member-access.js";
|
|
15
|
+
import { parseWeeklyGoal, weeklyGoalProgress } from "./weekly-goal.js";
|
|
16
|
+
import { DEFAULT_WEEKLY_GOAL, MAX_ALL_TIME_SESSIONS, MAX_PAGES, allTimeSessions, sessionsInWeek, streakMayBeLonger, weekRange, weeklyStreak } from "./performance-tracker-weeks.js";
|
|
17
|
+
|
|
18
|
+
export interface PerformanceTrackerOptions {
|
|
19
|
+
/** The weekly session goal. Not a goal in [1, 21]: the source's default of 2. */
|
|
20
|
+
goal?: number;
|
|
21
|
+
/** Show the all-time sessions row (default true, as the source). */
|
|
22
|
+
showTotal?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface PerformanceTrackerState {
|
|
26
|
+
status: "loading" | "ready" | "error";
|
|
27
|
+
/** A guest, or a member Wix refused: the section asks to sign in instead of reading. */
|
|
28
|
+
signedOut: boolean;
|
|
29
|
+
/** "Nov 16 – Nov 22". */
|
|
30
|
+
weekRange: string;
|
|
31
|
+
/** "1 of 2 sessions this week". */
|
|
32
|
+
goalLabel: string;
|
|
33
|
+
/** "1 more to reach your weekly goal". */
|
|
34
|
+
remainingLabel: string;
|
|
35
|
+
/** 0..1, the ring's fill. */
|
|
36
|
+
progress: number;
|
|
37
|
+
/** "1/2", inside the ring. */
|
|
38
|
+
ringText: string;
|
|
39
|
+
streak: string; streakLabel: string;
|
|
40
|
+
/** "500+" past the source's cap. */
|
|
41
|
+
total: string; totalLabel: string;
|
|
42
|
+
notLoading: boolean; notErrored: boolean; notSignedOut: boolean;
|
|
43
|
+
/** Nothing to show yet: loading, failed or signed out. */
|
|
44
|
+
noContent: boolean;
|
|
45
|
+
/** The all-time row is hidden: no content, or the source turned it off. */
|
|
46
|
+
noTotal: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function registerPerformanceTrackerSection(serviceName: string, options: PerformanceTrackerOptions = {}) {
|
|
50
|
+
const goal = parseWeeklyGoal(options.goal) || DEFAULT_WEEKLY_GOAL;
|
|
51
|
+
const showTotal = options.showTotal !== false;
|
|
52
|
+
const blank = { goalLabel: "", remainingLabel: "", progress: 0, ringText: "", streak: "", total: "" };
|
|
53
|
+
const view = (status: PerformanceTrackerState["status"], signedOut: boolean, fields: Partial<typeof blank> = {}, now?: number): PerformanceTrackerState => {
|
|
54
|
+
const noContent = !(status === "ready" && !signedOut);
|
|
55
|
+
return {
|
|
56
|
+
// No clock read at registration (a worker boots deterministically): the range is set by the load.
|
|
57
|
+
status, signedOut, weekRange: now === undefined ? "" : weekRange(now), ...blank, ...fields,
|
|
58
|
+
streakLabel: copyParam("performanceTracker.weekStreak", "Week streak"),
|
|
59
|
+
totalLabel: copyParam("performanceTracker.allTimeSessions", "All-time sessions"),
|
|
60
|
+
notLoading: status !== "loading", notErrored: status !== "error", notSignedOut: !signedOut,
|
|
61
|
+
noContent, noTotal: noContent || !showTotal,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
const session = hostSessionFromGlobal();
|
|
65
|
+
// Only the newest load may answer: a guest read that finishes after the member signed in must not overwrite the member's progress.
|
|
66
|
+
let sequence = 0;
|
|
67
|
+
const initial = view("loading", false);
|
|
68
|
+
// The member changed: the progress already published is the previous member's, so it goes at once.
|
|
69
|
+
const restart = () => { void service.clear(); void service.load(); };
|
|
70
|
+
const service = defineService<PerformanceTrackerState, { load: (state: PerformanceTrackerState, arg?: unknown) => Promise<PerformanceTrackerState | undefined>; clear: () => Promise<PerformanceTrackerState> }>(serviceName, {
|
|
71
|
+
state: initial,
|
|
72
|
+
// The progress is one member's: never written to disk and restored for the next person on the device.
|
|
73
|
+
notHydrated: Object.keys(initial) as Array<keyof PerformanceTrackerState>,
|
|
74
|
+
actions: {
|
|
75
|
+
clear: async () => initial,
|
|
76
|
+
load: async (_state, arg) => {
|
|
77
|
+
stashCopy(arg);
|
|
78
|
+
const seq = ++sequence;
|
|
79
|
+
let member: Awaited<ReturnType<typeof memberAccess>> | undefined;
|
|
80
|
+
try {
|
|
81
|
+
member = await memberAccess();
|
|
82
|
+
if (seq !== sequence) return undefined;
|
|
83
|
+
if (!member.email) return view("ready", true);
|
|
84
|
+
const now = Date.now();
|
|
85
|
+
const nowIso = new Date(now).toISOString();
|
|
86
|
+
const read = (cursor: string) => fetchMemberBookings({ query: "", filter: "value:Past", sort: "za", savedIds: [] }, cursor, nowIso, member);
|
|
87
|
+
let page = await read("");
|
|
88
|
+
const rows = [...page.items];
|
|
89
|
+
for (let pages = 1; pages < MAX_PAGES && page.nextCursor; pages++) { page = await read(page.nextCursor); rows.push(...page.items); }
|
|
90
|
+
// Older bookings the page cap left unread: the streak and the all-time total are then "at least", never a silent shortfall.
|
|
91
|
+
const unreadRemain = Boolean(page.nextCursor);
|
|
92
|
+
if (seq !== sequence) return undefined;
|
|
93
|
+
const progress = weeklyGoalProgress(sessionsInWeek(rows, now, 0), goal);
|
|
94
|
+
const total = allTimeSessions(rows, now);
|
|
95
|
+
const streak = weeklyStreak(rows, now, goal);
|
|
96
|
+
return view("ready", false, {
|
|
97
|
+
goalLabel: progress.label, remainingLabel: progress.remainingLabel, progress: progress.fraction,
|
|
98
|
+
ringText: `${formatNumber(progress.done)}/${formatNumber(progress.goal)}`,
|
|
99
|
+
streak: `${formatNumber(streak)}${streakMayBeLonger(rows, now, goal, streak, unreadRemain) ? "+" : ""}`,
|
|
100
|
+
total: total > MAX_ALL_TIME_SESSIONS ? `${formatNumber(MAX_ALL_TIME_SESSIONS)}+` : `${formatNumber(total)}${unreadRemain ? "+" : ""}`,
|
|
101
|
+
}, now);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (seq !== sequence) return undefined;
|
|
104
|
+
// The member signed out (or changed) while the read was out: read again for whoever is signed in now.
|
|
105
|
+
const changed = await memberChanged(member, error);
|
|
106
|
+
// A newer load may have answered while that check was out: restarting then would blank its card and read the bookings again.
|
|
107
|
+
if (seq !== sequence) return undefined;
|
|
108
|
+
if (changed) { restart(); return undefined; }
|
|
109
|
+
// Wix refusing the member is a sign-in state, as on My Bookings; anything else is a failed read.
|
|
110
|
+
if (memberAccessDenied(error)) return view("ready", true);
|
|
111
|
+
console.warn("performance_tracker_section: the bookings could not be read", error);
|
|
112
|
+
return view("error", false);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
// Signing in or out on another screen changes the progress this section shows.
|
|
118
|
+
session.subscribe(restart);
|
|
119
|
+
return service;
|
|
120
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// What a performance tracker counts, as pure functions over a member's bookings (no network, no clock read: `now` is an argument), so
|
|
2
|
+
// the rules are unit-tested directly. A session is what My Bookings' "This week" card counts (`isHeldSession` in `weekly-goal.ts`):
|
|
3
|
+
// the section and that card can never disagree.
|
|
4
|
+
import { formatMonthDay } from "./engine-intl.js";
|
|
5
|
+
import type { MemberBookingRow } from "./member-bookings.js";
|
|
6
|
+
import { isHeldSession, weekStartMs, weeklySessionsDone } from "./weekly-goal.js";
|
|
7
|
+
|
|
8
|
+
/** The source's default weekly goal. */
|
|
9
|
+
export const DEFAULT_WEEKLY_GOAL = 2;
|
|
10
|
+
/** The source shows "500+" past this many all-time sessions. */
|
|
11
|
+
export const MAX_ALL_TIME_SESSIONS = 500;
|
|
12
|
+
/** The source looks back one year for the streak. */
|
|
13
|
+
export const STREAK_WEEKS = 52;
|
|
14
|
+
/** 11 pages of 50 past bookings: enough to tell "500 or fewer" from "more", and to reach a year back. */
|
|
15
|
+
export const MAX_PAGES = 11;
|
|
16
|
+
|
|
17
|
+
/** Monday 00:00 local, `weeksBack` weeks before the week `now` is in (DST-safe: calendar days, not 7 * 24 h). */
|
|
18
|
+
const weekStartBack = (now: number, weeksBack: number): number => {
|
|
19
|
+
const d = new Date(weekStartMs(now));
|
|
20
|
+
d.setDate(d.getDate() - 7 * weeksBack);
|
|
21
|
+
return d.getTime();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Sessions held in the week `weeksBack` weeks before `now`'s (0 = this week, up to `now`). */
|
|
25
|
+
export function sessionsInWeek(rows: readonly MemberBookingRow[], now: number, weeksBack: number): number {
|
|
26
|
+
// A millisecond before the next Monday is still in that week, and `weeklySessionsDone` takes its week from the instant it is given.
|
|
27
|
+
return weeklySessionsDone(rows, weeksBack === 0 ? now : weekStartBack(now, weeksBack - 1) - 1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Consecutive weeks that met `goal`, newest first. The week still running counts once it has met the goal and never breaks the
|
|
32
|
+
* streak while it has not: the member still has days left.
|
|
33
|
+
*/
|
|
34
|
+
export function weeklyStreak(rows: readonly MemberBookingRow[], now: number, goal: number): number {
|
|
35
|
+
const current = sessionsInWeek(rows, now, 0);
|
|
36
|
+
let streak = 0;
|
|
37
|
+
for (let back = current >= goal ? 0 : 1; back < STREAK_WEEKS; back++) {
|
|
38
|
+
if ((back === 0 ? current : sessionsInWeek(rows, now, back)) < goal) break;
|
|
39
|
+
streak++;
|
|
40
|
+
}
|
|
41
|
+
return streak;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Whether `streak` may be longer than the rows show: the read stopped at the page cap with older bookings unread, and the run of weeks
|
|
46
|
+
* reaches the oldest week those rows cover (an older week the rows do not hold looks empty and would end the run early).
|
|
47
|
+
*/
|
|
48
|
+
export function streakMayBeLonger(rows: readonly MemberBookingRow[], now: number, goal: number, streak: number, unreadRemain: boolean): boolean {
|
|
49
|
+
if (!unreadRemain) return false;
|
|
50
|
+
const starts = rows.map((row) => Date.parse(row.start)).filter(Number.isFinite);
|
|
51
|
+
if (!starts.length) return false;
|
|
52
|
+
const week = 7 * 24 * 3600 * 1000;
|
|
53
|
+
const oldestBack = Math.round((weekStartMs(now) - weekStartMs(Math.min(...starts))) / week);
|
|
54
|
+
const firstWeek = sessionsInWeek(rows, now, 0) >= goal ? 0 : 1;
|
|
55
|
+
// A run that ended at the 52-week look-back ended by the source's own limit: older bookings cannot lengthen it.
|
|
56
|
+
if (firstWeek + streak >= STREAK_WEEKS) return false;
|
|
57
|
+
return firstWeek + streak >= oldestBack;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Sessions held, all time (one per booking id). */
|
|
61
|
+
export function allTimeSessions(rows: readonly MemberBookingRow[], now: number): number {
|
|
62
|
+
return new Set(rows.filter((row) => isHeldSession(row, now)).map((row) => row.id || `${row.start}|${row.title}`)).size;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** "Nov 16 – Nov 22": Monday to Sunday of the week `now` is in. */
|
|
66
|
+
export function weekRange(now: number): string {
|
|
67
|
+
const start = new Date(weekStartMs(now));
|
|
68
|
+
const end = new Date(start);
|
|
69
|
+
end.setDate(end.getDate() + 6);
|
|
70
|
+
return `${formatMonthDay(start)} – ${formatMonthDay(end)}`;
|
|
71
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// A page's podcast section as a registrable service: the show's header (cover, title, author, description) and its latest episodes, read
|
|
2
|
+
// from the source section's own RSS feed. The One App's widget shows the latest three and a "View all episodes" link when the feed has more.
|
|
3
|
+
// feedUrl -> the source section's feed (`settings.feedUrl`); a feed that is not an http(s) URL reads nothing and shows the error state,
|
|
4
|
+
// limit -> how many episodes the section lists (the section is a short preview; the template Podcasts screen lists and plays them all),
|
|
5
|
+
// `noMore` is false when the feed has more, which is when the section's "View all episodes" link shows.
|
|
6
|
+
// Reads the same public Wix Podcasts feed gateway as the template Podcasts screen's worker (`createPodcastService`), because a worker has
|
|
7
|
+
// no general `fetch` and the wix_api bridge refuses a third-party URL; the gateway reads the RSS, follows its redirects and owns host
|
|
8
|
+
// safety. A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipe podcasts-widget).
|
|
9
|
+
import { defineService } from "@himalaya/state";
|
|
10
|
+
import { formatMonthDay } from "./engine-intl.js";
|
|
11
|
+
import { stashCopy } from "./himi-copy.js";
|
|
12
|
+
|
|
13
|
+
type WixApi = { call: (method: string, path: string, body?: unknown) => Promise<unknown> };
|
|
14
|
+
|
|
15
|
+
export interface PodcastSectionOptions {
|
|
16
|
+
/** The source section's RSS feed URL. */
|
|
17
|
+
feedUrl: string;
|
|
18
|
+
/** How many episodes to list (default 3, the source widget's own count). */
|
|
19
|
+
limit?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface PodcastEpisodeRow {
|
|
23
|
+
id: string; title: string; subtitle: string; description: string; image: string;
|
|
24
|
+
/** hiddenWhen gates (they hide on TRUE) for the parts an episode has none of. */
|
|
25
|
+
noImage: boolean; noDescription: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface PodcastSectionState {
|
|
29
|
+
status: "loading" | "ready" | "error";
|
|
30
|
+
podcastTitle: string; podcastAuthor: string; podcastDescription: string; podcastImage: string;
|
|
31
|
+
rows: PodcastEpisodeRow[];
|
|
32
|
+
notLoading: boolean; notErrored: boolean; noRows: boolean;
|
|
33
|
+
/** true until the read answered with a show title: the header has nothing to introduce. */
|
|
34
|
+
noHeader: boolean; noAuthor: boolean; noDescription: boolean; noPodcastImage: boolean;
|
|
35
|
+
/** false when the feed has more episodes than the section lists. */
|
|
36
|
+
noMore: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The gateway the template Podcasts screen reads (POST only, no credential). */
|
|
40
|
+
const FEED_ENDPOINT = "https://podcasts.wix.com/api/feed/graphql";
|
|
41
|
+
const DEFAULT_LIMIT = 3;
|
|
42
|
+
const MAX_URL_LENGTH = 2048;
|
|
43
|
+
const QUERY = `
|
|
44
|
+
query PodcastSection($url: String!, $limit: Int) {
|
|
45
|
+
podcast(url: $url) { title author image description }
|
|
46
|
+
episodes(url: $url, limit: $limit) { id title date duration image descriptionExcerpt(length: 220) }
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
interface FeedPodcast { title?: unknown; author?: unknown; image?: unknown; description?: unknown }
|
|
51
|
+
interface FeedEpisode { id?: unknown; title?: unknown; date?: unknown; duration?: unknown; image?: unknown; descriptionExcerpt?: unknown }
|
|
52
|
+
|
|
53
|
+
// Block tags (a paragraph, a break, a list item) separate words; inline ones (<b>, <a>) vanish without leaving a stray space before punctuation.
|
|
54
|
+
const plain = (value: unknown): string => typeof value === "string"
|
|
55
|
+
? value.replace(/<\/?(?:p|br|div|li|ul|ol|h[1-6])\b[^>]*>/gi, " ").replace(/<[^>]*>/g, "").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"").replace(/'/g, "'").replace(/\s+/g, " ").trim()
|
|
56
|
+
: "";
|
|
57
|
+
/** An artwork URL the app may load: https only (the podcast hosts all serve it), never a credential-bearing or non-web one. */
|
|
58
|
+
const imageUrl = (value: unknown): string => {
|
|
59
|
+
const url = typeof value === "string" ? value.trim() : "";
|
|
60
|
+
return /^https:\/\/[^\s@/]+(?:[/?#]\S*)?$/i.test(url) && url.length <= MAX_URL_LENGTH ? url : "";
|
|
61
|
+
};
|
|
62
|
+
/** The feed as the gateway can read it: an http(s) URL with no user info, or "" (no read is made for anything else). */
|
|
63
|
+
const feedOf = (value: unknown): string => {
|
|
64
|
+
const url = typeof value === "string" ? value.trim() : "";
|
|
65
|
+
return /^https?:\/\/[^\s@/]+(?:[/?#]\S*)?$/i.test(url) && url.length <= MAX_URL_LENGTH ? url : "";
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/** "1200", "20:00" or "1:02:03" as a clock ("20:00"); anything else (a length the feed did not write) is no length. */
|
|
69
|
+
function lengthOf(value: unknown): string {
|
|
70
|
+
const raw = typeof value === "string" ? value.trim() : typeof value === "number" ? String(value) : "";
|
|
71
|
+
const pieces = raw.split(":");
|
|
72
|
+
if (!raw || pieces.length > 3 || !pieces.every((piece) => /^\d+$/.test(piece))) return "";
|
|
73
|
+
const seconds = pieces.length === 1 ? Number(raw) : pieces.map(Number).reduce((total, piece) => total * 60 + piece, 0);
|
|
74
|
+
if (!(seconds > 0)) return "";
|
|
75
|
+
const hours = Math.floor(seconds / 3600), minutes = Math.floor((seconds % 3600) / 60), rest = String(seconds % 60).padStart(2, "0");
|
|
76
|
+
return hours ? `${hours}:${String(minutes).padStart(2, "0")}:${rest}` : `${minutes}:${rest}`;
|
|
77
|
+
}
|
|
78
|
+
function dateOf(value: unknown): string {
|
|
79
|
+
const parsed = typeof value === "string" && value ? Date.parse(value) : NaN;
|
|
80
|
+
// The app's pinned language, not the device's: an app set to Spanish on an English phone reads "4 nov".
|
|
81
|
+
return Number.isFinite(parsed) ? formatMonthDay(new Date(parsed)) : "";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function rowOf(episode: FeedEpisode): PodcastEpisodeRow | undefined {
|
|
85
|
+
const title = plain(episode.title);
|
|
86
|
+
const id = typeof episode.id === "string" ? episode.id.trim() : "";
|
|
87
|
+
if (!id && !title) return undefined;
|
|
88
|
+
const image = imageUrl(episode.image), description = plain(episode.descriptionExcerpt);
|
|
89
|
+
return {
|
|
90
|
+
// An episode with an id and no title is named by its date, then its id: a fixed English word would be untranslated in every other app language.
|
|
91
|
+
id: id || title, title: title || dateOf(episode.date) || id,
|
|
92
|
+
subtitle: [dateOf(episode.date), lengthOf(episode.duration)].filter(Boolean).join(" · "),
|
|
93
|
+
description, image, noImage: !image, noDescription: !description,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function registerPodcastSection(serviceName: string, options: PodcastSectionOptions) {
|
|
98
|
+
const feedUrl = feedOf(options.feedUrl);
|
|
99
|
+
const limit = Math.max(1, Math.min(10, Math.trunc(options.limit ?? DEFAULT_LIMIT) || DEFAULT_LIMIT));
|
|
100
|
+
const view = (status: PodcastSectionState["status"], podcast: FeedPodcast = {}, rows: PodcastEpisodeRow[] = [], more = false): PodcastSectionState => {
|
|
101
|
+
const podcastTitle = plain(podcast.title), podcastAuthor = plain(podcast.author), podcastDescription = plain(podcast.description), podcastImage = imageUrl(podcast.image);
|
|
102
|
+
return {
|
|
103
|
+
status, podcastTitle, podcastAuthor, podcastDescription, podcastImage, rows,
|
|
104
|
+
notLoading: status !== "loading", notErrored: status !== "error", noRows: !rows.length,
|
|
105
|
+
noHeader: status !== "ready" || !podcastTitle, noAuthor: !podcastAuthor, noDescription: !podcastDescription, noPodcastImage: !podcastImage,
|
|
106
|
+
noMore: !more,
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
return defineService<PodcastSectionState, { load: (state: PodcastSectionState, arg?: unknown) => Promise<PodcastSectionState> }>(serviceName, {
|
|
110
|
+
state: view("loading"),
|
|
111
|
+
actions: {
|
|
112
|
+
load: async (_state, arg) => {
|
|
113
|
+
stashCopy(arg);
|
|
114
|
+
const api = (globalThis as { himalaya?: { wixApi?: WixApi } }).himalaya?.wixApi;
|
|
115
|
+
if (!feedUrl || !api) return view("error");
|
|
116
|
+
try {
|
|
117
|
+
// One more than the section lists tells whether the feed has more, as the source widget reads it.
|
|
118
|
+
const response = await api.call("POST", FEED_ENDPOINT, { query: QUERY, variables: { url: feedUrl, limit: limit + 1 } }) as
|
|
119
|
+
{ data?: { podcast?: FeedPodcast | null; episodes?: unknown } | null; errors?: unknown } | null;
|
|
120
|
+
// A GraphQL error is the gateway saying it could not read this feed (unknown, unreachable or not RSS).
|
|
121
|
+
if (!response || (Array.isArray(response.errors) && response.errors.length) || !Array.isArray(response.data?.episodes)) return view("error");
|
|
122
|
+
const rows = (response.data!.episodes as FeedEpisode[]).map(rowOf).filter((row): row is PodcastEpisodeRow => row !== undefined);
|
|
123
|
+
return view("ready", response.data!.podcast ?? {}, rows.slice(0, limit), rows.length > limit);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.warn("podcast_section: the feed could not be read", error);
|
|
126
|
+
return view("error");
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// A page's wishlist section as a registrable service: the products saved on this device, the same list the template's
|
|
2
|
+
// `himi_saved_products` screen shows (`himi-store-saved`), as tiles that open the product.
|
|
3
|
+
// limit -> how many tiles (the section is a short grid, not the wishlist screen); `noMore` is false when more are saved,
|
|
4
|
+
// which is when the section's See All button (to `himi_saved_products`) shows.
|
|
5
|
+
// The One App wishlist is the member's account list on a private One App service no worker can call, so this module reads the
|
|
6
|
+
// device-local list only. A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*`
|
|
7
|
+
// (recipe wishlist-grid).
|
|
8
|
+
import { defineService } from "@himalaya/state";
|
|
9
|
+
import { readSavedProducts, type SavedProduct } from "./himi-store-saved.js";
|
|
10
|
+
|
|
11
|
+
export interface SavedProductsSectionOptions {
|
|
12
|
+
/** How many products to show; unset shows every saved product. */
|
|
13
|
+
limit?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface SavedProductRow {
|
|
17
|
+
id: string; name: string; price: string;
|
|
18
|
+
image: string; initial: string; hasImage: boolean; noImage: boolean;
|
|
19
|
+
/** The product screen a tile opens; the tile binds `id` as its nav param. */
|
|
20
|
+
detailScreenId: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SavedProductsSectionState {
|
|
24
|
+
status: "loading" | "ready" | "error";
|
|
25
|
+
rows: SavedProductRow[];
|
|
26
|
+
notLoading: boolean; notErrored: boolean; noRows: boolean;
|
|
27
|
+
/** false while nothing is saved and the read succeeded: the empty state shows. */
|
|
28
|
+
noEmpty: boolean;
|
|
29
|
+
/** false when more products are saved than the section shows. */
|
|
30
|
+
noMore: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function rowOf(product: SavedProduct): SavedProductRow {
|
|
34
|
+
const name = product.name.trim();
|
|
35
|
+
return {
|
|
36
|
+
id: product.id, name, price: product.price,
|
|
37
|
+
image: product.image, initial: (name[0] ?? "#").toUpperCase(), hasImage: !!product.image, noImage: !product.image,
|
|
38
|
+
detailScreenId: "himi_product",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function registerSavedProductsSection(serviceName: string, options: SavedProductsSectionOptions = {}) {
|
|
43
|
+
const view = (status: SavedProductsSectionState["status"], rows: SavedProductRow[], more: boolean): SavedProductsSectionState => ({
|
|
44
|
+
status, rows,
|
|
45
|
+
notLoading: status !== "loading", notErrored: status !== "error", noRows: !rows.length,
|
|
46
|
+
noEmpty: !(status === "ready" && !rows.length), noMore: !more,
|
|
47
|
+
});
|
|
48
|
+
return defineService<SavedProductsSectionState, { load: (state: SavedProductsSectionState, arg?: unknown) => SavedProductsSectionState }>(serviceName, {
|
|
49
|
+
state: view("loading", [], false),
|
|
50
|
+
actions: {
|
|
51
|
+
// The list is read on every appearance, so a product saved or removed on another screen shows when the page comes back.
|
|
52
|
+
load: () => {
|
|
53
|
+
try {
|
|
54
|
+
const saved = readSavedProducts();
|
|
55
|
+
const shown = options.limit !== undefined ? saved.slice(0, options.limit) : saved;
|
|
56
|
+
return view("ready", shown.map(rowOf), shown.length < saved.length);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.warn("saved_products_section: the saved products could not be read", error);
|
|
59
|
+
return view("error", [], false);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -40,14 +40,18 @@ export function weekStartMs(now: number): number {
|
|
|
40
40
|
return d.getTime();
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/** Is `row` a session that was booked and already held at `now`? The one rule every count here uses. */
|
|
44
|
+
export function isHeldSession(row: MemberBookingRow, now: number): boolean {
|
|
45
|
+
const start = Date.parse(row.start);
|
|
46
|
+
return Number.isFinite(start) && start < now && COUNTS_AS_SESSION.test((row.status || "").trim().toUpperCase());
|
|
47
|
+
}
|
|
48
|
+
|
|
43
49
|
/** Sessions toward the goal among `rows` — see the file header for what counts. */
|
|
44
50
|
export function weeklySessionsDone(rows: readonly MemberBookingRow[], now: number): number {
|
|
45
51
|
const from = weekStartMs(now);
|
|
46
52
|
const seen = new Set<string>();
|
|
47
53
|
for (const row of rows) {
|
|
48
|
-
|
|
49
|
-
if (!Number.isFinite(start) || start < from || start >= now) continue;
|
|
50
|
-
if (!COUNTS_AS_SESSION.test((row.status || "").trim().toUpperCase())) continue;
|
|
54
|
+
if (Date.parse(row.start) < from || !isHeldSession(row, now)) continue;
|
|
51
55
|
seen.add(row.id || `${row.start}|${row.title}`);
|
|
52
56
|
}
|
|
53
57
|
return seen.size;
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "موسّع",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, zero {# منشور} one {منشور واحد} two {منشوران} few {# منشورات} many {# منشورًا} other {# منشور}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Rozbaleno",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# příspěvek} few {# příspěvky} many {# příspěvku} other {# příspěvků}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Udvidet",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# opslag} other {# opslag}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Ausgeklappt",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# Beitrag} other {# Beiträge}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Ανεπτυγμένο",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# ανάρτηση} other {# αναρτήσεις}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Expandido",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# publicación} other {# publicaciones}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Laajennettu",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# julkaisu} other {# julkaisua}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Développé",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# article} other {# articles}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -2507,6 +2507,10 @@
|
|
|
2507
2507
|
"h_6d1704748e0c": {
|
|
2508
2508
|
"source": "Expanded",
|
|
2509
2509
|
"translation": "מורחב"
|
|
2510
|
+
},
|
|
2511
|
+
"h_3219c81fa232": {
|
|
2512
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
2513
|
+
"translation": "{n, plural, one {פוסט אחד} other {# פוסטים}}"
|
|
2510
2514
|
}
|
|
2511
2515
|
}
|
|
2512
2516
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Kibontva",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# bejegyzés} other {# bejegyzés}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Diperluas",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, other {# kiriman}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Espanso",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# articolo} other {# articoli}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "展開済み",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, other {#件の投稿}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "펼침",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, other {게시물 #개}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Išskleista",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# įrašas} few {# įrašai} many {# įrašo} other {# įrašų}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Uitgevouwen",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# bericht} other {# berichten}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Utvidet",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# innlegg} other {# innlegg}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|
|
@@ -3063,6 +3063,11 @@
|
|
|
3063
3063
|
"source": "Expanded",
|
|
3064
3064
|
"translation": "Rozwinięte",
|
|
3065
3065
|
"origin": "machine"
|
|
3066
|
+
},
|
|
3067
|
+
"h_3219c81fa232": {
|
|
3068
|
+
"source": "{n, plural, one {# post} other {# posts}}",
|
|
3069
|
+
"translation": "{n, plural, one {# wpis} few {# wpisy} many {# wpisów} other {# wpisu}}",
|
|
3070
|
+
"origin": "machine"
|
|
3066
3071
|
}
|
|
3067
3072
|
}
|
|
3068
3073
|
}
|