@bailaya/react 1.0.28 → 1.0.30
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 +6 -46
- package/dist/components/ClassSchedule.d.ts.map +1 -1
- package/dist/components/ClassSchedule.js +2 -22
- package/dist/components/ClassScheduleByType.d.ts.map +1 -1
- package/dist/components/ClassScheduleByType.js +2 -22
- package/dist/components/EventSchedule.d.ts +67 -0
- package/dist/components/EventSchedule.d.ts.map +1 -0
- package/dist/components/EventSchedule.js +81 -0
- package/dist/hooks/useEvents.d.ts +16 -0
- package/dist/hooks/useEvents.d.ts.map +1 -0
- package/dist/hooks/useEvents.js +60 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +24 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* `useInstructors(overrideId?)`
|
|
24
24
|
* `useClasses(from?, overrideId?)`
|
|
25
25
|
* `useClassesByType(typeName, from?, overrideId?)`
|
|
26
|
+
* `useEvents(from?, overrideId?)`
|
|
26
27
|
* **Components** (all props overridable)
|
|
27
28
|
|
|
28
29
|
* `<StudioProfileCard />`
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
* `<InstructorList />`
|
|
31
32
|
* `<ClassSchedule />`
|
|
32
33
|
* `<ClassScheduleByType />`
|
|
34
|
+
* `<EventSchedule />`
|
|
33
35
|
* `<StudioDescription />`
|
|
34
36
|
|
|
35
37
|
## Installation
|
|
@@ -51,50 +53,6 @@ yarn add @bailaya/react
|
|
|
51
53
|
|
|
52
54
|
---
|
|
53
55
|
|
|
54
|
-
## Tailwind Setup (optional)
|
|
55
|
-
|
|
56
|
-
If your app uses Tailwind, add this glob so JIT scans our package classes:
|
|
57
|
-
|
|
58
|
-
```js
|
|
59
|
-
// tailwind.config.js or tailwind.config.ts
|
|
60
|
-
module.exports = {
|
|
61
|
-
content: [
|
|
62
|
-
'./node_modules/@bailaya/**/*.{js,mjs,ts,tsx}',
|
|
63
|
-
],
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
> If you’re not using Tailwind, skip this section.
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## Styling without Tailwind
|
|
72
|
-
|
|
73
|
-
You can use all components in non-Tailwind projects:
|
|
74
|
-
|
|
75
|
-
* Pass your own `className`/`*ClassName` props to inject your CSS classes.
|
|
76
|
-
* Or use `renderItem` / `renderProfile` props to fully control markup.
|
|
77
|
-
|
|
78
|
-
```tsx
|
|
79
|
-
import { InstructorList } from '@bailaya/react'
|
|
80
|
-
|
|
81
|
-
export function Team() {
|
|
82
|
-
return (
|
|
83
|
-
<InstructorList
|
|
84
|
-
className="team"
|
|
85
|
-
itemClassName="card"
|
|
86
|
-
imageWrapperClassName="avatarWrap"
|
|
87
|
-
imageClassName="avatar"
|
|
88
|
-
bodyClassName="cardBody"
|
|
89
|
-
nameClassName="cardTitle"
|
|
90
|
-
bioClassName="cardText"
|
|
91
|
-
/>
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
56
|
## Quick Start
|
|
99
57
|
|
|
100
58
|
First, wrap your app with **BailayaProvider**:
|
|
@@ -178,12 +136,13 @@ All hooks return:
|
|
|
178
136
|
```
|
|
179
137
|
|
|
180
138
|
| Hook | Description |
|
|
181
|
-
|
|
139
|
+
|--------------------------------------------------|--------------------------------------------------------------|
|
|
182
140
|
| `useStudioProfile(overrideId?)` | Fetch a studio’s profile. |
|
|
183
141
|
| `useUserProfile(userId)` | Fetch a user’s profile / bio. |
|
|
184
142
|
| `useInstructors(overrideId?)` | Fetch list of active instructors (owner, admin, instructor). |
|
|
185
143
|
| `useClasses(from?, overrideId?)` | Fetch next 7 days of classes (all types). |
|
|
186
144
|
| `useClassesByType(typeName, from?, overrideId?)` | Fetch next 7 days of classes filtered by `typeName`. |
|
|
145
|
+
| `useEvents(from?, overrideId?)` | Fetch next 7 days of events. |
|
|
187
146
|
|
|
188
147
|
### Components
|
|
189
148
|
|
|
@@ -195,12 +154,13 @@ All components share:
|
|
|
195
154
|
* **`renderItem`** for full JSX override
|
|
196
155
|
|
|
197
156
|
| Component | Props |
|
|
198
|
-
|
|
157
|
+
|---------------------------| --------------------------------------------------------------------------------------------------------------------------------- |
|
|
199
158
|
| `<StudioProfileCard />` | `overrideId?`, `locale?`, `labels?`, `className?`, `nameClassName?`, `descriptionClassName?`, `labelClassName?`, `renderProfile?` |
|
|
200
159
|
| `<UserProfileCard />` | `userId`, `locale?`, `labels?`, `className?`, `nameClassName?`, `bioClassName?`, `renderProfile?` |
|
|
201
160
|
| `<InstructorList />` | `overrideId?`, `renderItem?`, plus styling slots: `className?`, `itemClassName?`, `imageWrapperClassName?`, etc. |
|
|
202
161
|
| `<ClassSchedule />` | `from?`, `overrideId?`, `locale?`, `labels?`, `renderItem?`, plus slots: `className?`, `itemClassName?`, etc. |
|
|
203
162
|
| `<ClassScheduleByType />` | `typeName`, `from?`, `overrideId?`, `locale?`, `labels?`, `renderItem?`, plus same styling slots as `<ClassSchedule />`. |
|
|
163
|
+
| `<EventSchedule />` | `from?`, `overrideId?`, `locale?`, `labels?`, `renderItem?`, plus slots: `className?`, `itemClassName?`, etc. |
|
|
204
164
|
| `<StudioDescription />` | `overrideId?`, `locale?`, `render?`, plus styling slots: `className?`, `paragraphClassName?` |
|
|
205
165
|
|
|
206
166
|
## License
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassSchedule.d.ts","sourceRoot":"","sources":["../../src/components/ClassSchedule.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
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;IAEzB,oDAAoD;IACpD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,MAAM,CAAC;IAE1D;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;KAC7B,KAAK,KAAK,CAAC,SAAS,CAAC;IAEtB,iDAAiD;IACjD,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,KAAK,CAAC,SAAS,CAAC;CACtD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA6GtD,CAAC"}
|
|
@@ -8,27 +8,7 @@ exports.ClassSchedule = void 0;
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const useClasses_1 = require("../hooks/useClasses");
|
|
10
10
|
const LoadingIcon_1 = require("./ui/LoadingIcon");
|
|
11
|
-
|
|
12
|
-
function defaultFormatPrice(price, locale, currency) {
|
|
13
|
-
if (Number.isFinite(price)) {
|
|
14
|
-
if (currency) {
|
|
15
|
-
try {
|
|
16
|
-
return new Intl.NumberFormat(locale !== null && locale !== void 0 ? locale : "en", {
|
|
17
|
-
style: "currency",
|
|
18
|
-
currency,
|
|
19
|
-
}).format(price);
|
|
20
|
-
}
|
|
21
|
-
catch (_a) {
|
|
22
|
-
/* ignore invalid currency and fall through */
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return new Intl.NumberFormat(locale !== null && locale !== void 0 ? locale : "en", {
|
|
26
|
-
minimumFractionDigits: 2,
|
|
27
|
-
maximumFractionDigits: 2,
|
|
28
|
-
}).format(price);
|
|
29
|
-
}
|
|
30
|
-
return "";
|
|
31
|
-
}
|
|
11
|
+
const utils_1 = require("../lib/utils");
|
|
32
12
|
/**
|
|
33
13
|
* Displays an upcoming-class schedule for a studio:
|
|
34
14
|
* - name + level
|
|
@@ -62,7 +42,7 @@ const ClassSchedule = ({ from, overrideId, locale, currency, labels = {}, classN
|
|
|
62
42
|
}
|
|
63
43
|
const priceText = formatPrice
|
|
64
44
|
? formatPrice(cls.price, cls)
|
|
65
|
-
: defaultFormatPrice(cls.price, locale, currency);
|
|
45
|
+
: (0, utils_1.defaultFormatPrice)(cls.price, locale, currency);
|
|
66
46
|
const href = `${bookBaseUrl}${cls.id}`;
|
|
67
47
|
return (react_1.default.createElement("li", { key: cls.id, className: itemClassName },
|
|
68
48
|
react_1.default.createElement("div", { className: rowClassName },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassScheduleByType.d.ts","sourceRoot":"","sources":["../../src/components/ClassScheduleByType.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ClassScheduleByType.d.ts","sourceRoot":"","sources":["../../src/components/ClassScheduleByType.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,MAAM,WAAW,wBAAwB;IACrC,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IAEjB,kEAAkE;IAClE,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oBAAoB;IACpB,MAAM,CAAC,EAAE;QACL,oEAAoE;QACpE,UAAU,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IAEF,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,C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
|
|
|
7
7
|
exports.ClassScheduleByType = void 0;
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const useClassesByType_1 = require("../hooks/useClassesByType");
|
|
10
|
-
|
|
11
|
-
function defaultFormatPrice(price, locale, currency) {
|
|
12
|
-
if (Number.isFinite(price)) {
|
|
13
|
-
if (currency) {
|
|
14
|
-
try {
|
|
15
|
-
return new Intl.NumberFormat(locale !== null && locale !== void 0 ? locale : "en", {
|
|
16
|
-
style: "currency",
|
|
17
|
-
currency,
|
|
18
|
-
}).format(price);
|
|
19
|
-
}
|
|
20
|
-
catch (_a) {
|
|
21
|
-
// Fallback to decimal if currency code is invalid
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return new Intl.NumberFormat(locale !== null && locale !== void 0 ? locale : "en", {
|
|
25
|
-
minimumFractionDigits: 2,
|
|
26
|
-
maximumFractionDigits: 2,
|
|
27
|
-
}).format(price);
|
|
28
|
-
}
|
|
29
|
-
return "";
|
|
30
|
-
}
|
|
10
|
+
const utils_1 = require("../lib/utils");
|
|
31
11
|
/**
|
|
32
12
|
* Displays a schedule of upcoming classes of a specific dance type:
|
|
33
13
|
* - name + level
|
|
@@ -68,7 +48,7 @@ const ClassScheduleByType = ({ typeName, from, overrideId, locale, currency, lab
|
|
|
68
48
|
}
|
|
69
49
|
const priceText = formatPrice
|
|
70
50
|
? formatPrice(cls.price, cls)
|
|
71
|
-
: defaultFormatPrice(cls.price, locale, currency);
|
|
51
|
+
: (0, utils_1.defaultFormatPrice)(cls.price, locale, currency);
|
|
72
52
|
const href = `${bookBaseUrl}${cls.id}`;
|
|
73
53
|
return (react_1.default.createElement("li", { key: cls.id, className: itemClassName },
|
|
74
54
|
react_1.default.createElement("div", { className: rowClassName },
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { StudioEvent } from "@bailaya/core";
|
|
3
|
+
export interface EventScheduleProps {
|
|
4
|
+
/** Optional start date for the 7-day window; defaults to today */
|
|
5
|
+
from?: Date;
|
|
6
|
+
/** Optional studio ID to override the default configured ID */
|
|
7
|
+
overrideId?: string;
|
|
8
|
+
/** Locale code for date/price formatting (e.g. "en", "es"); falls back to browser default */
|
|
9
|
+
locale?: string;
|
|
10
|
+
/** Currency code for price formatting (e.g., "USD", "MXN"). If omitted, shows decimal. */
|
|
11
|
+
currency?: string;
|
|
12
|
+
/** Custom labels (e.g. for "Host:" text) */
|
|
13
|
+
labels?: {
|
|
14
|
+
/** Label text for the instructor line; defaults to "Host:" */
|
|
15
|
+
host?: string;
|
|
16
|
+
};
|
|
17
|
+
/** Root container wrapper */
|
|
18
|
+
className?: string;
|
|
19
|
+
/** Each class "card" wrapper */
|
|
20
|
+
itemClassName?: string;
|
|
21
|
+
/** Wrapper for the inner row (left/right) */
|
|
22
|
+
rowClassName?: string;
|
|
23
|
+
/** Left column (title/meta/instructor) */
|
|
24
|
+
leftClassName?: string;
|
|
25
|
+
/** Event name element */
|
|
26
|
+
nameClassName?: string;
|
|
27
|
+
/** Level element "(Beginner)" */
|
|
28
|
+
levelClassName?: string;
|
|
29
|
+
/** Details (date/time) element */
|
|
30
|
+
detailsClassName?: string;
|
|
31
|
+
/** Host line element */
|
|
32
|
+
hostClassName?: string;
|
|
33
|
+
/** Right column container (price + button) */
|
|
34
|
+
rightClassName?: string;
|
|
35
|
+
/** Price element */
|
|
36
|
+
priceClassName?: string;
|
|
37
|
+
/** Button element */
|
|
38
|
+
buttonClassName?: string;
|
|
39
|
+
/** Text for the Book CTA (i18n). Default: "Book This Event" */
|
|
40
|
+
bookNowText?: string;
|
|
41
|
+
/** Base URL for booking links. Default: "https://www.bailaya.com/book/" */
|
|
42
|
+
bookBaseUrl?: string;
|
|
43
|
+
/** Hide the Book button entirely. Default: false */
|
|
44
|
+
hideBookButton?: boolean;
|
|
45
|
+
/** Custom price formatter (overrides `currency`) */
|
|
46
|
+
formatPrice?: (price: number, evt: StudioEvent) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Optional link renderer.
|
|
49
|
+
* If not provided, a plain <a> will be rendered.
|
|
50
|
+
*/
|
|
51
|
+
renderLink?: (opts: {
|
|
52
|
+
href: string;
|
|
53
|
+
className?: string;
|
|
54
|
+
children: React.ReactNode;
|
|
55
|
+
}) => React.ReactNode;
|
|
56
|
+
/** Completely override the default renderItem */
|
|
57
|
+
renderItem?: (evt: StudioEvent) => React.ReactNode;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Displays an upcoming-event schedule for a studio:
|
|
61
|
+
* - name + level
|
|
62
|
+
* - weekday, date, time
|
|
63
|
+
* - optional instructor
|
|
64
|
+
* - RIGHT: price + "Book This Event" CTA
|
|
65
|
+
*/
|
|
66
|
+
export declare const EventSchedule: React.FC<EventScheduleProps>;
|
|
67
|
+
//# sourceMappingURL=EventSchedule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventSchedule.d.ts","sourceRoot":"","sources":["../../src/components/EventSchedule.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAIjD,MAAM,WAAW,kBAAkB;IAC/B,kEAAkE;IAClE,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,4CAA4C;IAC5C,MAAM,CAAC,EAAE;QACL,8DAA8D;QAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yBAAyB;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wBAAwB;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qBAAqB;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,oDAAoD;IACpD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,MAAM,CAAC;IAE1D;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;KAC7B,KAAK,KAAK,CAAC,SAAS,CAAC;IAEtB,iDAAiD;IACjD,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,KAAK,CAAC,SAAS,CAAC;CACtD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA6GtD,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.EventSchedule = void 0;
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const useEvents_1 = require("../hooks/useEvents");
|
|
10
|
+
const LoadingIcon_1 = require("./ui/LoadingIcon");
|
|
11
|
+
const utils_1 = require("../lib/utils");
|
|
12
|
+
/**
|
|
13
|
+
* Displays an upcoming-event schedule for a studio:
|
|
14
|
+
* - name + level
|
|
15
|
+
* - weekday, date, time
|
|
16
|
+
* - optional instructor
|
|
17
|
+
* - RIGHT: price + "Book This Event" CTA
|
|
18
|
+
*/
|
|
19
|
+
const EventSchedule = ({ from, overrideId, locale, currency, labels = {}, className = "by-scheduleList", itemClassName = "by-scheduleItem", rowClassName = "by-scheduleRow", leftClassName = "by-scheduleLeft", nameClassName = "by-scheduleName", levelClassName = "by-scheduleLevel", detailsClassName = "by-scheduleMeta", hostClassName = "by-scheduleInstructor", rightClassName = "by-scheduleRight", priceClassName = "by-schedulePrice", buttonClassName = "by-btn by-btnBook", bookNowText = "Book This Class", bookBaseUrl = "https://www.bailaya.com/book/", hideBookButton = false, formatPrice, renderLink, renderItem, }) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const { data: events, loading, error } = (0, useEvents_1.useEvents)(from, overrideId);
|
|
22
|
+
const weekdayFmt = new Intl.DateTimeFormat(locale !== null && locale !== void 0 ? locale : "en", { weekday: "long" });
|
|
23
|
+
const dateFmt = new Intl.DateTimeFormat(locale !== null && locale !== void 0 ? locale : "en", {
|
|
24
|
+
month: "short",
|
|
25
|
+
day: "numeric",
|
|
26
|
+
});
|
|
27
|
+
const hostLabel = (_a = labels === null || labels === void 0 ? void 0 : labels.host) !== null && _a !== void 0 ? _a : "Host:";
|
|
28
|
+
if (loading) {
|
|
29
|
+
return (react_1.default.createElement("ul", { className: className },
|
|
30
|
+
react_1.default.createElement("li", null,
|
|
31
|
+
react_1.default.createElement(LoadingIcon_1.LoadingIcon, null))));
|
|
32
|
+
}
|
|
33
|
+
if (error) {
|
|
34
|
+
return (react_1.default.createElement("ul", { className: className },
|
|
35
|
+
react_1.default.createElement("li", null, error.message)));
|
|
36
|
+
}
|
|
37
|
+
return (react_1.default.createElement("ul", { className: className }, events === null || events === void 0 ? void 0 : events.map((evt) => {
|
|
38
|
+
const dayName = weekdayFmt.format(evt.date);
|
|
39
|
+
const shortDate = dateFmt.format(evt.date);
|
|
40
|
+
if (renderItem) {
|
|
41
|
+
return react_1.default.createElement("li", { key: evt.id }, renderItem(evt));
|
|
42
|
+
}
|
|
43
|
+
const priceText = formatPrice
|
|
44
|
+
? formatPrice(evt.price, evt)
|
|
45
|
+
: (0, utils_1.defaultFormatPrice)(evt.price, locale, currency);
|
|
46
|
+
const href = `${bookBaseUrl}${evt.id}`;
|
|
47
|
+
return (react_1.default.createElement("li", { key: evt.id, className: itemClassName },
|
|
48
|
+
react_1.default.createElement("div", { className: rowClassName },
|
|
49
|
+
react_1.default.createElement("div", { className: leftClassName },
|
|
50
|
+
react_1.default.createElement("div", { className: nameClassName },
|
|
51
|
+
evt.name,
|
|
52
|
+
" ",
|
|
53
|
+
react_1.default.createElement("span", { className: levelClassName },
|
|
54
|
+
"(",
|
|
55
|
+
evt.level,
|
|
56
|
+
")")),
|
|
57
|
+
react_1.default.createElement("div", { className: detailsClassName },
|
|
58
|
+
dayName,
|
|
59
|
+
", ",
|
|
60
|
+
shortDate,
|
|
61
|
+
" \u2014 ",
|
|
62
|
+
evt.startTime,
|
|
63
|
+
"\u2013",
|
|
64
|
+
evt.endTime),
|
|
65
|
+
evt.host && (react_1.default.createElement("div", { className: hostClassName },
|
|
66
|
+
hostLabel,
|
|
67
|
+
" ",
|
|
68
|
+
react_1.default.createElement("strong", null,
|
|
69
|
+
evt.host.name,
|
|
70
|
+
evt.host.lastname ? ` ${evt.host.lastname}` : "")))),
|
|
71
|
+
react_1.default.createElement("div", { className: rightClassName },
|
|
72
|
+
Number.isFinite(evt.price) && (react_1.default.createElement("div", { className: priceClassName }, priceText)),
|
|
73
|
+
!hideBookButton &&
|
|
74
|
+
(renderLink ? (renderLink({
|
|
75
|
+
href,
|
|
76
|
+
className: buttonClassName,
|
|
77
|
+
children: bookNowText,
|
|
78
|
+
})) : (react_1.default.createElement("a", { href: href, className: buttonClassName }, bookNowText)))))));
|
|
79
|
+
})));
|
|
80
|
+
};
|
|
81
|
+
exports.EventSchedule = EventSchedule;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StudioEvent } from '@bailaya/core';
|
|
2
|
+
type UseEventsResult = {
|
|
3
|
+
data: StudioEvent[] | null;
|
|
4
|
+
error: Error | null;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
refetch: () => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Hook to fetch upcoming events for a studio within a 7-day window.
|
|
10
|
+
*
|
|
11
|
+
* @param from - Optional Date to start the 7-day window; defaults to today.
|
|
12
|
+
* @param overrideId - Optional studio ID to override the default configured ID.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useEvents(from?: Date, overrideId?: string): UseEventsResult;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=useEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEvents.d.ts","sourceRoot":"","sources":["../../src/hooks/useEvents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,eAAe,CA+C3E"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useEvents = useEvents;
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const BailayaProvider_1 = require("../context/BailayaProvider");
|
|
15
|
+
/**
|
|
16
|
+
* Hook to fetch upcoming events for a studio within a 7-day window.
|
|
17
|
+
*
|
|
18
|
+
* @param from - Optional Date to start the 7-day window; defaults to today.
|
|
19
|
+
* @param overrideId - Optional studio ID to override the default configured ID.
|
|
20
|
+
*/
|
|
21
|
+
function useEvents(from, overrideId) {
|
|
22
|
+
const client = (0, BailayaProvider_1.useBailayaClient)();
|
|
23
|
+
// Normalize `from` to a day key so the effect only re-runs when the day changes
|
|
24
|
+
const fromKey = (0, react_1.useMemo)(() => (from ? from.toISOString().split('T')[0] : 'today'), [from]);
|
|
25
|
+
const [data, setData] = (0, react_1.useState)(null);
|
|
26
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
27
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
28
|
+
// Prevent race conditions when params change quickly
|
|
29
|
+
const seqRef = (0, react_1.useRef)(0);
|
|
30
|
+
const doFetch = () => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const seq = ++seqRef.current;
|
|
32
|
+
setLoading(true);
|
|
33
|
+
setError(null);
|
|
34
|
+
try {
|
|
35
|
+
const events = yield client.getEvents(from, overrideId);
|
|
36
|
+
if (seq === seqRef.current) {
|
|
37
|
+
setData(events);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (seq === seqRef.current) {
|
|
42
|
+
setError(err);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
if (seq === seqRef.current) {
|
|
47
|
+
setLoading(false);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
(0, react_1.useEffect)(() => {
|
|
52
|
+
doFetch();
|
|
53
|
+
// cleanup just bumps the sequence so late resolves are ignored
|
|
54
|
+
return () => {
|
|
55
|
+
seqRef.current++;
|
|
56
|
+
};
|
|
57
|
+
// Depend on the normalized key + overrideId + client
|
|
58
|
+
}, [client, fromKey, overrideId]);
|
|
59
|
+
return { data, error, loading, refetch: doFetch };
|
|
60
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,11 +14,13 @@ export { useStudioProfile } from './hooks/useStudioProfile';
|
|
|
14
14
|
export { useInstructors } from './hooks/useInstructors';
|
|
15
15
|
export { useClasses } from './hooks/useClasses';
|
|
16
16
|
export { useClassesByType } from './hooks/useClassesByType';
|
|
17
|
+
export { useEvents } from './hooks/useEvents';
|
|
17
18
|
/**
|
|
18
19
|
* React components
|
|
19
20
|
*/
|
|
20
21
|
export { ClassSchedule, ClassScheduleProps } from './components/ClassSchedule';
|
|
21
22
|
export { ClassScheduleByType, ClassScheduleByTypeProps } from './components/ClassScheduleByType';
|
|
23
|
+
export { EventSchedule, EventScheduleProps } from './components/EventSchedule';
|
|
22
24
|
export { InstructorList, InstructorListProps } from './components/InstructorList';
|
|
23
25
|
export { StudioProfileCard, StudioProfileCardProps } from './components/StudioProfileCard';
|
|
24
26
|
export { StudioTypesList, StudioTypesListProps } from './components/StudioTypesList';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE9E;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE9E;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;GAEG;AACH,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
19
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.StudioDescription = exports.UserProfileCard = exports.StudioTypesGrid = exports.StudioTypesList = exports.StudioProfileCard = exports.InstructorList = exports.ClassScheduleByType = exports.ClassSchedule = exports.useClassesByType = exports.useClasses = exports.useInstructors = exports.useStudioProfile = exports.useBailayaClient = exports.BailayaProvider = void 0;
|
|
22
|
+
exports.StudioDescription = exports.UserProfileCard = exports.StudioTypesGrid = exports.StudioTypesList = exports.StudioProfileCard = exports.InstructorList = exports.EventSchedule = exports.ClassScheduleByType = exports.ClassSchedule = exports.useEvents = exports.useClassesByType = exports.useClasses = exports.useInstructors = exports.useStudioProfile = exports.useBailayaClient = exports.BailayaProvider = void 0;
|
|
23
23
|
/**
|
|
24
24
|
* Re-exported context and hooks for easy import
|
|
25
25
|
*/
|
|
@@ -37,6 +37,8 @@ var useClasses_1 = require("./hooks/useClasses");
|
|
|
37
37
|
Object.defineProperty(exports, "useClasses", { enumerable: true, get: function () { return useClasses_1.useClasses; } });
|
|
38
38
|
var useClassesByType_1 = require("./hooks/useClassesByType");
|
|
39
39
|
Object.defineProperty(exports, "useClassesByType", { enumerable: true, get: function () { return useClassesByType_1.useClassesByType; } });
|
|
40
|
+
var useEvents_1 = require("./hooks/useEvents");
|
|
41
|
+
Object.defineProperty(exports, "useEvents", { enumerable: true, get: function () { return useEvents_1.useEvents; } });
|
|
40
42
|
/**
|
|
41
43
|
* React components
|
|
42
44
|
*/
|
|
@@ -44,6 +46,8 @@ var ClassSchedule_1 = require("./components/ClassSchedule");
|
|
|
44
46
|
Object.defineProperty(exports, "ClassSchedule", { enumerable: true, get: function () { return ClassSchedule_1.ClassSchedule; } });
|
|
45
47
|
var ClassScheduleByType_1 = require("./components/ClassScheduleByType");
|
|
46
48
|
Object.defineProperty(exports, "ClassScheduleByType", { enumerable: true, get: function () { return ClassScheduleByType_1.ClassScheduleByType; } });
|
|
49
|
+
var EventSchedule_1 = require("./components/EventSchedule");
|
|
50
|
+
Object.defineProperty(exports, "EventSchedule", { enumerable: true, get: function () { return EventSchedule_1.EventSchedule; } });
|
|
47
51
|
var InstructorList_1 = require("./components/InstructorList");
|
|
48
52
|
Object.defineProperty(exports, "InstructorList", { enumerable: true, get: function () { return InstructorList_1.InstructorList; } });
|
|
49
53
|
var StudioProfileCard_1 = require("./components/StudioProfileCard");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,wBAAgB,kBAAkB,CAC9B,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAClB,MAAM,CAkBR"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultFormatPrice = defaultFormatPrice;
|
|
4
|
+
/** Default price formatter (uses currency if provided; falls back to decimal). */
|
|
5
|
+
function defaultFormatPrice(price, locale, currency) {
|
|
6
|
+
if (Number.isFinite(price)) {
|
|
7
|
+
if (currency) {
|
|
8
|
+
try {
|
|
9
|
+
return new Intl.NumberFormat(locale !== null && locale !== void 0 ? locale : "en", {
|
|
10
|
+
style: "currency",
|
|
11
|
+
currency,
|
|
12
|
+
}).format(price);
|
|
13
|
+
}
|
|
14
|
+
catch (_a) {
|
|
15
|
+
/* ignore invalid currency and fall through */
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return new Intl.NumberFormat(locale !== null && locale !== void 0 ? locale : "en", {
|
|
19
|
+
minimumFractionDigits: 2,
|
|
20
|
+
maximumFractionDigits: 2,
|
|
21
|
+
}).format(price);
|
|
22
|
+
}
|
|
23
|
+
return "";
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bailaya/react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"description": "A React component library for the BailaYa public API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"typescript": "^5.8.3"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@bailaya/core": "^1.0.
|
|
35
|
+
"@bailaya/core": "^1.0.8",
|
|
36
36
|
"lucide-react": "^0.536.0"
|
|
37
37
|
},
|
|
38
38
|
"license": "ISC"
|