@evelan/jexity-widget 0.14.0 → 0.16.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.
@@ -10,10 +10,15 @@ interface MagiclineFormMessageProps {
10
10
  * Three states driven by `message.magiclineForm.status`:
11
11
  * - `submitted` → read-only success card (NOT re-submittable).
12
12
  * - `failed` → read-only failure card.
13
- * - `open` → renders the interactive trial form. v1 is trial-only — the
13
+ * - `open` → renders the interactive form: `trialSessionBooking`
14
+ * TrialSessionBookingForm, `contractCreation` → ContractCreationForm. The
14
15
  * dormant `leadApplication` action is intentionally NOT routed (the file stays
15
16
  * on disk but is no longer imported).
16
17
  *
18
+ * `contractCreation` is routed for EVERY status (not just `open`): its submit
19
+ * action flips the row to `submitted` at claim time, so the form must stay
20
+ * mounted to render its own result envelope (customer number / terminal notice).
21
+ *
17
22
  * 409 retry: when a `slot_unavailable` 409 reopens the form (status flips
18
23
  * back to `open` while the linked submission carries `errorCode === "slot_unavailable"`),
19
24
  * the form shows a "pick another time" notice and reloads slots. This is detected
@@ -1 +1 @@
1
- {"version":3,"file":"MagiclineFormMessage.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/components/MagiclineFormMessage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAExE,UAAU,yBAAyB;IACjC,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,CAAA;IAC7B,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,yBAAyB,uCAyEhG"}
1
+ {"version":3,"file":"MagiclineFormMessage.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/components/MagiclineFormMessage.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAExE,UAAU,yBAAyB;IACjC,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,CAAA;IAC7B,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,yBAAyB,uCAgGhG"}
@@ -0,0 +1,34 @@
1
+ import type { Id } from '@repo/backend/convex/_generated/dataModel';
2
+ interface ContractCreationFormProps {
3
+ formMessageId: Id<'conversations'>;
4
+ sessionId: Id<'contactSessions'>;
5
+ visitorId: string;
6
+ projectId: Id<'projects'>;
7
+ /**
8
+ * The reactive form-row status. The submit flips this to `submitted` at claim
9
+ * time, so the LIVE result envelope (held in component state) always wins; this
10
+ * is only consulted when there is no live result — i.e. a resumed/cold session
11
+ * landing on an already-terminal row.
12
+ */
13
+ formStatus: 'open' | 'submitted' | 'failed';
14
+ }
15
+ /**
16
+ * Inline Magicline membership-signup STEP WIZARD. Renders the contract-creation
17
+ * flow as internal steps inside ONE chat card:
18
+ *
19
+ * Offer → Personal → Address → Payment → Review
20
+ *
21
+ * All form state (offers, selected term, personal/address/payment fields,
22
+ * consents, server preview) lives in `useContractCreationState`, mounted ONCE
23
+ * here above the step switch so navigating steps never refetches offers.
24
+ *
25
+ * The submit action is synchronous and authoritative: it claims the submission
26
+ * (which flips the form row to `submitted` reactively), then dispatches and
27
+ * returns a result envelope. Because the reactive flip would otherwise unmount
28
+ * this form mid-await, the component owns its OWN `submitResult` and renders the
29
+ * success / terminal UI from the returned envelope — `MagiclineFormMessage`
30
+ * keeps this form mounted while it owns a live result.
31
+ */
32
+ export declare function ContractCreationForm({ formMessageId, sessionId, visitorId, projectId, formStatus, }: ContractCreationFormProps): import("preact").JSX.Element;
33
+ export {};
34
+ //# sourceMappingURL=ContractCreationForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractCreationForm.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chat/components/magicline/ContractCreationForm.tsx"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAuBnE,UAAU,yBAAyB;IACjC,aAAa,EAAE,EAAE,CAAC,eAAe,CAAC,CAAA;IAClC,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,CAAA;IACzB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;CAC5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,aAAa,EACb,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,GACX,EAAE,yBAAyB,gCAgjB3B"}
@@ -1,3 +1,4 @@
1
+ import type { WidgetStrings } from '../../../../i18n/locales/en';
1
2
  export declare function isValidEmail(value: string): boolean;
2
3
  /**
3
4
  * Whole-years age from an ISO `YYYY-MM-DD` date-of-birth string at `now`.
@@ -20,4 +21,93 @@ export declare function todayIsoDate(now?: Date): string;
20
21
  * default.
21
22
  */
22
23
  export declare function resolvePrivacyUrl(): string;
24
+ /** Strip whitespace and uppercase — the canonical IBAN form for validation. */
25
+ export declare function normalizeIban(raw: string): string;
26
+ /**
27
+ * Client-side IBAN check mirroring the backend `validateIban` exactly:
28
+ * 1. length against the per-country table (or the generic 15–34 bound);
29
+ * 2. the ISO 13616 mod-97 check (move first 4 chars to the end, expand
30
+ * letters A=10..Z=35, chunked reduction to stay in safe-integer range).
31
+ *
32
+ * Pure UX gate — the backend re-validates. The raw IBAN is never logged here.
33
+ */
34
+ export declare function isValidIban(raw: string): boolean;
35
+ /**
36
+ * Mask an IBAN for the review summary: show the first 4 and last 4 characters
37
+ * of the normalized value, bullets in between, regrouped into 4-char blocks.
38
+ * e.g. `DE89 3704 0044 0532 0130 00` → `DE89 •••• •••• •••• •••• 00`. Used for
39
+ * display ONLY — the raw IBAN never leaves component memory through this path.
40
+ */
41
+ export declare function maskIban(raw: string): string;
42
+ /**
43
+ * Format a Magicline money amount with its currency code, localised to the
44
+ * widget locale. Magicline rate-bundle / flat-fee prices are decimal MAJOR
45
+ * units (e.g. `29` → "29,00 €"), so the value is rendered as-is — never divided.
46
+ * Falls back to a bare numeric string when the currency code is unsupported by
47
+ * the runtime's `Intl`.
48
+ */
49
+ export declare function formatContractMoney(amount: number, currencyCode: string, widgetLocale: 'en' | 'de'): string;
50
+ /**
51
+ * Localised "{value} {unit}" period label, e.g. "12 months" / "12 Monate". The
52
+ * Magicline period unit is an uppercase enum (`DAY` / `WEEK` / `MONTH` / `YEAR`);
53
+ * unknown units fall back to a lowercased raw unit so the label degrades safely.
54
+ */
55
+ export declare function formatContractPeriod(value: number, unit: string, widgetLocale: 'en' | 'de'): string;
56
+ /**
57
+ * Format an ISO date (`YYYY-MM-DD` or a full datetime) for display in the
58
+ * review summary, localised to the widget locale. Falls back to the raw value
59
+ * when unparseable so a malformed start date never blanks the summary row.
60
+ */
61
+ export declare function formatContractDate(isoDate: string, widgetLocale: 'en' | 'de'): string;
62
+ /**
63
+ * Recurring-price frequency suffix for a rate-bundle term price, e.g.
64
+ * "per week" / "pro Woche" (value === 1) or "every 3 weeks" / "alle 3 Wochen"
65
+ * (value > 1). Used as a suffix after a formatted money amount in offer cards
66
+ * and the review base-price line.
67
+ *
68
+ * Supported units: DAY / WEEK / MONTH / YEAR (Magicline uppercase enum).
69
+ * Unknown units fall back to a lowercased raw unit so the label degrades safely.
70
+ */
71
+ export declare function formatPaymentFrequency(value: number, unit: string, widgetLocale: 'en' | 'de'): string;
72
+ /**
73
+ * Formatted price label for an optional module, combining the money amount with
74
+ * the appropriate frequency or type suffix. Mirrors Fit Inn's formatPriceLabel.
75
+ *
76
+ * paymentFrequencyType values:
77
+ * "TERM_BASED" → "{money} per term"
78
+ * "RECURRING" → "{money} " + formatPaymentFrequency(1, recurringUnit)
79
+ * "NON_RECURRING" → "{money} one-time"
80
+ * "MONTH_DAY" → "{money} one-time"
81
+ * "FREE" → "included"
82
+ * null / other → bare money string
83
+ */
84
+ export declare function formatModulePrice(amount: number, currencyCode: string, paymentFrequencyType: string | null, recurringUnit: string | null, widgetLocale: 'en' | 'de'): string;
85
+ /**
86
+ * Formatted voucher discount label. PERCENTAGE type produces "-{value}%";
87
+ * AMOUNT type produces "-{formatted money}" via `formatContractMoney`.
88
+ *
89
+ * Used in the Review step to show the active voucher's saving alongside the
90
+ * discounted base price.
91
+ */
92
+ export declare function formatVoucherDiscount(discountValue: number, discountType: 'AMOUNT' | 'PERCENTAGE', currencyCode: string, locale: 'en' | 'de'): string;
93
+ /**
94
+ * Localize a raw Magicline flat-fee name. When the normalized name is in the
95
+ * known-fee map, the locale string for that key is returned. Otherwise the
96
+ * original raw name is returned unchanged so unmapped fees degrade safely.
97
+ */
98
+ export declare function localizeFeeName(rawName: string, t: WidgetStrings): string;
99
+ /**
100
+ * Renewal label for an optional module extension type. Returns an empty string
101
+ * when the type produces no visible renewal line (SUBSEQUENT_RATE_DETAIL, null).
102
+ *
103
+ * extensionType values:
104
+ * "NONE" → "No automatic renewal"
105
+ * "TERM_EXTENSION" → "Renewal: {n} {unit}" (via the period table)
106
+ * "SUBSEQUENT_RATE_DETAIL"→ "" (no line rendered)
107
+ * null → "" (no line rendered)
108
+ */
109
+ export declare function formatModuleRenewal(extensionType: string | null, termExtension: {
110
+ value: number;
111
+ unit: string;
112
+ } | null, widgetLocale: 'en' | 'de'): string;
23
113
  //# sourceMappingURL=formUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chat/components/magicline/formUtils.ts"],"names":[],"mappings":"AAKA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,GAAG,IAAI,CA8BrF;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,GAAG,GAAE,IAAiB,GAAG,MAAM,CAK3D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAG1C"}
1
+ {"version":3,"file":"formUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chat/components/magicline/formUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAQhE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,GAAG,IAAI,CA8BrF;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,GAAG,GAAE,IAAiB,GAAG,MAAM,CAK3D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAG1C;AA4BD,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAgChD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAS5C;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,IAAI,GAAG,IAAI,GACxB,MAAM,CAUR;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,IAAI,GAAG,IAAI,GACxB,MAAM,CAcR;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAWrF;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,IAAI,GAAG,IAAI,GACxB,MAAM,CAuBR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,oBAAoB,EAAE,MAAM,GAAG,IAAI,EACnC,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,YAAY,EAAE,IAAI,GAAG,IAAI,GACxB,MAAM,CAmBR;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,QAAQ,GAAG,YAAY,EACrC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,IAAI,GAAG,IAAI,GAClB,MAAM,CAKR;AAeD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,GAAG,MAAM,CAOzE;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,aAAa,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,EACrD,YAAY,EAAE,IAAI,GAAG,IAAI,GACxB,MAAM,CAYR"}
@@ -0,0 +1,250 @@
1
+ import { type ContractFlatFee, type ContractPeriod, type ContractPreviewModule, type ContractVolume, type ContractVoucher, type RateBundleTermCard } from '../../hooks/useMagicline';
2
+ import type { Id } from '@repo/backend/convex/_generated/dataModel';
3
+ /**
4
+ * Offers lifecycle. `empty` (healthy, zero eligible terms) is split from
5
+ * `error` (unavailable / network rejection) so the Offer step shows a friendly
6
+ * no-offers message on `empty` and a Retry affordance on `error`.
7
+ */
8
+ export type OffersState = {
9
+ phase: 'loading';
10
+ } | {
11
+ phase: 'ready';
12
+ terms: RateBundleTermCard[];
13
+ allowVoucherCodes: boolean;
14
+ } | {
15
+ phase: 'empty';
16
+ } | {
17
+ phase: 'error';
18
+ };
19
+ /**
20
+ * Server-resolved pricing for the Review step. Fetched on entering Review and
21
+ * re-fetched after a `price_changed` outcome. The `fingerprint` is replayed to
22
+ * the submit action so the backend can confirm the price the visitor saw.
23
+ */
24
+ export interface ContractPricing {
25
+ basePrice: number;
26
+ preUseCharge: number;
27
+ currencyCode: string;
28
+ flatFees: ContractFlatFee[];
29
+ modules: ContractPreviewModule[];
30
+ contractVolume: ContractVolume | null;
31
+ startDate: string;
32
+ /** Payment frequency of the revalidated term; renders the base-price period. */
33
+ paymentFrequency: ContractPeriod;
34
+ fingerprint: string;
35
+ }
36
+ /**
37
+ * Preview lifecycle. `idle` is the pre-Review state (no fetch yet). A non-ok
38
+ * preview status is surfaced as the `error` phase carrying the status code so
39
+ * the view can route an `offer_unavailable` back to the Offer step.
40
+ */
41
+ export type PreviewState = {
42
+ phase: 'idle';
43
+ } | {
44
+ phase: 'loading';
45
+ } | {
46
+ phase: 'reloading';
47
+ pricing: ContractPricing;
48
+ } | {
49
+ phase: 'ready';
50
+ pricing: ContractPricing;
51
+ } | {
52
+ phase: 'error';
53
+ code: 'consent_required' | 'invalid_fields' | 'offer_unavailable' | 'unavailable';
54
+ };
55
+ /** Personal detail fields — all required by the backend. */
56
+ export interface ContractPersonalFields {
57
+ firstName: string;
58
+ lastName: string;
59
+ email: string;
60
+ dateOfBirth: string;
61
+ gender: string;
62
+ phone: string;
63
+ }
64
+ /** Address fields — country is a static "Deutschland"/"Germany", not collected. */
65
+ export interface ContractAddressFields {
66
+ street: string;
67
+ houseNumber: string;
68
+ zipCode: string;
69
+ city: string;
70
+ }
71
+ /**
72
+ * Payment fields. `accountHolderTouched` tracks whether the visitor has edited
73
+ * the account holder so the firstname+lastname prefill only auto-fills once and
74
+ * never clobbers a manual edit. The IBAN lives ONLY here, in memory — it is
75
+ * never persisted to sessionStorage and never logged.
76
+ */
77
+ export interface ContractPaymentFields {
78
+ accountHolder: string;
79
+ accountHolderTouched: boolean;
80
+ iban: string;
81
+ }
82
+ /** Consent flags — both must be accepted before submit. */
83
+ export interface ContractConsentFields {
84
+ privacy: boolean;
85
+ sepa: boolean;
86
+ }
87
+ export interface ContractFormFields {
88
+ termId: number | null;
89
+ /** Chosen paid optional-module ids for the current term. */
90
+ selectedModuleIds: number[];
91
+ /**
92
+ * Acceptance of required confirmations, keyed by ackKey. Carries both contract
93
+ * text-block acknowledgements and selected-module consents — a single source
94
+ * of truth for every gating tick across the wizard.
95
+ */
96
+ acknowledgedBlocks: Record<string, boolean>;
97
+ personal: ContractPersonalFields;
98
+ address: ContractAddressFields;
99
+ payment: ContractPaymentFields;
100
+ consents: ContractConsentFields;
101
+ }
102
+ /**
103
+ * Lifecycle status for an in-progress or resolved voucher application.
104
+ * - `idle` — no voucher attempt yet (or after CLEAR_VOUCHER).
105
+ * - `applying` — backend call in-flight.
106
+ * - `applied` — a valid voucher is active and its discount shows in the quote.
107
+ * - `invalid` — the code was rejected by the backend (`voucher_invalid`).
108
+ * - `disabled` — vouchers are turned off for this studio (`voucher_disabled`).
109
+ */
110
+ export type VoucherStatus = 'idle' | 'applying' | 'applied' | 'invalid' | 'disabled';
111
+ /**
112
+ * All mutable voucher fields held alongside the contract form. Kept in a
113
+ * dedicated reducer so voucher concerns are isolated and easy to delete.
114
+ *
115
+ * `voucherUnavailable` is session-sticky: once the backend returns
116
+ * `voucher_disabled`, no further voucher UI is shown for this session.
117
+ *
118
+ * `voucherRequestId` is a monotonic counter bumped on every VOUCHER_APPLYING
119
+ * dispatch. VOUCHER_APPLIED checks payload.requestId === state.voucherRequestId
120
+ * before committing — any response carrying a stale id is silently discarded.
121
+ */
122
+ export interface VoucherState {
123
+ /** The string the visitor is currently typing into the voucher input. */
124
+ draftVoucherCode: string;
125
+ /**
126
+ * The code that was sent with the last successful preview fetch. Only set
127
+ * when `voucherStatus === 'applied'`; cleared on any invalidation.
128
+ */
129
+ appliedVoucherCode: string | null;
130
+ /**
131
+ * The parsed voucher block from the last successful apply response. Mirrors
132
+ * `ContractVoucher` from `useMagicline` (excludes null — null means cleared).
133
+ */
134
+ appliedVoucher: Exclude<ContractVoucher, null> | null;
135
+ /** Current lifecycle status of the voucher attempt. */
136
+ voucherStatus: VoucherStatus;
137
+ /**
138
+ * Monotonic counter. Bumped by VOUCHER_APPLYING; VOUCHER_APPLIED only commits
139
+ * when the payload requestId matches this value (stale-response discard).
140
+ */
141
+ voucherRequestId: number;
142
+ /**
143
+ * Session-sticky flag. Set to `true` on VOUCHER_DISABLED and never cleared.
144
+ * The UI uses this to permanently hide the voucher entry once the studio has
145
+ * disabled vouchers.
146
+ */
147
+ voucherUnavailable: boolean;
148
+ }
149
+ export interface UseContractCreationStateOptions {
150
+ sessionId: Id<'contactSessions'>;
151
+ visitorId: string;
152
+ }
153
+ export interface ContractCreationState {
154
+ fields: ContractFormFields;
155
+ offersState: OffersState;
156
+ previewState: PreviewState;
157
+ /** The currently selected term card (or null when none is chosen). */
158
+ selectedTerm: RateBundleTermCard | null;
159
+ /**
160
+ * ackKeys that MUST be acknowledged before submit for the current term:
161
+ * required text blocks ∪ the consents of SELECTED modules that carry one
162
+ * ∪ any voucher text-block acks (when a voucher is applied).
163
+ */
164
+ requiredAckKeys: string[];
165
+ /** True when every `requiredAckKeys` entry is currently acknowledged. */
166
+ allAcknowledged: boolean;
167
+ /** Current voucher lifecycle status. */
168
+ voucherStatus: VoucherStatus;
169
+ /** The string currently typed into the voucher input. */
170
+ draftVoucherCode: string;
171
+ /** The code tied to the currently displayed quote (set when `voucherStatus === 'applied'`). */
172
+ appliedVoucherCode: string | null;
173
+ /**
174
+ * Parsed voucher block from the last successful apply. Non-null only when
175
+ * `voucherStatus === 'applied'`.
176
+ */
177
+ appliedVoucher: Exclude<ContractVoucher, null> | null;
178
+ /**
179
+ * Session-sticky: true once the backend has returned `voucher_disabled`.
180
+ * The UI hides the voucher section permanently when this is true.
181
+ */
182
+ voucherUnavailable: boolean;
183
+ setTermId: (termId: number) => void;
184
+ setPersonal: (key: keyof ContractPersonalFields, value: string) => void;
185
+ setAddress: (key: keyof ContractAddressFields, value: string) => void;
186
+ /**
187
+ * Add/remove a paid optional module from the current term. Pass the module's
188
+ * consent ackKey so deselecting clears its acknowledgement in one dispatch.
189
+ */
190
+ toggleModule: (moduleId: number, selected: boolean, consentAckKey?: string) => void;
191
+ /** Set the acknowledgement for a contract block or module consent by ackKey. */
192
+ setBlockAck: (ackKey: string, value: boolean) => void;
193
+ setAccountHolder: (value: string) => void;
194
+ setIban: (value: string) => void;
195
+ setConsent: (key: keyof ContractConsentFields, value: boolean) => void;
196
+ clearIban: () => void;
197
+ /** Clears the selected term so a stale selection does not survive an offer refetch. */
198
+ clearTermId: () => void;
199
+ /** Re-run the offers fetch (Retry button + `offer_unavailable` recovery). */
200
+ refetchOffers: () => void;
201
+ /** Fetch the server pricing for the selected term (called entering Review). */
202
+ fetchPreview: () => void;
203
+ /** Reset the preview back to idle (e.g. when leaving Review). */
204
+ resetPreview: () => void;
205
+ /** Update the voucher input field. Clears any currently applied voucher. */
206
+ setVoucherDraft: (value: string) => void;
207
+ /**
208
+ * Signal that the voucher backend call is starting. Bumps `voucherRequestId`
209
+ * to enable stale-response discard for any concurrent in-flight request.
210
+ * Returns the new requestId so the caller can include it in the VOUCHER_APPLIED
211
+ * dispatch.
212
+ */
213
+ beginVoucherApply: () => number;
214
+ /**
215
+ * Commit a successful voucher response. Only takes effect if `requestId`
216
+ * matches the latest (stale responses are silently discarded). Updates
217
+ * `previewState.pricing` to the voucher-inclusive pricing from the apply
218
+ * response (fingerprint + discounted amounts) and seeds voucher ackKeys into
219
+ * `acknowledgedBlocks` as unticked.
220
+ */
221
+ commitVoucherApplied: (options: {
222
+ requestId: number;
223
+ voucher: Exclude<ContractVoucher, null>;
224
+ appliedCode: string;
225
+ voucherAckKeys: string[];
226
+ /** Voucher-inclusive pricing from the same getContractPreview response. */
227
+ pricing: ContractPricing;
228
+ }) => void;
229
+ /** Mark the current code as invalid and clear the applied state. */
230
+ markVoucherInvalid: () => void;
231
+ /** Mark vouchers as disabled for this session (session-sticky). */
232
+ markVoucherDisabled: () => void;
233
+ /** Remove the applied voucher and revert to a no-voucher quote. */
234
+ clearVoucher: () => void;
235
+ }
236
+ /**
237
+ * Single fetch-once container for the membership-signup wizard.
238
+ *
239
+ * - Offers are fetched ONCE on mount and again on `refetchOffers` (Retry /
240
+ * `offer_unavailable` recovery). A `offersKey` counter drives the effect.
241
+ * - The preview is NOT fetched until `fetchPreview` runs (entering Review). A
242
+ * `previewKey` counter re-runs it for `price_changed` recovery.
243
+ * - The account holder auto-prefills from firstname+lastname the first time both
244
+ * are present and the field is still untouched.
245
+ *
246
+ * The IBAN is held only in this hook's in-memory reducer state — it is never
247
+ * written to sessionStorage and never logged.
248
+ */
249
+ export declare function useContractCreationState({ sessionId, visitorId, }: UseContractCreationStateOptions): ContractCreationState;
250
+ //# sourceMappingURL=useContractCreationState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContractCreationState.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chat/components/magicline/useContractCreationState.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAE1B,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAEnE;;;;GAIG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,G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