@bookr-cl/widget 0.0.1

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 ADDED
@@ -0,0 +1,34 @@
1
+ # @bookr-cl/widget
2
+
3
+ Shared booking-flow logic (typed API client, auth helpers, and React hooks) used by Bookr client widgets (ko-pilates, magnolia, and future clients — including third-party integrators). Each site keeps its own JSX/Tailwind presentation layer — this package only owns the parts that cause bugs when duplicated: API calls, validation, state machines, and auth/token handling.
4
+
5
+ ## Install
6
+
7
+ Published on the public npm registry — no auth or custom `.npmrc` needed:
8
+
9
+ ```bash
10
+ npm install @bookr-cl/widget
11
+ ```
12
+
13
+ Requires React 19+ (see `peerDependencies`).
14
+
15
+ ## What's exported
16
+
17
+ - `api.ts` — thin typed functions for every Bookr endpoint the widgets call (`listLocations`, `createBooking`, `sendMagicLink`, etc.), each taking an explicit `{ apiBase, apiKey }` config.
18
+ - `clientAuth.ts` — `getClientToken`/`setClientToken`/`clearClientToken`/`fetchMe`.
19
+ - `dateUtils.ts` — week/date helpers and the default provider-color palette used by class-schedule UIs.
20
+ - `hooks/useBookingFlow` — locations→services→providers→slots fetch chain, validation, submit with 409 handling. Anonymous submissions are resolved server-side by contact fields (rut/email); a caller-supplied `client_id` is only honored alongside a client or staff auth token.
21
+ - `hooks/useClassSchedule` — weekly group-class schedule fetch/submit logic, same anonymous-booking contract as `useBookingFlow`.
22
+ - `hooks/useMagicLinkAuth` — passwordless (magic-link) auth; also accepts optional profile fields (`firstName`/`lastName`/`phone`/`rut`) for signup-style forms, linked server-side by rut first, then email.
23
+ - `hooks/useRegisterForm`, `useClientAccount` — the client account/auth pages' remaining logic.
24
+
25
+ ## Publishing a new version
26
+
27
+ Publishing happens under the `bookr-cl` npm account (a service account for the product, not any individual's personal npm login):
28
+
29
+ ```bash
30
+ npm run build
31
+ npm version patch # or minor/major
32
+ npm publish
33
+ git push --tags
34
+ ```