@wix/himalaya-cli 0.1858.0 → 0.1860.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/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{b2b76cc19f21f7c6d8b1a3cd6aa1ac0f194b052fa183761d08bd4f43fd46f844.bin → a60c092217d4c21970ff66e8b63221007e49d0792eb9d5fe66238f8efbce884a.bin} +1 -1
- package/dist/browser-plane/sw.js +7 -7
- package/dist/cli.mjs +633 -335
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/one-app-to-himi-app.md +2 -1
- package/guides/testing-himi-apps.md +4 -5
- package/package.json +2 -2
- package/templates/bare-fashion/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/beauty-salon/l10n/ar.json +0 -5
- package/templates/beauty-salon/l10n/cs.json +0 -5
- package/templates/beauty-salon/l10n/da.json +0 -5
- package/templates/beauty-salon/l10n/de.json +0 -5
- package/templates/beauty-salon/l10n/el.json +0 -5
- package/templates/beauty-salon/l10n/en.json +1 -6
- package/templates/beauty-salon/l10n/es.json +0 -5
- package/templates/beauty-salon/l10n/fi.json +0 -5
- package/templates/beauty-salon/l10n/fr.json +0 -5
- package/templates/beauty-salon/l10n/he.json +0 -5
- package/templates/beauty-salon/l10n/hu.json +0 -5
- package/templates/beauty-salon/l10n/id.json +0 -5
- package/templates/beauty-salon/l10n/it.json +0 -5
- package/templates/beauty-salon/l10n/ja.json +0 -5
- package/templates/beauty-salon/l10n/ko.json +0 -5
- package/templates/beauty-salon/l10n/lt.json +0 -5
- package/templates/beauty-salon/l10n/nl.json +0 -5
- package/templates/beauty-salon/l10n/no.json +0 -5
- package/templates/beauty-salon/l10n/pl.json +0 -5
- package/templates/beauty-salon/l10n/pt.json +0 -5
- package/templates/beauty-salon/l10n/ru.json +0 -5
- package/templates/beauty-salon/l10n/sv.json +0 -5
- package/templates/beauty-salon/l10n/th.json +0 -5
- package/templates/beauty-salon/l10n/tr.json +0 -5
- package/templates/beauty-salon/l10n/uk.json +0 -5
- package/templates/beauty-salon/l10n/vi.json +0 -5
- package/templates/beauty-salon/l10n/zh.json +0 -5
- package/templates/beauty-salon/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/beauty-salon-owner/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/branded-lite/dev/index.ts +3148 -2899
- package/templates/branded-lite/l10n/ar.json +181 -87
- package/templates/branded-lite/l10n/cs.json +181 -87
- package/templates/branded-lite/l10n/da.json +181 -87
- package/templates/branded-lite/l10n/de.json +181 -87
- package/templates/branded-lite/l10n/el.json +181 -87
- package/templates/branded-lite/l10n/en.json +105 -37
- package/templates/branded-lite/l10n/es.json +181 -87
- package/templates/branded-lite/l10n/fi.json +181 -87
- package/templates/branded-lite/l10n/fr.json +181 -87
- package/templates/branded-lite/l10n/he.json +150 -77
- package/templates/branded-lite/l10n/hu.json +181 -87
- package/templates/branded-lite/l10n/id.json +181 -87
- package/templates/branded-lite/l10n/it.json +181 -87
- package/templates/branded-lite/l10n/ja.json +181 -87
- package/templates/branded-lite/l10n/ko.json +181 -87
- package/templates/branded-lite/l10n/lt.json +181 -87
- package/templates/branded-lite/l10n/nl.json +181 -87
- package/templates/branded-lite/l10n/no.json +181 -87
- package/templates/branded-lite/l10n/pl.json +181 -87
- package/templates/branded-lite/l10n/pt.json +181 -87
- package/templates/branded-lite/l10n/ru.json +181 -87
- package/templates/branded-lite/l10n/sv.json +181 -87
- package/templates/branded-lite/l10n/th.json +181 -87
- package/templates/branded-lite/l10n/tr.json +181 -87
- package/templates/branded-lite/l10n/uk.json +181 -87
- package/templates/branded-lite/l10n/vi.json +181 -87
- package/templates/branded-lite/l10n/zh.json +181 -87
- package/templates/branded-lite/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/branded-lite/tier5-src/_shared/loyalty-offerings.ts +23 -5
- package/templates/branded-lite/tier5-src/_shared/loyalty-status-section.ts +1 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-loyalty/index.ts +280 -99
- package/templates/branded-lite/tier5-src/himi-branded-lite-loyalty-rewards/index.ts +158 -43
- package/templates/brandy/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/community-club/l10n/ar.json +0 -5
- package/templates/community-club/l10n/cs.json +0 -5
- package/templates/community-club/l10n/da.json +0 -5
- package/templates/community-club/l10n/de.json +0 -5
- package/templates/community-club/l10n/el.json +0 -5
- package/templates/community-club/l10n/en.json +1 -6
- package/templates/community-club/l10n/es.json +0 -5
- package/templates/community-club/l10n/fi.json +0 -5
- package/templates/community-club/l10n/fr.json +0 -5
- package/templates/community-club/l10n/he.json +0 -5
- package/templates/community-club/l10n/hu.json +0 -5
- package/templates/community-club/l10n/id.json +0 -5
- package/templates/community-club/l10n/it.json +0 -5
- package/templates/community-club/l10n/ja.json +0 -5
- package/templates/community-club/l10n/ko.json +0 -5
- package/templates/community-club/l10n/lt.json +0 -5
- package/templates/community-club/l10n/nl.json +0 -5
- package/templates/community-club/l10n/no.json +0 -5
- package/templates/community-club/l10n/pl.json +0 -5
- package/templates/community-club/l10n/pt.json +0 -5
- package/templates/community-club/l10n/ru.json +0 -5
- package/templates/community-club/l10n/sv.json +0 -5
- package/templates/community-club/l10n/th.json +0 -5
- package/templates/community-club/l10n/tr.json +0 -5
- package/templates/community-club/l10n/uk.json +0 -5
- package/templates/community-club/l10n/vi.json +0 -5
- package/templates/community-club/l10n/zh.json +0 -5
- package/templates/community-club/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/community-club-owner/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/conference/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/events-meetups/l10n/ar.json +0 -5
- package/templates/events-meetups/l10n/cs.json +0 -5
- package/templates/events-meetups/l10n/da.json +0 -5
- package/templates/events-meetups/l10n/de.json +0 -5
- package/templates/events-meetups/l10n/el.json +0 -5
- package/templates/events-meetups/l10n/en.json +1 -6
- package/templates/events-meetups/l10n/es.json +0 -5
- package/templates/events-meetups/l10n/fi.json +0 -5
- package/templates/events-meetups/l10n/fr.json +0 -5
- package/templates/events-meetups/l10n/he.json +0 -5
- package/templates/events-meetups/l10n/hu.json +0 -5
- package/templates/events-meetups/l10n/id.json +0 -5
- package/templates/events-meetups/l10n/it.json +0 -5
- package/templates/events-meetups/l10n/ja.json +0 -5
- package/templates/events-meetups/l10n/ko.json +0 -5
- package/templates/events-meetups/l10n/lt.json +0 -5
- package/templates/events-meetups/l10n/nl.json +0 -5
- package/templates/events-meetups/l10n/no.json +0 -5
- package/templates/events-meetups/l10n/pl.json +0 -5
- package/templates/events-meetups/l10n/pt.json +0 -5
- package/templates/events-meetups/l10n/ru.json +0 -5
- package/templates/events-meetups/l10n/sv.json +0 -5
- package/templates/events-meetups/l10n/th.json +0 -5
- package/templates/events-meetups/l10n/tr.json +0 -5
- package/templates/events-meetups/l10n/uk.json +0 -5
- package/templates/events-meetups/l10n/vi.json +0 -5
- package/templates/events-meetups/l10n/zh.json +0 -5
- package/templates/events-meetups/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/events-meetups-owner/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/fitness-gym/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/gym-fitness/l10n/ar.json +0 -5
- package/templates/gym-fitness/l10n/cs.json +0 -5
- package/templates/gym-fitness/l10n/da.json +0 -5
- package/templates/gym-fitness/l10n/de.json +0 -5
- package/templates/gym-fitness/l10n/el.json +0 -5
- package/templates/gym-fitness/l10n/en.json +1 -6
- package/templates/gym-fitness/l10n/es.json +0 -5
- package/templates/gym-fitness/l10n/fi.json +0 -5
- package/templates/gym-fitness/l10n/fr.json +0 -5
- package/templates/gym-fitness/l10n/he.json +0 -5
- package/templates/gym-fitness/l10n/hu.json +0 -5
- package/templates/gym-fitness/l10n/id.json +0 -5
- package/templates/gym-fitness/l10n/it.json +0 -5
- package/templates/gym-fitness/l10n/ja.json +0 -5
- package/templates/gym-fitness/l10n/ko.json +0 -5
- package/templates/gym-fitness/l10n/lt.json +0 -5
- package/templates/gym-fitness/l10n/nl.json +0 -5
- package/templates/gym-fitness/l10n/no.json +0 -5
- package/templates/gym-fitness/l10n/pl.json +0 -5
- package/templates/gym-fitness/l10n/pt.json +0 -5
- package/templates/gym-fitness/l10n/ru.json +0 -5
- package/templates/gym-fitness/l10n/sv.json +0 -5
- package/templates/gym-fitness/l10n/th.json +0 -5
- package/templates/gym-fitness/l10n/tr.json +0 -5
- package/templates/gym-fitness/l10n/uk.json +0 -5
- package/templates/gym-fitness/l10n/vi.json +0 -5
- package/templates/gym-fitness/l10n/zh.json +0 -5
- package/templates/gym-fitness/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/gym-fitness-owner/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/medical-services/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/nonprofit-cause/l10n/ar.json +0 -5
- package/templates/nonprofit-cause/l10n/cs.json +0 -5
- package/templates/nonprofit-cause/l10n/da.json +0 -5
- package/templates/nonprofit-cause/l10n/de.json +0 -5
- package/templates/nonprofit-cause/l10n/el.json +0 -5
- package/templates/nonprofit-cause/l10n/en.json +1 -6
- package/templates/nonprofit-cause/l10n/es.json +0 -5
- package/templates/nonprofit-cause/l10n/fi.json +0 -5
- package/templates/nonprofit-cause/l10n/fr.json +0 -5
- package/templates/nonprofit-cause/l10n/he.json +0 -5
- package/templates/nonprofit-cause/l10n/hu.json +0 -5
- package/templates/nonprofit-cause/l10n/id.json +0 -5
- package/templates/nonprofit-cause/l10n/it.json +0 -5
- package/templates/nonprofit-cause/l10n/ja.json +0 -5
- package/templates/nonprofit-cause/l10n/ko.json +0 -5
- package/templates/nonprofit-cause/l10n/lt.json +0 -5
- package/templates/nonprofit-cause/l10n/nl.json +0 -5
- package/templates/nonprofit-cause/l10n/no.json +0 -5
- package/templates/nonprofit-cause/l10n/pl.json +0 -5
- package/templates/nonprofit-cause/l10n/pt.json +0 -5
- package/templates/nonprofit-cause/l10n/ru.json +0 -5
- package/templates/nonprofit-cause/l10n/sv.json +0 -5
- package/templates/nonprofit-cause/l10n/th.json +0 -5
- package/templates/nonprofit-cause/l10n/tr.json +0 -5
- package/templates/nonprofit-cause/l10n/uk.json +0 -5
- package/templates/nonprofit-cause/l10n/vi.json +0 -5
- package/templates/nonprofit-cause/l10n/zh.json +0 -5
- package/templates/nonprofit-cause/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/owner-lite/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/personal-fitness-trainer/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/podcast-creator/l10n/ar.json +0 -5
- package/templates/podcast-creator/l10n/cs.json +0 -5
- package/templates/podcast-creator/l10n/da.json +0 -5
- package/templates/podcast-creator/l10n/de.json +0 -5
- package/templates/podcast-creator/l10n/el.json +0 -5
- package/templates/podcast-creator/l10n/en.json +1 -6
- package/templates/podcast-creator/l10n/es.json +0 -5
- package/templates/podcast-creator/l10n/fi.json +0 -5
- package/templates/podcast-creator/l10n/fr.json +0 -5
- package/templates/podcast-creator/l10n/he.json +0 -5
- package/templates/podcast-creator/l10n/hu.json +0 -5
- package/templates/podcast-creator/l10n/id.json +0 -5
- package/templates/podcast-creator/l10n/it.json +0 -5
- package/templates/podcast-creator/l10n/ja.json +0 -5
- package/templates/podcast-creator/l10n/ko.json +0 -5
- package/templates/podcast-creator/l10n/lt.json +0 -5
- package/templates/podcast-creator/l10n/nl.json +0 -5
- package/templates/podcast-creator/l10n/no.json +0 -5
- package/templates/podcast-creator/l10n/pl.json +0 -5
- package/templates/podcast-creator/l10n/pt.json +0 -5
- package/templates/podcast-creator/l10n/ru.json +0 -5
- package/templates/podcast-creator/l10n/sv.json +0 -5
- package/templates/podcast-creator/l10n/th.json +0 -5
- package/templates/podcast-creator/l10n/tr.json +0 -5
- package/templates/podcast-creator/l10n/uk.json +0 -5
- package/templates/podcast-creator/l10n/vi.json +0 -5
- package/templates/podcast-creator/l10n/zh.json +0 -5
- package/templates/podcast-creator/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/podcast-creator-owner/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/portfolio-creative/l10n/ar.json +0 -5
- package/templates/portfolio-creative/l10n/cs.json +0 -5
- package/templates/portfolio-creative/l10n/da.json +0 -5
- package/templates/portfolio-creative/l10n/de.json +0 -5
- package/templates/portfolio-creative/l10n/el.json +0 -5
- package/templates/portfolio-creative/l10n/en.json +1 -6
- package/templates/portfolio-creative/l10n/es.json +0 -5
- package/templates/portfolio-creative/l10n/fi.json +0 -5
- package/templates/portfolio-creative/l10n/fr.json +0 -5
- package/templates/portfolio-creative/l10n/he.json +0 -5
- package/templates/portfolio-creative/l10n/hu.json +0 -5
- package/templates/portfolio-creative/l10n/id.json +0 -5
- package/templates/portfolio-creative/l10n/it.json +0 -5
- package/templates/portfolio-creative/l10n/ja.json +0 -5
- package/templates/portfolio-creative/l10n/ko.json +0 -5
- package/templates/portfolio-creative/l10n/lt.json +0 -5
- package/templates/portfolio-creative/l10n/nl.json +0 -5
- package/templates/portfolio-creative/l10n/no.json +0 -5
- package/templates/portfolio-creative/l10n/pl.json +0 -5
- package/templates/portfolio-creative/l10n/pt.json +0 -5
- package/templates/portfolio-creative/l10n/ru.json +0 -5
- package/templates/portfolio-creative/l10n/sv.json +0 -5
- package/templates/portfolio-creative/l10n/th.json +0 -5
- package/templates/portfolio-creative/l10n/tr.json +0 -5
- package/templates/portfolio-creative/l10n/uk.json +0 -5
- package/templates/portfolio-creative/l10n/vi.json +0 -5
- package/templates/portfolio-creative/l10n/zh.json +0 -5
- package/templates/portfolio-creative/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/portfolio-creative-owner/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/restaurant/l10n/ar.json +0 -5
- package/templates/restaurant/l10n/cs.json +0 -5
- package/templates/restaurant/l10n/da.json +0 -5
- package/templates/restaurant/l10n/de.json +0 -5
- package/templates/restaurant/l10n/el.json +0 -5
- package/templates/restaurant/l10n/en.json +1 -6
- package/templates/restaurant/l10n/es.json +0 -5
- package/templates/restaurant/l10n/fi.json +0 -5
- package/templates/restaurant/l10n/fr.json +0 -5
- package/templates/restaurant/l10n/he.json +0 -5
- package/templates/restaurant/l10n/hu.json +0 -5
- package/templates/restaurant/l10n/id.json +0 -5
- package/templates/restaurant/l10n/it.json +0 -5
- package/templates/restaurant/l10n/ja.json +0 -5
- package/templates/restaurant/l10n/ko.json +0 -5
- package/templates/restaurant/l10n/lt.json +0 -5
- package/templates/restaurant/l10n/nl.json +0 -5
- package/templates/restaurant/l10n/no.json +0 -5
- package/templates/restaurant/l10n/pl.json +0 -5
- package/templates/restaurant/l10n/pt.json +0 -5
- package/templates/restaurant/l10n/ru.json +0 -5
- package/templates/restaurant/l10n/sv.json +0 -5
- package/templates/restaurant/l10n/th.json +0 -5
- package/templates/restaurant/l10n/tr.json +0 -5
- package/templates/restaurant/l10n/uk.json +0 -5
- package/templates/restaurant/l10n/vi.json +0 -5
- package/templates/restaurant/l10n/zh.json +0 -5
- package/templates/restaurant/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/restaurant-owner/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/retail-store/l10n/ar.json +0 -5
- package/templates/retail-store/l10n/cs.json +0 -5
- package/templates/retail-store/l10n/da.json +0 -5
- package/templates/retail-store/l10n/de.json +0 -5
- package/templates/retail-store/l10n/el.json +0 -5
- package/templates/retail-store/l10n/en.json +1 -6
- package/templates/retail-store/l10n/es.json +0 -5
- package/templates/retail-store/l10n/fi.json +0 -5
- package/templates/retail-store/l10n/fr.json +0 -5
- package/templates/retail-store/l10n/he.json +0 -5
- package/templates/retail-store/l10n/hu.json +0 -5
- package/templates/retail-store/l10n/id.json +0 -5
- package/templates/retail-store/l10n/it.json +0 -5
- package/templates/retail-store/l10n/ja.json +0 -5
- package/templates/retail-store/l10n/ko.json +0 -5
- package/templates/retail-store/l10n/lt.json +0 -5
- package/templates/retail-store/l10n/nl.json +0 -5
- package/templates/retail-store/l10n/no.json +0 -5
- package/templates/retail-store/l10n/pl.json +0 -5
- package/templates/retail-store/l10n/pt.json +0 -5
- package/templates/retail-store/l10n/ru.json +0 -5
- package/templates/retail-store/l10n/sv.json +0 -5
- package/templates/retail-store/l10n/th.json +0 -5
- package/templates/retail-store/l10n/tr.json +0 -5
- package/templates/retail-store/l10n/uk.json +0 -5
- package/templates/retail-store/l10n/vi.json +0 -5
- package/templates/retail-store/l10n/zh.json +0 -5
- package/templates/retail-store/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/retail-store-owner/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/salon-spa/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/wholesale-store/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/yoga-studio/l10n/ar.json +0 -5
- package/templates/yoga-studio/l10n/cs.json +0 -5
- package/templates/yoga-studio/l10n/da.json +0 -5
- package/templates/yoga-studio/l10n/de.json +0 -5
- package/templates/yoga-studio/l10n/el.json +0 -5
- package/templates/yoga-studio/l10n/en.json +1 -6
- package/templates/yoga-studio/l10n/es.json +0 -5
- package/templates/yoga-studio/l10n/fi.json +0 -5
- package/templates/yoga-studio/l10n/fr.json +0 -5
- package/templates/yoga-studio/l10n/he.json +0 -5
- package/templates/yoga-studio/l10n/hu.json +0 -5
- package/templates/yoga-studio/l10n/id.json +0 -5
- package/templates/yoga-studio/l10n/it.json +0 -5
- package/templates/yoga-studio/l10n/ja.json +0 -5
- package/templates/yoga-studio/l10n/ko.json +0 -5
- package/templates/yoga-studio/l10n/lt.json +0 -5
- package/templates/yoga-studio/l10n/nl.json +0 -5
- package/templates/yoga-studio/l10n/no.json +0 -5
- package/templates/yoga-studio/l10n/pl.json +0 -5
- package/templates/yoga-studio/l10n/pt.json +0 -5
- package/templates/yoga-studio/l10n/ru.json +0 -5
- package/templates/yoga-studio/l10n/sv.json +0 -5
- package/templates/yoga-studio/l10n/th.json +0 -5
- package/templates/yoga-studio/l10n/tr.json +0 -5
- package/templates/yoga-studio/l10n/uk.json +0 -5
- package/templates/yoga-studio/l10n/vi.json +0 -5
- package/templates/yoga-studio/l10n/zh.json +0 -5
- package/templates/yoga-studio/tier5-src/_shared/collection-contract.ts +0 -1
- package/templates/yoga-studio-owner/tier5-src/_shared/collection-contract.ts +0 -1
|
@@ -1,30 +1,59 @@
|
|
|
1
1
|
// Member rewards use their own service, so a public offering can never hydrate a
|
|
2
2
|
// balance or coupon. All private state is online-only, and every completion checks
|
|
3
3
|
// the principal and business. Navigation parameters provide an ID, never a price.
|
|
4
|
+
//
|
|
5
|
+
// Redesign phase 1 (revision 2): a card for each coupon (with "Copy") and for each reward;
|
|
6
|
+
// "Copy" writes the RAW code to the system clipboard (@himalaya/clipboard — the descriptor
|
|
7
|
+
// declares `clipboard`; the pattern of wix-spaces-coupon-detail `copyCode`), says "Copied" on
|
|
8
|
+
// the card and shows a "Code copied" toast. A redemption keeps its sheet open and turns it into
|
|
9
|
+
// "Coupon ready" with the code, its Copy and Done.
|
|
4
10
|
import { defineService, navigate } from "@himalaya/state";
|
|
5
|
-
import {
|
|
6
|
-
|
|
11
|
+
import { writeText } from "@himalaya/clipboard";
|
|
12
|
+
import { getLoyaltyProgram, listLoyaltyRewards, getCurrentMemberLoyaltyAccount, getLoyaltyTiersProgram, listMyLoyaltyCoupons, listMyReferralRewards, redeemMyLoyaltyReward,
|
|
13
|
+
type WixLoyaltyReward, type WixLoyaltyAccount, type WixLoyaltyCoupon, type WixLoyaltyProgram, type WixLoyaltyTiersProgram, type WixReferralReward } from "@himalaya/wix-loyalty";
|
|
7
14
|
import { memberAccess, assertMemberAccess, type MemberAccess } from "../_shared/member-access.js";
|
|
8
15
|
import { withOnlineWrites } from "../_shared/online-actions.js";
|
|
9
16
|
import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
|
|
10
|
-
import { offeringRewardLabel, memberRewardCost, pointLabel } from "../_shared/loyalty-offerings.js";
|
|
17
|
+
import { offeringRewardLabel, memberRewardCost, pointLabel, currentTierName } from "../_shared/loyalty-offerings.js";
|
|
18
|
+
import { formatNumber } from "../_shared/engine-intl.js";
|
|
11
19
|
|
|
12
|
-
|
|
20
|
+
/** One card of the list. A coupon card shows its name, code and Copy; a reward card its value, a
|
|
21
|
+
* note, and "Available" or "180 more" on the right. A section heading rides on the first card of
|
|
22
|
+
* its section (`noFirstSection` / `noLaterSection` pick the heading with or without a gap). */
|
|
23
|
+
export interface MemberRow {
|
|
24
|
+
id: string; name: string; subtitle: string; note: string; more: string; code: string;
|
|
25
|
+
isCoupon: boolean; notCoupon: boolean; copied: boolean; notCopied: boolean;
|
|
26
|
+
noAvailable: boolean; noMore: boolean; section: string; noFirstSection: boolean; noLaterSection: boolean;
|
|
27
|
+
}
|
|
13
28
|
interface S {
|
|
14
|
-
hideLoading: boolean; hideContent: boolean; hideSignIn: boolean; hideError: boolean; error: string;
|
|
15
|
-
points
|
|
16
|
-
|
|
17
|
-
|
|
29
|
+
hideLoading: boolean; hideContent: boolean; hideSignIn: boolean; hideError: boolean; error: string; oldAppText: string;
|
|
30
|
+
/** "320 points", and the subtitle "320 points · Gold tier". */
|
|
31
|
+
points: string; subtitle: string; items: MemberRow[]; emptyText: string; hideEmpty: boolean;
|
|
32
|
+
/** The sheet: the confirm view (`confirming`) or the "Coupon ready" view, never both. */
|
|
33
|
+
sheetOpen: boolean; confirming: boolean; noConfirmView: boolean; noReadyView: boolean;
|
|
34
|
+
confirmation: string; confirmBody: string; redeemLabel: string; selectedId: string; writeBusy: boolean; message: string;
|
|
35
|
+
referralError: string; resultCode: string; resultName: string; resultNote: string; resultCopied: boolean; resultNotCopied: boolean;
|
|
36
|
+
/** The copy toast: its text, its gate, and when it showed (the `_poll` tick hides it). */
|
|
37
|
+
toast: string; noToast: boolean; toastAt: number;
|
|
18
38
|
}
|
|
19
|
-
const INITIAL: S = { hideLoading: false, hideContent: true, hideSignIn: true, hideError: true, error: "", points: "", items: [], emptyText: "",
|
|
20
|
-
referralError: "", confirming: false, confirmation: "",
|
|
39
|
+
const INITIAL: S = { hideLoading: false, hideContent: true, hideSignIn: true, hideError: true, error: "", oldAppText: "", points: "", subtitle: "", items: [], emptyText: "", hideEmpty: true,
|
|
40
|
+
referralError: "", sheetOpen: false, confirming: false, noConfirmView: true, noReadyView: true, confirmation: "", confirmBody: "", redeemLabel: "", selectedId: "", writeBusy: false, message: "",
|
|
41
|
+
resultCode: "", resultName: "", resultNote: "", resultCopied: false, resultNotCopied: true, toast: "", noToast: true, toastAt: 0 };
|
|
42
|
+
/** How long the copy toast shows (the brief: 2 s). */
|
|
43
|
+
export const TOAST_MS = 2000;
|
|
44
|
+
const TOAST_POLL = { id: "loyalty-copy-toast", intervalMs: 500, action: "himiBrandedLoyaltyRewards.tick", immediate: false };
|
|
45
|
+
const TOAST_POLL_STOP = { id: "loyalty-copy-toast", stop: true as const };
|
|
21
46
|
const PRIVATE_KEYS = Object.keys(INITIAL) as (keyof S)[];
|
|
22
47
|
const input = () => (globalThis as { himalaya?: { input?: Record<string, unknown>; readLifecycleVersion?: number } }).himalaya;
|
|
23
48
|
const business = () => input()?.input?.__himiPreferenceBusiness;
|
|
24
49
|
const object = (arg: unknown): Record<string, unknown> => arg && typeof arg === "object" ? arg as Record<string, unknown> : {};
|
|
25
50
|
let generation = 0, writing = false, reviewing = false;
|
|
26
51
|
let currency = "", restaurantScreen = "";
|
|
27
|
-
let context: { member: MemberAccess; business: unknown; program: WixLoyaltyProgram; account: WixLoyaltyAccount; rewards: WixLoyaltyReward[]; coupons: WixLoyaltyCoupon[]; referrals: WixReferralReward[]; referralKnown: boolean } | undefined;
|
|
52
|
+
let context: { member: MemberAccess; business: unknown; program: WixLoyaltyProgram; account: WixLoyaltyAccount; rewards: WixLoyaltyReward[]; coupons: WixLoyaltyCoupon[]; referrals: WixReferralReward[]; referralKnown: boolean; tiers?: WixLoyaltyTiersProgram } | undefined;
|
|
53
|
+
/** The cards whose code was copied in this visit ("Copied" on the card), and the coupon the last
|
|
54
|
+
* redemption returned (it leads "Your coupons"). */
|
|
55
|
+
const copiedIds = new Set<string>();
|
|
56
|
+
let latestCouponId = "";
|
|
28
57
|
let confirmation: { id: string; member: MemberAccess; business: unknown; cost: number } | undefined;
|
|
29
58
|
let result: { generation: number; message: string; coupon?: WixLoyaltyCoupon } | undefined;
|
|
30
59
|
// One confirmed write may await two independently replicated reads. Keep its
|
|
@@ -50,6 +79,7 @@ const guard = async (c: NonNullable<typeof context>) => {
|
|
|
50
79
|
if (context !== c || business() !== c.business) throw new Error("Member access changed");
|
|
51
80
|
};
|
|
52
81
|
const signInState = (): S => ({ ...INITIAL, hideLoading: true, hideSignIn: false });
|
|
82
|
+
const SHEET_CLOSED = { sheetOpen: false, confirming: false, noConfirmView: true, noReadyView: true, selectedId: "", confirmation: "", confirmBody: "", redeemLabel: "" };
|
|
53
83
|
function reconcile(c: NonNullable<typeof context>) {
|
|
54
84
|
if (!confirmed) return;
|
|
55
85
|
const points = c.account.points;
|
|
@@ -57,34 +87,66 @@ function reconcile(c: NonNullable<typeof context>) {
|
|
|
57
87
|
|| (confirmed.redeemedAfter !== undefined && pointAmount(points?.redeemed) && points.redeemed >= confirmed.redeemedAfter);
|
|
58
88
|
if (debited && c.coupons.some(coupon => coupon.id === confirmed!.coupon.id)) confirmed = undefined;
|
|
59
89
|
}
|
|
60
|
-
function rows(c: NonNullable<typeof context>): Pick<S, "items" | "points" | "emptyText" | "referralError"> {
|
|
90
|
+
function rows(c: NonNullable<typeof context>): Pick<S, "items" | "points" | "subtitle" | "emptyText" | "hideEmpty" | "hideContent" | "referralError"> {
|
|
61
91
|
const unit = c.program.pointDefinition?.customName ?? "";
|
|
62
92
|
const balance = c.account.points?.balance;
|
|
93
|
+
const knownBalance = typeof balance === "number" && Number.isFinite(balance);
|
|
94
|
+
const tierId = c.account.tier?.id;
|
|
63
95
|
const ordered = c.rewards.filter(r => r.active === true && !!r.id).map((reward, index) => {
|
|
64
|
-
const cost = memberRewardCost(reward,
|
|
65
|
-
|
|
96
|
+
const cost = memberRewardCost(reward, tierId);
|
|
97
|
+
// The same rule as the "Available" pill below: priced in points on this tier and covered.
|
|
98
|
+
return { reward, index, available: !confirmed && !blocked(reward.id) && reward.type !== "SPI_DISCOUNT_AMOUNT" && cost !== undefined && knownBalance && balance >= cost ? 1 : 0 };
|
|
66
99
|
}).sort((a, b) => b.available - a.available || a.index - b.index);
|
|
67
|
-
const rewards = ordered.map(({ reward }
|
|
68
|
-
const cost = memberRewardCost(reward,
|
|
69
|
-
|
|
100
|
+
const rewards = ordered.map(({ reward }) => {
|
|
101
|
+
const cost = memberRewardCost(reward, tierId);
|
|
102
|
+
// The right side: "Available" or "180 more", only for a reward priced in points on this tier.
|
|
103
|
+
const priced = !confirmed && !blocked(reward.id) && reward.type !== "SPI_DISCOUNT_AMOUNT" && cost !== undefined && knownBalance;
|
|
104
|
+
const note = confirmed ? copyParam("loyalty.redeemedRefreshFailed", "Reward redeemed. Your balance couldn't be refreshed; refresh before redeeming again.")
|
|
70
105
|
: blocked(reward.id) ? copyParam("loyalty.redemptionUncertain", "Check your coupons: this redemption could not be confirmed.")
|
|
71
|
-
: reward.type === "DISCOUNT_AMOUNT" ? copyParam("loyalty.orderToRedeem", "Use
|
|
106
|
+
: reward.type === "DISCOUNT_AMOUNT" ? copyParam("loyalty.orderToRedeem", "Use it when you place an order.")
|
|
72
107
|
: !couponReward(reward) ? copyParam("loyalty.checkoutReward", "Use this reward at checkout.")
|
|
73
108
|
: cost === undefined ? copyParam("loyalty.notOnTier", "This reward is not available on your tier.")
|
|
74
|
-
:
|
|
75
|
-
|
|
76
|
-
: copyParam("loyalty.
|
|
77
|
-
|
|
109
|
+
: !knownBalance ? copyParam("loyalty.pointsUnavailable", "Your points aren't available yet.") : "";
|
|
110
|
+
return { id: reward.id, code: "", isCoupon: false, notCoupon: true, copied: false, notCopied: true, section: "", noFirstSection: true, noLaterSection: true,
|
|
111
|
+
name: reward.name || copyParam("loyalty.rewardFallback", "Reward"), subtitle: offeringRewardLabel(reward, tierId, unit, currency), note,
|
|
112
|
+
noAvailable: !(priced && balance >= cost), noMore: !(priced && balance < cost),
|
|
113
|
+
more: priced && balance < cost ? copyTemplate("loyalty.moreNeeded", "{points} more", { points: formatNumber(cost - balance) }) : "" };
|
|
78
114
|
});
|
|
79
115
|
const knownCoupons = confirmed && !c.coupons.some(coupon => coupon.id === confirmed!.coupon.id) ? [...c.coupons, confirmed.coupon] : c.coupons;
|
|
80
116
|
const coupons = knownCoupons.filter(c => c.status === "ACTIVE" && !c.couponReference?.deleted && !!c.id && !!c.couponReference?.code)
|
|
81
|
-
.map(c => ({ id: c.id!, name: c.rewardName || copyParam("loyalty.rewardFallback", "Reward"), code: c.couponReference!.code! }))
|
|
117
|
+
.map(c => ({ id: c.id!, name: c.rewardName || copyParam("loyalty.rewardFallback", "Reward"), code: c.couponReference!.code! }))
|
|
118
|
+
// The coupon the member just redeemed leads the list.
|
|
119
|
+
.sort((a, b) => Number(b.id === latestCouponId) - Number(a.id === latestCouponId));
|
|
82
120
|
const referralCoupons = c.referrals.filter(r => r.rewardType === "COUPON" && r.coupon?.status === "ACTIVE" && !!r.id && !!r.coupon.code)
|
|
83
121
|
.map(r => ({ id: `referral:${r.id}`, name: r.coupon!.couponSpecification?.name || copyParam("loyalty.referralReward", "Referral reward"), code: r.coupon!.code! }));
|
|
84
122
|
const allCoupons = [...coupons, ...referralCoupons];
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
123
|
+
const couponItems: MemberRow[] = allCoupons.map((coupon, index) => {
|
|
124
|
+
const id = `coupon:${coupon.id}`, copied = copiedIds.has(id);
|
|
125
|
+
return { ...coupon, id, isCoupon: true, notCoupon: false, copied, notCopied: !copied, subtitle: "", note: "", more: "", noAvailable: true, noMore: true,
|
|
126
|
+
section: index === 0 ? copyParam("loyalty.claimedRewards", "Your coupons") : "", noFirstSection: index !== 0, noLaterSection: true };
|
|
127
|
+
});
|
|
128
|
+
if (rewards.length) {
|
|
129
|
+
const later = couponItems.length > 0;
|
|
130
|
+
rewards[0] = { ...rewards[0], section: copyParam("loyalty.redeemHeading", "Redeem points"), noFirstSection: later, noLaterSection: !later };
|
|
131
|
+
}
|
|
132
|
+
const points = !confirmed && knownBalance ? pointLabel(balance, unit) : "";
|
|
133
|
+
const tier = currentTierName(c.tiers, tierId || undefined);
|
|
134
|
+
const empty = !rewards.length && !allCoupons.length;
|
|
135
|
+
return { items: [...couponItems, ...rewards], referralError: c.referralKnown ? "" : copyParam("loyalty.referralsError", "Referral rewards couldn't be verified. Refresh to try again."), points,
|
|
136
|
+
subtitle: points && tier ? copyTemplate("loyalty.balanceTier", "{points} · {tier} tier", { points, tier }) : points,
|
|
137
|
+
emptyText: empty ? copyParam("loyalty.emptyTitle", "No rewards yet") : "", hideEmpty: !empty, hideContent: empty };
|
|
138
|
+
}
|
|
139
|
+
/** The confirm sheet's lines for a reward and its price. */
|
|
140
|
+
function confirmLines(name: string, cost: number, unit: string): Pick<S, "confirmation" | "confirmBody" | "redeemLabel"> {
|
|
141
|
+
return {
|
|
142
|
+
confirmation: copyTemplate("loyalty.confirmTitle", "Redeem {name}?", { name }),
|
|
143
|
+
confirmBody: copyTemplate("loyalty.confirmBody", "{points} come off your balance. You get a coupon to use at checkout.", { points: pointLabel(cost, unit) }),
|
|
144
|
+
redeemLabel: copyParam("loyalty.redeem", "Redeem"),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** Show `message` as the toast and arm the tick that hides it. */
|
|
148
|
+
function withToast(s: S, message: string): S {
|
|
149
|
+
return { ...s, toast: message, noToast: false, toastAt: Date.now(), _poll: { ...TOAST_POLL } } as S;
|
|
88
150
|
}
|
|
89
151
|
|
|
90
152
|
async function redeem(c: NonNullable<typeof context>, selected: NonNullable<typeof confirmation>, version: number) {
|
|
@@ -100,7 +162,8 @@ async function redeem(c: NonNullable<typeof context>, selected: NonNullable<type
|
|
|
100
162
|
if (!coupon?.id || !coupon.couponReference?.code) throw new Error("Redemption was not confirmed");
|
|
101
163
|
confirmed = { coupon, balanceAfter: pointAmount(before?.balance) ? Math.max(0, before.balance - selected.cost) : undefined,
|
|
102
164
|
redeemedAfter: pointAmount(before?.redeemed) ? before.redeemed + selected.cost : undefined };
|
|
103
|
-
|
|
165
|
+
latestCouponId = coupon.id;
|
|
166
|
+
message = copyParam("loyalty.useAtCheckout", "Use it at checkout.");
|
|
104
167
|
const [account, coupons] = await Promise.allSettled([getCurrentMemberLoyaltyAccount(), listMyLoyaltyCoupons()]);
|
|
105
168
|
await guard(c);
|
|
106
169
|
// A failed follow-up read cannot erase the successful coupon or retain a stale spendable balance.
|
|
@@ -126,39 +189,44 @@ async function redeem(c: NonNullable<typeof context>, selected: NonNullable<type
|
|
|
126
189
|
const register = withOnlineWrites(defineService, ["confirmRedemption"], { messageFields: ["message"] });
|
|
127
190
|
const svc = register<S, {
|
|
128
191
|
prepare: (s: S) => S; load: (s: S, arg?: unknown) => Promise<S | undefined>;
|
|
129
|
-
reviewReward: (s: S, arg?: unknown) => Promise<S>; cancelRedemption: (s: S) => S;
|
|
130
|
-
confirmRedemption: (s: S) => S; finishRedemption: (s: S) => S;
|
|
192
|
+
reviewReward: (s: S, arg?: unknown) => Promise<S>; cancelRedemption: (s: S) => S; closeSheet: (s: S) => S; refresh: (s: S) => S;
|
|
193
|
+
confirmRedemption: (s: S) => S; finishRedemption: (s: S) => S; copyCode: (s: S, arg?: unknown) => Promise<S | undefined>; tick: (s: S) => S | undefined;
|
|
131
194
|
}>("himiBrandedLoyaltyRewards", {
|
|
132
195
|
state: INITIAL, notHydrated: PRIVATE_KEYS, notPersisted: PRIVATE_KEYS, perVisit: PRIVATE_KEYS,
|
|
133
196
|
actions: {
|
|
134
|
-
prepare: () => { generation++; context = undefined; confirmation = undefined; result = undefined; return { ...INITIAL }; },
|
|
197
|
+
prepare: () => { generation++; context = undefined; confirmation = undefined; result = undefined; copiedIds.clear(); return { ...INITIAL }; },
|
|
135
198
|
load: async (s, arg) => {
|
|
136
199
|
stashCopy(arg);
|
|
137
200
|
if (writing) return s;
|
|
138
|
-
const version = ++generation; context = undefined; confirmation = undefined; result = undefined;
|
|
201
|
+
const version = ++generation; context = undefined; confirmation = undefined; result = undefined; copiedIds.clear();
|
|
139
202
|
const args = object(arg);
|
|
140
203
|
if ("currency" in args) currency = typeof args.currency === "string" && /^[A-Z]{3}$/.test(args.currency) ? args.currency : "";
|
|
141
204
|
if ("restaurantScreen" in args) restaurantScreen = args.restaurantScreen === "himi_menu" ? "himi_menu" : "";
|
|
142
205
|
const site = business(), member = await memberAccess();
|
|
143
206
|
if (!member.email) return signInState();
|
|
144
|
-
if (!member.scope || (input()?.readLifecycleVersion ?? 0) < 1)
|
|
207
|
+
if (!member.scope || (input()?.readLifecycleVersion ?? 0) < 1) {
|
|
208
|
+
const text = copyParam("loyalty.updateApp", "Update the app to see your points.");
|
|
209
|
+
return { ...INITIAL, hideLoading: true, error: text, oldAppText: text };
|
|
210
|
+
}
|
|
145
211
|
if (uncertainPrincipal !== stamp(member)) { uncertain.clear(); uncertaintyOverflow = false; confirmed = undefined; uncertainPrincipal = stamp(member); }
|
|
146
212
|
try {
|
|
147
|
-
const [program, rewards, account, coupons, referrals] = await Promise.all([getLoyaltyProgram(), listLoyaltyRewards(), getCurrentMemberLoyaltyAccount(), listMyLoyaltyCoupons(),
|
|
148
|
-
listMyReferralRewards().then(value => ({ value, failed: false }), () => ({ value: undefined, failed: true }))
|
|
213
|
+
const [program, rewards, account, coupons, referrals, tiers] = await Promise.all([getLoyaltyProgram(), listLoyaltyRewards(), getCurrentMemberLoyaltyAccount(), listMyLoyaltyCoupons(),
|
|
214
|
+
listMyReferralRewards().then(value => ({ value, failed: false }), () => ({ value: undefined, failed: true })),
|
|
215
|
+
// Only the subtitle's tier name: a failed read drops the tier, never the list.
|
|
216
|
+
getLoyaltyTiersProgram().catch(() => undefined)]);
|
|
149
217
|
await assertMemberAccess(member);
|
|
150
218
|
if (business() !== site || version !== generation) return undefined;
|
|
151
219
|
const p = program.loyaltyProgram ?? program.program;
|
|
152
220
|
if (!p || p.status !== "ACTIVE" || p.premiumFeatures?.loyaltyProgram === false) throw new Error("Program unavailable");
|
|
153
221
|
if ((rewards.rewards !== undefined && !Array.isArray(rewards.rewards)) || (coupons.loyaltyCoupons !== undefined && !Array.isArray(coupons.loyaltyCoupons))) throw new Error("Incomplete member rewards response");
|
|
154
|
-
context = { member, business: site, program: p, account: account.account ?? {}, rewards: rewards.rewards ?? [], coupons: coupons.loyaltyCoupons ?? [], referrals: referrals.value?.referralRewards ?? [], referralKnown: !referrals.failed };
|
|
222
|
+
context = { member, business: site, program: p, account: account.account ?? {}, rewards: rewards.rewards ?? [], coupons: coupons.loyaltyCoupons ?? [], referrals: referrals.value?.referralRewards ?? [], referralKnown: !referrals.failed, tiers };
|
|
155
223
|
reconcile(context);
|
|
156
|
-
return { ...INITIAL, hideLoading: true,
|
|
224
|
+
return { ...INITIAL, hideLoading: true, ...rows(context) };
|
|
157
225
|
} catch {
|
|
158
226
|
if (version !== generation || business() !== site) return undefined;
|
|
159
227
|
const current = await memberAccess();
|
|
160
228
|
if (!current.email || stamp(current) !== stamp(member)) return signInState();
|
|
161
|
-
return { ...INITIAL, hideLoading: true, hideError: false, error: copyParam("loyalty.memberRewardsError", "Your rewards couldn't be loaded.
|
|
229
|
+
return { ...INITIAL, hideLoading: true, hideError: false, error: copyParam("loyalty.memberRewardsError", "Your rewards couldn't be loaded.") };
|
|
162
230
|
}
|
|
163
231
|
},
|
|
164
232
|
reviewReward: async (s, arg) => {
|
|
@@ -179,27 +247,74 @@ const svc = register<S, {
|
|
|
179
247
|
const cost = memberRewardCost(fresh, c.account.tier?.id), balance = c.account.points?.balance;
|
|
180
248
|
if (cost === undefined || typeof balance !== "number" || !Number.isFinite(balance) || balance < cost) return { ...s, ...rows(c), message: copyParam("loyalty.cannotRedeem", "This reward can't be redeemed with your current points and tier.") };
|
|
181
249
|
confirmation = { id, member: c.member, business: c.business, cost };
|
|
182
|
-
return { ...s, ...rows(c), selectedId: id,
|
|
250
|
+
return { ...s, ...rows(c), selectedId: id, sheetOpen: true, confirming: true, noConfirmView: false, noReadyView: true, message: "",
|
|
251
|
+
...confirmLines(fresh.name || copyParam("loyalty.rewardFallback", "Reward"), cost, c.program.pointDefinition?.customName ?? "") };
|
|
183
252
|
} catch {
|
|
184
253
|
confirmation = undefined;
|
|
185
254
|
const current = await memberAccess();
|
|
186
255
|
if (context !== c || business() !== c.business || stamp(current) !== stamp(c.member)) return signInState();
|
|
187
|
-
return { ...s,
|
|
256
|
+
return { ...s, ...SHEET_CLOSED, message: copyParam("loyalty.cannotRedeem", "This reward can't be redeemed with your current points and tier.") }; }
|
|
188
257
|
finally { reviewing = false; }
|
|
189
258
|
},
|
|
190
|
-
|
|
259
|
+
// The empty state's Refresh: the skeleton shows at once (the list is hidden while empty), then load.
|
|
260
|
+
refresh: s => { if (writing) return s; void svc.load(); return { ...s, hideLoading: false, hideEmpty: true, hideError: true }; },
|
|
261
|
+
cancelRedemption: s => { if (writing) return s; confirmation = undefined; return { ...s, ...SHEET_CLOSED }; },
|
|
262
|
+
// A dismiss while the write is in flight follows the host (the sheet is gone); the write keeps
|
|
263
|
+
// going and its result opens the sheet again as "Coupon ready" or says why on the page.
|
|
264
|
+
closeSheet: s => { if (writing) return { ...s, sheetOpen: false }; confirmation = undefined; return { ...s, ...SHEET_CLOSED, resultCopied: false, resultNotCopied: true }; },
|
|
265
|
+
copyCode: async (s, arg) => {
|
|
266
|
+
const id = object(arg).id;
|
|
267
|
+
if (typeof id !== "string") return undefined;
|
|
268
|
+
// The code the member tapped, read before any await.
|
|
269
|
+
const code = id === "result" ? s.resultCode : s.items.find(item => item.isCoupon && item.id === id)?.code;
|
|
270
|
+
if (!code) return undefined;
|
|
271
|
+
// Every result below is built on the state as it is NOW: a refresh, a sheet dismiss or a toast
|
|
272
|
+
// tick that committed during the awaits is never rolled back to the tap-time snapshot.
|
|
273
|
+
const latest = (): S => svc.getState?.() ?? s;
|
|
274
|
+
const failed = () => withToast(latest(), copyParam("loyalty.copyFailed", "Couldn't copy the code."));
|
|
275
|
+
// A coupon code is a bearer credential: copy it only for the member these rows were read for.
|
|
276
|
+
const c = context;
|
|
277
|
+
if (!c) return failed(); // a load is replacing the rows: nothing verified to copy yet
|
|
278
|
+
// The member check comes BEFORE the write: the code is a bearer credential. (On the web the write
|
|
279
|
+
// already crosses the worker-to-host hop; one identity read stays well inside the browser's
|
|
280
|
+
// transient-activation window.)
|
|
281
|
+
try { await guard(c); }
|
|
282
|
+
catch {
|
|
283
|
+
// Copy nothing. When the member (not just the rows) changed, a reload decides who is signed in
|
|
284
|
+
// now; a transient identity failure therefore never wipes the screen by itself.
|
|
285
|
+
if (context === c) void svc.load();
|
|
286
|
+
return failed();
|
|
287
|
+
}
|
|
288
|
+
try {
|
|
289
|
+
await writeText(code);
|
|
290
|
+
} catch {
|
|
291
|
+
return failed();
|
|
292
|
+
}
|
|
293
|
+
const now = latest();
|
|
294
|
+
if (id === "result") return withToast(now.resultCode === code ? { ...now, resultCopied: true, resultNotCopied: false } : now, copyParam("loyalty.codeCopied", "Code copied"));
|
|
295
|
+
copiedIds.add(id);
|
|
296
|
+
return withToast({ ...now, items: now.items.map(item => item.id === id ? { ...item, copied: true, notCopied: false } : item) }, copyParam("loyalty.codeCopied", "Code copied"));
|
|
297
|
+
},
|
|
298
|
+
// The `_poll` tick: hide a toast that has shown for TOAST_MS; otherwise change nothing.
|
|
299
|
+
tick: s => {
|
|
300
|
+
if (!s.noToast && Date.now() - s.toastAt < TOAST_MS) return undefined;
|
|
301
|
+
return { ...s, toast: "", noToast: true, toastAt: 0, _poll: { ...TOAST_POLL_STOP } } as S;
|
|
302
|
+
},
|
|
191
303
|
confirmRedemption: s => {
|
|
192
304
|
const c = context, selected = confirmation;
|
|
193
305
|
if (!c || !selected || !s.confirming || writing || blocked(selected.id) || selected.business !== business() || selected.member !== c.member) return s;
|
|
194
306
|
writing = true; confirmation = undefined;
|
|
195
307
|
void redeem(c, selected, generation);
|
|
196
|
-
return { ...s, writeBusy: true, message: copyParam("loyalty.redeeming", "Redeeming…") };
|
|
308
|
+
return { ...s, writeBusy: true, message: "", redeemLabel: copyParam("loyalty.redeeming", "Redeeming…") };
|
|
197
309
|
},
|
|
198
310
|
finishRedemption: s => {
|
|
199
311
|
if (!result || result.generation !== generation || !context) return s;
|
|
200
312
|
const done = result; result = undefined;
|
|
201
|
-
|
|
202
|
-
|
|
313
|
+
const code = done.coupon?.couponReference?.code ?? "";
|
|
314
|
+
// A coupon: the sheet turns into "Coupon ready". A failure closes it and says why on the page.
|
|
315
|
+
const sheet = code ? { ...SHEET_CLOSED, sheetOpen: true, noReadyView: false } : SHEET_CLOSED;
|
|
316
|
+
return { ...s, hideLoading: true, hideSignIn: true, hideError: true, ...rows(context), ...sheet, writeBusy: false, message: code ? "" : done.message,
|
|
317
|
+
resultCode: code, resultName: done.coupon?.rewardName ?? "", resultNote: code ? done.message : "", resultCopied: false, resultNotCopied: true };
|
|
203
318
|
},
|
|
204
319
|
},
|
|
205
320
|
});
|
|
@@ -99,7 +99,6 @@ export const COLLECTIONS: Record<string, CollectionConfig> = {
|
|
|
99
99
|
himiBrandedPrograms: { rows: 'rows', title: 'name', subtitle: 'description', image: 'image', view: 'grid' },
|
|
100
100
|
himiBrandedCoupons: { rows: 'coupons', title: 'name', subtitle: 'subtitle', view: 'list', primaryVerb: { label: 'Get code' } },
|
|
101
101
|
himiBrandedNotifications: { rows: 'items', title: 'name', subtitle: 'subtitle', image: 'photo', metadata: ['unreadDot'], view: 'list' },
|
|
102
|
-
himiBrandedLoyalty: { rows: 'rewards', title: 'name', subtitle: 'description', view: 'grid', primaryVerb: { label: 'Redeem' } },
|
|
103
102
|
himiBrandedReviews: { rows: 'reviews', title: 'title', subtitle: 'body', metadata: ['author'], rating: 'rating', view: 'list' },
|
|
104
103
|
himiBrandedPortfolio: { rows: 'projects', title: 'title', subtitle: 'subtitle', image: 'image', view: 'grid', gridImageHeight: 180 },
|
|
105
104
|
himiBrandedInvoices: { rows: 'invoices', title: 'title', subtitle: 'subtitle', view: 'list' },
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "سجّل الدخول لعرض أحداثك.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "استرداد",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "عرض أحداثي",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Pro zobrazení událostí se přihlaste.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Uplatnit",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Zobrazit mé události",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Log ind for at se dine events.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Indløs",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Se mine events",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Melde dich an, um deine Veranstaltungen zu sehen.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Einlösen",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Meine Veranstaltungen ansehen",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Συνδεθείτε για να δείτε τις εκδηλώσεις σας.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Εξαργύρωση",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Προβολή των εκδηλώσεών μου",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$source": "en",
|
|
3
|
-
"$generated": "2026-11-
|
|
3
|
+
"$generated": "2026-11-23T21:02:21.462Z",
|
|
4
4
|
"messages": {
|
|
5
5
|
"h_009bd0adf237": {
|
|
6
6
|
"source": "Custom collections published by this business.",
|
|
@@ -1924,11 +1924,6 @@
|
|
|
1924
1924
|
"kind": "Button.title",
|
|
1925
1925
|
"translation": ""
|
|
1926
1926
|
},
|
|
1927
|
-
"h_db3f81436889": {
|
|
1928
|
-
"source": "Redeem",
|
|
1929
|
-
"kind": "Button.title",
|
|
1930
|
-
"translation": ""
|
|
1931
|
-
},
|
|
1932
1927
|
"h_dd6a76a4448a": {
|
|
1933
1928
|
"source": "View My Events",
|
|
1934
1929
|
"kind": "Button.title",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Inicia sesión para ver tus eventos.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Canjear",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Ver mis eventos",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Kirjaudu sisään nähdäksesi tapahtumasi.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Lunasta",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Näytä omat tapahtumani",
|
|
@@ -1756,11 +1756,6 @@
|
|
|
1756
1756
|
"translation": "Connectez-vous pour voir vos événements.",
|
|
1757
1757
|
"origin": "machine"
|
|
1758
1758
|
},
|
|
1759
|
-
"h_db3f81436889": {
|
|
1760
|
-
"source": "Redeem",
|
|
1761
|
-
"translation": "Utiliser",
|
|
1762
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1763
|
-
},
|
|
1764
1759
|
"h_dd6a76a4448a": {
|
|
1765
1760
|
"source": "View My Events",
|
|
1766
1761
|
"translation": "Voir mes événements",
|
|
@@ -1465,11 +1465,6 @@
|
|
|
1465
1465
|
"source": "Sign in to see your events.",
|
|
1466
1466
|
"translation": "יש להתחבר כדי לראות את האירועים שלך."
|
|
1467
1467
|
},
|
|
1468
|
-
"h_db3f81436889": {
|
|
1469
|
-
"source": "Redeem",
|
|
1470
|
-
"kind": "Button.title",
|
|
1471
|
-
"translation": "מימוש"
|
|
1472
|
-
},
|
|
1473
1468
|
"h_dd6a76a4448a": {
|
|
1474
1469
|
"source": "View My Events",
|
|
1475
1470
|
"translation": "לצפייה באירועים שלי"
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Az eseményeid megtekintéséhez jelentkezz be.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Beváltás",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Eseményeim megtekintése",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Login untuk melihat event Anda.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Tukarkan",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Lihat Event Saya",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Accedi per vedere i tuoi eventi.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Riscatta",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Vedi i miei eventi",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "イベントを表示するにはログインしてください。",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "引き換える",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "マイイベントを表示",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "이벤트를 보려면 로그인하세요.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "사용하기",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "내 이벤트 보기",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Prisijunkite, kad matytumėte savo renginius.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Naudoti",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Žiūrėti mano renginius",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Log in om je evenementen te zien.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Inwisselen",
|
|
1782
|
-
"origin": "one-app:wix-one-app-ecom-platform:merchant.order.bookingItem.redeemPlan.confirmationModal.redeemButton"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Mijn evenementen bekijken",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Logg inn for å se arrangementene dine.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Løs inn",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Se arrangementene mine",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Zaloguj się, aby zobaczyć swoje wydarzenia.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Wykorzystaj",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Zobacz moje wydarzenia",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Faça login para ver seus eventos.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Resgatar",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Ver meus eventos",
|
|
@@ -1776,11 +1776,6 @@
|
|
|
1776
1776
|
"translation": "Войдите, чтобы увидеть свои события.",
|
|
1777
1777
|
"origin": "machine"
|
|
1778
1778
|
},
|
|
1779
|
-
"h_db3f81436889": {
|
|
1780
|
-
"source": "Redeem",
|
|
1781
|
-
"translation": "Списать",
|
|
1782
|
-
"origin": "one-app:wix-one-app-pos:pos.redeemPoints.page.cta"
|
|
1783
|
-
},
|
|
1784
1779
|
"h_dd6a76a4448a": {
|
|
1785
1780
|
"source": "View My Events",
|
|
1786
1781
|
"translation": "Посмотреть мои события",
|