@wix/himalaya-cli 0.1870.0 → 0.1872.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/dev-server/src/app-module.d.ts +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/portfolio/src/index.d.ts +19 -0
- package/dist/cli.mjs +90 -39
- package/fixtures/wix-canned.json +8 -0
- package/guides/android-ux.md +3 -2
- package/guides/designing-himi-screens.md +10 -4
- package/guides/ios-ux.md +3 -2
- package/guides/release-notes.md +18 -0
- package/guides/sdk-reference.json +8 -1
- package/package.json +2 -2
- package/template-icons/professional-services.png +0 -0
- package/templates/bare-fashion/config.ts +37 -2
- package/templates/bare-fashion/dev/index.ts +4006 -48
- package/templates/bare-fashion/himalaya.content.json +15 -0
- package/templates/bare-fashion/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/bare-fashion/tier5-src/_shared/member-account-routes.ts +56 -0
- package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
- package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
- package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
- package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
- package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/beauty-salon/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/beauty-salon/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/beauty-salon-owner/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/beauty-salon-owner/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/branded-lite/dev/index.ts +22 -1
- package/templates/branded-lite/l10n/ar.json +10 -0
- package/templates/branded-lite/l10n/cs.json +10 -0
- package/templates/branded-lite/l10n/da.json +10 -0
- package/templates/branded-lite/l10n/de.json +10 -0
- package/templates/branded-lite/l10n/el.json +10 -0
- package/templates/branded-lite/l10n/es.json +10 -0
- package/templates/branded-lite/l10n/fi.json +10 -0
- package/templates/branded-lite/l10n/fr.json +10 -0
- package/templates/branded-lite/l10n/he.json +8 -0
- package/templates/branded-lite/l10n/hu.json +10 -0
- package/templates/branded-lite/l10n/id.json +10 -0
- package/templates/branded-lite/l10n/it.json +10 -0
- package/templates/branded-lite/l10n/ja.json +10 -0
- package/templates/branded-lite/l10n/ko.json +10 -0
- package/templates/branded-lite/l10n/lt.json +10 -0
- package/templates/branded-lite/l10n/nl.json +10 -0
- package/templates/branded-lite/l10n/no.json +10 -0
- package/templates/branded-lite/l10n/pl.json +10 -0
- package/templates/branded-lite/l10n/pt.json +10 -0
- package/templates/branded-lite/l10n/ru.json +10 -0
- package/templates/branded-lite/l10n/sv.json +10 -0
- package/templates/branded-lite/l10n/th.json +10 -0
- package/templates/branded-lite/l10n/tr.json +10 -0
- package/templates/branded-lite/l10n/uk.json +10 -0
- package/templates/branded-lite/l10n/vi.json +10 -0
- package/templates/branded-lite/l10n/zh.json +10 -0
- package/templates/branded-lite/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/branded-lite/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/branded-lite/tier5-src/_shared/portfolio-details.ts +70 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-coupons/index.ts +13 -2
- package/templates/branded-lite/tier5-src/himi-branded-lite-portfolio/index.ts +90 -9
- package/templates/branded-lite/tier5-src/himi-branded-lite-portfolio-project/index.ts +53 -4
- package/templates/branded-lite/tier5-src/himi-events-detail/index.ts +3 -1
- package/templates/branded-lite/tier5-src/himi-events-list/index.ts +38 -8
- package/templates/branded-lite/tier5-src/himi-events-my-events/index.ts +4 -2
- package/templates/brandy/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/community-club/dev/index.ts +20 -0
- package/templates/community-club/l10n/ar.json +10 -0
- package/templates/community-club/l10n/cs.json +10 -0
- package/templates/community-club/l10n/da.json +10 -0
- package/templates/community-club/l10n/de.json +10 -0
- package/templates/community-club/l10n/el.json +10 -0
- package/templates/community-club/l10n/es.json +10 -0
- package/templates/community-club/l10n/fi.json +10 -0
- package/templates/community-club/l10n/fr.json +10 -0
- package/templates/community-club/l10n/he.json +8 -0
- package/templates/community-club/l10n/hu.json +10 -0
- package/templates/community-club/l10n/id.json +10 -0
- package/templates/community-club/l10n/it.json +10 -0
- package/templates/community-club/l10n/ja.json +10 -0
- package/templates/community-club/l10n/ko.json +10 -0
- package/templates/community-club/l10n/lt.json +10 -0
- package/templates/community-club/l10n/nl.json +10 -0
- package/templates/community-club/l10n/no.json +10 -0
- package/templates/community-club/l10n/pl.json +10 -0
- package/templates/community-club/l10n/pt.json +10 -0
- package/templates/community-club/l10n/ru.json +10 -0
- package/templates/community-club/l10n/sv.json +10 -0
- package/templates/community-club/l10n/th.json +10 -0
- package/templates/community-club/l10n/tr.json +10 -0
- package/templates/community-club/l10n/uk.json +10 -0
- package/templates/community-club/l10n/vi.json +10 -0
- package/templates/community-club/l10n/zh.json +10 -0
- package/templates/community-club/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/community-club/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/community-club/tier5-src/himi-events-detail/index.ts +3 -1
- package/templates/community-club/tier5-src/himi-events-list/index.ts +38 -8
- package/templates/community-club/tier5-src/himi-events-my-events/index.ts +4 -2
- package/templates/community-club-owner/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/community-club-owner/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/conference/config.ts +43 -1
- package/templates/conference/dev/index.ts +4147 -0
- package/templates/conference/himalaya.content.json +18 -0
- package/templates/conference/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/conference/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/conference/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
- package/templates/conference/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
- package/templates/conference/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
- package/templates/conference/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
- package/templates/conference/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/conference/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/conference/tier5-src/himi-events-detail/index.ts +3 -1
- package/templates/conference/tier5-src/himi-events-list/index.ts +38 -8
- package/templates/conference/tier5-src/himi-events-my-events/index.ts +4 -2
- package/templates/conference/tier5-src/wix-spaces-delete-account/index.ts +59 -0
- package/templates/events-meetups/dev/index.ts +20 -0
- package/templates/events-meetups/l10n/ar.json +10 -0
- package/templates/events-meetups/l10n/cs.json +10 -0
- package/templates/events-meetups/l10n/da.json +10 -0
- package/templates/events-meetups/l10n/de.json +10 -0
- package/templates/events-meetups/l10n/el.json +10 -0
- package/templates/events-meetups/l10n/es.json +10 -0
- package/templates/events-meetups/l10n/fi.json +10 -0
- package/templates/events-meetups/l10n/fr.json +10 -0
- package/templates/events-meetups/l10n/he.json +8 -0
- package/templates/events-meetups/l10n/hu.json +10 -0
- package/templates/events-meetups/l10n/id.json +10 -0
- package/templates/events-meetups/l10n/it.json +10 -0
- package/templates/events-meetups/l10n/ja.json +10 -0
- package/templates/events-meetups/l10n/ko.json +10 -0
- package/templates/events-meetups/l10n/lt.json +10 -0
- package/templates/events-meetups/l10n/nl.json +10 -0
- package/templates/events-meetups/l10n/no.json +10 -0
- package/templates/events-meetups/l10n/pl.json +10 -0
- package/templates/events-meetups/l10n/pt.json +10 -0
- package/templates/events-meetups/l10n/ru.json +10 -0
- package/templates/events-meetups/l10n/sv.json +10 -0
- package/templates/events-meetups/l10n/th.json +10 -0
- package/templates/events-meetups/l10n/tr.json +10 -0
- package/templates/events-meetups/l10n/uk.json +10 -0
- package/templates/events-meetups/l10n/vi.json +10 -0
- package/templates/events-meetups/l10n/zh.json +10 -0
- package/templates/events-meetups/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/events-meetups/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/events-meetups/tier5-src/himi-events-detail/index.ts +3 -1
- package/templates/events-meetups/tier5-src/himi-events-list/index.ts +38 -8
- package/templates/events-meetups/tier5-src/himi-events-my-events/index.ts +4 -2
- package/templates/events-meetups-owner/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/events-meetups-owner/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/fitness-gym/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/gym-fitness/dev/index.ts +20 -0
- package/templates/gym-fitness/l10n/ar.json +10 -0
- package/templates/gym-fitness/l10n/cs.json +10 -0
- package/templates/gym-fitness/l10n/da.json +10 -0
- package/templates/gym-fitness/l10n/de.json +10 -0
- package/templates/gym-fitness/l10n/el.json +10 -0
- package/templates/gym-fitness/l10n/es.json +10 -0
- package/templates/gym-fitness/l10n/fi.json +10 -0
- package/templates/gym-fitness/l10n/fr.json +10 -0
- package/templates/gym-fitness/l10n/he.json +8 -0
- package/templates/gym-fitness/l10n/hu.json +10 -0
- package/templates/gym-fitness/l10n/id.json +10 -0
- package/templates/gym-fitness/l10n/it.json +10 -0
- package/templates/gym-fitness/l10n/ja.json +10 -0
- package/templates/gym-fitness/l10n/ko.json +10 -0
- package/templates/gym-fitness/l10n/lt.json +10 -0
- package/templates/gym-fitness/l10n/nl.json +10 -0
- package/templates/gym-fitness/l10n/no.json +10 -0
- package/templates/gym-fitness/l10n/pl.json +10 -0
- package/templates/gym-fitness/l10n/pt.json +10 -0
- package/templates/gym-fitness/l10n/ru.json +10 -0
- package/templates/gym-fitness/l10n/sv.json +10 -0
- package/templates/gym-fitness/l10n/th.json +10 -0
- package/templates/gym-fitness/l10n/tr.json +10 -0
- package/templates/gym-fitness/l10n/uk.json +10 -0
- package/templates/gym-fitness/l10n/vi.json +10 -0
- package/templates/gym-fitness/l10n/zh.json +10 -0
- package/templates/gym-fitness/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/gym-fitness/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/gym-fitness/tier5-src/himi-events-detail/index.ts +3 -1
- package/templates/gym-fitness/tier5-src/himi-events-list/index.ts +38 -8
- package/templates/gym-fitness/tier5-src/himi-events-my-events/index.ts +4 -2
- package/templates/gym-fitness-owner/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/gym-fitness-owner/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/medical-services/config.ts +42 -0
- package/templates/medical-services/dev/index.ts +4136 -0
- package/templates/medical-services/himalaya.content.json +18 -0
- package/templates/medical-services/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
- package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
- package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
- package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
- package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/medical-services/tier5-src/wix-spaces-delete-account/index.ts +59 -0
- package/templates/nonprofit-cause/dev/index.ts +20 -0
- package/templates/nonprofit-cause/l10n/ar.json +10 -0
- package/templates/nonprofit-cause/l10n/cs.json +10 -0
- package/templates/nonprofit-cause/l10n/da.json +10 -0
- package/templates/nonprofit-cause/l10n/de.json +10 -0
- package/templates/nonprofit-cause/l10n/el.json +10 -0
- package/templates/nonprofit-cause/l10n/es.json +10 -0
- package/templates/nonprofit-cause/l10n/fi.json +10 -0
- package/templates/nonprofit-cause/l10n/fr.json +10 -0
- package/templates/nonprofit-cause/l10n/he.json +8 -0
- package/templates/nonprofit-cause/l10n/hu.json +10 -0
- package/templates/nonprofit-cause/l10n/id.json +10 -0
- package/templates/nonprofit-cause/l10n/it.json +10 -0
- package/templates/nonprofit-cause/l10n/ja.json +10 -0
- package/templates/nonprofit-cause/l10n/ko.json +10 -0
- package/templates/nonprofit-cause/l10n/lt.json +10 -0
- package/templates/nonprofit-cause/l10n/nl.json +10 -0
- package/templates/nonprofit-cause/l10n/no.json +10 -0
- package/templates/nonprofit-cause/l10n/pl.json +10 -0
- package/templates/nonprofit-cause/l10n/pt.json +10 -0
- package/templates/nonprofit-cause/l10n/ru.json +10 -0
- package/templates/nonprofit-cause/l10n/sv.json +10 -0
- package/templates/nonprofit-cause/l10n/th.json +10 -0
- package/templates/nonprofit-cause/l10n/tr.json +10 -0
- package/templates/nonprofit-cause/l10n/uk.json +10 -0
- package/templates/nonprofit-cause/l10n/vi.json +10 -0
- package/templates/nonprofit-cause/l10n/zh.json +10 -0
- package/templates/nonprofit-cause/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/nonprofit-cause/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/nonprofit-cause/tier5-src/himi-events-detail/index.ts +3 -1
- package/templates/nonprofit-cause/tier5-src/himi-events-list/index.ts +38 -8
- package/templates/nonprofit-cause/tier5-src/himi-events-my-events/index.ts +4 -2
- package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/nonprofit-cause-owner/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/owner-lite/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/owner-lite/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/personal-fitness-trainer/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/podcast-creator/dev/index.ts +20 -0
- package/templates/podcast-creator/l10n/ar.json +10 -0
- package/templates/podcast-creator/l10n/cs.json +10 -0
- package/templates/podcast-creator/l10n/da.json +10 -0
- package/templates/podcast-creator/l10n/de.json +10 -0
- package/templates/podcast-creator/l10n/el.json +10 -0
- package/templates/podcast-creator/l10n/es.json +10 -0
- package/templates/podcast-creator/l10n/fi.json +10 -0
- package/templates/podcast-creator/l10n/fr.json +10 -0
- package/templates/podcast-creator/l10n/he.json +8 -0
- package/templates/podcast-creator/l10n/hu.json +10 -0
- package/templates/podcast-creator/l10n/id.json +10 -0
- package/templates/podcast-creator/l10n/it.json +10 -0
- package/templates/podcast-creator/l10n/ja.json +10 -0
- package/templates/podcast-creator/l10n/ko.json +10 -0
- package/templates/podcast-creator/l10n/lt.json +10 -0
- package/templates/podcast-creator/l10n/nl.json +10 -0
- package/templates/podcast-creator/l10n/no.json +10 -0
- package/templates/podcast-creator/l10n/pl.json +10 -0
- package/templates/podcast-creator/l10n/pt.json +10 -0
- package/templates/podcast-creator/l10n/ru.json +10 -0
- package/templates/podcast-creator/l10n/sv.json +10 -0
- package/templates/podcast-creator/l10n/th.json +10 -0
- package/templates/podcast-creator/l10n/tr.json +10 -0
- package/templates/podcast-creator/l10n/uk.json +10 -0
- package/templates/podcast-creator/l10n/vi.json +10 -0
- package/templates/podcast-creator/l10n/zh.json +10 -0
- package/templates/podcast-creator/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/podcast-creator/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/podcast-creator/tier5-src/himi-events-detail/index.ts +3 -1
- package/templates/podcast-creator/tier5-src/himi-events-list/index.ts +38 -8
- package/templates/podcast-creator/tier5-src/himi-events-my-events/index.ts +4 -2
- package/templates/podcast-creator-owner/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/podcast-creator-owner/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/portfolio-creative/dev/index.ts +22 -1
- package/templates/portfolio-creative/l10n/ar.json +10 -0
- package/templates/portfolio-creative/l10n/cs.json +10 -0
- package/templates/portfolio-creative/l10n/da.json +10 -0
- package/templates/portfolio-creative/l10n/de.json +10 -0
- package/templates/portfolio-creative/l10n/el.json +10 -0
- package/templates/portfolio-creative/l10n/es.json +10 -0
- package/templates/portfolio-creative/l10n/fi.json +10 -0
- package/templates/portfolio-creative/l10n/fr.json +10 -0
- package/templates/portfolio-creative/l10n/he.json +8 -0
- package/templates/portfolio-creative/l10n/hu.json +10 -0
- package/templates/portfolio-creative/l10n/id.json +10 -0
- package/templates/portfolio-creative/l10n/it.json +10 -0
- package/templates/portfolio-creative/l10n/ja.json +10 -0
- package/templates/portfolio-creative/l10n/ko.json +10 -0
- package/templates/portfolio-creative/l10n/lt.json +10 -0
- package/templates/portfolio-creative/l10n/nl.json +10 -0
- package/templates/portfolio-creative/l10n/no.json +10 -0
- package/templates/portfolio-creative/l10n/pl.json +10 -0
- package/templates/portfolio-creative/l10n/pt.json +10 -0
- package/templates/portfolio-creative/l10n/ru.json +10 -0
- package/templates/portfolio-creative/l10n/sv.json +10 -0
- package/templates/portfolio-creative/l10n/th.json +10 -0
- package/templates/portfolio-creative/l10n/tr.json +10 -0
- package/templates/portfolio-creative/l10n/uk.json +10 -0
- package/templates/portfolio-creative/l10n/vi.json +10 -0
- package/templates/portfolio-creative/l10n/zh.json +10 -0
- package/templates/portfolio-creative/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/portfolio-creative/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/portfolio-creative/tier5-src/_shared/portfolio-details.ts +70 -0
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-portfolio/index.ts +90 -9
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-portfolio-project/index.ts +53 -4
- package/templates/portfolio-creative/tier5-src/himi-events-detail/index.ts +3 -1
- package/templates/portfolio-creative/tier5-src/himi-events-list/index.ts +38 -8
- package/templates/portfolio-creative/tier5-src/himi-events-my-events/index.ts +4 -2
- package/templates/portfolio-creative-owner/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/portfolio-creative-owner/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/professional-services/README.md +55 -0
- package/templates/professional-services/config.ts +436 -0
- package/templates/professional-services/dev/index.ts +44772 -0
- package/templates/professional-services/himalaya.content.json +100 -0
- package/templates/professional-services/himalaya.template.json +16 -0
- package/templates/professional-services/icon.png +0 -0
- package/templates/professional-services/platforms.json +1 -0
- package/templates/professional-services/tier5-src/_shared/app-locale.ts +70 -0
- package/templates/professional-services/tier5-src/_shared/booking-location.ts +147 -0
- package/templates/professional-services/tier5-src/_shared/booking-session.ts +224 -0
- package/templates/professional-services/tier5-src/_shared/branded-lite-hosted.ts +282 -0
- package/templates/professional-services/tier5-src/_shared/branded-load-state.ts +109 -0
- package/templates/professional-services/tier5-src/_shared/business-chat-copy.ts +40 -0
- package/templates/professional-services/tier5-src/_shared/business-chat-history.ts +51 -0
- package/templates/professional-services/tier5-src/_shared/business-chat-message-model.ts +177 -0
- package/templates/professional-services/tier5-src/_shared/business-chat-model.ts +56 -0
- package/templates/professional-services/tier5-src/_shared/business-chat-presenter.ts +587 -0
- package/templates/professional-services/tier5-src/_shared/business-chat-transport.ts +164 -0
- package/templates/professional-services/tier5-src/_shared/chat-live.ts +242 -0
- package/templates/professional-services/tier5-src/_shared/collection-contract.ts +232 -0
- package/templates/professional-services/tier5-src/_shared/collection-query.ts +201 -0
- package/templates/professional-services/tier5-src/_shared/collection-service.ts +429 -0
- package/templates/professional-services/tier5-src/_shared/detail-presence.ts +51 -0
- package/templates/professional-services/tier5-src/_shared/engine-intl.ts +538 -0
- package/templates/professional-services/tier5-src/_shared/event-registration.ts +86 -0
- package/templates/professional-services/tier5-src/_shared/events-inline-options.ts +77 -0
- package/templates/professional-services/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/professional-services/tier5-src/_shared/featured-event.ts +63 -0
- package/templates/professional-services/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/professional-services/tier5-src/_shared/group-privacy.ts +14 -0
- package/templates/professional-services/tier5-src/_shared/guest-sign-in.ts +36 -0
- package/templates/professional-services/tier5-src/_shared/himi-account.ts +222 -0
- package/templates/professional-services/tier5-src/_shared/himi-blog-hidden.ts +66 -0
- package/templates/professional-services/tier5-src/_shared/himi-blog-post-row.ts +214 -0
- package/templates/professional-services/tier5-src/_shared/himi-blog-saved.ts +64 -0
- package/templates/professional-services/tier5-src/_shared/himi-booking-saved.ts +88 -0
- package/templates/professional-services/tier5-src/_shared/himi-bookings.ts +318 -0
- package/templates/professional-services/tier5-src/_shared/himi-copy.ts +123 -0
- package/templates/professional-services/tier5-src/_shared/himi-events.ts +92 -0
- package/templates/professional-services/tier5-src/_shared/himi-media.ts +33 -0
- package/templates/professional-services/tier5-src/_shared/himi-store.ts +7 -0
- package/templates/professional-services/tier5-src/_shared/himi-text.ts +24 -0
- package/templates/professional-services/tier5-src/_shared/host-events.ts +66 -0
- package/templates/professional-services/tier5-src/_shared/hosted-checkout.ts +70 -0
- package/templates/professional-services/tier5-src/_shared/iap-attendance-form.ts +106 -0
- package/templates/professional-services/tier5-src/_shared/iap-attendance-purchase.ts +235 -0
- package/templates/professional-services/tier5-src/_shared/iap-attendance.ts +38 -0
- package/templates/professional-services/tier5-src/_shared/iap-worker.ts +127 -0
- package/templates/professional-services/tier5-src/_shared/inbox-rooms.ts +163 -0
- package/templates/professional-services/tier5-src/_shared/local-preferences.ts +38 -0
- package/templates/professional-services/tier5-src/_shared/member-access.ts +63 -0
- package/templates/professional-services/tier5-src/_shared/member-account-routes.ts +56 -0
- package/templates/professional-services/tier5-src/_shared/member-avatar.ts +76 -0
- package/templates/professional-services/tier5-src/_shared/member-bookings.ts +107 -0
- package/templates/professional-services/tier5-src/_shared/member-read.ts +82 -0
- package/templates/professional-services/tier5-src/_shared/member-screen.ts +99 -0
- package/templates/professional-services/tier5-src/_shared/notification-target.ts +141 -0
- package/templates/professional-services/tier5-src/_shared/offset-page.ts +10 -0
- package/templates/professional-services/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/professional-services/tier5-src/_shared/owner-load-error.ts +348 -0
- package/templates/professional-services/tier5-src/_shared/payment-setup.ts +6 -0
- package/templates/professional-services/tier5-src/_shared/portfolio-details.ts +70 -0
- package/templates/professional-services/tier5-src/_shared/pricing-plan-display.ts +64 -0
- package/templates/professional-services/tier5-src/_shared/relative-time.ts +21 -0
- package/templates/professional-services/tier5-src/_shared/result-snackbar.ts +26 -0
- package/templates/professional-services/tier5-src/_shared/rich-body.ts +78 -0
- package/templates/professional-services/tier5-src/_shared/rich-content-link.ts +34 -0
- package/templates/professional-services/tier5-src/_shared/sign-in-sheet.ts +18 -0
- package/templates/professional-services/tier5-src/_shared/staff-name.ts +18 -0
- package/templates/professional-services/tier5-src/_shared/weekly-goal.ts +111 -0
- package/templates/professional-services/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/professional-services/tier5-src/_shared/wix-member-links.ts +114 -0
- package/templates/professional-services/tier5-src/_shared/wix-service-price.ts +146 -0
- package/templates/professional-services/tier5-src/business-chat/index.ts +797 -0
- package/templates/professional-services/tier5-src/business-contact/index.ts +6 -0
- package/templates/professional-services/tier5-src/himi-blog-feed/index.ts +444 -0
- package/templates/professional-services/tier5-src/himi-blog-post/index.ts +1239 -0
- package/templates/professional-services/tier5-src/himi-booking-account/index.ts +278 -0
- package/templates/professional-services/tier5-src/himi-booking-bookings/index.ts +475 -0
- package/templates/professional-services/tier5-src/himi-booking-service/index.ts +1197 -0
- package/templates/professional-services/tier5-src/himi-booking-services/index.ts +795 -0
- package/templates/professional-services/tier5-src/himi-booking-time/index.ts +1840 -0
- package/templates/professional-services/tier5-src/himi-branded-lite-coupons/index.ts +96 -0
- package/templates/professional-services/tier5-src/himi-branded-lite-faq/index.ts +6 -0
- package/templates/professional-services/tier5-src/himi-branded-lite-file-share/index.ts +12 -0
- package/templates/professional-services/tier5-src/himi-branded-lite-group/index.ts +310 -0
- package/templates/professional-services/tier5-src/himi-branded-lite-group-about/index.ts +240 -0
- package/templates/professional-services/tier5-src/himi-branded-lite-my-groups/index.ts +237 -0
- package/templates/professional-services/tier5-src/himi-branded-lite-notifications/index.ts +263 -0
- package/templates/professional-services/tier5-src/himi-branded-lite-plans/index.ts +498 -0
- package/templates/professional-services/tier5-src/himi-branded-lite-portfolio/index.ts +136 -0
- package/templates/professional-services/tier5-src/himi-branded-lite-portfolio-project/index.ts +198 -0
- package/templates/professional-services/tier5-src/himi-events-detail/index.ts +1306 -0
- package/templates/professional-services/tier5-src/himi-events-list/index.ts +171 -0
- package/templates/professional-services/tier5-src/himi-events-my-events/index.ts +227 -0
- package/templates/professional-services/tier5-src/himi-events-rsvp/index.ts +230 -0
- package/templates/professional-services/tier5-src/himi-professional-services-community/index.ts +318 -0
- package/templates/professional-services/tier5-src/himi-professional-services-home/index.ts +772 -0
- package/templates/professional-services/tier5-src/himi-store-account/index.ts +1514 -0
- package/templates/professional-services/tier5-src/wix-spaces-coupon-detail/index.ts +43 -0
- package/templates/professional-services/tier5-src/wix-spaces-my-subscriptions/index.ts +89 -0
- package/templates/professional-services/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
- package/templates/professional-services/tokens.json +456 -0
- package/templates/restaurant/dev/index.ts +20 -0
- package/templates/restaurant/l10n/ar.json +10 -0
- package/templates/restaurant/l10n/cs.json +10 -0
- package/templates/restaurant/l10n/da.json +10 -0
- package/templates/restaurant/l10n/de.json +10 -0
- package/templates/restaurant/l10n/el.json +10 -0
- package/templates/restaurant/l10n/es.json +10 -0
- package/templates/restaurant/l10n/fi.json +10 -0
- package/templates/restaurant/l10n/fr.json +10 -0
- package/templates/restaurant/l10n/he.json +8 -0
- package/templates/restaurant/l10n/hu.json +10 -0
- package/templates/restaurant/l10n/id.json +10 -0
- package/templates/restaurant/l10n/it.json +10 -0
- package/templates/restaurant/l10n/ja.json +10 -0
- package/templates/restaurant/l10n/ko.json +10 -0
- package/templates/restaurant/l10n/lt.json +10 -0
- package/templates/restaurant/l10n/nl.json +10 -0
- package/templates/restaurant/l10n/no.json +10 -0
- package/templates/restaurant/l10n/pl.json +10 -0
- package/templates/restaurant/l10n/pt.json +10 -0
- package/templates/restaurant/l10n/ru.json +10 -0
- package/templates/restaurant/l10n/sv.json +10 -0
- package/templates/restaurant/l10n/th.json +10 -0
- package/templates/restaurant/l10n/tr.json +10 -0
- package/templates/restaurant/l10n/uk.json +10 -0
- package/templates/restaurant/l10n/vi.json +10 -0
- package/templates/restaurant/l10n/zh.json +10 -0
- package/templates/restaurant/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/restaurant/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/restaurant/tier5-src/himi-events-detail/index.ts +3 -1
- package/templates/restaurant/tier5-src/himi-events-list/index.ts +38 -8
- package/templates/restaurant/tier5-src/himi-events-my-events/index.ts +4 -2
- package/templates/restaurant-owner/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/restaurant-owner/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/retail-store/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/retail-store/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/retail-store-owner/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/retail-store-owner/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/salon-spa/config.ts +42 -0
- package/templates/salon-spa/dev/index.ts +4136 -0
- package/templates/salon-spa/himalaya.content.json +18 -0
- package/templates/salon-spa/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
- package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
- package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
- package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
- package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/salon-spa/tier5-src/wix-spaces-delete-account/index.ts +59 -0
- package/templates/wholesale-store/config.ts +43 -1
- package/templates/wholesale-store/dev/index.ts +4136 -0
- package/templates/wholesale-store/himalaya.content.json +18 -0
- package/templates/wholesale-store/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
- package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
- package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
- package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
- package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/wholesale-store/tier5-src/wix-spaces-delete-account/index.ts +59 -0
- package/templates/yoga-studio/dev/index.ts +20 -0
- package/templates/yoga-studio/l10n/ar.json +10 -0
- package/templates/yoga-studio/l10n/cs.json +10 -0
- package/templates/yoga-studio/l10n/da.json +10 -0
- package/templates/yoga-studio/l10n/de.json +10 -0
- package/templates/yoga-studio/l10n/el.json +10 -0
- package/templates/yoga-studio/l10n/es.json +10 -0
- package/templates/yoga-studio/l10n/fi.json +10 -0
- package/templates/yoga-studio/l10n/fr.json +10 -0
- package/templates/yoga-studio/l10n/he.json +8 -0
- package/templates/yoga-studio/l10n/hu.json +10 -0
- package/templates/yoga-studio/l10n/id.json +10 -0
- package/templates/yoga-studio/l10n/it.json +10 -0
- package/templates/yoga-studio/l10n/ja.json +10 -0
- package/templates/yoga-studio/l10n/ko.json +10 -0
- package/templates/yoga-studio/l10n/lt.json +10 -0
- package/templates/yoga-studio/l10n/nl.json +10 -0
- package/templates/yoga-studio/l10n/no.json +10 -0
- package/templates/yoga-studio/l10n/pl.json +10 -0
- package/templates/yoga-studio/l10n/pt.json +10 -0
- package/templates/yoga-studio/l10n/ru.json +10 -0
- package/templates/yoga-studio/l10n/sv.json +10 -0
- package/templates/yoga-studio/l10n/th.json +10 -0
- package/templates/yoga-studio/l10n/tr.json +10 -0
- package/templates/yoga-studio/l10n/uk.json +10 -0
- package/templates/yoga-studio/l10n/vi.json +10 -0
- package/templates/yoga-studio/l10n/zh.json +10 -0
- package/templates/yoga-studio/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/yoga-studio/tier5-src/_shared/himi-events.ts +27 -0
- package/templates/yoga-studio/tier5-src/himi-events-detail/index.ts +3 -1
- package/templates/yoga-studio/tier5-src/himi-events-list/index.ts +38 -8
- package/templates/yoga-studio/tier5-src/himi-events-my-events/index.ts +4 -2
- package/templates/yoga-studio-owner/tier5-src/_shared/collection-contract.ts +6 -1
- package/templates/yoga-studio-owner/tier5-src/_shared/himi-events.ts +27 -0
|
@@ -0,0 +1,772 @@
|
|
|
1
|
+
// Tier-5 bundle: himi-professional-services-home — the professional-services template's Home.
|
|
2
|
+
//
|
|
3
|
+
// One screen for two people. A visitor asks "what can this firm do for my business, and what is
|
|
4
|
+
// on soon?"; a client asks "what is next for me, and what did the firm say?".
|
|
5
|
+
//
|
|
6
|
+
// Visitor (catalog reads, no sign-in): the services as problem-led rows, the next 2 workshops,
|
|
7
|
+
// the Portfolio projects, the consultants (Bookings staff).
|
|
8
|
+
// Client (their own data, each read on its own): Up next — the next sessions (Wix Bookings) and
|
|
9
|
+
// the workshops registered for IN THIS APP (Wix gives no server list of a member's RSVPs), by
|
|
10
|
+
// date, max 3 — the latest 2 chat messages with the business and its unread count, up to 3 paid
|
|
11
|
+
// services, and the package row (the member's active plan, else the lowest public plan).
|
|
12
|
+
//
|
|
13
|
+
// A section whose read fails collapses (member) or shows a Banner with Retry (catalog); nothing
|
|
14
|
+
// loadable is the ErrorState. Clock values (the greeting, "upcoming", "renews", message times) are
|
|
15
|
+
// computed in `load`, an action the screen's onAppear dispatches, never in the boot state.
|
|
16
|
+
import { defineService, navigate } from "@himalaya/state";
|
|
17
|
+
import { queryBookings, queryServices, type WixService } from "@himalaya/wix-bookings";
|
|
18
|
+
import { queryEvents, type WixEvent } from "@himalaya/wix-events";
|
|
19
|
+
import { listMyPlanOrders, listPublicPlans, type WixPlan } from "@himalaya/wix-pricing-plans";
|
|
20
|
+
import { listCollections, listProjects, portfolioCoverRef, type WixPortfolioProject } from "@himalaya/wix-portfolio";
|
|
21
|
+
import { listMessages } from "@himalaya/wix-ai-site-chat";
|
|
22
|
+
import { wixMediaUrl, WIX_LIST_IMAGE } from "@himalaya/wix-media";
|
|
23
|
+
import { open as openUrl } from "@himalaya/open-url";
|
|
24
|
+
import { presentEditor } from "@himalaya/calendar";
|
|
25
|
+
import { loadMemberProfile } from "../_shared/himi-account.js";
|
|
26
|
+
import { memberAccess, assertMemberAccess, type MemberAccess } from "../_shared/member-access.js";
|
|
27
|
+
import { memberBookingRow, CANCELLED_STATUSES, type MemberBookingRow } from "../_shared/member-bookings.js";
|
|
28
|
+
import { memberScreenOpener } from "../_shared/member-screen.js";
|
|
29
|
+
import { confirmedRsvpIds, normalizeEvent } from "../_shared/himi-events";
|
|
30
|
+
import { chatIdentity, fence, listRooms, messagesPage } from "../_shared/business-chat-transport.js";
|
|
31
|
+
import { selectExistingBusinessRoom } from "../_shared/business-chat-presenter.js";
|
|
32
|
+
import { smartChatHistory } from "../_shared/business-chat-history.js";
|
|
33
|
+
import { normalizeMessages } from "../_shared/business-chat-message-model.js";
|
|
34
|
+
import { serviceDurationText, servicePriceLine, type BookingLabel } from "../_shared/himi-bookings.js";
|
|
35
|
+
import { nameWords } from "../_shared/staff-name.js";
|
|
36
|
+
import { collectionNames, projectCollection, projectDetails } from "../_shared/portfolio-details.js";
|
|
37
|
+
import { formatClock, formatCurrency, formatDateMedium } from "../_shared/engine-intl.js";
|
|
38
|
+
import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
|
|
39
|
+
|
|
40
|
+
export const SERVICE = "himiProfessionalServicesHome";
|
|
41
|
+
const HELP_MAX = 4;
|
|
42
|
+
const BOOK_MAX = 3;
|
|
43
|
+
const WORKSHOPS_MAX = 2;
|
|
44
|
+
const PROJECTS_MAX = 6;
|
|
45
|
+
const UP_NEXT_MAX = 3;
|
|
46
|
+
const MESSAGES_MAX = 2;
|
|
47
|
+
const STAFF_MAX = 4;
|
|
48
|
+
|
|
49
|
+
export interface ServiceRow { id: string; title: string; line: string; image: string; hasImage: boolean; noImage: boolean; a11y: string }
|
|
50
|
+
export interface WorkshopRow { id: string; day: string; month: string; title: string; line: string; pill: string; free: boolean; paid: boolean; a11y: string }
|
|
51
|
+
export interface ProjectRow { id: string; title: string; collection: string; noCollection: boolean; location: string; noLocation: boolean; image: string; hasImage: boolean; noImage: boolean }
|
|
52
|
+
export interface ConsultantRow { id: string; name: string; role: string; noRole: boolean; image: string; hasImage: boolean; noImage: boolean; initials: string; a11y: string }
|
|
53
|
+
export interface UpNextRow {
|
|
54
|
+
id: string; kind: "session" | "workshop"; tag: string; pill: string; isSession: boolean; isWorkshop: boolean;
|
|
55
|
+
title: string; when: string; day: string; month: string; withLine: string; noWithLine: boolean;
|
|
56
|
+
start: string; end: string; place: string; a11y: string;
|
|
57
|
+
}
|
|
58
|
+
export interface MessageRowView { id: string; sender: string; time: string; text: string; unread: boolean; read: boolean }
|
|
59
|
+
|
|
60
|
+
export interface S {
|
|
61
|
+
status: "loading" | "ready" | "error";
|
|
62
|
+
isLoading: boolean; notLoading: boolean; failed: boolean; notFailed: boolean;
|
|
63
|
+
// The member
|
|
64
|
+
isMember: boolean; notMember: boolean;
|
|
65
|
+
greeting: string; memberInitials: string; memberImage: string; hasMemberImage: boolean; noMemberImage: boolean;
|
|
66
|
+
hasUnread: boolean; noUnread: boolean;
|
|
67
|
+
// Catalog (visitor)
|
|
68
|
+
catalogErrored: boolean; catalogOk: boolean;
|
|
69
|
+
helpRows: ServiceRow[]; noHelp: boolean;
|
|
70
|
+
workshops: WorkshopRow[]; noWorkshops: boolean;
|
|
71
|
+
projects: ProjectRow[]; noProjects: boolean;
|
|
72
|
+
consultants: ConsultantRow[]; noConsultants: boolean;
|
|
73
|
+
freeServiceId: string;
|
|
74
|
+
// Up next (client)
|
|
75
|
+
hideUpNext: boolean; hasUpNext: boolean; noUpNext: boolean;
|
|
76
|
+
upFirst: UpNextRow; upRows: UpNextRow[]; noUpRows: boolean;
|
|
77
|
+
bookAgain: string; bookAgainServiceId: string; noBookAgain: boolean;
|
|
78
|
+
// Messages (client)
|
|
79
|
+
messages: MessageRowView[]; noMessageRows: boolean;
|
|
80
|
+
messagesEmpty: boolean; notMessagesEmpty: boolean; messagesErrored: boolean; notMessagesErrored: boolean;
|
|
81
|
+
newCount: string; noNewCount: boolean;
|
|
82
|
+
// Book a service + package row (client)
|
|
83
|
+
bookRows: ServiceRow[]; noBookRows: boolean;
|
|
84
|
+
packageTitle: string; packageLine: string; packageScreen: string; noPackage: boolean;
|
|
85
|
+
/** The outcome line of the last Get in touch link ("" when it opened). */
|
|
86
|
+
linkMessage: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const EMPTY_UP: UpNextRow = {
|
|
90
|
+
id: "", kind: "session", tag: "", pill: "", isSession: true, isWorkshop: false, title: "", when: "", day: "", month: "",
|
|
91
|
+
withLine: "", noWithLine: true, start: "", end: "", place: "", a11y: "",
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const BOOT: S = {
|
|
95
|
+
status: "loading", isLoading: true, notLoading: false, failed: false, notFailed: true,
|
|
96
|
+
isMember: false, notMember: true, greeting: "", memberInitials: "", memberImage: "", hasMemberImage: false, noMemberImage: true,
|
|
97
|
+
hasUnread: false, noUnread: true,
|
|
98
|
+
catalogErrored: false, catalogOk: true,
|
|
99
|
+
helpRows: [], noHelp: true, workshops: [], noWorkshops: true, projects: [], noProjects: true, consultants: [], noConsultants: true,
|
|
100
|
+
freeServiceId: "",
|
|
101
|
+
hideUpNext: true, hasUpNext: false, noUpNext: true, upFirst: EMPTY_UP, upRows: [], noUpRows: true,
|
|
102
|
+
bookAgain: "", bookAgainServiceId: "", noBookAgain: true,
|
|
103
|
+
messages: [], noMessageRows: true, messagesEmpty: false, notMessagesEmpty: true, messagesErrored: false, notMessagesErrored: true,
|
|
104
|
+
newCount: "", noNewCount: true,
|
|
105
|
+
bookRows: [], noBookRows: true, packageTitle: "", packageLine: "", packageScreen: "himi_plans", noPackage: true,
|
|
106
|
+
linkMessage: "",
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// ── Small helpers ────────────────────────────────────────────────────────────
|
|
110
|
+
|
|
111
|
+
const clean = (value: unknown): string => (typeof value === "string" ? value.replace(/\s+/g, " ").trim() : "");
|
|
112
|
+
const label: BookingLabel = (key, fallback, values) =>
|
|
113
|
+
values ? copyTemplate(`session.${key}`, fallback, values) : copyParam(`session.${key}`, fallback);
|
|
114
|
+
|
|
115
|
+
function firstNameOf(name: string): string {
|
|
116
|
+
const { words } = nameWords(clean(name));
|
|
117
|
+
const word = words[0] ?? "";
|
|
118
|
+
return word.includes("@") ? "" : word;
|
|
119
|
+
}
|
|
120
|
+
function initialsOf(name: string): string {
|
|
121
|
+
const { words } = nameWords(clean(name));
|
|
122
|
+
return ((words[0]?.[0] ?? "") + (words.length > 1 ? words[words.length - 1]?.[0] ?? "" : "")).toUpperCase();
|
|
123
|
+
}
|
|
124
|
+
function mediaUrl(raw: unknown): string {
|
|
125
|
+
const media = raw as { image?: { url?: string; id?: string } } | undefined;
|
|
126
|
+
return wixMediaUrl(media?.image?.url || media?.image?.id || "", WIX_LIST_IMAGE);
|
|
127
|
+
}
|
|
128
|
+
function serviceImage(service: WixService | undefined): string {
|
|
129
|
+
const media = (service as { media?: { mainMedia?: unknown; items?: unknown[] } } | undefined)?.media;
|
|
130
|
+
return mediaUrl(media?.mainMedia) || mediaUrl(media?.items?.[0]);
|
|
131
|
+
}
|
|
132
|
+
/** Every slug Wix knows the service by: a rename adds a new main slug and keeps the old one. */
|
|
133
|
+
function slugsOf(service: WixService): string[] {
|
|
134
|
+
const s = service as { mainSlug?: { name?: string }; supportedSlugs?: Array<{ name?: string }>; slug?: string };
|
|
135
|
+
return [s.mainSlug?.name, ...(s.supportedSlugs ?? []).map((x) => x?.name), s.slug].map(clean).filter(Boolean);
|
|
136
|
+
}
|
|
137
|
+
/** The copy-pack problem title for the service ("Deliver projects on time"), "" when the pack has none. */
|
|
138
|
+
function problemTitle(service: WixService): string {
|
|
139
|
+
for (const slug of slugsOf(service)) {
|
|
140
|
+
const title = copyParam(`home.problem.${slug}`, "");
|
|
141
|
+
if (title) return title;
|
|
142
|
+
}
|
|
143
|
+
return "";
|
|
144
|
+
}
|
|
145
|
+
const isFree = (service: WixService) => String((service as { payment?: { rateType?: string } }).payment?.rateType ?? "").toUpperCase() === "NO_FEE";
|
|
146
|
+
const isBookable = (service: WixService) => !(service as { hidden?: boolean }).hidden;
|
|
147
|
+
const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
148
|
+
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
149
|
+
|
|
150
|
+
/** The weekday, day and month of `date` on the device's clock — the time the shared Workshops list,
|
|
151
|
+
* the workshop detail and My bookings show, so one item reads the same on every screen. */
|
|
152
|
+
export function dateParts(date: Date): { weekday: string; day: number; month: string } {
|
|
153
|
+
return { weekday: DAYS[date.getDay()] ?? "", day: date.getDate(), month: MONTHS[date.getMonth()] ?? "" };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function serviceRow(service: WixService, problemFirst: boolean): ServiceRow {
|
|
157
|
+
const name = clean(service.name) || copyParam("home.serviceFallback", "Service");
|
|
158
|
+
const problem = problemFirst ? problemTitle(service) : "";
|
|
159
|
+
const title = problem || name;
|
|
160
|
+
const duration = serviceDurationText(service, label);
|
|
161
|
+
const price = servicePriceLine(service, label).text;
|
|
162
|
+
const parts = [problem ? name : "", duration, price].filter(Boolean);
|
|
163
|
+
const line = parts.join(" · ");
|
|
164
|
+
const image = serviceImage(service);
|
|
165
|
+
return { id: service.id ?? "", title, line, image, hasImage: !!image, noImage: !image, a11y: copyTemplate("home.serviceRowA11y", "{title}. {line}", { title, line }) };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** "Free" for an RSVP workshop, "From $45" for a ticketed one (the lowest ticket price). */
|
|
169
|
+
function workshopPill(event: WixEvent): { pill: string; free: boolean } {
|
|
170
|
+
const raw = event as unknown as { eventType?: string; registration?: { type?: string; initialType?: string; tickets?: { lowestPrice?: { value?: string; currency?: string; formattedValue?: string } } } };
|
|
171
|
+
const type = String(raw.registration?.type ?? raw.eventType ?? raw.registration?.initialType ?? "").toUpperCase();
|
|
172
|
+
if (type === "TICKETING") {
|
|
173
|
+
const low = raw.registration?.tickets?.lowestPrice;
|
|
174
|
+
let price = clean(low?.formattedValue);
|
|
175
|
+
if (!price && low?.value && Number.isFinite(Number(low.value))) {
|
|
176
|
+
try { price = formatCurrency(Number(low.value), low.currency || "USD"); } catch { price = String(low.value); }
|
|
177
|
+
}
|
|
178
|
+
return price ? { pill: copyTemplate("home.fromPill", "From {price}", { price }), free: false } : { pill: "", free: false };
|
|
179
|
+
}
|
|
180
|
+
return type === "RSVP" ? { pill: copyParam("home.freePill", "Free"), free: true } : { pill: "", free: false };
|
|
181
|
+
}
|
|
182
|
+
const eventStart = (event: WixEvent): string => clean((event as unknown as { dateAndTimeSettings?: { startDate?: string } }).dateAndTimeSettings?.startDate);
|
|
183
|
+
const eventEnd = (event: WixEvent): string => clean((event as unknown as { dateAndTimeSettings?: { endDate?: string } }).dateAndTimeSettings?.endDate);
|
|
184
|
+
const eventCity = (event: WixEvent): string => {
|
|
185
|
+
const loc = (event as unknown as { location?: { name?: string; address?: { city?: string } | string } }).location;
|
|
186
|
+
const city = typeof loc?.address === "object" ? clean(loc.address.city) : "";
|
|
187
|
+
return city || clean(loc?.name);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export function workshopRow(event: WixEvent): WorkshopRow {
|
|
191
|
+
const row = normalizeEvent(event);
|
|
192
|
+
const start = new Date(eventStart(event));
|
|
193
|
+
const dated = Number.isFinite(start.getTime());
|
|
194
|
+
const parts = dateParts(start);
|
|
195
|
+
const { pill, free } = workshopPill(event);
|
|
196
|
+
const line = dated
|
|
197
|
+
? copyTemplate("home.workshopLine", "{day} · {time} · {place}", { day: parts.weekday, time: formatClock(start), place: eventCity(event) }).replace(/ · $/, "")
|
|
198
|
+
: row.dateLine;
|
|
199
|
+
return {
|
|
200
|
+
id: event.id, day: dated ? String(parts.day) : row.day, month: dated ? parts.month : row.month,
|
|
201
|
+
title: row.title, line, pill, free, paid: !free && !!pill,
|
|
202
|
+
a11y: copyTemplate("home.workshopRowA11y", "{title}, {when}", { title: row.title, when: line }),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function projectRow(project: WixPortfolioProject, names: Map<string, string>): ProjectRow {
|
|
207
|
+
const title = clean(project.title) || "Project";
|
|
208
|
+
const image = wixMediaUrl(portfolioCoverRef(project.coverImage), WIX_LIST_IMAGE);
|
|
209
|
+
const collection = projectCollection(project, names).name;
|
|
210
|
+
const location = projectDetails(project).location;
|
|
211
|
+
return { id: project.id, title, collection, noCollection: !collection, location, noLocation: !location, image, hasImage: !!image, noImage: !image };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
interface RawStaff { id?: unknown; name?: unknown; description?: unknown; mainMedia?: unknown }
|
|
215
|
+
export function consultantRow(raw: RawStaff): ConsultantRow {
|
|
216
|
+
const name = clean(raw.name);
|
|
217
|
+
const description = clean(raw.description);
|
|
218
|
+
// The staff description is the role ("Founder and Principal"); its first sentence when longer.
|
|
219
|
+
const fromSite = (description.split(/(?<=[.!?])\s/)[0] ?? "").replace(/[.!?]$/, "").slice(0, 60);
|
|
220
|
+
const role = fromSite || copyParam(`home.role.${name}`, "");
|
|
221
|
+
const image = mediaUrl(raw.mainMedia);
|
|
222
|
+
return { id: String(raw.id ?? ""), name, role, noRole: !role, image, hasImage: !!image, noImage: !image, initials: initialsOf(name), a11y: [name, role].filter(Boolean).join(", ") };
|
|
223
|
+
}
|
|
224
|
+
/** Named staff ("Staff Member #1" is Wix's unnamed default), pictured first, in the site's order. */
|
|
225
|
+
export function consultantsOf(staff: RawStaff[]): ConsultantRow[] {
|
|
226
|
+
const rows = staff.map(consultantRow).filter((row) => row.id && row.name && !/^staff member\b/i.test(row.name));
|
|
227
|
+
return [...rows.filter((r) => r.hasImage), ...rows.filter((r) => !r.hasImage)].slice(0, STAFF_MAX);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ── Up next ──────────────────────────────────────────────────────────────────
|
|
231
|
+
|
|
232
|
+
function whenLine(start: Date, end: Date | undefined): string {
|
|
233
|
+
const p = dateParts(start);
|
|
234
|
+
const date = `${p.weekday}, ${p.month} ${p.day}`;
|
|
235
|
+
const time = end && Number.isFinite(end.getTime()) ? `${formatClock(start)}–${formatClock(end)}` : formatClock(start);
|
|
236
|
+
return `${date} · ${time}`;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export function sessionItem(row: MemberBookingRow): UpNextRow {
|
|
240
|
+
const start = new Date(row.start);
|
|
241
|
+
const end = row.end ? new Date(row.end) : undefined;
|
|
242
|
+
const withLine = [row.staff ? copyTemplate("home.withStaff", "with {staff}", { staff: row.staff }) : "", row.placeName].filter(Boolean).join(" · ");
|
|
243
|
+
const when = whenLine(start, end);
|
|
244
|
+
const parts = dateParts(start);
|
|
245
|
+
return {
|
|
246
|
+
id: row.id, kind: "session", tag: copyParam("home.sessionTag", "SESSION"), pill: copyParam("home.sessionPill", "Session"), isSession: true, isWorkshop: false,
|
|
247
|
+
title: row.title, when, day: String(parts.day), month: parts.month, withLine, noWithLine: !withLine,
|
|
248
|
+
start: row.start, end: row.end ?? "", place: row.placeAddress || row.placeName, a11y: [row.title, when, withLine].filter(Boolean).join(", "),
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
export function workshopItem(event: WixEvent): UpNextRow {
|
|
252
|
+
const startIso = eventStart(event);
|
|
253
|
+
const start = new Date(startIso);
|
|
254
|
+
const endIso = eventEnd(event);
|
|
255
|
+
const end = endIso ? new Date(endIso) : undefined;
|
|
256
|
+
const title = clean(event.title) || normalizeEvent(event).title;
|
|
257
|
+
const place = eventCity(event);
|
|
258
|
+
const when = whenLine(start, end);
|
|
259
|
+
const parts = dateParts(start);
|
|
260
|
+
return {
|
|
261
|
+
id: event.id, kind: "workshop", tag: copyParam("home.workshopTag", "WORKSHOP"), pill: copyParam("home.workshopPill", "Workshop"), isSession: false, isWorkshop: true,
|
|
262
|
+
title, when, day: String(parts.day), month: parts.month, withLine: place, noWithLine: !place,
|
|
263
|
+
start: startIso, end: endIso, place, a11y: [title, when, place].filter(Boolean).join(", "),
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/** Sessions and workshops in one list, the soonest first, still ahead of `nowMs`, max 3. */
|
|
267
|
+
export function mergeUpNext(sessions: UpNextRow[], workshops: UpNextRow[], nowMs: number): UpNextRow[] {
|
|
268
|
+
return [...sessions, ...workshops]
|
|
269
|
+
.filter((row) => Date.parse(row.start) > nowMs)
|
|
270
|
+
.sort((a, b) => Date.parse(a.start) - Date.parse(b.start))
|
|
271
|
+
.slice(0, UP_NEXT_MAX);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// ── Messages ─────────────────────────────────────────────────────────────────
|
|
275
|
+
|
|
276
|
+
/** "N new" — never "0 new", nothing when the count is unknown. */
|
|
277
|
+
export function newCountLabel(count: number | undefined): string {
|
|
278
|
+
if (typeof count !== "number" || !Number.isFinite(count) || count <= 0) return "";
|
|
279
|
+
return copyTemplate("home.newCount", "{n} new", { n: Math.min(99, Math.floor(count)) });
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** The latest messages, newest first: sender ("You" for the member), time, 2-line text, and an
|
|
283
|
+
* unread dot on the newest `unread` messages from the business. `participantId` is the member's own
|
|
284
|
+
* participant in the room, as the Chat screen reads it (`presentBusinessMessages`): a message whose
|
|
285
|
+
* sender `userId` is that participant is the member's. Raw messages are matched by id, not by index,
|
|
286
|
+
* because `normalizeMessages` merges and orders them. */
|
|
287
|
+
export function messageViews(raw: unknown[], unread: number, participantId = ""): MessageRowView[] {
|
|
288
|
+
const rows = normalizeMessages(raw);
|
|
289
|
+
type RawMessage = { id?: unknown; aiSiteChatSender?: unknown; sender?: { userId?: unknown } };
|
|
290
|
+
const rawById = new Map((raw as RawMessage[]).map((m) => [String(m?.id ?? ""), m]));
|
|
291
|
+
const isMine = (row: (typeof rows)[number]): boolean => {
|
|
292
|
+
const m = rawById.get(row.id);
|
|
293
|
+
if (m?.aiSiteChatSender === "SITE_VISITOR") return true;
|
|
294
|
+
if (participantId && typeof m?.sender?.userId === "string") return m.sender.userId === participantId;
|
|
295
|
+
return row.mine;
|
|
296
|
+
};
|
|
297
|
+
const sorted = rows
|
|
298
|
+
.map((row) => ({ row, mine: isMine(row) }))
|
|
299
|
+
.filter(({ row }) => clean(row.plainText) || row.parts.some((p) => p.fileName))
|
|
300
|
+
.sort((a, b) => Date.parse(b.row.createdDate) - Date.parse(a.row.createdDate))
|
|
301
|
+
.slice(0, MESSAGES_MAX);
|
|
302
|
+
let dots = Math.max(0, unread);
|
|
303
|
+
return sorted.map(({ row, mine }) => {
|
|
304
|
+
const file = row.parts.find((p) => p.fileName)?.fileName ?? "";
|
|
305
|
+
const text = clean(row.plainText) || (file ? copyTemplate("home.attachment", "Attachment: {name}", { name: file }) : "");
|
|
306
|
+
const unreadHere = !mine && dots > 0;
|
|
307
|
+
if (unreadHere) dots--;
|
|
308
|
+
const date = new Date(row.createdDate);
|
|
309
|
+
return {
|
|
310
|
+
id: row.id,
|
|
311
|
+
sender: mine ? copyParam("home.you", "You") : clean(row.sender) || copyParam("home.businessName", "James Consulting"),
|
|
312
|
+
time: Number.isFinite(date.getTime()) ? formatClock(date) : "",
|
|
313
|
+
text, unread: unreadHere, read: !unreadHere,
|
|
314
|
+
};
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// ── Reads ────────────────────────────────────────────────────────────────────
|
|
319
|
+
|
|
320
|
+
function wixApi(): { call(method: string, path: string, body?: unknown): Promise<unknown> } | undefined {
|
|
321
|
+
return (globalThis as { himalaya?: { wixApi?: { call(method: string, path: string, body?: unknown): Promise<unknown> } } }).himalaya?.wixApi;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
interface Catalog {
|
|
325
|
+
services: WixService[];
|
|
326
|
+
workshops: WixEvent[];
|
|
327
|
+
projects: ProjectRow[];
|
|
328
|
+
consultants: ConsultantRow[];
|
|
329
|
+
plans: WixPlan[];
|
|
330
|
+
/** Which of the visitor reads failed (each collapses its own section, Home keeps the rest). */
|
|
331
|
+
failed: { services: boolean; workshops: boolean; projects: boolean; consultants: boolean };
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
async function readCatalog(nowMs: number): Promise<Catalog> {
|
|
335
|
+
const nowIso = new Date(nowMs).toISOString();
|
|
336
|
+
const api = wixApi();
|
|
337
|
+
const [services, workshops, projects, consultants, plans] = await Promise.all([
|
|
338
|
+
// The Services tab's order (the site's Book Online order), so Home lists the services alike.
|
|
339
|
+
queryServices({ query: { filter: { hidden: { $ne: true } }, paging: { limit: 100 }, sort: [{ fieldName: "category.sortOrder", order: "ASC" }, { fieldName: "sortOrder", order: "ASC" }, { fieldName: "id", order: "ASC" }] } }).then((r) => ({ ok: true, list: (r.services ?? []).filter((s) => s.id && isBookable(s)) })).catch(() => ({ ok: false, list: [] as WixService[] })),
|
|
340
|
+
queryEvents({ limit: 20, fields: ["DETAILS", "REGISTRATION"], query: { filter: { status: { $in: ["UPCOMING", "STARTED"] }, "dateAndTimeSettings.startDate": { $gte: nowIso } }, sort: [{ fieldName: "dateAndTimeSettings.startDate", order: "ASC" }] } })
|
|
341
|
+
.then((r) => ({ ok: true, list: (r.events ?? []).filter((e) => e.id && Date.parse(eventStart(e)) > nowMs) })).catch(() => ({ ok: false, list: [] as WixEvent[] })),
|
|
342
|
+
Promise.all([listProjects(50), listCollections(100).then((r) => r.collections ?? []).catch(() => [])])
|
|
343
|
+
.then(([r, collections]) => {
|
|
344
|
+
const names = collectionNames(collections);
|
|
345
|
+
// Newest first: the owner's latest case study leads the rail.
|
|
346
|
+
const list = (r.projects ?? []).filter((p) => p.id && p.hidden !== true)
|
|
347
|
+
.sort((a, b) => Date.parse(b.createdDate ?? "") - Date.parse(a.createdDate ?? ""))
|
|
348
|
+
.slice(0, PROJECTS_MAX).map((p) => projectRow(p, names));
|
|
349
|
+
return { ok: true, list };
|
|
350
|
+
}).catch(() => ({ ok: false, list: [] as ProjectRow[] })),
|
|
351
|
+
api
|
|
352
|
+
? api.call("POST", "/bookings/v1/staff-members/query", { query: { cursorPaging: { limit: 100 } } })
|
|
353
|
+
.then((r) => ({ ok: true, list: consultantsOf(((r as { staffMembers?: RawStaff[] } | null)?.staffMembers) ?? []) })).catch(() => ({ ok: false, list: [] as ConsultantRow[] }))
|
|
354
|
+
: Promise.resolve({ ok: false, list: [] as ConsultantRow[] }),
|
|
355
|
+
listPublicPlans().then((r) => (r.plans ?? []).filter((p) => p.id)).catch(() => [] as WixPlan[]),
|
|
356
|
+
]);
|
|
357
|
+
return {
|
|
358
|
+
services: services.list, workshops: workshops.list, projects: projects.list, consultants: consultants.list, plans,
|
|
359
|
+
failed: { services: !services.ok, workshops: !workshops.ok, projects: !projects.ok, consultants: !consultants.ok },
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
interface MemberPart {
|
|
364
|
+
isMember: boolean; firstName: string; initials: string; image: string;
|
|
365
|
+
sessions: UpNextRow[]; sessionsFailed: boolean;
|
|
366
|
+
workshops: UpNextRow[];
|
|
367
|
+
lastServiceId: string; lastServiceName: string;
|
|
368
|
+
hasPastBooking: boolean;
|
|
369
|
+
messages: MessageRowView[]; messagesFailed: boolean; unread: number | undefined;
|
|
370
|
+
planName: string; planEnd: string;
|
|
371
|
+
}
|
|
372
|
+
const GUEST: MemberPart = {
|
|
373
|
+
isMember: false, firstName: "", initials: "", image: "", sessions: [], sessionsFailed: false, workshops: [],
|
|
374
|
+
lastServiceId: "", lastServiceName: "", hasPastBooking: false, messages: [], messagesFailed: false, unread: undefined, planName: "", planEnd: "",
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
async function readMessages(): Promise<{ ok: boolean; messages: MessageRowView[]; unread: number | undefined }> {
|
|
378
|
+
const identity = await chatIdentity();
|
|
379
|
+
if (!identity.authenticated) return { ok: true, messages: [], unread: undefined };
|
|
380
|
+
const rooms = await listRooms(identity);
|
|
381
|
+
const room = selectExistingBusinessRoom(rooms.items, copyParam("home.businessName", "James Consulting"));
|
|
382
|
+
const raw = room ? (rooms.items as Array<Record<string, unknown>>).find((r) => r.id === room.id) : undefined;
|
|
383
|
+
const unread = typeof raw?.unreadCount === "number" ? raw.unreadCount : room ? 0 : undefined;
|
|
384
|
+
// As the Chat screen does: the Smart Chat transcript when there is one, else the Members room.
|
|
385
|
+
const [memberPage, aiPage] = await Promise.all([
|
|
386
|
+
room ? messagesPage(identity, room.id).catch(() => [] as unknown[]) : Promise.resolve([] as unknown[]),
|
|
387
|
+
fence(identity, () => listMessages({ cursorPaging: { limit: 100 } })).then((r) => (Array.isArray(r?.messages) ? r.messages : [])).catch(() => [] as unknown[]),
|
|
388
|
+
]);
|
|
389
|
+
// The member's participant in the room, as the Chat screen uses it; Smart Chat rows carry the visitor's.
|
|
390
|
+
const participantId = room?.participantId || "smart-chat:visitor";
|
|
391
|
+
const smart = smartChatHistory(aiPage, memberPage, participantId);
|
|
392
|
+
const page = smart?.messages ?? memberPage;
|
|
393
|
+
return { ok: true, messages: messageViews(page, unread ?? 0, participantId), unread };
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** The RSVP statuses that hold a seat (the event detail screen reads the same three). */
|
|
397
|
+
const HELD_RSVP = new Set(["YES", "WAITLIST", "WAITING"]);
|
|
398
|
+
|
|
399
|
+
/** The device's RSVP list holds event ids with no member attached, so another member who signed in
|
|
400
|
+
* on this device left theirs there too. A workshop reaches Up next only once THIS member's RSVP is
|
|
401
|
+
* read back, as My workshops does (`himi-events-my-events` confirmRsvps): the single-event read is
|
|
402
|
+
* the member-readable one. A failed read hides the row; Up next never shows an unconfirmed RSVP. */
|
|
403
|
+
export async function heldRsvps(events: WixEvent[]): Promise<WixEvent[]> {
|
|
404
|
+
const api = wixApi();
|
|
405
|
+
if (!api) return [];
|
|
406
|
+
const held = await Promise.all(events.map(async (event) => {
|
|
407
|
+
try {
|
|
408
|
+
const res = await api.call("GET", `/events/v2/rsvps/current?eventId=${encodeURIComponent(event.id ?? "")}`);
|
|
409
|
+
const rsvps = (res as { rsvps?: Array<{ status?: string }> }).rsvps ?? [];
|
|
410
|
+
// An allowlist, as the event detail screen reads it: "NO" (declined) and any status Wix adds later hold nothing.
|
|
411
|
+
return rsvps.some((r) => HELD_RSVP.has((r.status ?? "").toUpperCase()));
|
|
412
|
+
} catch {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
}));
|
|
416
|
+
return events.filter((_, i) => held[i]);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
async function readMember(nowMs: number): Promise<MemberPart> {
|
|
420
|
+
let member: MemberAccess;
|
|
421
|
+
try { member = await memberAccess(); } catch { return GUEST; }
|
|
422
|
+
if (!member.email) return GUEST;
|
|
423
|
+
const nowIso = new Date(nowMs).toISOString();
|
|
424
|
+
const mine = (b: { contactDetails?: { email?: string } }) => b.contactDetails?.email?.trim().toLowerCase() === member.email;
|
|
425
|
+
const rsvpIds = confirmedRsvpIds();
|
|
426
|
+
const [profile, upcoming, past, workshops, messages, plan] = await Promise.all([
|
|
427
|
+
loadMemberProfile("").catch(() => undefined),
|
|
428
|
+
queryBookings({ query: {
|
|
429
|
+
filter: { "contactDetails.email": { $eq: member.email }, startDate: { $gte: nowIso }, status: { $in: ["CONFIRMED"] } },
|
|
430
|
+
sort: [{ fieldName: "startDate", order: "ASC" }], paging: { limit: 10 },
|
|
431
|
+
} }).then((r) => ({ ok: true as const, rows: (r.bookings ?? []).filter((b) => b.id && mine(b)).map(memberBookingRow) }))
|
|
432
|
+
.catch(() => ({ ok: false as const, rows: [] as MemberBookingRow[] })),
|
|
433
|
+
queryBookings({ query: {
|
|
434
|
+
filter: { "contactDetails.email": { $eq: member.email }, startDate: { $lt: nowIso }, status: { $nin: CANCELLED_STATUSES } },
|
|
435
|
+
sort: [{ fieldName: "startDate", order: "DESC" }], paging: { limit: 1 },
|
|
436
|
+
} }).then((r) => (r.bookings ?? []).filter((b) => b.id && mine(b)).map(memberBookingRow)[0]).catch(() => undefined),
|
|
437
|
+
rsvpIds.length
|
|
438
|
+
? queryEvents({ limit: 50, fields: ["DETAILS"], query: { filter: { id: { $in: rsvpIds } } } })
|
|
439
|
+
.then((r) => heldRsvps((r.events ?? []).filter((e) => e.id && rsvpIds.includes(e.id) && Date.parse(eventStart(e)) > nowMs))).catch(() => [] as WixEvent[])
|
|
440
|
+
: Promise.resolve([] as WixEvent[]),
|
|
441
|
+
readMessages().catch(() => ({ ok: false, messages: [] as MessageRowView[], unread: undefined })),
|
|
442
|
+
listMyPlanOrders({ statuses: ["ACTIVE"], limit: 10 }).then((r) => {
|
|
443
|
+
const order = (r.orders ?? []).find((o) => o.status === "ACTIVE");
|
|
444
|
+
return { name: clean(order?.planName), end: order?.endDate ?? "" };
|
|
445
|
+
}).catch(() => ({ name: "", end: "" })),
|
|
446
|
+
]);
|
|
447
|
+
// The account must still be the one the reads were made for: a sign-out during them answers as a visitor.
|
|
448
|
+
try { await assertMemberAccess(member); } catch { return GUEST; }
|
|
449
|
+
const name = profile?.isMember ? profile.memberName : "";
|
|
450
|
+
return {
|
|
451
|
+
isMember: true,
|
|
452
|
+
firstName: firstNameOf(name),
|
|
453
|
+
initials: profile?.isMember ? profile.memberInitials : "",
|
|
454
|
+
image: profile?.isMember ? profile.memberImage : "",
|
|
455
|
+
sessions: upcoming.rows.map(sessionItem), sessionsFailed: !upcoming.ok,
|
|
456
|
+
workshops: workshops.map(workshopItem),
|
|
457
|
+
lastServiceId: past?.serviceId ?? "", lastServiceName: past?.title ?? "", hasPastBooking: !!past,
|
|
458
|
+
messages: messages.messages, messagesFailed: !messages.ok, unread: messages.unread,
|
|
459
|
+
planName: plan.name, planEnd: plan.end,
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// ── Derivation ───────────────────────────────────────────────────────────────
|
|
464
|
+
|
|
465
|
+
function planPrice(plan: WixPlan): string {
|
|
466
|
+
const price = plan.pricing?.price;
|
|
467
|
+
const value = Number(price?.value);
|
|
468
|
+
if (price?.value == null || !Number.isFinite(value)) return "";
|
|
469
|
+
// A whole amount without cents ("$290", the brief's package line); cents only when the price has them.
|
|
470
|
+
try { return price.currency ? formatCurrency(value, price.currency, undefined, Number.isInteger(value) ? 0 : undefined) : String(price.value); } catch { return String(price.value); }
|
|
471
|
+
}
|
|
472
|
+
const isMonthly = (plan: WixPlan) => String(plan.pricing?.subscription?.cycleDuration?.unit ?? "").toUpperCase().startsWith("MONTH") && Number(plan.pricing?.subscription?.cycleDuration?.count ?? 0) === 1;
|
|
473
|
+
|
|
474
|
+
export function greetingFor(firstName: string, hour: number): string {
|
|
475
|
+
if (!firstName) return copyParam("home.greetingFallback", "Welcome back");
|
|
476
|
+
const key = hour < 12 ? "home.greetingMorning" : hour < 18 ? "home.greetingAfternoon" : "home.greetingEvening";
|
|
477
|
+
const fallback = hour < 12 ? "Good morning, {name}" : hour < 18 ? "Good afternoon, {name}" : "Good evening, {name}";
|
|
478
|
+
return copyTemplate(key, fallback, { name: firstName });
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
let last: { member: MemberPart; catalog: Catalog; nowMs: number } | undefined;
|
|
482
|
+
|
|
483
|
+
function derive(base: S): S {
|
|
484
|
+
if (!last) return base;
|
|
485
|
+
const { member, catalog, nowMs } = last;
|
|
486
|
+
const isMember = member.isMember;
|
|
487
|
+
const now = new Date(nowMs);
|
|
488
|
+
|
|
489
|
+
// Catalog
|
|
490
|
+
const withProblem = catalog.services.filter((s) => problemTitle(s));
|
|
491
|
+
const helpRows = (withProblem.length ? withProblem : catalog.services).slice(0, HELP_MAX).map((s) => serviceRow(s, true));
|
|
492
|
+
// A client: paid services first; the free call only for a client who never booked.
|
|
493
|
+
const bookable = catalog.services.filter((s) => !isFree(s) || !member.hasPastBooking);
|
|
494
|
+
const bookRows = [...bookable.filter((s) => !isFree(s)), ...bookable.filter(isFree)].slice(0, BOOK_MAX).map((s) => serviceRow(s, true));
|
|
495
|
+
const freeService = catalog.services.find((s) => isFree(s) && slugsOf(s).some((slug) => slug.startsWith("free-consultation"))) ?? catalog.services.find(isFree);
|
|
496
|
+
const workshops = catalog.workshops.slice(0, WORKSHOPS_MAX).map(workshopRow);
|
|
497
|
+
const catalogErrored = catalog.failed.services || catalog.failed.workshops || catalog.failed.projects || catalog.failed.consultants;
|
|
498
|
+
const allFailed = catalog.failed.services && catalog.failed.workshops && catalog.failed.projects && catalog.failed.consultants && !isMember;
|
|
499
|
+
|
|
500
|
+
// Up next
|
|
501
|
+
const items = mergeUpNext(member.sessions, member.workshops, nowMs);
|
|
502
|
+
const [first, ...rest] = items;
|
|
503
|
+
|
|
504
|
+
// Package row
|
|
505
|
+
const offer = [...catalog.plans].sort((a, b) => Number(a.pricing?.price?.value ?? Infinity) - Number(b.pricing?.price?.value ?? Infinity))[0];
|
|
506
|
+
const planEnd = member.planEnd ? new Date(member.planEnd) : undefined;
|
|
507
|
+
const ownPackage = isMember && !!member.planName;
|
|
508
|
+
const offerPrice = offer ? planPrice(offer) : "";
|
|
509
|
+
|
|
510
|
+
const unread = member.unread;
|
|
511
|
+
const status: S["status"] = allFailed ? "error" : "ready";
|
|
512
|
+
return {
|
|
513
|
+
...base,
|
|
514
|
+
status, isLoading: false, notLoading: true, failed: status === "error", notFailed: status !== "error",
|
|
515
|
+
isMember, notMember: !isMember,
|
|
516
|
+
greeting: isMember ? greetingFor(member.firstName, now.getHours()) : "",
|
|
517
|
+
memberInitials: member.initials, memberImage: member.image, hasMemberImage: !!member.image, noMemberImage: !member.image,
|
|
518
|
+
hasUnread: isMember && typeof unread === "number" && unread > 0, noUnread: !(isMember && typeof unread === "number" && unread > 0),
|
|
519
|
+
catalogErrored, catalogOk: !catalogErrored,
|
|
520
|
+
helpRows, noHelp: helpRows.length === 0,
|
|
521
|
+
workshops, noWorkshops: workshops.length === 0,
|
|
522
|
+
projects: catalog.projects, noProjects: catalog.projects.length === 0,
|
|
523
|
+
consultants: catalog.consultants, noConsultants: catalog.consultants.length === 0,
|
|
524
|
+
freeServiceId: freeService?.id ?? "",
|
|
525
|
+
hideUpNext: !isMember || member.sessionsFailed,
|
|
526
|
+
hasUpNext: !!first, noUpNext: !first,
|
|
527
|
+
upFirst: first ?? EMPTY_UP, upRows: rest, noUpRows: rest.length === 0,
|
|
528
|
+
bookAgain: member.lastServiceName ? copyTemplate("home.bookAgain", "Book again: {service}", { service: member.lastServiceName }) : "",
|
|
529
|
+
bookAgainServiceId: member.lastServiceId, noBookAgain: !member.lastServiceId || !member.lastServiceName,
|
|
530
|
+
messages: member.messages, noMessageRows: member.messages.length === 0,
|
|
531
|
+
messagesEmpty: !member.messagesFailed && member.messages.length === 0, notMessagesEmpty: member.messagesFailed || member.messages.length > 0,
|
|
532
|
+
messagesErrored: member.messagesFailed, notMessagesErrored: !member.messagesFailed,
|
|
533
|
+
newCount: newCountLabel(unread), noNewCount: !newCountLabel(unread),
|
|
534
|
+
bookRows, noBookRows: bookRows.length === 0,
|
|
535
|
+
packageTitle: ownPackage ? copyTemplate("home.packageName", "Your package: {name}", { name: member.planName }) : copyParam("home.packagesTitle", "Consulting packages"),
|
|
536
|
+
packageLine: ownPackage
|
|
537
|
+
? (planEnd && Number.isFinite(planEnd.getTime()) ? copyTemplate("home.packageRenews", "Renews {date}", { date: formatDateMedium(planEnd) }) : copyParam("home.packageActive", "Active"))
|
|
538
|
+
: offerPrice ? (offer && isMonthly(offer) ? copyTemplate("home.packagesFrom", "Ongoing support from {price} a month", { price: offerPrice }) : copyTemplate("home.packagesFromOnce", "Ongoing support from {price}", { price: offerPrice })) : "",
|
|
539
|
+
packageScreen: ownPackage ? "himi_my_subscriptions" : "himi_plans",
|
|
540
|
+
noPackage: !ownPackage && !offer,
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// ── Load ─────────────────────────────────────────────────────────────────────
|
|
545
|
+
|
|
546
|
+
let loadSeq = 0;
|
|
547
|
+
let latest: S = BOOT;
|
|
548
|
+
const commit = (next: S): S => (latest = next);
|
|
549
|
+
const now = (): S => (svc.getState?.() as S | undefined) ?? latest;
|
|
550
|
+
const openMemberScreen = memberScreenOpener();
|
|
551
|
+
const strArg = (arg: unknown, key: string): string => {
|
|
552
|
+
const v = (arg as Record<string, unknown> | undefined)?.[key];
|
|
553
|
+
return typeof v === "string" ? v : "";
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
/** Who the member data on screen belongs to (`[email, scope]`, "" for a visitor). */
|
|
557
|
+
let shownIdentity = "";
|
|
558
|
+
const identityOf = (m: MemberAccess | undefined): string => (m?.email ? JSON.stringify([m.email, m.scope]) : "");
|
|
559
|
+
|
|
560
|
+
// The screen's copy for a load that runs before its onAppear (a restarted tab worker): the last
|
|
561
|
+
// onAppear's copy params, kept on the device. Copy only, never member data.
|
|
562
|
+
const COPY_KEY = "himiPsHome.loadCopy";
|
|
563
|
+
const COPY_PARAMS = ["copy", "textCopy", "locale", "businessTimeZone"] as const;
|
|
564
|
+
interface StorageLike { getItem(key: string): string | null; setItem(key: string, value: string): void }
|
|
565
|
+
function storage(): StorageLike | undefined {
|
|
566
|
+
const host = globalThis as unknown as { himalaya?: { storage?: StorageLike }; localStorage?: StorageLike };
|
|
567
|
+
return host.himalaya?.storage ?? host.localStorage;
|
|
568
|
+
}
|
|
569
|
+
/** The copy params of a load's arg as one string ("" when it carries none). */
|
|
570
|
+
function copyKeyOf(arg: unknown): string {
|
|
571
|
+
if (!arg || typeof arg !== "object") return "";
|
|
572
|
+
const picked: Record<string, unknown> = {};
|
|
573
|
+
for (const key of COPY_PARAMS) if (key in arg) picked[key] = (arg as Record<string, unknown>)[key];
|
|
574
|
+
return Object.keys(picked).length ? JSON.stringify(picked) : "";
|
|
575
|
+
}
|
|
576
|
+
function saveCopy(key: string): void {
|
|
577
|
+
try { if (key && storage()?.getItem(COPY_KEY) !== key) storage()?.setItem(COPY_KEY, key); } catch { /* best-effort: a start load uses fallbacks */ }
|
|
578
|
+
}
|
|
579
|
+
function savedCopy(): Record<string, unknown> | undefined {
|
|
580
|
+
// A device-local copy cache, not a read of the site: unreadable means no saved copy, and the
|
|
581
|
+
// screen's onAppear loads as on a first launch.
|
|
582
|
+
let parsed: unknown = null;
|
|
583
|
+
try { parsed = JSON.parse(storage()?.getItem(COPY_KEY) ?? "null"); } catch { /* corrupt cache: no saved copy */ }
|
|
584
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed as Record<string, unknown> : undefined;
|
|
585
|
+
}
|
|
586
|
+
/** The load the worker started at boot, which the screen's first onAppear joins when its copy is the same. */
|
|
587
|
+
let startup: { copyKey: string; done: Promise<S>; seq: number; settledAt?: number } | undefined;
|
|
588
|
+
/** How long after it ends a start load still counts as this visit's read. A later onAppear reads again. */
|
|
589
|
+
const STARTUP_JOIN_MS = 5_000;
|
|
590
|
+
|
|
591
|
+
async function load(s: S): Promise<S> {
|
|
592
|
+
const mine = ++loadSeq;
|
|
593
|
+
const nowMs = Date.now();
|
|
594
|
+
// Another member (or a sign-out) since the last read: the old member's data leaves the screen
|
|
595
|
+
// BEFORE the new reads, never after them.
|
|
596
|
+
const who = await memberAccess().catch(() => undefined);
|
|
597
|
+
if (shownIdentity && identityOf(who) !== shownIdentity) {
|
|
598
|
+
shownIdentity = "";
|
|
599
|
+
await svc.clearMember();
|
|
600
|
+
s = now();
|
|
601
|
+
}
|
|
602
|
+
const [member, catalog] = await Promise.all([readMember(nowMs), readCatalog(nowMs)]);
|
|
603
|
+
if (mine !== loadSeq) return now();
|
|
604
|
+
shownIdentity = member.isMember ? identityOf(who) : "";
|
|
605
|
+
last = { member, catalog, nowMs };
|
|
606
|
+
return derive(s);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/** A call, an email or a map: only these schemes leave the app, and a map only to a maps host. */
|
|
610
|
+
export function allowedLink(raw: string): string {
|
|
611
|
+
const url = raw.trim();
|
|
612
|
+
if (/^(tel|mailto):[^\s]+$/i.test(url)) return url;
|
|
613
|
+
// No `URL`: a bare iOS JSContext (the worker engine floor) has none.
|
|
614
|
+
const match = /^https:\/\/([^/?#:@\s\\]+)(?::\d+)?([/?#]\S*)?$/i.exec(url);
|
|
615
|
+
if (!match) return "";
|
|
616
|
+
const host = match[1].toLowerCase();
|
|
617
|
+
const path = match[2] ?? "";
|
|
618
|
+
if (host === "maps.apple.com" || host === "maps.google.com" || host === "maps.app.goo.gl") return url;
|
|
619
|
+
if ((host === "www.google.com" || host === "google.com") && /^\/maps(?:[/?#]|$)/i.test(path)) return url;
|
|
620
|
+
return "";
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/** The state keys that come from the member, dropped from a persisted snapshot. */
|
|
624
|
+
export const MEMBER_KEYS: Array<keyof S> = [
|
|
625
|
+
"linkMessage",
|
|
626
|
+
"isMember", "notMember", "greeting", "memberImage", "memberInitials", "hasMemberImage", "noMemberImage", "hasUnread", "noUnread",
|
|
627
|
+
"hideUpNext", "hasUpNext", "noUpNext", "upFirst", "upRows", "noUpRows", "bookAgain", "bookAgainServiceId", "noBookAgain",
|
|
628
|
+
"messages", "noMessageRows", "messagesEmpty", "notMessagesEmpty", "messagesErrored", "notMessagesErrored", "newCount", "noNewCount",
|
|
629
|
+
"bookRows", "noBookRows", "packageTitle", "packageLine", "packageScreen", "noPackage",
|
|
630
|
+
];
|
|
631
|
+
|
|
632
|
+
const svc = defineService<S, {
|
|
633
|
+
openLink: (s: S, arg?: unknown) => Promise<S | undefined>;
|
|
634
|
+
startLoad: (s: S) => S | Promise<S>;
|
|
635
|
+
load: (s: S, arg?: unknown) => Promise<S>;
|
|
636
|
+
refresh: (s: S, arg?: unknown) => Promise<S>;
|
|
637
|
+
startRetry: (s: S) => S;
|
|
638
|
+
clearMember: (s: S) => S;
|
|
639
|
+
openTab: (s: S, arg?: unknown) => S;
|
|
640
|
+
openService: (s: S, arg?: unknown) => S;
|
|
641
|
+
openFreeConsultation: (s: S) => S;
|
|
642
|
+
openWorkshop: (s: S, arg?: unknown) => S;
|
|
643
|
+
openProject: (s: S, arg?: unknown) => S;
|
|
644
|
+
openUpNext: (s: S, arg?: unknown) => S;
|
|
645
|
+
openBookAgain: (s: S) => S;
|
|
646
|
+
openPackage: (s: S) => S;
|
|
647
|
+
addToCalendar: (s: S) => Promise<S | undefined>;
|
|
648
|
+
openForMember: (s: S, arg?: unknown) => Promise<S>;
|
|
649
|
+
}>(SERVICE, {
|
|
650
|
+
// Member data is this run's: a cold start never shows another member. Every key `derive` takes
|
|
651
|
+
// from the member is in both lists: `notHydrated` stops the restore, `notPersisted` keeps it off
|
|
652
|
+
// the device. A snapshot boots as a visitor until `load` reads the member again.
|
|
653
|
+
notHydrated: MEMBER_KEYS,
|
|
654
|
+
notPersisted: MEMBER_KEYS,
|
|
655
|
+
state: BOOT,
|
|
656
|
+
actions: {
|
|
657
|
+
openLink: async (_s, arg) => {
|
|
658
|
+
stashCopy(arg);
|
|
659
|
+
const url = allowedLink(strArg(arg, "url"));
|
|
660
|
+
let opened = false;
|
|
661
|
+
if (url) { try { opened = (await openUrl(url)).opened === true; } catch { opened = false; } }
|
|
662
|
+
const current = now();
|
|
663
|
+
const linkMessage = opened ? "" : copyParam("home.linkFailed", "This link could not be opened.");
|
|
664
|
+
return current.linkMessage === linkMessage ? undefined : commit({ ...current, linkMessage });
|
|
665
|
+
},
|
|
666
|
+
// The boot's own load (below): only with an earlier onAppear's copy, which it reads with.
|
|
667
|
+
startLoad: (s) => {
|
|
668
|
+
const saved = savedCopy();
|
|
669
|
+
if (!saved) return s;
|
|
670
|
+
stashCopy(saved);
|
|
671
|
+
const done = load(s).then(commit);
|
|
672
|
+
// `load` takes its loadSeq before its first await, so this is the start load's own number.
|
|
673
|
+
const entry: NonNullable<typeof startup> = { copyKey: copyKeyOf(saved), done, seq: loadSeq };
|
|
674
|
+
startup = entry;
|
|
675
|
+
void done.then(() => { entry.settledAt = Date.now(); }, () => { if (startup === entry) startup = undefined; });
|
|
676
|
+
return done;
|
|
677
|
+
},
|
|
678
|
+
load: async (s, arg) => {
|
|
679
|
+
const copyKey = copyKeyOf(arg);
|
|
680
|
+
const entry = startup;
|
|
681
|
+
startup = undefined;
|
|
682
|
+
// The screen's first onAppear after a start load with the same copy: that load's reads are this
|
|
683
|
+
// one's, so wait for them instead of reading everything again (H-54). Only while they are still
|
|
684
|
+
// the newest (no refresh or other load began after them) and the member is still the one they
|
|
685
|
+
// read (no sign-in, sign-out or switch since); otherwise read again.
|
|
686
|
+
const fresh = entry && (entry.settledAt === undefined || Date.now() - entry.settledAt < STARTUP_JOIN_MS);
|
|
687
|
+
if (entry && fresh && copyKey && copyKey === entry.copyKey) {
|
|
688
|
+
const result = await entry.done.catch(() => undefined);
|
|
689
|
+
if (result) {
|
|
690
|
+
const who = await memberAccess().catch(() => undefined);
|
|
691
|
+
if (loadSeq === entry.seq && identityOf(who) === shownIdentity) return latest;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
stashCopy(arg);
|
|
695
|
+
saveCopy(copyKey);
|
|
696
|
+
return load(now()).then(commit);
|
|
697
|
+
},
|
|
698
|
+
// Retry and pull to refresh: the loading state shows before the reads start.
|
|
699
|
+
refresh: async (s, arg) => {
|
|
700
|
+
stashCopy(arg);
|
|
701
|
+
if (s.status === "error") await svc.startRetry();
|
|
702
|
+
return load(now()).then(commit);
|
|
703
|
+
},
|
|
704
|
+
startRetry: (s) => commit({ ...s, status: "loading", isLoading: true, notLoading: false, failed: false, notFailed: true }),
|
|
705
|
+
// Publishes the visitor's member fields (BOOT's) while the next member's reads run.
|
|
706
|
+
clearMember: (s) => {
|
|
707
|
+
if (last) last = { ...last, member: GUEST };
|
|
708
|
+
const reset = { ...s } as Record<string, unknown>;
|
|
709
|
+
for (const key of MEMBER_KEYS) if (key !== "linkMessage") reset[key] = BOOT[key];
|
|
710
|
+
return commit(last ? derive(reset as unknown as S) : (reset as unknown as S));
|
|
711
|
+
},
|
|
712
|
+
// A tab from a tap on Home ("View all"): a tab switch, never a push.
|
|
713
|
+
openTab: (s, arg) => {
|
|
714
|
+
const tab = strArg(arg, "tab");
|
|
715
|
+
return tab ? navigate(s, { tab }) : s;
|
|
716
|
+
},
|
|
717
|
+
openService: (s, arg) => {
|
|
718
|
+
const id = strArg(arg, "id");
|
|
719
|
+
return id ? navigate(s, { screenId: "himi_service", args: { id } }) : s;
|
|
720
|
+
},
|
|
721
|
+
// The hero CTA: the Free Consultation service; the time screen asks a visitor to sign in.
|
|
722
|
+
openFreeConsultation: (s) => (s.freeServiceId ? navigate(s, { screenId: "himi_service", args: { id: s.freeServiceId } }) : navigate(s, { tab: "services" })),
|
|
723
|
+
openWorkshop: (s, arg) => {
|
|
724
|
+
const id = strArg(arg, "id");
|
|
725
|
+
return id ? navigate(s, { screenId: "himi_event", args: { id } }) : s;
|
|
726
|
+
},
|
|
727
|
+
openProject: (s, arg) => {
|
|
728
|
+
const id = strArg(arg, "id");
|
|
729
|
+
return id ? navigate(s, { screenId: "himi_portfolio_project", args: { id } }) : s;
|
|
730
|
+
},
|
|
731
|
+
// An Up next item: a session opens My bookings (its details sheet), a workshop its detail.
|
|
732
|
+
openUpNext: (s, arg) => {
|
|
733
|
+
const id = strArg(arg, "id") || s.upFirst.id;
|
|
734
|
+
const item = [s.upFirst, ...s.upRows].find((row) => row.id === id);
|
|
735
|
+
if (!item?.id) return s;
|
|
736
|
+
return item.kind === "workshop" ? navigate(s, { screenId: "himi_event", args: { id: item.id } }) : navigate(s, { screenId: "himi_bookings" });
|
|
737
|
+
},
|
|
738
|
+
openBookAgain: (s) => (s.bookAgainServiceId ? navigate(s, { screenId: "himi_service", args: { id: s.bookAgainServiceId } }) : s),
|
|
739
|
+
openPackage: (s) => navigate(s, { screenId: s.packageScreen || "himi_plans" }),
|
|
740
|
+
// "Add to calendar" on the first Up next item: the system editor (no calendar permission).
|
|
741
|
+
addToCalendar: async () => {
|
|
742
|
+
const item = now().upFirst;
|
|
743
|
+
const start = Date.parse(item.start);
|
|
744
|
+
if (!item.id || !Number.isFinite(start)) return undefined;
|
|
745
|
+
const end = Date.parse(item.end);
|
|
746
|
+
try {
|
|
747
|
+
await presentEditor({ title: item.title, start, end: Number.isFinite(end) ? end : start + 60 * 60_000, ...(item.place ? { location: item.place } : {}) });
|
|
748
|
+
} catch { /* the editor is best-effort */ }
|
|
749
|
+
return undefined;
|
|
750
|
+
},
|
|
751
|
+
// A member screen (the chat, My bookings, Coupons): a member goes there; a visitor gets the
|
|
752
|
+
// sign-in sheet first (_shared/member-screen.ts), and the screen opens once signed in.
|
|
753
|
+
openForMember: async (_s, arg) => {
|
|
754
|
+
const nav = await openMemberScreen(arg);
|
|
755
|
+
return nav ? navigate(now(), nav) : now();
|
|
756
|
+
},
|
|
757
|
+
},
|
|
758
|
+
});
|
|
759
|
+
// An older iOS or Android runtime ignores both lists and restores the whole snapshot, so put the
|
|
760
|
+
// member keys back to BOOT before any action runs. In place, because on those runtimes
|
|
761
|
+
// getState() IS the stored state.
|
|
762
|
+
if ((globalThis as { himalaya?: { hydrationOptOut?: unknown } }).himalaya?.hydrationOptOut !== true) {
|
|
763
|
+
const live = (svc as { getState?: () => S | undefined }).getState?.();
|
|
764
|
+
if (live && typeof live === "object") for (const key of MEMBER_KEYS) (live as unknown as Record<string, unknown>)[key] = BOOT[key];
|
|
765
|
+
}
|
|
766
|
+
// Load on start when an earlier onAppear left its copy here. iOS starts a new worker for a tab root
|
|
767
|
+
// when you come back to its tab, without a new onAppear, and the member keys above boot as a
|
|
768
|
+
// visitor: with no load, a signed-in client stayed on the visitor Home. The load uses that copy, so
|
|
769
|
+
// the problem-led titles stay. A first launch has no saved copy and waits for its onAppear, and an
|
|
770
|
+
// onAppear with the same copy joins this load instead of reading again.
|
|
771
|
+
if (savedCopy()) void svc.startLoad();
|
|
772
|
+
export { svc };
|