@wix/himalaya-cli 0.1750.0 → 0.1751.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/builder.d.ts +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/himi-package.d.ts +478 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/host-compatibility.d.ts +56 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/icon-catalog.generated.d.ts +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +4 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +154 -7
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/index.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast-service.d.ts +105 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast.d.ts +116 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +326 -13
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +730 -81
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +155 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{b40ea5d0d6251898ff5617139fde8be008dd11e99a70b14c1052093685401700.bin → 21f35a12bd94f4ab97a9a75453c4adcadc438daf024a4b1950d5c356c123bd01.bin} +1 -1
- package/dist/browser-plane/sw.js +7 -7
- package/dist/cli.mjs +34995 -31326
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/component-reference.json +1 -1
- package/guides/component-reference.md +4 -0
- package/guides/designing-himi-screens.md +7 -0
- package/guides/getting-started.md +2 -0
- package/guides/headless-loop.md +1 -1
- package/guides/himi-skill.md +2 -0
- package/guides/index.json +6 -0
- package/guides/qa-builds.md +12 -1
- package/guides/recipe-podcast.md +149 -0
- package/guides/tier-5-add-a-screen.md +16 -2
- package/guides/wix-business-context.md +29 -0
- package/guides/wix-platform-usage.md +7 -2
- package/package.json +10 -10
- package/template-icons/fitness-gym.png +0 -0
- package/templates/beauty-salon/dev/index.ts +1 -1
- package/templates/beauty-salon/l10n/en.json +1 -1
- package/templates/beauty-salon/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/beauty-salon/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/beauty-salon/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/branded-lite/dev/index.ts +101 -1
- package/templates/branded-lite/l10n/en.json +22 -1
- package/templates/branded-lite/l10n/es.json +22 -0
- package/templates/branded-lite/l10n/fr.json +18 -0
- package/templates/branded-lite/l10n/he.json +15 -0
- package/templates/branded-lite/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/branded-lite/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/branded-lite/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/branded-lite/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
- package/templates/brandy/README.md +33 -0
- package/templates/brandy/config.ts +51 -7
- package/templates/brandy/dev/index.ts +23 -9
- package/templates/community-club/l10n/en.json +1 -1
- package/templates/community-club/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/community-club/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/events-meetups/l10n/en.json +1 -1
- package/templates/events-meetups/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/events-meetups/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/fitness-gym/README.md +53 -0
- package/templates/fitness-gym/config.ts +560 -0
- package/templates/fitness-gym/dev/index.ts +25787 -0
- package/templates/fitness-gym/himalaya.content.json +64 -0
- package/templates/fitness-gym/himalaya.template.json +15 -0
- package/templates/fitness-gym/icon.png +0 -0
- package/templates/fitness-gym/platforms.json +1 -0
- package/templates/fitness-gym/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/fitness-gym/tier5-src/_shared/booking-location.ts +147 -0
- package/templates/fitness-gym/tier5-src/_shared/booking-session.ts +224 -0
- package/templates/fitness-gym/tier5-src/_shared/branded-lite-hosted.ts +280 -0
- package/templates/fitness-gym/tier5-src/_shared/branded-load-state.ts +109 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-copy.ts +40 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-history.ts +51 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-message-model.ts +177 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-model.ts +56 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-presenter.ts +576 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-transport.ts +148 -0
- package/templates/fitness-gym/tier5-src/_shared/collection-contract.ts +228 -0
- package/templates/fitness-gym/tier5-src/_shared/collection-query.ts +193 -0
- package/templates/fitness-gym/tier5-src/_shared/collection-service.ts +400 -0
- package/templates/fitness-gym/tier5-src/_shared/detail-presence.ts +51 -0
- package/templates/fitness-gym/tier5-src/_shared/engine-intl.ts +523 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-account.ts +194 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-booking-saved.ts +88 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-bookings.ts +318 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-copy.ts +116 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-media.ts +29 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-store.ts +7 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-text.ts +24 -0
- package/templates/fitness-gym/tier5-src/_shared/host-events.ts +66 -0
- package/templates/fitness-gym/tier5-src/_shared/hosted-checkout.ts +70 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-attendance-form.ts +106 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-attendance.ts +38 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-worker.ts +127 -0
- package/templates/fitness-gym/tier5-src/_shared/inbox-rooms.ts +68 -0
- package/templates/fitness-gym/tier5-src/_shared/local-preferences.ts +38 -0
- package/templates/fitness-gym/tier5-src/_shared/member-access.ts +63 -0
- package/templates/fitness-gym/tier5-src/_shared/member-account-routes.ts +52 -0
- package/templates/fitness-gym/tier5-src/_shared/member-bookings.ts +107 -0
- package/templates/fitness-gym/tier5-src/_shared/member-screen.ts +99 -0
- package/templates/fitness-gym/tier5-src/_shared/notification-target.ts +141 -0
- package/templates/fitness-gym/tier5-src/_shared/offset-page.ts +10 -0
- package/templates/fitness-gym/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/fitness-gym/tier5-src/_shared/owner-load-error.ts +348 -0
- package/templates/fitness-gym/tier5-src/_shared/payment-setup.ts +6 -0
- package/templates/fitness-gym/tier5-src/_shared/pricing-plan-display.ts +64 -0
- package/templates/fitness-gym/tier5-src/_shared/program-description.ts +11 -0
- package/templates/fitness-gym/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/fitness-gym/tier5-src/_shared/program-standing.ts +46 -0
- package/templates/fitness-gym/tier5-src/_shared/rich-body.ts +78 -0
- package/templates/fitness-gym/tier5-src/_shared/rich-content-link.ts +34 -0
- package/templates/fitness-gym/tier5-src/_shared/sign-in-sheet.ts +18 -0
- package/templates/fitness-gym/tier5-src/_shared/staff-name.ts +18 -0
- package/templates/fitness-gym/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/fitness-gym/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/fitness-gym/tier5-src/_shared/wix-member-links.ts +114 -0
- package/templates/fitness-gym/tier5-src/_shared/wix-service-price.ts +146 -0
- package/templates/fitness-gym/tier5-src/business-chat/index.ts +732 -0
- package/templates/fitness-gym/tier5-src/business-contact/index.ts +6 -0
- package/templates/fitness-gym/tier5-src/himi-booking-account/index.ts +267 -0
- package/templates/fitness-gym/tier5-src/himi-booking-bookings/index.ts +468 -0
- package/templates/fitness-gym/tier5-src/himi-booking-service/index.ts +1190 -0
- package/templates/fitness-gym/tier5-src/himi-booking-services/index.ts +791 -0
- package/templates/fitness-gym/tier5-src/himi-booking-time/index.ts +1729 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-agenda/index.ts +988 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-member-programs/index.ts +656 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-notifications/index.ts +256 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-plans/index.ts +495 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-program/facts.ts +52 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-program/index.ts +845 -0
- package/templates/fitness-gym/tier5-src/himi-fitcoach-goal/index.ts +191 -0
- package/templates/fitness-gym/tier5-src/himi-fitcoach-home/index.ts +619 -0
- package/templates/fitness-gym/tier5-src/himi-store-account/index.ts +1007 -0
- package/templates/fitness-gym/tier5-src/wix-spaces-my-subscriptions/index.ts +84 -0
- package/templates/fitness-gym/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
- package/templates/fitness-gym/tokens.json +414 -0
- package/templates/gym-fitness/dev/index.ts +1 -1
- package/templates/gym-fitness/l10n/en.json +1 -1
- package/templates/gym-fitness/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/gym-fitness/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/gym-fitness/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/medical-services/dev/index.ts +2 -1
- package/templates/medical-services/tier5-src/himi-booking-account/index.ts +16 -1
- package/templates/nonprofit-cause/l10n/en.json +1 -1
- package/templates/nonprofit-cause/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/nonprofit-cause/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/personal-fitness-trainer/dev/index.ts +2 -2
- package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/podcast-creator/dev/index.ts +100 -0
- package/templates/podcast-creator/l10n/en.json +22 -1
- package/templates/podcast-creator/l10n/es.json +22 -0
- package/templates/podcast-creator/l10n/fr.json +18 -0
- package/templates/podcast-creator/l10n/he.json +15 -0
- package/templates/podcast-creator/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/podcast-creator/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/podcast-creator/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
- package/templates/portfolio-creative/l10n/en.json +1 -1
- package/templates/portfolio-creative/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/portfolio-creative/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/restaurant/l10n/en.json +1 -1
- package/templates/restaurant/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/restaurant/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/retail-store/l10n/en.json +1 -1
- package/templates/retail-store/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/retail-store/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/salon-spa/dev/index.ts +1 -1
- package/templates/salon-spa/tier5-src/himi-booking-account/index.ts +16 -1
- package/templates/salon-spa/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/yoga-studio/dev/index.ts +1 -1
- package/templates/yoga-studio/l10n/en.json +1 -1
- package/templates/yoga-studio/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/yoga-studio/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/yoga-studio/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createBusinessContactService } from "@himalaya/screens";
|
|
2
|
+
|
|
3
|
+
// Contact values and the optional public total are build-time source evidence.
|
|
4
|
+
// No owner API, device location, or cross-site source URL is read by this worker.
|
|
5
|
+
const svc = createBusinessContactService();
|
|
6
|
+
export { svc };
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
// Tier-5 bundle: himi-booking — visitor/member account state.
|
|
2
|
+
import { defineService, navigate } from "@himalaya/state";
|
|
3
|
+
import { dispatch } from "@himalaya/dispatch";
|
|
4
|
+
import { queryBookings, type WixBooking } from "@himalaya/wix-bookings";
|
|
5
|
+
import { loadMemberProfile, strOf, fmtDateTime, titleCase, type AccountActivityRow } from "../_shared/himi-account";
|
|
6
|
+
import { stashCopy, copyParam } from "../_shared/himi-copy.js";
|
|
7
|
+
import { memberScreenOpener } from "../_shared/member-screen.js";
|
|
8
|
+
|
|
9
|
+
const openMemberScreen = memberScreenOpener();
|
|
10
|
+
|
|
11
|
+
interface S {
|
|
12
|
+
status: "loading" | "ready";
|
|
13
|
+
isMember: boolean;
|
|
14
|
+
notMember: boolean;
|
|
15
|
+
identityLine: string;
|
|
16
|
+
detailLine: string;
|
|
17
|
+
memberName: string;
|
|
18
|
+
memberEmail: string;
|
|
19
|
+
memberImage: string;
|
|
20
|
+
memberInitials: string;
|
|
21
|
+
hasMemberImage: boolean;
|
|
22
|
+
noMemberImage: boolean;
|
|
23
|
+
authTitle: string;
|
|
24
|
+
authBody: string;
|
|
25
|
+
email: string;
|
|
26
|
+
password: string;
|
|
27
|
+
firstName: string;
|
|
28
|
+
lastName: string;
|
|
29
|
+
message: string;
|
|
30
|
+
isLoading: boolean;
|
|
31
|
+
notLoading: boolean;
|
|
32
|
+
isRegistering: boolean;
|
|
33
|
+
notRegistering: boolean;
|
|
34
|
+
activityTitle: string;
|
|
35
|
+
activitySummary: string;
|
|
36
|
+
activityRows: AccountActivityRow[];
|
|
37
|
+
activityEmptyText: string;
|
|
38
|
+
hasActivity: boolean;
|
|
39
|
+
noActivity: boolean;
|
|
40
|
+
servicesScreenId: string;
|
|
41
|
+
bookingsScreenId: string;
|
|
42
|
+
/** Sign out asks first on a screen that binds the confirm step (askSignOut → signOut, or
|
|
43
|
+
* cancelSignOut). A screen that calls signOut directly signs out at once, as before. */
|
|
44
|
+
confirmingSignOut?: boolean;
|
|
45
|
+
notConfirmingSignOut?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function derive(s: S): S {
|
|
49
|
+
const isRegistering = !!s.isRegistering;
|
|
50
|
+
const hasActivity = s.activityRows.length > 0;
|
|
51
|
+
return {
|
|
52
|
+
...s,
|
|
53
|
+
confirmingSignOut: !!s.confirmingSignOut && s.isMember,
|
|
54
|
+
notConfirmingSignOut: !(s.confirmingSignOut && s.isMember),
|
|
55
|
+
isLoading: s.status === "loading",
|
|
56
|
+
notLoading: s.status !== "loading",
|
|
57
|
+
notMember: !s.isMember,
|
|
58
|
+
isRegistering,
|
|
59
|
+
notRegistering: !isRegistering,
|
|
60
|
+
hasActivity,
|
|
61
|
+
noActivity: !hasActivity,
|
|
62
|
+
authTitle: isRegistering
|
|
63
|
+
? copyParam("bookingAccount.authTitleRegister", "Create account")
|
|
64
|
+
: copyParam("bookingAccount.authTitle", "Welcome"),
|
|
65
|
+
authBody: isRegistering
|
|
66
|
+
? copyParam("bookingAccount.authBodyRegister", "Create a member account to book services and see your history.")
|
|
67
|
+
: copyParam("bookingAccount.authBody", "Sign in to book services and see your history."),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function bookingEmail(booking: WixBooking): string {
|
|
72
|
+
const contact = booking.contactDetails as { email?: string; contactEmail?: string } | undefined;
|
|
73
|
+
return (contact?.email ?? contact?.contactEmail ?? "").toLowerCase();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function bookingTitle(booking: WixBooking): string {
|
|
77
|
+
const entity = booking.bookedEntity as { serviceName?: string; title?: string } | undefined;
|
|
78
|
+
return entity?.serviceName || entity?.title || "Booking";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function bookingStart(booking: WixBooking): string | undefined {
|
|
82
|
+
const entity = booking.bookedEntity as { slot?: { startDate?: string } } | undefined;
|
|
83
|
+
return entity?.slot?.startDate || booking.startDate || booking.createdDate;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function bookingRow(booking: WixBooking): AccountActivityRow {
|
|
87
|
+
const start = bookingStart(booking);
|
|
88
|
+
return {
|
|
89
|
+
id: booking.id || start || bookingTitle(booking),
|
|
90
|
+
title: bookingTitle(booking),
|
|
91
|
+
subtitle: fmtDateTime(start) || "Booked time",
|
|
92
|
+
meta: titleCase(booking.paymentStatus) || "",
|
|
93
|
+
status: titleCase(booking.status) || "Booked",
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function bookingRows(memberEmail: string): Promise<AccountActivityRow[]> {
|
|
98
|
+
if (!memberEmail) return [];
|
|
99
|
+
const res = await queryBookings({ query: { paging: { limit: 50 } } });
|
|
100
|
+
return (res.bookings ?? [])
|
|
101
|
+
.filter((booking) => bookingEmail(booking) === memberEmail.toLowerCase())
|
|
102
|
+
.sort((a, b) => (Date.parse(bookingStart(b) || "") || 0) - (Date.parse(bookingStart(a) || "") || 0))
|
|
103
|
+
.slice(0, 3)
|
|
104
|
+
.map(bookingRow);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function probe(s: S): Promise<S> {
|
|
108
|
+
const profile = await loadMemberProfile(copyParam("bookingAccount.guestDetail", "Sign in to book services and see your booking history."));
|
|
109
|
+
let activityRows: AccountActivityRow[] = [];
|
|
110
|
+
if (profile.isMember) {
|
|
111
|
+
try {
|
|
112
|
+
activityRows = await bookingRows(profile.memberEmail);
|
|
113
|
+
} catch {
|
|
114
|
+
activityRows = [];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return derive({
|
|
118
|
+
...s,
|
|
119
|
+
status: "ready",
|
|
120
|
+
isMember: profile.isMember,
|
|
121
|
+
identityLine: profile.identityLine,
|
|
122
|
+
detailLine: profile.detailLine,
|
|
123
|
+
memberName: profile.memberName,
|
|
124
|
+
memberEmail: profile.memberEmail,
|
|
125
|
+
memberImage: profile.memberImage,
|
|
126
|
+
memberInitials: profile.memberInitials,
|
|
127
|
+
hasMemberImage: profile.hasMemberImage,
|
|
128
|
+
noMemberImage: profile.noMemberImage,
|
|
129
|
+
email: profile.memberEmail || s.email,
|
|
130
|
+
message: "",
|
|
131
|
+
activityRows,
|
|
132
|
+
activityTitle: copyParam("bookingAccount.activityTitle", "Recent bookings"),
|
|
133
|
+
activitySummary: activityRows.length
|
|
134
|
+
? `${activityRows.length} recent ${activityRows.length === 1 ? "booking" : "bookings"}`
|
|
135
|
+
: copyParam("bookingAccount.activityHint", "Bookings are loaded from Wix Bookings."),
|
|
136
|
+
activityEmptyText: profile.isMember
|
|
137
|
+
? copyParam("bookingAccount.activityEmptyMember", "No bookings for this member yet.")
|
|
138
|
+
: copyParam("bookingAccount.activityEmptyGuest", "Sign in to see bookings."),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function optimisticMember(s: S, email: string): S {
|
|
143
|
+
return derive({
|
|
144
|
+
...s,
|
|
145
|
+
status: "ready",
|
|
146
|
+
isMember: true,
|
|
147
|
+
identityLine: copyParam("bookingAccount.signedIn", "Signed in"),
|
|
148
|
+
detailLine: email,
|
|
149
|
+
memberName: email,
|
|
150
|
+
memberEmail: email,
|
|
151
|
+
memberImage: "",
|
|
152
|
+
memberInitials: "M",
|
|
153
|
+
hasMemberImage: false,
|
|
154
|
+
noMemberImage: true,
|
|
155
|
+
email,
|
|
156
|
+
password: "",
|
|
157
|
+
firstName: "",
|
|
158
|
+
lastName: "",
|
|
159
|
+
isRegistering: false,
|
|
160
|
+
message: "",
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const svc = defineService<S, {
|
|
165
|
+
load: (s: S, arg?: unknown) => Promise<S>;
|
|
166
|
+
refresh: (s: S, arg?: unknown) => Promise<S>;
|
|
167
|
+
setEmail: (s: S, arg?: unknown) => S;
|
|
168
|
+
setPassword: (s: S, arg?: unknown) => S;
|
|
169
|
+
setFirstName: (s: S, arg?: unknown) => S;
|
|
170
|
+
setLastName: (s: S, arg?: unknown) => S;
|
|
171
|
+
showRegister: (s: S) => S;
|
|
172
|
+
showSignIn: (s: S) => S;
|
|
173
|
+
signIn: (s: S) => Promise<S>;
|
|
174
|
+
register: (s: S) => Promise<S>;
|
|
175
|
+
signOut: (s: S) => Promise<S>;
|
|
176
|
+
askSignOut: (s: S) => S;
|
|
177
|
+
cancelSignOut: (s: S) => S;
|
|
178
|
+
openForMember: (s: S, arg?: unknown) => Promise<S>;
|
|
179
|
+
}>("himiBookingAccount", {
|
|
180
|
+
// An open sign-out confirm is this run's: a cold start never re-opens the dialog, and the flag
|
|
181
|
+
// is never written to the device.
|
|
182
|
+
notHydrated: ["confirmingSignOut", "notConfirmingSignOut"],
|
|
183
|
+
notPersisted: ["confirmingSignOut", "notConfirmingSignOut"],
|
|
184
|
+
state: derive({
|
|
185
|
+
status: "loading",
|
|
186
|
+
isMember: false,
|
|
187
|
+
notMember: true,
|
|
188
|
+
identityLine: "",
|
|
189
|
+
detailLine: "",
|
|
190
|
+
memberName: "",
|
|
191
|
+
memberEmail: "",
|
|
192
|
+
memberImage: "",
|
|
193
|
+
memberInitials: "M",
|
|
194
|
+
hasMemberImage: false,
|
|
195
|
+
noMemberImage: true,
|
|
196
|
+
authTitle: "Welcome",
|
|
197
|
+
authBody: "Sign in to book services and see your history.",
|
|
198
|
+
email: "",
|
|
199
|
+
password: "",
|
|
200
|
+
firstName: "",
|
|
201
|
+
lastName: "",
|
|
202
|
+
message: "",
|
|
203
|
+
isLoading: true,
|
|
204
|
+
notLoading: false,
|
|
205
|
+
isRegistering: false,
|
|
206
|
+
notRegistering: true,
|
|
207
|
+
activityTitle: "Recent bookings",
|
|
208
|
+
activitySummary: "",
|
|
209
|
+
activityRows: [],
|
|
210
|
+
activityEmptyText: "No bookings for this member yet.",
|
|
211
|
+
hasActivity: false,
|
|
212
|
+
noActivity: true,
|
|
213
|
+
servicesScreenId: "himi_services",
|
|
214
|
+
bookingsScreenId: "himi_bookings",
|
|
215
|
+
}),
|
|
216
|
+
actions: {
|
|
217
|
+
load: (s, arg) => { stashCopy(arg); return probe(s); },
|
|
218
|
+
refresh: (s, arg) => { stashCopy(arg); return probe(s); },
|
|
219
|
+
setEmail: (s, arg) => derive({ ...s, email: strOf(arg), message: "" }),
|
|
220
|
+
setPassword: (s, arg) => derive({ ...s, password: strOf(arg), message: "" }),
|
|
221
|
+
setFirstName: (s, arg) => derive({ ...s, firstName: strOf(arg), message: "" }),
|
|
222
|
+
setLastName: (s, arg) => derive({ ...s, lastName: strOf(arg), message: "" }),
|
|
223
|
+
showRegister: (s) => derive({ ...s, isRegistering: true, message: "" }),
|
|
224
|
+
showSignIn: (s) => derive({ ...s, isRegistering: false, message: "" }),
|
|
225
|
+
signIn: async (s) => {
|
|
226
|
+
if (!s.email || !s.password) return derive({ ...s, message: copyParam("bookingAccount.validationEmailPassword", "Enter your email and password.") });
|
|
227
|
+
try {
|
|
228
|
+
await dispatch("himi.wix.signInDirect", { email: s.email, password: s.password });
|
|
229
|
+
const next = await probe(optimisticMember(s, s.email));
|
|
230
|
+
return derive({ ...next, password: "", message: next.isMember ? "" : copyParam("bookingAccount.signInCheckDetails", "Sign in failed. Check your details.") });
|
|
231
|
+
} catch {
|
|
232
|
+
return derive({ ...s, password: "", message: copyParam("bookingAccount.signInFailed", "Sign in failed. Try again.") });
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
register: async (s) => {
|
|
236
|
+
if (!s.email || !s.password) return derive({ ...s, message: copyParam("bookingAccount.validationEmailPassword", "Enter your email and password.") });
|
|
237
|
+
try {
|
|
238
|
+
await dispatch("himi.wix.registerDirect", {
|
|
239
|
+
email: s.email,
|
|
240
|
+
password: s.password,
|
|
241
|
+
firstName: s.firstName,
|
|
242
|
+
lastName: s.lastName,
|
|
243
|
+
});
|
|
244
|
+
const next = await probe(optimisticMember(s, s.email));
|
|
245
|
+
return derive({ ...next, password: "", message: next.isMember ? "" : copyParam("bookingAccount.registerTrySignIn", "Account creation failed. Try signing in.") });
|
|
246
|
+
} catch {
|
|
247
|
+
return derive({ ...s, password: "", message: copyParam("bookingAccount.registerFailed", "Account creation failed. Try another email.") });
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
// A member-only screen from Profile (Salon & Spa's Messages row): a guest signs in first, and the
|
|
251
|
+
// screen opens on `returnTab` once signed in (_shared/member-screen.ts).
|
|
252
|
+
openForMember: async (s, arg): Promise<S> => {
|
|
253
|
+
const nav = await openMemberScreen(arg);
|
|
254
|
+
const current: S = svc.getState?.() ?? s;
|
|
255
|
+
return nav ? navigate(current, nav) : current;
|
|
256
|
+
},
|
|
257
|
+
signOut: async (s) => {
|
|
258
|
+
try { await dispatch("himi.wix.signOut"); } catch { /* ignore */ }
|
|
259
|
+
return probe({ ...s, isMember: false, isRegistering: false, message: "", confirmingSignOut: false });
|
|
260
|
+
},
|
|
261
|
+
// The confirm step before a sign-out (a destructive action always confirms).
|
|
262
|
+
askSignOut: (s) => derive({ ...s, confirmingSignOut: true }),
|
|
263
|
+
cancelSignOut: (s) => derive({ ...s, confirmingSignOut: false }),
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
svc.load();
|
|
267
|
+
export { svc };
|