@cimplify/sdk 0.89.0 → 0.92.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/advanced.d.mts +3 -3
- package/dist/advanced.d.ts +3 -3
- package/dist/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-JHJTXAPS.js → chunk-3MBMIEWT.js} +4 -4
- package/dist/{chunk-DENWOZEA.mjs → chunk-3XD2FVP4.mjs} +163 -43
- package/dist/{chunk-M4ALCELT.mjs → chunk-54H2YYIW.mjs} +2 -2
- package/dist/{chunk-T2CJ67QV.js → chunk-DCRN67NO.js} +201 -78
- package/dist/{chunk-T7Z25EY4.js → chunk-HKN3YG76.js} +84 -0
- package/dist/{chunk-GHFDYM5K.js → chunk-IVJEUGWF.js} +10 -1
- package/dist/{chunk-ROBTTS3Q.js → chunk-OAHSF542.js} +40 -1
- package/dist/{chunk-APBLFZ2I.mjs → chunk-PYBFTMHI.mjs} +40 -1
- package/dist/{chunk-OZDDHSIB.mjs → chunk-RRBY35TJ.mjs} +80 -1
- package/dist/{chunk-ZU4ZRYUR.mjs → chunk-T7LDBZZZ.mjs} +10 -1
- package/dist/chunk-U4MW6PYU.mjs +23 -0
- package/dist/chunk-XREIZ56K.js +26 -0
- package/dist/{client-CqZgdUtw.d.ts → client-BQbSKlHS.d.mts} +165 -11
- package/dist/{client-CAY2NbRG.d.mts → client-Bw4HtLP1.d.mts} +2 -2
- package/dist/{client-D8ZFs-sq.d.mts → client-CeW3acve.d.ts} +165 -11
- package/dist/{client-CUbwb6Om.d.ts → client-Otzv_rgP.d.ts} +2 -2
- package/dist/{index-CmWOz9bi.d.mts → index-CmIboQjl.d.mts} +3 -3
- package/dist/{index-Bc5qUxAt.d.ts → index-DgoRwz8l.d.ts} +3 -3
- package/dist/index.d.mts +49 -7
- package/dist/index.d.ts +49 -7
- package/dist/index.js +109 -82
- package/dist/index.mjs +11 -5
- package/dist/mock/cli.mjs +61 -1
- package/dist/mock/library.js +61 -1
- package/dist/mock/library.mjs +61 -1
- package/dist/mock/msw.js +61 -1
- package/dist/mock/msw.mjs +61 -1
- package/dist/{payment-Dcgb9n1n.d.mts → payment-BFtLqiG2.d.mts} +1 -1
- package/dist/{payment-Xq0WDZXh.d.ts → payment-Cq8FT1B6.d.ts} +1 -1
- package/dist/{price-DAAjKgAp.d.ts → price-DaFXT-Lr.d.ts} +1 -1
- package/dist/{price--Ma_WO5_.d.mts → price-DleDWk_s.d.mts} +1 -1
- package/dist/{product-BakHcsP2.d.ts → product-bZ8G5Z8D.d.mts} +95 -2
- package/dist/{product-BakHcsP2.d.mts → product-bZ8G5Z8D.d.ts} +95 -2
- package/dist/react.d.mts +471 -8
- package/dist/react.d.ts +471 -8
- package/dist/react.js +2787 -402
- package/dist/react.mjs +2699 -337
- package/dist/{server-Bk_hlefX.d.mts → server-D-iK-bNt.d.mts} +8 -1
- package/dist/{server-Bei5lBrc.d.ts → server-DwsY9hlX.d.ts} +8 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +7 -7
- package/dist/server.mjs +2 -2
- package/dist/styles.css +1 -1
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +3 -2
- package/dist/testing/msw.mjs +2 -1
- package/dist/testing/suite.d.mts +6 -6
- package/dist/testing/suite.d.ts +6 -6
- package/dist/testing/suite.js +24 -23
- package/dist/testing/suite.mjs +5 -4
- package/dist/testing.d.mts +5 -5
- package/dist/testing.d.ts +5 -5
- package/dist/testing.js +80 -79
- package/dist/testing.mjs +6 -5
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/package.json +4 -1
- package/registry/booking-page.json +1 -1
- package/registry/chat-widget.json +1 -1
- package/registry/customer-input-fields.json +1 -1
- package/registry/date-slot-picker.json +1 -1
- package/registry/product-customizer.json +1 -1
- package/registry/rental-service-card.json +1 -1
package/dist/testing/suite.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-54H2YYIW.mjs';
|
|
2
|
+
import '../chunk-PYBFTMHI.mjs';
|
|
3
|
+
import '../chunk-U4MW6PYU.mjs';
|
|
4
|
+
import '../chunk-3XD2FVP4.mjs';
|
|
5
|
+
import '../chunk-T7LDBZZZ.mjs';
|
|
5
6
|
import '../chunk-KFLGQGMC.mjs';
|
|
6
7
|
import '../chunk-K5EN2W2Q.mjs';
|
|
7
8
|
import '../chunk-3G6RQLXK.mjs';
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { $ZodType } from 'zod/v4/core';
|
|
3
|
-
export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-
|
|
4
|
-
import './client-
|
|
5
|
-
import './product-
|
|
6
|
-
import './payment-
|
|
7
|
-
import './server-
|
|
3
|
+
export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-Bw4HtLP1.mjs';
|
|
4
|
+
import './client-BQbSKlHS.mjs';
|
|
5
|
+
import './product-bZ8G5Z8D.mjs';
|
|
6
|
+
import './payment-BFtLqiG2.mjs';
|
|
7
|
+
import './server-D-iK-bNt.mjs';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { $ZodType } from 'zod/v4/core';
|
|
3
|
-
export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-
|
|
4
|
-
import './client-
|
|
5
|
-
import './product-
|
|
6
|
-
import './payment-
|
|
7
|
-
import './server-
|
|
3
|
+
export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-Otzv_rgP.js';
|
|
4
|
+
import './client-CeW3acve.js';
|
|
5
|
+
import './product-bZ8G5Z8D.js';
|
|
6
|
+
import './payment-Cq8FT1B6.js';
|
|
7
|
+
import './server-DwsY9hlX.js';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
package/dist/testing.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
3
|
+
var chunk3MBMIEWT_js = require('./chunk-3MBMIEWT.js');
|
|
4
|
+
require('./chunk-OAHSF542.js');
|
|
5
|
+
require('./chunk-XREIZ56K.js');
|
|
6
|
+
require('./chunk-DCRN67NO.js');
|
|
7
|
+
require('./chunk-IVJEUGWF.js');
|
|
7
8
|
require('./chunk-PTPOQVXS.js');
|
|
8
9
|
require('./chunk-AETVRBKI.js');
|
|
9
10
|
require('./chunk-OWW5GUSB.js');
|
|
10
11
|
var zod = require('zod');
|
|
11
12
|
|
|
12
13
|
var PUBLIC_SCHEMAS = {
|
|
13
|
-
Brand:
|
|
14
|
-
AddItemPayload:
|
|
15
|
-
Cart:
|
|
16
|
-
CartItem:
|
|
17
|
-
CartPricing:
|
|
18
|
-
CheckoutBody:
|
|
19
|
-
CheckoutResponse:
|
|
20
|
-
VariantInfo:
|
|
14
|
+
Brand: chunk3MBMIEWT_js.BrandSchema,
|
|
15
|
+
AddItemPayload: chunk3MBMIEWT_js.AddItemPayloadSchema,
|
|
16
|
+
Cart: chunk3MBMIEWT_js.CartSchema,
|
|
17
|
+
CartItem: chunk3MBMIEWT_js.CartItemSchema,
|
|
18
|
+
CartPricing: chunk3MBMIEWT_js.CartPricingSchema,
|
|
19
|
+
CheckoutBody: chunk3MBMIEWT_js.CheckoutBodySchema,
|
|
20
|
+
CheckoutResponse: chunk3MBMIEWT_js.CheckoutResponseSchema,
|
|
21
|
+
VariantInfo: chunk3MBMIEWT_js.VariantInfoSchema
|
|
21
22
|
};
|
|
22
23
|
function exportJsonSchemas() {
|
|
23
24
|
const out = {};
|
|
24
25
|
for (const [name, schema] of Object.entries(PUBLIC_SCHEMAS)) {
|
|
25
|
-
const meta =
|
|
26
|
-
const json = zod.z.toJSONSchema(schema, { metadata:
|
|
26
|
+
const meta = chunk3MBMIEWT_js.cimplifyRegistry.get(schema);
|
|
27
|
+
const json = zod.z.toJSONSchema(schema, { metadata: chunk3MBMIEWT_js.cimplifyRegistry });
|
|
27
28
|
if (meta) {
|
|
28
29
|
json.$id = meta.id;
|
|
29
30
|
json["x-cimplify-version"] = meta.version;
|
|
@@ -35,16 +36,16 @@ function exportJsonSchemas() {
|
|
|
35
36
|
function listRegisteredSchemas() {
|
|
36
37
|
const entries = [];
|
|
37
38
|
for (const schema of [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
chunk3MBMIEWT_js.BrandSchema,
|
|
40
|
+
chunk3MBMIEWT_js.AddItemPayloadSchema,
|
|
41
|
+
chunk3MBMIEWT_js.CartSchema,
|
|
42
|
+
chunk3MBMIEWT_js.CartItemSchema,
|
|
43
|
+
chunk3MBMIEWT_js.CartPricingSchema,
|
|
44
|
+
chunk3MBMIEWT_js.CheckoutBodySchema,
|
|
45
|
+
chunk3MBMIEWT_js.CheckoutResponseSchema,
|
|
46
|
+
chunk3MBMIEWT_js.VariantInfoSchema
|
|
46
47
|
]) {
|
|
47
|
-
const meta =
|
|
48
|
+
const meta = chunk3MBMIEWT_js.cimplifyRegistry.get(schema);
|
|
48
49
|
if (meta) entries.push({ schema, meta });
|
|
49
50
|
}
|
|
50
51
|
return entries;
|
|
@@ -52,227 +53,227 @@ function listRegisteredSchemas() {
|
|
|
52
53
|
|
|
53
54
|
Object.defineProperty(exports, "AddItemPayloadSchema", {
|
|
54
55
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
56
|
+
get: function () { return chunk3MBMIEWT_js.AddItemPayloadSchema; }
|
|
56
57
|
});
|
|
57
58
|
Object.defineProperty(exports, "AddOnDetailsSchema", {
|
|
58
59
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
60
|
+
get: function () { return chunk3MBMIEWT_js.AddOnDetailsSchema; }
|
|
60
61
|
});
|
|
61
62
|
Object.defineProperty(exports, "AddOnGroupDetailsSchema", {
|
|
62
63
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
64
|
+
get: function () { return chunk3MBMIEWT_js.AddOnGroupDetailsSchema; }
|
|
64
65
|
});
|
|
65
66
|
Object.defineProperty(exports, "AddOnInDetailsSchema", {
|
|
66
67
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
68
|
+
get: function () { return chunk3MBMIEWT_js.AddOnInDetailsSchema; }
|
|
68
69
|
});
|
|
69
70
|
Object.defineProperty(exports, "AddOnOptionDetailsSchema", {
|
|
70
71
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
72
|
+
get: function () { return chunk3MBMIEWT_js.AddOnOptionDetailsSchema; }
|
|
72
73
|
});
|
|
73
74
|
Object.defineProperty(exports, "AuthorizationTypeSchema", {
|
|
74
75
|
enumerable: true,
|
|
75
|
-
get: function () { return
|
|
76
|
+
get: function () { return chunk3MBMIEWT_js.AuthorizationTypeSchema; }
|
|
76
77
|
});
|
|
77
78
|
Object.defineProperty(exports, "BrandContactSchema", {
|
|
78
79
|
enumerable: true,
|
|
79
|
-
get: function () { return
|
|
80
|
+
get: function () { return chunk3MBMIEWT_js.BrandContactSchema; }
|
|
80
81
|
});
|
|
81
82
|
Object.defineProperty(exports, "BrandFaqSchema", {
|
|
82
83
|
enumerable: true,
|
|
83
|
-
get: function () { return
|
|
84
|
+
get: function () { return chunk3MBMIEWT_js.BrandFaqSchema; }
|
|
84
85
|
});
|
|
85
86
|
Object.defineProperty(exports, "BrandHeroSchema", {
|
|
86
87
|
enumerable: true,
|
|
87
|
-
get: function () { return
|
|
88
|
+
get: function () { return chunk3MBMIEWT_js.BrandHeroSchema; }
|
|
88
89
|
});
|
|
89
90
|
Object.defineProperty(exports, "BrandNavLinkSchema", {
|
|
90
91
|
enumerable: true,
|
|
91
|
-
get: function () { return
|
|
92
|
+
get: function () { return chunk3MBMIEWT_js.BrandNavLinkSchema; }
|
|
92
93
|
});
|
|
93
94
|
Object.defineProperty(exports, "BrandPolicyPageSchema", {
|
|
94
95
|
enumerable: true,
|
|
95
|
-
get: function () { return
|
|
96
|
+
get: function () { return chunk3MBMIEWT_js.BrandPolicyPageSchema; }
|
|
96
97
|
});
|
|
97
98
|
Object.defineProperty(exports, "BrandPolicySectionSchema", {
|
|
98
99
|
enumerable: true,
|
|
99
|
-
get: function () { return
|
|
100
|
+
get: function () { return chunk3MBMIEWT_js.BrandPolicySectionSchema; }
|
|
100
101
|
});
|
|
101
102
|
Object.defineProperty(exports, "BrandSchema", {
|
|
102
103
|
enumerable: true,
|
|
103
|
-
get: function () { return
|
|
104
|
+
get: function () { return chunk3MBMIEWT_js.BrandSchema; }
|
|
104
105
|
});
|
|
105
106
|
Object.defineProperty(exports, "BrandSocialSchema", {
|
|
106
107
|
enumerable: true,
|
|
107
|
-
get: function () { return
|
|
108
|
+
get: function () { return chunk3MBMIEWT_js.BrandSocialSchema; }
|
|
108
109
|
});
|
|
109
110
|
Object.defineProperty(exports, "BundleResolvedSchema", {
|
|
110
111
|
enumerable: true,
|
|
111
|
-
get: function () { return
|
|
112
|
+
get: function () { return chunk3MBMIEWT_js.BundleResolvedSchema; }
|
|
112
113
|
});
|
|
113
114
|
Object.defineProperty(exports, "BundleSelectionInputSchema", {
|
|
114
115
|
enumerable: true,
|
|
115
|
-
get: function () { return
|
|
116
|
+
get: function () { return chunk3MBMIEWT_js.BundleSelectionInputSchema; }
|
|
116
117
|
});
|
|
117
118
|
Object.defineProperty(exports, "CartItemSchema", {
|
|
118
119
|
enumerable: true,
|
|
119
|
-
get: function () { return
|
|
120
|
+
get: function () { return chunk3MBMIEWT_js.CartItemSchema; }
|
|
120
121
|
});
|
|
121
122
|
Object.defineProperty(exports, "CartPricingSchema", {
|
|
122
123
|
enumerable: true,
|
|
123
|
-
get: function () { return
|
|
124
|
+
get: function () { return chunk3MBMIEWT_js.CartPricingSchema; }
|
|
124
125
|
});
|
|
125
126
|
Object.defineProperty(exports, "CartSchema", {
|
|
126
127
|
enumerable: true,
|
|
127
|
-
get: function () { return
|
|
128
|
+
get: function () { return chunk3MBMIEWT_js.CartSchema; }
|
|
128
129
|
});
|
|
129
130
|
Object.defineProperty(exports, "CheckoutBodySchema", {
|
|
130
131
|
enumerable: true,
|
|
131
|
-
get: function () { return
|
|
132
|
+
get: function () { return chunk3MBMIEWT_js.CheckoutBodySchema; }
|
|
132
133
|
});
|
|
133
134
|
Object.defineProperty(exports, "CheckoutCustomerSchema", {
|
|
134
135
|
enumerable: true,
|
|
135
|
-
get: function () { return
|
|
136
|
+
get: function () { return chunk3MBMIEWT_js.CheckoutCustomerSchema; }
|
|
136
137
|
});
|
|
137
138
|
Object.defineProperty(exports, "CheckoutResponseSchema", {
|
|
138
139
|
enumerable: true,
|
|
139
|
-
get: function () { return
|
|
140
|
+
get: function () { return chunk3MBMIEWT_js.CheckoutResponseSchema; }
|
|
140
141
|
});
|
|
141
142
|
Object.defineProperty(exports, "ChosenPriceSchema", {
|
|
142
143
|
enumerable: true,
|
|
143
|
-
get: function () { return
|
|
144
|
+
get: function () { return chunk3MBMIEWT_js.ChosenPriceSchema; }
|
|
144
145
|
});
|
|
145
146
|
Object.defineProperty(exports, "CompositeResolvedSchema", {
|
|
146
147
|
enumerable: true,
|
|
147
|
-
get: function () { return
|
|
148
|
+
get: function () { return chunk3MBMIEWT_js.CompositeResolvedSchema; }
|
|
148
149
|
});
|
|
149
150
|
Object.defineProperty(exports, "CompositeSelectionInputSchema", {
|
|
150
151
|
enumerable: true,
|
|
151
|
-
get: function () { return
|
|
152
|
+
get: function () { return chunk3MBMIEWT_js.CompositeSelectionInputSchema; }
|
|
152
153
|
});
|
|
153
154
|
Object.defineProperty(exports, "CountryCodeSchema", {
|
|
154
155
|
enumerable: true,
|
|
155
|
-
get: function () { return
|
|
156
|
+
get: function () { return chunk3MBMIEWT_js.CountryCodeSchema; }
|
|
156
157
|
});
|
|
157
158
|
Object.defineProperty(exports, "CurrencyCodeSchema", {
|
|
158
159
|
enumerable: true,
|
|
159
|
-
get: function () { return
|
|
160
|
+
get: function () { return chunk3MBMIEWT_js.CurrencyCodeSchema; }
|
|
160
161
|
});
|
|
161
162
|
Object.defineProperty(exports, "CustomerInputValueSchema", {
|
|
162
163
|
enumerable: true,
|
|
163
|
-
get: function () { return
|
|
164
|
+
get: function () { return chunk3MBMIEWT_js.CustomerInputValueSchema; }
|
|
164
165
|
});
|
|
165
166
|
Object.defineProperty(exports, "DiscountDetailsSchema", {
|
|
166
167
|
enumerable: true,
|
|
167
|
-
get: function () { return
|
|
168
|
+
get: function () { return chunk3MBMIEWT_js.DiscountDetailsSchema; }
|
|
168
169
|
});
|
|
169
170
|
Object.defineProperty(exports, "IsoDateTimeSchema", {
|
|
170
171
|
enumerable: true,
|
|
171
|
-
get: function () { return
|
|
172
|
+
get: function () { return chunk3MBMIEWT_js.IsoDateTimeSchema; }
|
|
172
173
|
});
|
|
173
174
|
Object.defineProperty(exports, "LineTypeSchema", {
|
|
174
175
|
enumerable: true,
|
|
175
|
-
get: function () { return
|
|
176
|
+
get: function () { return chunk3MBMIEWT_js.LineTypeSchema; }
|
|
176
177
|
});
|
|
177
178
|
Object.defineProperty(exports, "LocaleSchema", {
|
|
178
179
|
enumerable: true,
|
|
179
|
-
get: function () { return
|
|
180
|
+
get: function () { return chunk3MBMIEWT_js.LocaleSchema; }
|
|
180
181
|
});
|
|
181
182
|
Object.defineProperty(exports, "MoneyLooseSchema", {
|
|
182
183
|
enumerable: true,
|
|
183
|
-
get: function () { return
|
|
184
|
+
get: function () { return chunk3MBMIEWT_js.MoneyLooseSchema; }
|
|
184
185
|
});
|
|
185
186
|
Object.defineProperty(exports, "MoneySchema", {
|
|
186
187
|
enumerable: true,
|
|
187
|
-
get: function () { return
|
|
188
|
+
get: function () { return chunk3MBMIEWT_js.MoneySchema; }
|
|
188
189
|
});
|
|
189
190
|
Object.defineProperty(exports, "NextActionSchema", {
|
|
190
191
|
enumerable: true,
|
|
191
|
-
get: function () { return
|
|
192
|
+
get: function () { return chunk3MBMIEWT_js.NextActionSchema; }
|
|
192
193
|
});
|
|
193
194
|
Object.defineProperty(exports, "PhoneE164Schema", {
|
|
194
195
|
enumerable: true,
|
|
195
|
-
get: function () { return
|
|
196
|
+
get: function () { return chunk3MBMIEWT_js.PhoneE164Schema; }
|
|
196
197
|
});
|
|
197
198
|
Object.defineProperty(exports, "ProductTypeSchema", {
|
|
198
199
|
enumerable: true,
|
|
199
|
-
get: function () { return
|
|
200
|
+
get: function () { return chunk3MBMIEWT_js.ProductTypeSchema; }
|
|
200
201
|
});
|
|
201
202
|
Object.defineProperty(exports, "SchemaViolationError", {
|
|
202
203
|
enumerable: true,
|
|
203
|
-
get: function () { return
|
|
204
|
+
get: function () { return chunk3MBMIEWT_js.SchemaViolationError; }
|
|
204
205
|
});
|
|
205
206
|
Object.defineProperty(exports, "SeedNameSchema", {
|
|
206
207
|
enumerable: true,
|
|
207
|
-
get: function () { return
|
|
208
|
+
get: function () { return chunk3MBMIEWT_js.SeedNameSchema; }
|
|
208
209
|
});
|
|
209
210
|
Object.defineProperty(exports, "SelectedAddOnOptionSchema", {
|
|
210
211
|
enumerable: true,
|
|
211
|
-
get: function () { return
|
|
212
|
+
get: function () { return chunk3MBMIEWT_js.SelectedAddOnOptionSchema; }
|
|
212
213
|
});
|
|
213
214
|
Object.defineProperty(exports, "ServiceStatusSchema", {
|
|
214
215
|
enumerable: true,
|
|
215
|
-
get: function () { return
|
|
216
|
+
get: function () { return chunk3MBMIEWT_js.ServiceStatusSchema; }
|
|
216
217
|
});
|
|
217
218
|
Object.defineProperty(exports, "TimestampSchema", {
|
|
218
219
|
enumerable: true,
|
|
219
|
-
get: function () { return
|
|
220
|
+
get: function () { return chunk3MBMIEWT_js.TimestampSchema; }
|
|
220
221
|
});
|
|
221
222
|
Object.defineProperty(exports, "VariantDetailsSchema", {
|
|
222
223
|
enumerable: true,
|
|
223
|
-
get: function () { return
|
|
224
|
+
get: function () { return chunk3MBMIEWT_js.VariantDetailsSchema; }
|
|
224
225
|
});
|
|
225
226
|
Object.defineProperty(exports, "VariantDisplayAttributeSchema", {
|
|
226
227
|
enumerable: true,
|
|
227
|
-
get: function () { return
|
|
228
|
+
get: function () { return chunk3MBMIEWT_js.VariantDisplayAttributeSchema; }
|
|
228
229
|
});
|
|
229
230
|
Object.defineProperty(exports, "VariantInfoSchema", {
|
|
230
231
|
enumerable: true,
|
|
231
|
-
get: function () { return
|
|
232
|
+
get: function () { return chunk3MBMIEWT_js.VariantInfoSchema; }
|
|
232
233
|
});
|
|
233
234
|
Object.defineProperty(exports, "assertAddItemPayload", {
|
|
234
235
|
enumerable: true,
|
|
235
|
-
get: function () { return
|
|
236
|
+
get: function () { return chunk3MBMIEWT_js.assertAddItemPayload; }
|
|
236
237
|
});
|
|
237
238
|
Object.defineProperty(exports, "assertBrand", {
|
|
238
239
|
enumerable: true,
|
|
239
|
-
get: function () { return
|
|
240
|
+
get: function () { return chunk3MBMIEWT_js.assertBrand; }
|
|
240
241
|
});
|
|
241
242
|
Object.defineProperty(exports, "assertCart", {
|
|
242
243
|
enumerable: true,
|
|
243
|
-
get: function () { return
|
|
244
|
+
get: function () { return chunk3MBMIEWT_js.assertCart; }
|
|
244
245
|
});
|
|
245
246
|
Object.defineProperty(exports, "assertCartItem", {
|
|
246
247
|
enumerable: true,
|
|
247
|
-
get: function () { return
|
|
248
|
+
get: function () { return chunk3MBMIEWT_js.assertCartItem; }
|
|
248
249
|
});
|
|
249
250
|
Object.defineProperty(exports, "assertCheckoutBody", {
|
|
250
251
|
enumerable: true,
|
|
251
|
-
get: function () { return
|
|
252
|
+
get: function () { return chunk3MBMIEWT_js.assertCheckoutBody; }
|
|
252
253
|
});
|
|
253
254
|
Object.defineProperty(exports, "assertCheckoutResponse", {
|
|
254
255
|
enumerable: true,
|
|
255
|
-
get: function () { return
|
|
256
|
+
get: function () { return chunk3MBMIEWT_js.assertCheckoutResponse; }
|
|
256
257
|
});
|
|
257
258
|
Object.defineProperty(exports, "cimplifyRegistry", {
|
|
258
259
|
enumerable: true,
|
|
259
|
-
get: function () { return
|
|
260
|
+
get: function () { return chunk3MBMIEWT_js.cimplifyRegistry; }
|
|
260
261
|
});
|
|
261
262
|
Object.defineProperty(exports, "createTestClient", {
|
|
262
263
|
enumerable: true,
|
|
263
|
-
get: function () { return
|
|
264
|
+
get: function () { return chunk3MBMIEWT_js.createTestClient; }
|
|
264
265
|
});
|
|
265
266
|
Object.defineProperty(exports, "fixtures", {
|
|
266
267
|
enumerable: true,
|
|
267
|
-
get: function () { return
|
|
268
|
+
get: function () { return chunk3MBMIEWT_js.fixtures; }
|
|
268
269
|
});
|
|
269
270
|
Object.defineProperty(exports, "makeAssertion", {
|
|
270
271
|
enumerable: true,
|
|
271
|
-
get: function () { return
|
|
272
|
+
get: function () { return chunk3MBMIEWT_js.makeAssertion; }
|
|
272
273
|
});
|
|
273
274
|
Object.defineProperty(exports, "registerSchema", {
|
|
274
275
|
enumerable: true,
|
|
275
|
-
get: function () { return
|
|
276
|
+
get: function () { return chunk3MBMIEWT_js.registerSchema; }
|
|
276
277
|
});
|
|
277
278
|
exports.exportJsonSchemas = exportJsonSchemas;
|
|
278
279
|
exports.listRegisteredSchemas = listRegisteredSchemas;
|
package/dist/testing.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { VariantInfoSchema, CheckoutResponseSchema, CheckoutBodySchema, CartPricingSchema, CartItemSchema, CartSchema, AddItemPayloadSchema, BrandSchema, cimplifyRegistry } from './chunk-
|
|
2
|
-
export { AddItemPayloadSchema, AddOnDetailsSchema, AddOnGroupDetailsSchema, AddOnInDetailsSchema, AddOnOptionDetailsSchema, AuthorizationTypeSchema, BrandContactSchema, BrandFaqSchema, BrandHeroSchema, BrandNavLinkSchema, BrandPolicyPageSchema, BrandPolicySectionSchema, BrandSchema, BrandSocialSchema, BundleResolvedSchema, BundleSelectionInputSchema, CartItemSchema, CartPricingSchema, CartSchema, CheckoutBodySchema, CheckoutCustomerSchema, CheckoutResponseSchema, ChosenPriceSchema, CompositeResolvedSchema, CompositeSelectionInputSchema, CountryCodeSchema, CurrencyCodeSchema, CustomerInputValueSchema, DiscountDetailsSchema, IsoDateTimeSchema, LineTypeSchema, LocaleSchema, MoneyLooseSchema, MoneySchema, NextActionSchema, PhoneE164Schema, ProductTypeSchema, SchemaViolationError, SeedNameSchema, SelectedAddOnOptionSchema, ServiceStatusSchema, TimestampSchema, VariantDetailsSchema, VariantDisplayAttributeSchema, VariantInfoSchema, assertAddItemPayload, assertBrand, assertCart, assertCartItem, assertCheckoutBody, assertCheckoutResponse, cimplifyRegistry, createTestClient, fixtures, makeAssertion, registerSchema } from './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
5
|
-
import './chunk-
|
|
1
|
+
import { VariantInfoSchema, CheckoutResponseSchema, CheckoutBodySchema, CartPricingSchema, CartItemSchema, CartSchema, AddItemPayloadSchema, BrandSchema, cimplifyRegistry } from './chunk-54H2YYIW.mjs';
|
|
2
|
+
export { AddItemPayloadSchema, AddOnDetailsSchema, AddOnGroupDetailsSchema, AddOnInDetailsSchema, AddOnOptionDetailsSchema, AuthorizationTypeSchema, BrandContactSchema, BrandFaqSchema, BrandHeroSchema, BrandNavLinkSchema, BrandPolicyPageSchema, BrandPolicySectionSchema, BrandSchema, BrandSocialSchema, BundleResolvedSchema, BundleSelectionInputSchema, CartItemSchema, CartPricingSchema, CartSchema, CheckoutBodySchema, CheckoutCustomerSchema, CheckoutResponseSchema, ChosenPriceSchema, CompositeResolvedSchema, CompositeSelectionInputSchema, CountryCodeSchema, CurrencyCodeSchema, CustomerInputValueSchema, DiscountDetailsSchema, IsoDateTimeSchema, LineTypeSchema, LocaleSchema, MoneyLooseSchema, MoneySchema, NextActionSchema, PhoneE164Schema, ProductTypeSchema, SchemaViolationError, SeedNameSchema, SelectedAddOnOptionSchema, ServiceStatusSchema, TimestampSchema, VariantDetailsSchema, VariantDisplayAttributeSchema, VariantInfoSchema, assertAddItemPayload, assertBrand, assertCart, assertCartItem, assertCheckoutBody, assertCheckoutResponse, cimplifyRegistry, createTestClient, fixtures, makeAssertion, registerSchema } from './chunk-54H2YYIW.mjs';
|
|
3
|
+
import './chunk-PYBFTMHI.mjs';
|
|
4
|
+
import './chunk-U4MW6PYU.mjs';
|
|
5
|
+
import './chunk-3XD2FVP4.mjs';
|
|
6
|
+
import './chunk-T7LDBZZZ.mjs';
|
|
6
7
|
import './chunk-KFLGQGMC.mjs';
|
|
7
8
|
import './chunk-K5EN2W2Q.mjs';
|
|
8
9
|
import './chunk-3G6RQLXK.mjs';
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, c as categorizePaymentError, d as detectMobileMoneyProvider, f as formatMoney, a as formatNumberCompact, b as formatPrice, e as formatPriceAdjustment, g as formatPriceCompact, i as formatPriceWithTax, j as formatProductPrice, k as getBasePrice, l as getCurrencySymbol, m as getDiscountPercentage, n as getDisplayPrice, o as getMarkupPercentage, q as getProductCurrency, r as getTaxAmount, t as hasTaxInfo, u as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, y as isTaxInclusive, z as isValidPhoneForContext, A as normalizePaymentResponse, B as normalizePhoneToE164, D as normalizeStatusResponse, E as parsePrice, F as resolvePhoneCountryCode } from './index-
|
|
2
|
-
import './product-
|
|
3
|
-
import './price
|
|
4
|
-
import './payment-
|
|
1
|
+
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, c as categorizePaymentError, d as detectMobileMoneyProvider, f as formatMoney, a as formatNumberCompact, b as formatPrice, e as formatPriceAdjustment, g as formatPriceCompact, i as formatPriceWithTax, j as formatProductPrice, k as getBasePrice, l as getCurrencySymbol, m as getDiscountPercentage, n as getDisplayPrice, o as getMarkupPercentage, q as getProductCurrency, r as getTaxAmount, t as hasTaxInfo, u as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, y as isTaxInclusive, z as isValidPhoneForContext, A as normalizePaymentResponse, B as normalizePhoneToE164, D as normalizeStatusResponse, E as parsePrice, F as resolvePhoneCountryCode } from './index-CmIboQjl.mjs';
|
|
2
|
+
import './product-bZ8G5Z8D.mjs';
|
|
3
|
+
import './price-DleDWk_s.mjs';
|
|
4
|
+
import './payment-BFtLqiG2.mjs';
|
|
5
5
|
import 'libphonenumber-js';
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, c as categorizePaymentError, d as detectMobileMoneyProvider, f as formatMoney, a as formatNumberCompact, b as formatPrice, e as formatPriceAdjustment, g as formatPriceCompact, i as formatPriceWithTax, j as formatProductPrice, k as getBasePrice, l as getCurrencySymbol, m as getDiscountPercentage, n as getDisplayPrice, o as getMarkupPercentage, q as getProductCurrency, r as getTaxAmount, t as hasTaxInfo, u as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, y as isTaxInclusive, z as isValidPhoneForContext, A as normalizePaymentResponse, B as normalizePhoneToE164, D as normalizeStatusResponse, E as parsePrice, F as resolvePhoneCountryCode } from './index-
|
|
2
|
-
import './product-
|
|
3
|
-
import './price-
|
|
4
|
-
import './payment-
|
|
1
|
+
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, c as categorizePaymentError, d as detectMobileMoneyProvider, f as formatMoney, a as formatNumberCompact, b as formatPrice, e as formatPriceAdjustment, g as formatPriceCompact, i as formatPriceWithTax, j as formatProductPrice, k as getBasePrice, l as getCurrencySymbol, m as getDiscountPercentage, n as getDisplayPrice, o as getMarkupPercentage, q as getProductCurrency, r as getTaxAmount, t as hasTaxInfo, u as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, y as isTaxInclusive, z as isValidPhoneForContext, A as normalizePaymentResponse, B as normalizePhoneToE164, D as normalizeStatusResponse, E as parsePrice, F as resolvePhoneCountryCode } from './index-DgoRwz8l.js';
|
|
2
|
+
import './product-bZ8G5Z8D.js';
|
|
3
|
+
import './price-DaFXT-Lr.js';
|
|
4
|
+
import './payment-Cq8FT1B6.js';
|
|
5
5
|
import 'libphonenumber-js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cimplify/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.92.0",
|
|
4
4
|
"description": "Cimplify Commerce SDK for storefronts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cimplify",
|
|
@@ -162,9 +162,12 @@
|
|
|
162
162
|
"@base-ui/react": "^1.5.0",
|
|
163
163
|
"clsx": "^2.1.1",
|
|
164
164
|
"date-fns": "^4.4.0",
|
|
165
|
+
"dompurify": "3.4.10",
|
|
165
166
|
"jose": "^6.2.3",
|
|
166
167
|
"libphonenumber-js": "1.13.6",
|
|
168
|
+
"marked": "18.0.5",
|
|
167
169
|
"react-day-picker": "^10.0.1",
|
|
170
|
+
"streamdown": "2.5.0",
|
|
168
171
|
"tailwind-merge": "^3.6.0",
|
|
169
172
|
"xss": "^1.0.15",
|
|
170
173
|
"zod": "^4.4.3"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
{
|
|
15
15
|
"path": "booking-page.tsx",
|
|
16
|
-
"content": "\"use client\";\n\nimport React, { useState, useCallback } from \"react\";\nimport type { Product } from \"@cimplify/sdk\";\nimport type { CurrencyCode } from \"@cimplify/sdk\";\nimport type { Service, Staff, AvailableSlot, CustomerBooking } from \"@cimplify/sdk\";\nimport type { Resource } from \"./resource-picker\";\nimport { useCart } from \"@cimplify/sdk/react\";\nimport { useCimplifyClient } from \"@cimplify/sdk/react\";\nimport { DateSlotPicker } from \"@cimplify/sdk/react\";\nimport { StaffPicker } from \"@cimplify/sdk/react\";\nimport { ResourcePicker } from \"./resource-picker\";\nimport { Price } from \"@cimplify/sdk/react\";\nimport { cn } from \"@cimplify/sdk/react\";\nimport { formatDuration } from \"./utils/format-duration\";\nimport { parsePrice } from \"@cimplify/sdk\";\n\nexport interface BookingPageClassNames {\n root?: string;\n header?: string;\n title?: string;\n serviceInfo?: string;\n step?: string;\n stepTitle?: string;\n summary?: string;\n summaryRow?: string;\n confirmButton?: string;\n backButton?: string;\n error?: string;\n rescheduleInfo?: string;\n depositInfo?: string;\n cancellationPolicy?: string;\n resourceStep?: string;\n}\n\nexport interface BookingPageProps {\n /** The service being booked. */\n service: Service;\n /** The underlying product (for deposit/cancellation fields). Falls back to service fields. */\n product?: Product;\n /** Optional staff list for staff selection step. */\n staff?: Staff[];\n /** Optional resources for resource selection step (rooms, equipment, etc.). */\n resources?: Resource[];\n /** Number of participants. */\n participantCount?: number;\n /** Page title. */\n title?: string;\n /** Called after successfully adding to cart. */\n onBooked?: (slot: AvailableSlot, staffId: string | null) => void;\n /** Called when user wants to go back. */\n onBack?: () => void;\n /** Existing booking for reschedule mode. */\n existingBooking?: CustomerBooking;\n /** Called after a successful reschedule. */\n onRescheduled?: (booking: CustomerBooking, newSlot: AvailableSlot) => void;\n /** Show price on slots. Default: true. */\n showPrice?: boolean;\n className?: string;\n classNames?: BookingPageClassNames;\n}\n\nconst STEP = {\n SELECT_SLOT: \"select-slot\",\n SELECT_RESOURCE: \"select-resource\",\n SELECT_STAFF: \"select-staff\",\n CONFIRM: \"confirm\",\n} as const;\n\ntype BookingStep = (typeof STEP)[keyof typeof STEP];\n\nexport function BookingPage({\n service,\n product,\n staff,\n resources,\n participantCount,\n title,\n onBooked,\n onBack,\n existingBooking,\n onRescheduled,\n showPrice = true,\n className,\n classNames,\n}: BookingPageProps): React.ReactElement {\n const { addItem } = useCart();\n const { client } = useCimplifyClient();\n\n const currency = service.currency as CurrencyCode | undefined;\n\n const isReschedule = existingBooking !== undefined;\n\n const [step, setStep] = useState<BookingStep>(STEP.SELECT_SLOT);\n const [selectedSlot, setSelectedSlot] = useState<AvailableSlot | null>(null);\n const [selectedDate, setSelectedDate] = useState<string | null>(null);\n const [selectedStaffId, setSelectedStaffId] = useState<string | null>(null);\n const [selectedResourceId, setSelectedResourceId] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const hasResourceStep = resources && resources.length > 0;\n const hasStaffStep = staff && staff.length > 0;\n\n // Deposit info — prefer product fields, then fall back to service metadata\n const depositType = product?.deposit_type;\n const depositAmount = product?.deposit_amount;\n const hasDeposit = depositType !== undefined && depositType !== \"none\" && depositAmount !== undefined && parsePrice(depositAmount) !== 0;\n\n // Cancellation policy\n const cancellationMinutes = product?.cancellation_window_minutes;\n const noShowFee = product?.no_show_fee;\n\n const handleSlotSelect = useCallback(\n (slot: AvailableSlot, date: string) => {\n setSelectedSlot(slot);\n setSelectedDate(date);\n setError(null);\n if (hasResourceStep) {\n setStep(STEP.SELECT_RESOURCE);\n } else if (hasStaffStep) {\n setStep(STEP.SELECT_STAFF);\n } else {\n setStep(STEP.CONFIRM);\n }\n },\n [hasResourceStep, hasStaffStep],\n );\n\n const handleResourceSelect = useCallback(\n (resourceId: string | null) => {\n setSelectedResourceId(resourceId);\n if (hasStaffStep) {\n setStep(STEP.SELECT_STAFF);\n } else {\n setStep(STEP.CONFIRM);\n }\n },\n [hasStaffStep],\n );\n\n const handleStaffSelect = useCallback((staffId: string | null) => {\n setSelectedStaffId(staffId);\n setStep(STEP.CONFIRM);\n }, []);\n\n const handleBack = useCallback(() => {\n setError(null);\n if (step === STEP.CONFIRM && hasStaffStep) {\n setStep(STEP.SELECT_STAFF);\n } else if (step === STEP.CONFIRM && hasResourceStep) {\n setStep(STEP.SELECT_RESOURCE);\n } else if (step === STEP.SELECT_STAFF && hasResourceStep) {\n setStep(STEP.SELECT_RESOURCE);\n } else if (step === STEP.CONFIRM || step === STEP.SELECT_STAFF || step === STEP.SELECT_RESOURCE) {\n setStep(STEP.SELECT_SLOT);\n } else {\n onBack?.();\n }\n }, [step, hasStaffStep, hasResourceStep, onBack]);\n\n const handleConfirm = useCallback(async () => {\n if (!selectedSlot || !selectedDate) return;\n\n setIsSubmitting(true);\n setError(null);\n\n try {\n if (isReschedule && existingBooking) {\n // Reschedule mode — call the scheduling API instead of adding to cart\n const serviceItem = existingBooking.service_items[0];\n const result = await client.scheduling.rescheduleBooking({\n order_id: existingBooking.order_id,\n line_item_id: serviceItem?.service_id ?? existingBooking.order_id,\n new_start_time: selectedSlot.start_time,\n new_end_time: selectedSlot.end_time,\n new_staff_id: selectedStaffId || undefined,\n reschedule_type: \"customer\",\n });\n\n if (!result.ok) {\n throw result.error;\n }\n\n onRescheduled?.(existingBooking, selectedSlot);\n } else {\n // Normal booking mode — add to cart\n const serviceProduct = {\n id: service.product_id || service.id,\n business_id: service.business_id || \"\",\n category_id: service.category_id || undefined,\n name: service.name,\n slug: service.id,\n description: service.description || undefined,\n image_url: service.image_url || undefined,\n default_price: (service.price || \"0\") as Product[\"default_price\"],\n type: \"service\" as const,\n inventory_type: \"none\" as const,\n variant_strategy: \"fetch_all\" as const,\n is_active: service.is_available,\n created_at: new Date().toISOString(),\n updated_at: new Date().toISOString(),\n };\n\n await addItem(serviceProduct, 1, {\n scheduledStart: selectedSlot.start_time,\n scheduledEnd: selectedSlot.end_time,\n staffId: selectedStaffId || undefined,\n resourceId: selectedResourceId || undefined,\n });\n\n onBooked?.(selectedSlot, selectedStaffId);\n }\n } catch (err) {\n const fallbackMessage = isReschedule ? \"Failed to reschedule booking\" : \"Failed to add booking to cart\";\n setError(err instanceof Error ? err.message : fallbackMessage);\n } finally {\n setIsSubmitting(false);\n }\n }, [selectedSlot, selectedDate, selectedStaffId, service, addItem, onBooked, isReschedule, existingBooking, client, onRescheduled]);\n\n return (\n <div data-cimplify-booking-page className={cn(className, classNames?.root)}>\n <div data-cimplify-booking-page-header className={classNames?.header}>\n {onBack && step === STEP.SELECT_SLOT && (\n <button\n type=\"button\"\n onClick={onBack}\n data-cimplify-booking-page-back\n className={classNames?.backButton}\n >\n Back\n </button>\n )}\n {step !== STEP.SELECT_SLOT && (\n <button\n type=\"button\"\n onClick={handleBack}\n data-cimplify-booking-page-back\n className={classNames?.backButton}\n >\n Back\n </button>\n )}\n <h1 data-cimplify-booking-page-title className={classNames?.title}>\n {title || (isReschedule ? \"Reschedule Booking\" : `Book ${service.name}`)}\n </h1>\n </div>\n\n {isReschedule && existingBooking && (\n <div data-cimplify-booking-reschedule-info className={classNames?.rescheduleInfo}>\n <span>Rescheduling booking from {new Date(existingBooking.service_items[0]?.scheduled_start ?? existingBooking.created_at).toLocaleDateString()}</span>\n </div>\n )}\n\n <div data-cimplify-booking-service-info className={classNames?.serviceInfo}>\n <span data-cimplify-booking-service-name>{service.name}</span>\n <span data-cimplify-booking-service-duration>{formatDuration(service.duration_minutes, service.duration_unit)}</span>\n {service.price && (\n <span data-cimplify-booking-service-price>\n <Price amount={service.price} currency={currency} />\n </span>\n )}\n {hasDeposit && (\n <span data-cimplify-booking-deposit-info className={classNames?.depositInfo}>\n Deposit: {depositType === \"percentage\" ? `${parsePrice(depositAmount!)}%` : <Price amount={depositAmount!} currency={currency} />}\n </span>\n )}\n {cancellationMinutes !== undefined && cancellationMinutes > 0 && (\n <span data-cimplify-booking-cancellation-policy className={classNames?.cancellationPolicy}>\n Free cancellation up to {cancellationMinutes >= 60 ? `${Math.floor(cancellationMinutes / 60)} hour${Math.floor(cancellationMinutes / 60) !== 1 ? \"s\" : \"\"}` : `${cancellationMinutes} minute${cancellationMinutes !== 1 ? \"s\" : \"\"}`} before\n </span>\n )}\n {noShowFee !== undefined && parsePrice(noShowFee) !== 0 && (\n <span data-cimplify-booking-no-show-fee className={classNames?.cancellationPolicy}>\n No-show fee: <Price amount={noShowFee} currency={currency} />\n </span>\n )}\n </div>\n\n {error && (\n <div data-cimplify-booking-error className={classNames?.error}>\n {error}\n </div>\n )}\n\n {step === STEP.SELECT_SLOT && (\n <div data-cimplify-booking-step=\"select-slot\" className={classNames?.step}>\n <h2 data-cimplify-booking-step-title className={classNames?.stepTitle}>\n Select a date & time\n </h2>\n <DateSlotPicker\n serviceId={service.id}\n participantCount={participantCount}\n selectedSlot={selectedSlot}\n onSlotSelect={handleSlotSelect}\n showPrice={showPrice}\n currency={currency}\n />\n </div>\n )}\n\n {step === STEP.SELECT_RESOURCE && resources && (\n <div data-cimplify-booking-step=\"select-resource\" className={cn(classNames?.step, classNames?.resourceStep)}>\n <h2 data-cimplify-booking-step-title className={classNames?.stepTitle}>\n Choose a room\n </h2>\n <ResourcePicker\n resources={resources}\n selectedResourceId={selectedResourceId}\n onResourceSelect={handleResourceSelect}\n />\n </div>\n )}\n\n {step === STEP.SELECT_STAFF && staff && (\n <div data-cimplify-booking-step=\"select-staff\" className={classNames?.step}>\n <h2 data-cimplify-booking-step-title className={classNames?.stepTitle}>\n Choose a provider\n </h2>\n <StaffPicker\n staff={staff}\n selectedStaffId={selectedStaffId}\n onStaffSelect={handleStaffSelect}\n />\n </div>\n )}\n\n {step === STEP.CONFIRM && selectedSlot && (\n <div data-cimplify-booking-step=\"confirm\" className={classNames?.step}>\n <h2 data-cimplify-booking-step-title className={classNames?.stepTitle}>\n Confirm your booking\n </h2>\n <div data-cimplify-booking-summary className={classNames?.summary}>\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Service</span>\n <span>{service.name}</span>\n </div>\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Date</span>\n <span>{selectedDate}</span>\n </div>\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Time</span>\n <span>\n {new Date(selectedSlot.start_time).toLocaleTimeString(undefined, {\n hour: \"numeric\",\n minute: \"2-digit\",\n })}\n </span>\n </div>\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Duration</span>\n <span>{formatDuration(service.duration_minutes, service.duration_unit)}</span>\n </div>\n {selectedResourceId && resources && (\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Room</span>\n <span>{resources.find((r) => r.id === selectedResourceId)?.name ?? \"Selected\"}</span>\n </div>\n )}\n {selectedStaffId && staff && (\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Provider</span>\n <span>{staff.find((s) => s.id === selectedStaffId)?.name ?? \"Selected\"}</span>\n </div>\n )}\n {(selectedSlot.price || service.price) && (\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Price</span>\n <span>\n <Price amount={selectedSlot.price || service.price!} currency={currency} />\n </span>\n </div>\n )}\n {hasDeposit && (\n <div data-cimplify-booking-summary-row className={cn(classNames?.summaryRow, classNames?.depositInfo)}>\n <span>Deposit</span>\n <span>\n {depositType === \"percentage\" ? `${parsePrice(depositAmount!)}%` : <Price amount={depositAmount!} currency={currency} />}\n </span>\n </div>\n )}\n </div>\n <button\n type=\"button\"\n onClick={handleConfirm}\n disabled={isSubmitting}\n data-cimplify-booking-confirm\n className={classNames?.confirmButton}\n >\n {isSubmitting\n ? (isReschedule ? \"Rescheduling…\" : \"Adding to cart…\")\n : (isReschedule ? \"Reschedule\" : \"Confirm Booking\")}\n </button>\n </div>\n )}\n </div>\n );\n}\n"
|
|
16
|
+
"content": "\"use client\";\n\nimport React, { useState, useCallback } from \"react\";\nimport type { Product } from \"@cimplify/sdk\";\nimport type { CurrencyCode } from \"@cimplify/sdk\";\nimport type { Service, Staff, AvailableSlot, CustomerBooking } from \"@cimplify/sdk\";\nimport type { Resource } from \"./resource-picker\";\nimport { useCart } from \"@cimplify/sdk/react\";\nimport { useCimplifyClient } from \"@cimplify/sdk/react\";\nimport { DateSlotPicker } from \"@cimplify/sdk/react\";\nimport { StaffPicker } from \"@cimplify/sdk/react\";\nimport { ResourcePicker } from \"./resource-picker\";\nimport { Price } from \"@cimplify/sdk/react\";\nimport { cn } from \"@cimplify/sdk/react\";\nimport { formatDuration } from \"./utils/format-duration\";\nimport { parsePrice } from \"@cimplify/sdk\";\n\nexport interface BookingPageClassNames {\n root?: string;\n header?: string;\n title?: string;\n serviceInfo?: string;\n step?: string;\n stepTitle?: string;\n summary?: string;\n summaryRow?: string;\n confirmButton?: string;\n backButton?: string;\n error?: string;\n rescheduleInfo?: string;\n depositInfo?: string;\n cancellationPolicy?: string;\n resourceStep?: string;\n}\n\nexport interface BookingPageProps {\n /** The service being booked. */\n service: Service;\n /** The underlying product (for deposit/cancellation fields). Falls back to service fields. */\n product?: Product;\n /** Optional staff list for staff selection step. */\n staff?: Staff[];\n /** Optional resources for resource selection step (rooms, equipment, etc.). */\n resources?: Resource[];\n /** Number of participants. */\n participantCount?: number;\n /** Page title. */\n title?: string;\n /** Called after successfully adding to cart. */\n onBooked?: (slot: AvailableSlot, staffId: string | null) => void;\n /** Called when user wants to go back. */\n onBack?: () => void;\n /** Existing booking for reschedule mode. */\n existingBooking?: CustomerBooking;\n /** Called after a successful reschedule. */\n onRescheduled?: (booking: CustomerBooking, newSlot: AvailableSlot) => void;\n /** Show price on slots. Default: true. */\n showPrice?: boolean;\n className?: string;\n classNames?: BookingPageClassNames;\n}\n\nconst STEP = {\n SELECT_SLOT: \"select-slot\",\n SELECT_RESOURCE: \"select-resource\",\n SELECT_STAFF: \"select-staff\",\n CONFIRM: \"confirm\",\n} as const;\n\ntype BookingStep = (typeof STEP)[keyof typeof STEP];\n\nexport function BookingPage({\n service,\n product,\n staff,\n resources,\n participantCount,\n title,\n onBooked,\n onBack,\n existingBooking,\n onRescheduled,\n showPrice = true,\n className,\n classNames,\n}: BookingPageProps): React.ReactElement {\n const { addItem } = useCart();\n const { client } = useCimplifyClient();\n\n const currency = service.currency as CurrencyCode | undefined;\n\n const isReschedule = existingBooking !== undefined;\n\n const [step, setStep] = useState<BookingStep>(STEP.SELECT_SLOT);\n const [selectedSlot, setSelectedSlot] = useState<AvailableSlot | null>(null);\n const [selectedDate, setSelectedDate] = useState<string | null>(null);\n const [selectedStaffId, setSelectedStaffId] = useState<string | null>(null);\n const [selectedResourceId, setSelectedResourceId] = useState<string | null>(null);\n const [bookingUnits, setBookingUnits] = useState(1);\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const hasResourceStep = resources && resources.length > 0;\n const hasStaffStep = staff && staff.length > 0;\n\n // Deposit info — prefer product fields, then fall back to service metadata\n const depositType = product?.deposit_type;\n const depositAmount = product?.deposit_amount;\n const hasDeposit = depositType !== undefined && depositType !== \"none\" && depositAmount !== undefined && parsePrice(depositAmount) !== 0;\n\n // Cancellation policy\n const cancellationMinutes = product?.cancellation_window_minutes;\n const noShowFee = product?.no_show_fee;\n\n const handleSlotSelect = useCallback(\n (slot: AvailableSlot, date: string) => {\n setSelectedSlot(slot);\n setSelectedDate(date);\n setError(null);\n if (hasResourceStep) {\n setStep(STEP.SELECT_RESOURCE);\n } else if (hasStaffStep) {\n setStep(STEP.SELECT_STAFF);\n } else {\n setStep(STEP.CONFIRM);\n }\n },\n [hasResourceStep, hasStaffStep],\n );\n\n const handleResourceSelect = useCallback(\n (resourceId: string | null) => {\n setSelectedResourceId(resourceId);\n if (hasStaffStep) {\n setStep(STEP.SELECT_STAFF);\n } else {\n setStep(STEP.CONFIRM);\n }\n },\n [hasStaffStep],\n );\n\n const handleStaffSelect = useCallback((staffId: string | null) => {\n setSelectedStaffId(staffId);\n setStep(STEP.CONFIRM);\n }, []);\n\n const handleBack = useCallback(() => {\n setError(null);\n if (step === STEP.CONFIRM && hasStaffStep) {\n setStep(STEP.SELECT_STAFF);\n } else if (step === STEP.CONFIRM && hasResourceStep) {\n setStep(STEP.SELECT_RESOURCE);\n } else if (step === STEP.SELECT_STAFF && hasResourceStep) {\n setStep(STEP.SELECT_RESOURCE);\n } else if (step === STEP.CONFIRM || step === STEP.SELECT_STAFF || step === STEP.SELECT_RESOURCE) {\n setStep(STEP.SELECT_SLOT);\n } else {\n onBack?.();\n }\n }, [step, hasStaffStep, hasResourceStep, onBack]);\n\n const handleConfirm = useCallback(async () => {\n if (!selectedSlot || !selectedDate) return;\n\n setIsSubmitting(true);\n setError(null);\n\n try {\n if (isReschedule && existingBooking) {\n // Reschedule mode — call the scheduling API instead of adding to cart\n const serviceItem = existingBooking.service_items[0];\n const result = await client.scheduling.rescheduleBooking({\n order_id: existingBooking.order_id,\n line_item_id: serviceItem?.service_id ?? existingBooking.order_id,\n new_start_time: selectedSlot.start_time,\n new_end_time: selectedSlot.end_time,\n new_staff_id: selectedStaffId || undefined,\n reschedule_type: \"customer\",\n });\n\n if (!result.ok) {\n throw result.error;\n }\n\n onRescheduled?.(existingBooking, selectedSlot);\n } else {\n // Normal booking mode — add to cart\n const serviceProduct = {\n id: service.product_id || service.id,\n business_id: service.business_id || \"\",\n category_id: service.category_id || undefined,\n name: service.name,\n slug: service.id,\n description: service.description || undefined,\n image_url: service.image_url || undefined,\n default_price: (service.price || \"0\") as Product[\"default_price\"],\n type: \"service\" as const,\n inventory_type: \"none\" as const,\n variant_strategy: \"fetch_all\" as const,\n is_active: service.is_available,\n created_at: new Date().toISOString(),\n updated_at: new Date().toISOString(),\n };\n\n await addItem(serviceProduct, 1, {\n scheduledStart: selectedSlot.start_time,\n scheduledEnd: selectedSlot.end_time,\n staffId: selectedStaffId || undefined,\n resourceId: selectedResourceId || undefined,\n units: bookingUnits > 1 ? bookingUnits : undefined,\n });\n\n onBooked?.(selectedSlot, selectedStaffId);\n }\n } catch (err) {\n const fallbackMessage = isReschedule ? \"Failed to reschedule booking\" : \"Failed to add booking to cart\";\n setError(err instanceof Error ? err.message : fallbackMessage);\n } finally {\n setIsSubmitting(false);\n }\n }, [selectedSlot, selectedDate, selectedStaffId, service, addItem, onBooked, isReschedule, existingBooking, client, onRescheduled]);\n\n return (\n <div data-cimplify-booking-page className={cn(className, classNames?.root)}>\n <div data-cimplify-booking-page-header className={classNames?.header}>\n {onBack && step === STEP.SELECT_SLOT && (\n <button\n type=\"button\"\n onClick={onBack}\n data-cimplify-booking-page-back\n className={classNames?.backButton}\n >\n Back\n </button>\n )}\n {step !== STEP.SELECT_SLOT && (\n <button\n type=\"button\"\n onClick={handleBack}\n data-cimplify-booking-page-back\n className={classNames?.backButton}\n >\n Back\n </button>\n )}\n <h1 data-cimplify-booking-page-title className={classNames?.title}>\n {title || (isReschedule ? \"Reschedule Booking\" : `Book ${service.name}`)}\n </h1>\n </div>\n\n {isReschedule && existingBooking && (\n <div data-cimplify-booking-reschedule-info className={classNames?.rescheduleInfo}>\n <span>Rescheduling booking from {new Date(existingBooking.service_items[0]?.scheduled_start ?? existingBooking.created_at).toLocaleDateString()}</span>\n </div>\n )}\n\n <div data-cimplify-booking-service-info className={classNames?.serviceInfo}>\n <span data-cimplify-booking-service-name>{service.name}</span>\n <span data-cimplify-booking-service-duration>{formatDuration(service.duration_minutes, service.duration_unit)}</span>\n {service.price && (\n <span data-cimplify-booking-service-price>\n <Price amount={service.price} currency={currency} />\n </span>\n )}\n {hasDeposit && (\n <span data-cimplify-booking-deposit-info className={classNames?.depositInfo}>\n Deposit: {depositType === \"percentage\" ? `${parsePrice(depositAmount!)}%` : <Price amount={depositAmount!} currency={currency} />}\n </span>\n )}\n {cancellationMinutes !== undefined && cancellationMinutes > 0 && (\n <span data-cimplify-booking-cancellation-policy className={classNames?.cancellationPolicy}>\n Free cancellation up to {cancellationMinutes >= 60 ? `${Math.floor(cancellationMinutes / 60)} hour${Math.floor(cancellationMinutes / 60) !== 1 ? \"s\" : \"\"}` : `${cancellationMinutes} minute${cancellationMinutes !== 1 ? \"s\" : \"\"}`} before\n </span>\n )}\n {noShowFee !== undefined && parsePrice(noShowFee) !== 0 && (\n <span data-cimplify-booking-no-show-fee className={classNames?.cancellationPolicy}>\n No-show fee: <Price amount={noShowFee} currency={currency} />\n </span>\n )}\n </div>\n\n {error && (\n <div data-cimplify-booking-error className={classNames?.error}>\n {error}\n </div>\n )}\n\n {step === STEP.SELECT_SLOT && (\n <div data-cimplify-booking-step=\"select-slot\" className={classNames?.step}>\n <h2 data-cimplify-booking-step-title className={classNames?.stepTitle}>\n Select a date & time\n </h2>\n <DateSlotPicker\n serviceId={service.id}\n participantCount={participantCount}\n selectedSlot={selectedSlot}\n onSlotSelect={handleSlotSelect}\n showPrice={showPrice}\n currency={currency}\n />\n </div>\n )}\n\n {step === STEP.SELECT_RESOURCE && resources && (\n <div data-cimplify-booking-step=\"select-resource\" className={cn(classNames?.step, classNames?.resourceStep)}>\n <h2 data-cimplify-booking-step-title className={classNames?.stepTitle}>\n Choose a room\n </h2>\n <ResourcePicker\n resources={resources}\n selectedResourceId={selectedResourceId}\n onResourceSelect={handleResourceSelect}\n />\n </div>\n )}\n\n {step === STEP.SELECT_STAFF && staff && (\n <div data-cimplify-booking-step=\"select-staff\" className={classNames?.step}>\n <h2 data-cimplify-booking-step-title className={classNames?.stepTitle}>\n Choose a provider\n </h2>\n <StaffPicker\n staff={staff}\n selectedStaffId={selectedStaffId}\n onStaffSelect={handleStaffSelect}\n />\n </div>\n )}\n\n {step === STEP.CONFIRM && selectedSlot && (\n <div data-cimplify-booking-step=\"confirm\" className={classNames?.step}>\n <h2 data-cimplify-booking-step-title className={classNames?.stepTitle}>\n Confirm your booking\n </h2>\n <div data-cimplify-booking-units className={classNames?.summaryRow}>\n <span>Units</span>\n <div data-cimplify-booking-units-stepper>\n <button\n type=\"button\"\n data-cimplify-booking-units-decrement\n onClick={() => setBookingUnits((current) => Math.max(1, current - 1))}\n disabled={bookingUnits <= 1}\n >\n −\n </button>\n <span data-cimplify-booking-units-value>{bookingUnits}</span>\n <button\n type=\"button\"\n data-cimplify-booking-units-increment\n onClick={() => setBookingUnits((current) => current + 1)}\n >\n +\n </button>\n </div>\n </div>\n <div data-cimplify-booking-summary className={classNames?.summary}>\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Service</span>\n <span>{service.name}</span>\n </div>\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Date</span>\n <span>{selectedDate}</span>\n </div>\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Time</span>\n <span>\n {new Date(selectedSlot.start_time).toLocaleTimeString(undefined, {\n hour: \"numeric\",\n minute: \"2-digit\",\n })}\n </span>\n </div>\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Duration</span>\n <span>{formatDuration(service.duration_minutes, service.duration_unit)}</span>\n </div>\n {selectedResourceId && resources && (\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Room</span>\n <span>{resources.find((r) => r.id === selectedResourceId)?.name ?? \"Selected\"}</span>\n </div>\n )}\n {selectedStaffId && staff && (\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Provider</span>\n <span>{staff.find((s) => s.id === selectedStaffId)?.name ?? \"Selected\"}</span>\n </div>\n )}\n {(selectedSlot.price || service.price) && (\n <div data-cimplify-booking-summary-row className={classNames?.summaryRow}>\n <span>Price</span>\n <span>\n <Price amount={selectedSlot.price || service.price!} currency={currency} />\n </span>\n </div>\n )}\n {hasDeposit && (\n <div data-cimplify-booking-summary-row className={cn(classNames?.summaryRow, classNames?.depositInfo)}>\n <span>Deposit</span>\n <span>\n {depositType === \"percentage\" ? `${parsePrice(depositAmount!)}%` : <Price amount={depositAmount!} currency={currency} />}\n </span>\n </div>\n )}\n </div>\n <button\n type=\"button\"\n onClick={handleConfirm}\n disabled={isSubmitting}\n data-cimplify-booking-confirm\n className={classNames?.confirmButton}\n >\n {isSubmitting\n ? (isReschedule ? \"Rescheduling…\" : \"Adding to cart…\")\n : (isReschedule ? \"Reschedule\" : \"Confirm Booking\")}\n </button>\n </div>\n )}\n </div>\n );\n}\n"
|
|
17
17
|
}
|
|
18
18
|
]
|
|
19
19
|
}
|