@swift-food-services/catering-widget 0.1.0-beta.6 → 0.1.0-beta.7
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/README.md +8 -19
- package/dist/index.cjs +6065 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +6065 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -10,7 +10,6 @@ npm install @swift-food-services/catering-widget
|
|
|
10
10
|
|
|
11
11
|
```tsx
|
|
12
12
|
import { CateringWidget } from "@swift-food-services/catering-widget";
|
|
13
|
-
import "@swift-food-services/catering-widget/dist/styles.css";
|
|
14
13
|
|
|
15
14
|
export default function CateringPage() {
|
|
16
15
|
return (
|
|
@@ -33,13 +32,12 @@ Defaults: Swift-hosted backend, `localStorage` persistence, neutral theme.
|
|
|
33
32
|
|
|
34
33
|
- React 18+ and React-DOM 18+ as peer dependencies
|
|
35
34
|
- A publishable key from Swift (see [Getting a publishable key](#getting-a-publishable-key))
|
|
36
|
-
- At least one origin registered with Swift where the widget will load
|
|
37
35
|
|
|
38
36
|
## Props
|
|
39
37
|
|
|
40
38
|
| Prop | Type | Required | Description |
|
|
41
39
|
|---|---|---|---|
|
|
42
|
-
| `publishableKey` | `string` | yes | Your `pk_live_...`
|
|
40
|
+
| `publishableKey` | `string` | yes | Your `pk_live_...` key from Swift. |
|
|
43
41
|
| `googleMapsApiKey` | `string` | yes | Google Maps JavaScript API key with the Places library enabled. Used by the address-autocomplete field. |
|
|
44
42
|
| `theme` | `Theme` | no | Primary color, border radius, and font overrides. |
|
|
45
43
|
| `initialData` | `InitialData` | no | Pre-populate event, address, and contact fields. Applied only on first mount. |
|
|
@@ -56,7 +54,6 @@ Defaults: Swift-hosted backend, `localStorage` persistence, neutral theme.
|
|
|
56
54
|
```tsx
|
|
57
55
|
"use client";
|
|
58
56
|
import { CateringWidget } from "@swift-food-services/catering-widget";
|
|
59
|
-
import "@swift-food-services/catering-widget/dist/styles.css";
|
|
60
57
|
import { useRouter } from "next/navigation";
|
|
61
58
|
|
|
62
59
|
export default function Page() {
|
|
@@ -187,14 +184,13 @@ Fires on errors the widget can't recover from. `error.code` is one of:
|
|
|
187
184
|
- Multi-session meal building
|
|
188
185
|
- Contact details and delivery address
|
|
189
186
|
- Promo codes and pricing preview
|
|
190
|
-
- Google Maps address autocomplete
|
|
187
|
+
- Google Maps address autocomplete (requires the `googleMapsApiKey` you provide)
|
|
191
188
|
- Order submission to Swift's API
|
|
192
189
|
- State persistence in `localStorage` (namespaced)
|
|
193
190
|
|
|
194
191
|
## What you're responsible for
|
|
195
192
|
|
|
196
193
|
- Getting a publishable key from Swift.
|
|
197
|
-
- Registering your site's origin(s) with Swift.
|
|
198
194
|
- Providing a Google Maps JavaScript API key (with the Places library enabled) via the `googleMapsApiKey` prop. Restrict the key to your own domain(s) in the Google Cloud Console.
|
|
199
195
|
- Rendering `<CateringWidget>` wherever you want the flow to live.
|
|
200
196
|
- Navigating after `onOrderComplete`.
|
|
@@ -209,26 +205,19 @@ Fires on errors the widget can't recover from. `error.code` is one of:
|
|
|
209
205
|
|
|
210
206
|
## Getting a publishable key
|
|
211
207
|
|
|
212
|
-
Contact Swift at [
|
|
208
|
+
Contact Swift at [swiftfooduk@gmail.com](mailto:swiftfooduk@gmail.com) with:
|
|
213
209
|
|
|
214
210
|
1. Your company name.
|
|
215
|
-
2.
|
|
216
|
-
3. A technical contact for integration support.
|
|
211
|
+
2. A technical contact for integration support.
|
|
217
212
|
|
|
218
|
-
Swift provisions a partner record and returns a publishable key (format: `pk_live_...`
|
|
213
|
+
Swift provisions a partner record and returns a publishable key (format: `pk_live_...`) out of band.
|
|
219
214
|
|
|
220
|
-
The key is public
|
|
215
|
+
The key is public — it ships in the browser bundle.
|
|
221
216
|
|
|
222
217
|
## Troubleshooting
|
|
223
218
|
|
|
224
|
-
**Widget doesn't render / screen is blank**
|
|
225
|
-
Check that you've imported the stylesheet: `import "@swift-food-services/catering-widget/dist/styles.css";`.
|
|
226
|
-
|
|
227
219
|
**Errors mentioning `invalid_publishable_key` or `session_failed`**
|
|
228
|
-
Either the key is wrong
|
|
229
|
-
|
|
230
|
-
**Widget works on `localhost` but not in production**
|
|
231
|
-
Your production origin isn't registered. Ask Swift to add it.
|
|
220
|
+
Either the key is wrong or the key is inactive. Contact Swift if you need a new one.
|
|
232
221
|
|
|
233
222
|
**TypeScript errors importing types**
|
|
234
223
|
Ensure your `tsconfig.json` has `"moduleResolution": "bundler"` or `"node16"`/`"nodenext"`.
|
|
@@ -243,7 +232,7 @@ Modern evergreen browsers (Chrome, Firefox, Safari, Edge) on desktop and mobile.
|
|
|
243
232
|
|
|
244
233
|
## Support
|
|
245
234
|
|
|
246
|
-
- Integration questions: [
|
|
235
|
+
- Integration questions: [swiftfooduk@gmail.com](mailto:swiftfooduk@gmail.com)
|
|
247
236
|
- Bug reports: include your publishable key prefix (first 8 chars), the browser, and a reproducible example.
|
|
248
237
|
|
|
249
238
|
## License
|