@bailaya/react 1.0.7 → 1.0.8
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 +36 -30
- package/dist/components/ClassSchedule.js +1 -1
- package/dist/components/ClassScheduleByType.js +1 -1
- package/dist/components/InstructorList.js +1 -1
- package/dist/components/StudioDescription.js +1 -1
- package/dist/components/StudioProfileCard.js +1 -1
- package/dist/components/UserProfileCard.js +1 -1
- package/dist/hooks/useClasses.d.ts +9 -8
- package/dist/hooks/useClasses.d.ts.map +1 -1
- package/dist/hooks/useClasses.js +47 -12
- package/dist/hooks/useClassesByType.d.ts +10 -9
- package/dist/hooks/useClassesByType.d.ts.map +1 -1
- package/dist/hooks/useClassesByType.js +46 -13
- package/dist/hooks/useInstructors.d.ts +8 -8
- package/dist/hooks/useInstructors.d.ts.map +1 -1
- package/dist/hooks/useInstructors.js +42 -10
- package/dist/hooks/useStudioProfile.d.ts +8 -3
- package/dist/hooks/useStudioProfile.d.ts.map +1 -1
- package/dist/hooks/useStudioProfile.js +42 -5
- package/dist/hooks/useUserProfile.d.ts +9 -5
- package/dist/hooks/useUserProfile.d.ts.map +1 -1
- package/dist/hooks/useUserProfile.js +49 -7
- package/dist/types.d.ts +0 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
`@bailaya/react` builds on top of **@bailaya/core** to provide:
|
|
8
8
|
|
|
9
9
|
- A **`BailayaProvider`** + **`useBailayaClient`** context
|
|
10
|
-
- React
|
|
10
|
+
- React **hooks** for fetching all core data (with `loading`, `error`, `data`, and `refetch`)
|
|
11
11
|
- **Components** with sensible Tailwind defaults (and full styling slots)
|
|
12
12
|
- Full TypeScript support, including localized text & date formatting
|
|
13
13
|
|
|
@@ -16,7 +16,7 @@ Whether you need a quick `<StudioProfileCard />` or fine-grained hooks like `use
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
18
18
|
- **Context + client** (`BailayaProvider` + `useBailayaClient`)
|
|
19
|
-
- **Hooks**
|
|
19
|
+
- **Hooks** (all return `{ data, error, loading, refetch }`)
|
|
20
20
|
- `useStudioProfile(overrideId?)`
|
|
21
21
|
- `useUserProfile(userId)`
|
|
22
22
|
- `useInstructors(overrideId?)`
|
|
@@ -37,40 +37,34 @@ Whether you need a quick `<StudioProfileCard />` or fine-grained hooks like `use
|
|
|
37
37
|
## Installation
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
npm install @bailaya/react
|
|
40
|
+
npm install @bailaya/react
|
|
41
41
|
````
|
|
42
42
|
|
|
43
43
|
or with Yarn:
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
|
-
yarn add @bailaya/react
|
|
46
|
+
yarn add @bailaya/react
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
> **Peer Dependencies**
|
|
50
50
|
>
|
|
51
51
|
> * `"react": ">=17"`
|
|
52
52
|
> * `"react-dom": ">=17"`
|
|
53
|
-
> * `"@tanstack/react-query": ">=5"`
|
|
54
53
|
|
|
55
54
|
## Quick Start
|
|
56
55
|
|
|
57
|
-
First, wrap your app with
|
|
56
|
+
First, wrap your app with **BailayaProvider**:
|
|
58
57
|
|
|
59
58
|
```tsx
|
|
60
59
|
// App.tsx
|
|
61
60
|
import React from "react";
|
|
62
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
63
61
|
import { BailayaProvider } from "@bailaya/react";
|
|
64
62
|
|
|
65
|
-
const queryClient = new QueryClient();
|
|
66
|
-
|
|
67
63
|
export default function App() {
|
|
68
64
|
return (
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</BailayaProvider>
|
|
73
|
-
</QueryClientProvider>
|
|
65
|
+
<BailayaProvider config={{ studioId: "YOUR_STUDIO_ID" }}>
|
|
66
|
+
{/* ...your app */}
|
|
67
|
+
</BailayaProvider>
|
|
74
68
|
);
|
|
75
69
|
}
|
|
76
70
|
```
|
|
@@ -84,17 +78,20 @@ import React from "react";
|
|
|
84
78
|
import { useInstructors } from "@bailaya/react";
|
|
85
79
|
|
|
86
80
|
export function TeamSection() {
|
|
87
|
-
const { data: instructors,
|
|
81
|
+
const { data: instructors, loading, error, refetch } = useInstructors();
|
|
88
82
|
|
|
89
|
-
if (
|
|
83
|
+
if (loading) return <p>Loading...</p>;
|
|
90
84
|
if (error) return <p>Error: {error.message}</p>;
|
|
91
85
|
|
|
92
86
|
return (
|
|
93
|
-
|
|
94
|
-
{
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
<>
|
|
88
|
+
<button onClick={refetch}>Refresh</button>
|
|
89
|
+
<ul>
|
|
90
|
+
{instructors?.map((i) => (
|
|
91
|
+
<li key={i.id}>{i.name} {i.lastname}</li>
|
|
92
|
+
))}
|
|
93
|
+
</ul>
|
|
94
|
+
</>
|
|
98
95
|
);
|
|
99
96
|
}
|
|
100
97
|
```
|
|
@@ -132,15 +129,24 @@ Provides `useBailayaClient()` context.
|
|
|
132
129
|
|
|
133
130
|
### Hooks
|
|
134
131
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
132
|
+
All hooks return:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
{
|
|
136
|
+
data: T | null;
|
|
137
|
+
error: Error | null;
|
|
138
|
+
loading: boolean;
|
|
139
|
+
refetch: () => Promise<void>;
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
| Hook | Description |
|
|
144
|
+
| ------------------------------------------------ | ------------------------------------------------------------ |
|
|
145
|
+
| `useStudioProfile(overrideId?)` | Fetch a studio’s profile. |
|
|
146
|
+
| `useUserProfile(userId)` | Fetch a user’s profile / bio. |
|
|
147
|
+
| `useInstructors(overrideId?)` | Fetch list of active instructors (owner, admin, instructor). |
|
|
148
|
+
| `useClasses(from?, overrideId?)` | Fetch next 7 days of classes (all types). |
|
|
149
|
+
| `useClassesByType(typeName, from?, overrideId?)` | Fetch next 7 days of classes filtered by `typeName`. |
|
|
144
150
|
|
|
145
151
|
### Components
|
|
146
152
|
|
|
@@ -152,7 +158,7 @@ All components share:
|
|
|
152
158
|
* **`renderItem`** for full JSX override
|
|
153
159
|
|
|
154
160
|
| Component | Props |
|
|
155
|
-
|
|
161
|
+
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
156
162
|
| `<StudioProfileCard />` | `overrideId?`, `locale?`, `labels?`, `className?`, `nameClassName?`, `descriptionClassName?`, `labelClassName?`, `renderProfile?` |
|
|
157
163
|
| `<UserProfileCard />` | `userId`, `locale?`, `labels?`, `className?`, `nameClassName?`, `bioClassName?`, `renderProfile?` |
|
|
158
164
|
| `<InstructorList />` | `overrideId?`, `renderItem?`, plus styling slots: `className?`, `itemClassName?`, `imageWrapperClassName?`, etc. |
|
|
@@ -19,7 +19,7 @@ const LoadingIcon_1 = require("./ui/LoadingIcon");
|
|
|
19
19
|
*/
|
|
20
20
|
const ClassSchedule = ({ from, overrideId, locale, labels = {}, className = 'mt-6 md:mt-12 space-y-4', itemClassName = 'p-4 bg-white rounded-lg shadow', nameClassName = 'font-semibold text-lg', detailsClassName = 'text-sm text-gray-600', instructorClassName = 'text-sm text-gray-800 mt-1', renderItem, }) => {
|
|
21
21
|
var _a;
|
|
22
|
-
const { data: classes, isLoading, error } = (0, useClasses_1.useClasses)(from, overrideId);
|
|
22
|
+
const { data: classes, loading: isLoading, error } = (0, useClasses_1.useClasses)(from, overrideId);
|
|
23
23
|
const weekdayFmt = new Intl.DateTimeFormat(locale !== null && locale !== void 0 ? locale : 'en', { weekday: 'long' });
|
|
24
24
|
const dateFmt = new Intl.DateTimeFormat(locale !== null && locale !== void 0 ? locale : 'en', { month: 'short', day: 'numeric' });
|
|
25
25
|
const instructorLabel = (_a = labels === null || labels === void 0 ? void 0 : labels.instructor) !== null && _a !== void 0 ? _a : 'Instructor:';
|
|
@@ -18,7 +18,7 @@ const useClassesByType_1 = require("../hooks/useClassesByType");
|
|
|
18
18
|
*/
|
|
19
19
|
const ClassScheduleByType = ({ typeName, from, overrideId, locale, labels = {}, className = 'mt-6 md:mt-12 space-y-4', itemClassName = 'p-4 bg-white rounded-lg shadow', nameClassName = 'font-semibold text-lg', detailsClassName = 'text-sm text-gray-600', instructorClassName = 'text-sm text-gray-800 mt-1', renderItem, }) => {
|
|
20
20
|
var _a;
|
|
21
|
-
const { data: classes, isLoading, error } = (0, useClassesByType_1.useClassesByType)(typeName, from, overrideId);
|
|
21
|
+
const { data: classes, loading: isLoading, error } = (0, useClassesByType_1.useClassesByType)(typeName, from, overrideId);
|
|
22
22
|
const weekdayFmt = new Intl.DateTimeFormat(locale !== null && locale !== void 0 ? locale : 'en', { weekday: 'long' });
|
|
23
23
|
const dateFmt = new Intl.DateTimeFormat(locale !== null && locale !== void 0 ? locale : 'en', { month: 'short', day: 'numeric' });
|
|
24
24
|
const instructorLabel = (_a = labels === null || labels === void 0 ? void 0 : labels.instructor) !== null && _a !== void 0 ? _a : 'Instructor:';
|
|
@@ -16,7 +16,7 @@ const LoadingIcon_1 = require("./ui/LoadingIcon");
|
|
|
16
16
|
* or completely replace the layout with `renderItem`.
|
|
17
17
|
*/
|
|
18
18
|
const InstructorList = ({ overrideId, className = 'mt-6 md:mt-12 space-y-8', itemClassName = 'flex flex-col md:flex-row items-center rounded-lg border border-[#DCDCDC] shadow-lg overflow-hidden', imageWrapperClassName = 'w-full p-4 pb-0 md:pb-4 md:w-1/3 aspect-square', imageClassName = 'w-full h-full rounded-xl object-cover', bodyClassName = 'p-6 flex-1 text-left', nameClassName = 'text-xl md:text-3xl font-geologica font-semibold text-[#2A2343]', bioClassName = 'mt-2 text-xs md:text-xl font-sourcesans font-semibold text-[#464646]', renderItem, }) => {
|
|
19
|
-
const { data: instructors, isLoading, error } = (0, useInstructors_1.useInstructors)(overrideId);
|
|
19
|
+
const { data: instructors, loading: isLoading, error } = (0, useInstructors_1.useInstructors)(overrideId);
|
|
20
20
|
if (isLoading) {
|
|
21
21
|
return react_1.default.createElement("div", { className: className },
|
|
22
22
|
react_1.default.createElement(LoadingIcon_1.LoadingIcon, null));
|
|
@@ -16,7 +16,7 @@ const LoadingIcon_1 = require("./ui/LoadingIcon");
|
|
|
16
16
|
* - Safe text rendering (no HTML injection).
|
|
17
17
|
*/
|
|
18
18
|
const StudioDescription = ({ overrideId, locale, className = '', paragraphClassName = 'text-xs md:text-2xl font-geologica text-[#464646]', render, }) => {
|
|
19
|
-
const { data: profile, isLoading, error } = (0, useStudioProfile_1.useStudioProfile)(overrideId);
|
|
19
|
+
const { data: profile, loading: isLoading, error } = (0, useStudioProfile_1.useStudioProfile)(overrideId);
|
|
20
20
|
if (isLoading)
|
|
21
21
|
return react_1.default.createElement("div", { className: className },
|
|
22
22
|
react_1.default.createElement(LoadingIcon_1.LoadingIcon, null));
|
|
@@ -18,7 +18,7 @@ const LoadingIcon_1 = require("./ui/LoadingIcon");
|
|
|
18
18
|
*/
|
|
19
19
|
const StudioProfileCard = ({ overrideId, locale, className = 'mt-6 md:mt-12 space-y-8', itemClassName = 'flex flex-col md:flex-row items-center rounded-lg border border-[#DCDCDC] shadow-lg overflow-hidden', imageWrapperClassName = 'w-full p-4 pb-0 md:pb-4 md:w-1/3 aspect-square', imageClassName = 'w-full h-full rounded-xl object-cover', bodyClassName = 'p-6 flex-1 text-left', nameClassName = 'text-xl md:text-3xl font-geologica font-semibold text-[#2A2343]', descriptionClassName = 'mt-2 text-xs md:text-lg font-sourcesans text-[#464646]', labelClassName = 'mt-1 text-sm text-gray-600', renderProfile, labels = {}, }) => {
|
|
20
20
|
var _a, _b;
|
|
21
|
-
const { data: profile, isLoading, error } = (0, useStudioProfile_1.useStudioProfile)(overrideId);
|
|
21
|
+
const { data: profile, loading: isLoading, error } = (0, useStudioProfile_1.useStudioProfile)(overrideId);
|
|
22
22
|
if (isLoading) {
|
|
23
23
|
return react_1.default.createElement("div", { className: className },
|
|
24
24
|
react_1.default.createElement(LoadingIcon_1.LoadingIcon, null));
|
|
@@ -18,7 +18,7 @@ const LoadingIcon_1 = require("./ui/LoadingIcon");
|
|
|
18
18
|
*/
|
|
19
19
|
const UserProfileCard = ({ userId, locale, className = 'mt-6 md:mt-12 space-y-8', itemClassName = 'flex flex-col md:flex-row items-center rounded-lg border border-[#DCDCDC] shadow-lg overflow-hidden', imageWrapperClassName = 'w-full p-4 pb-0 md:pb-4 md:w-1/3 aspect-square', imageClassName = 'w-full h-full rounded-xl object-cover', bodyClassName = 'p-6 flex-1 text-left', nameClassName = 'text-xl md:text-3xl font-geologica font-semibold text-[#2A2343]', bioClassName = 'mt-2 text-xs md:text-xl font-sourcesans font-semibold text-[#464646]', labelClassName = 'mt-1 text-sm text-gray-600', renderProfile, labels = {}, }) => {
|
|
20
20
|
var _a, _b;
|
|
21
|
-
const { data: profile, isLoading, error } = (0, useUserProfile_1.useUserProfile)(userId);
|
|
21
|
+
const { data: profile, loading: isLoading, error } = (0, useUserProfile_1.useUserProfile)(userId);
|
|
22
22
|
if (isLoading) {
|
|
23
23
|
return react_1.default.createElement("div", { className: className },
|
|
24
24
|
react_1.default.createElement(LoadingIcon_1.LoadingIcon, null));
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
1
|
import type { StudioClass } from '@bailaya/core';
|
|
2
|
+
type UseClassesResult = {
|
|
3
|
+
data: StudioClass[] | null;
|
|
4
|
+
error: Error | null;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
refetch: () => Promise<void>;
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
9
|
* Hook to fetch upcoming classes for a studio within a 7-day window.
|
|
5
10
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @param from - Optional Date object to start the 7-day window; defaults to today.
|
|
11
|
+
* @param from - Optional Date to start the 7-day window; defaults to today.
|
|
9
12
|
* @param overrideId - Optional studio ID to override the default configured ID.
|
|
10
|
-
* @returns A React Query result with an array of `StudioClass` objects,
|
|
11
|
-
* or an error if the fetch fails.
|
|
12
|
-
* @throws If used outside of a `BailayaProvider`.
|
|
13
13
|
*/
|
|
14
|
-
export declare function useClasses(from?: Date, overrideId?: string):
|
|
14
|
+
export declare function useClasses(from?: Date, overrideId?: string): UseClassesResult;
|
|
15
|
+
export {};
|
|
15
16
|
//# sourceMappingURL=useClasses.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClasses.d.ts","sourceRoot":"","sources":["../../src/hooks/useClasses.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useClasses.d.ts","sourceRoot":"","sources":["../../src/hooks/useClasses.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,KAAK,gBAAgB,GAAG;IACtB,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;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,gBAAgB,CA+C7E"}
|
package/dist/hooks/useClasses.js
CHANGED
|
@@ -1,25 +1,60 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.useClasses = useClasses;
|
|
4
|
-
const
|
|
13
|
+
const react_1 = require("react");
|
|
5
14
|
const BailayaProvider_1 = require("../context/BailayaProvider");
|
|
6
15
|
/**
|
|
7
16
|
* Hook to fetch upcoming classes for a studio within a 7-day window.
|
|
8
17
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param from - Optional Date object to start the 7-day window; defaults to today.
|
|
18
|
+
* @param from - Optional Date to start the 7-day window; defaults to today.
|
|
12
19
|
* @param overrideId - Optional studio ID to override the default configured ID.
|
|
13
|
-
* @returns A React Query result with an array of `StudioClass` objects,
|
|
14
|
-
* or an error if the fetch fails.
|
|
15
|
-
* @throws If used outside of a `BailayaProvider`.
|
|
16
20
|
*/
|
|
17
21
|
function useClasses(from, overrideId) {
|
|
18
22
|
const client = (0, BailayaProvider_1.useBailayaClient)();
|
|
19
|
-
//
|
|
20
|
-
const fromKey = from ? from.toISOString().split('T')[0] : 'today';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 classes = yield client.getClasses(from, overrideId);
|
|
36
|
+
if (seq === seqRef.current) {
|
|
37
|
+
setData(classes);
|
|
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
|
+
}
|
|
24
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 };
|
|
25
60
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
1
|
import type { StudioClass } from '@bailaya/core';
|
|
2
|
+
type UseClassesByTypeResult = {
|
|
3
|
+
data: StudioClass[] | null;
|
|
4
|
+
error: Error | null;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
refetch: () => Promise<void>;
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
9
|
* Hook to fetch upcoming classes of a specific dance type for a studio within a 7-day window.
|
|
5
10
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @param typeName - Name of the dance type to filter by (e.g., "Salsa").
|
|
9
|
-
* @param from - Optional start `Date` for the 7-day window; defaults to today.
|
|
11
|
+
* @param typeName - Name of the dance type (e.g., "Salsa").
|
|
12
|
+
* @param from - Optional start Date for the 7-day window; defaults to today.
|
|
10
13
|
* @param overrideId - Optional studio ID to override the default configured ID.
|
|
11
|
-
* @returns A React Query result with an array of `StudioClass` objects,
|
|
12
|
-
* or an error if the fetch fails.
|
|
13
|
-
* @throws If used outside of a `BailayaProvider` or if `typeName` is missing.
|
|
14
14
|
*/
|
|
15
|
-
export declare function useClassesByType(typeName: string, from?: Date, overrideId?: string):
|
|
15
|
+
export declare function useClassesByType(typeName: string, from?: Date, overrideId?: string): UseClassesByTypeResult;
|
|
16
|
+
export {};
|
|
16
17
|
//# sourceMappingURL=useClassesByType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClassesByType.d.ts","sourceRoot":"","sources":["../../src/hooks/useClassesByType.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useClassesByType.d.ts","sourceRoot":"","sources":["../../src/hooks/useClassesByType.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,KAAK,sBAAsB,GAAG;IAC5B,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;CAC9B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC5B,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,IAAI,EACX,UAAU,CAAC,EAAE,MAAM,GACpB,sBAAsB,CA6CxB"}
|
|
@@ -1,28 +1,61 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.useClassesByType = useClassesByType;
|
|
4
|
-
const
|
|
13
|
+
const react_1 = require("react");
|
|
5
14
|
const BailayaProvider_1 = require("../context/BailayaProvider");
|
|
6
15
|
/**
|
|
7
16
|
* Hook to fetch upcoming classes of a specific dance type for a studio within a 7-day window.
|
|
8
17
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param typeName - Name of the dance type to filter by (e.g., "Salsa").
|
|
12
|
-
* @param from - Optional start `Date` for the 7-day window; defaults to today.
|
|
18
|
+
* @param typeName - Name of the dance type (e.g., "Salsa").
|
|
19
|
+
* @param from - Optional start Date for the 7-day window; defaults to today.
|
|
13
20
|
* @param overrideId - Optional studio ID to override the default configured ID.
|
|
14
|
-
* @returns A React Query result with an array of `StudioClass` objects,
|
|
15
|
-
* or an error if the fetch fails.
|
|
16
|
-
* @throws If used outside of a `BailayaProvider` or if `typeName` is missing.
|
|
17
21
|
*/
|
|
18
22
|
function useClassesByType(typeName, from, overrideId) {
|
|
19
|
-
const client = (0, BailayaProvider_1.useBailayaClient)();
|
|
20
23
|
if (!typeName) {
|
|
21
24
|
throw new Error('useClassesByType requires a typeName argument');
|
|
22
25
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const client = (0, BailayaProvider_1.useBailayaClient)();
|
|
27
|
+
// Normalize keys so effect only re-runs when they *meaningfully* change.
|
|
28
|
+
const fromKey = (0, react_1.useMemo)(() => (from ? from.toISOString().split('T')[0] : 'today'), [from]);
|
|
29
|
+
const normType = (0, react_1.useMemo)(() => typeName.trim().toLowerCase(), [typeName]);
|
|
30
|
+
const [data, setData] = (0, react_1.useState)(null);
|
|
31
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
32
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
33
|
+
// Prevent stale updates when inputs change quickly or on unmount.
|
|
34
|
+
const seqRef = (0, react_1.useRef)(0);
|
|
35
|
+
const doFetch = () => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const seq = ++seqRef.current;
|
|
37
|
+
setLoading(true);
|
|
38
|
+
setError(null);
|
|
39
|
+
try {
|
|
40
|
+
const classes = yield client.getClassesByType(normType, from, overrideId);
|
|
41
|
+
if (seq === seqRef.current)
|
|
42
|
+
setData(classes);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
if (seq === seqRef.current)
|
|
46
|
+
setError(err);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
if (seq === seqRef.current)
|
|
50
|
+
setLoading(false);
|
|
51
|
+
}
|
|
27
52
|
});
|
|
53
|
+
(0, react_1.useEffect)(() => {
|
|
54
|
+
doFetch();
|
|
55
|
+
return () => {
|
|
56
|
+
// invalidate any in-flight requests
|
|
57
|
+
seqRef.current++;
|
|
58
|
+
};
|
|
59
|
+
}, [client, fromKey, normType, overrideId]);
|
|
60
|
+
return { data, error, loading, refetch: doFetch };
|
|
28
61
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
1
|
import type { Instructor } from '@bailaya/core';
|
|
2
|
+
type UseInstructorsResult = {
|
|
3
|
+
data: Instructor[] | null;
|
|
4
|
+
error: Error | null;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
refetch: () => Promise<void>;
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
9
|
* Hook to fetch the list of instructors for a studio.
|
|
5
10
|
*
|
|
6
|
-
* Utilizes the Bailaya API client from context to retrieve instructor data
|
|
7
|
-
* and caches results using React Query.
|
|
8
|
-
*
|
|
9
11
|
* @param overrideId - Optional studio ID to override the default configured ID.
|
|
10
|
-
* @returns A React Query result containing an array of `Instructor` objects,
|
|
11
|
-
* or an error if the fetch fails.
|
|
12
|
-
* @throws If used outside of a `BailayaProvider`.
|
|
13
12
|
*/
|
|
14
|
-
export declare function useInstructors(overrideId?: string):
|
|
13
|
+
export declare function useInstructors(overrideId?: string): UseInstructorsResult;
|
|
14
|
+
export {};
|
|
15
15
|
//# sourceMappingURL=useInstructors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInstructors.d.ts","sourceRoot":"","sources":["../../src/hooks/useInstructors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useInstructors.d.ts","sourceRoot":"","sources":["../../src/hooks/useInstructors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAqCxE"}
|
|
@@ -1,23 +1,55 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.useInstructors = useInstructors;
|
|
4
|
-
const
|
|
13
|
+
const react_1 = require("react");
|
|
5
14
|
const BailayaProvider_1 = require("../context/BailayaProvider");
|
|
6
15
|
/**
|
|
7
16
|
* Hook to fetch the list of instructors for a studio.
|
|
8
17
|
*
|
|
9
|
-
* Utilizes the Bailaya API client from context to retrieve instructor data
|
|
10
|
-
* and caches results using React Query.
|
|
11
|
-
*
|
|
12
18
|
* @param overrideId - Optional studio ID to override the default configured ID.
|
|
13
|
-
* @returns A React Query result containing an array of `Instructor` objects,
|
|
14
|
-
* or an error if the fetch fails.
|
|
15
|
-
* @throws If used outside of a `BailayaProvider`.
|
|
16
19
|
*/
|
|
17
20
|
function useInstructors(overrideId) {
|
|
18
21
|
const client = (0, BailayaProvider_1.useBailayaClient)();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
// Normalize to a stable key so effect only fires on meaningful changes
|
|
23
|
+
const idKey = (0, react_1.useMemo)(() => overrideId !== null && overrideId !== void 0 ? overrideId : 'default', [overrideId]);
|
|
24
|
+
const [data, setData] = (0, react_1.useState)(null);
|
|
25
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
26
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
27
|
+
// Sequence guard to avoid race conditions on quick prop changes / unmount
|
|
28
|
+
const seqRef = (0, react_1.useRef)(0);
|
|
29
|
+
const doFetch = () => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const seq = ++seqRef.current;
|
|
31
|
+
setLoading(true);
|
|
32
|
+
setError(null);
|
|
33
|
+
try {
|
|
34
|
+
const instructors = yield client.getInstructors(overrideId);
|
|
35
|
+
if (seq === seqRef.current)
|
|
36
|
+
setData(instructors);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
if (seq === seqRef.current)
|
|
40
|
+
setError(err);
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
if (seq === seqRef.current)
|
|
44
|
+
setLoading(false);
|
|
45
|
+
}
|
|
22
46
|
});
|
|
47
|
+
(0, react_1.useEffect)(() => {
|
|
48
|
+
doFetch();
|
|
49
|
+
return () => {
|
|
50
|
+
// invalidate any in-flight request
|
|
51
|
+
seqRef.current++;
|
|
52
|
+
};
|
|
53
|
+
}, [client, idKey]);
|
|
54
|
+
return { data, error, loading, refetch: doFetch };
|
|
23
55
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
1
|
import type { StudioProfile } from '@bailaya/core';
|
|
2
|
+
type UseStudioProfileResult = {
|
|
3
|
+
data: StudioProfile | null;
|
|
4
|
+
error: Error | null;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
refetch: () => Promise<void>;
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
9
|
* Hook to fetch the studio profile.
|
|
5
10
|
*
|
|
6
11
|
* @param overrideId - Optional studio ID to override the default configured ID.
|
|
7
|
-
* @returns A React Query result with the `StudioProfile` object.
|
|
8
12
|
*/
|
|
9
|
-
export declare function useStudioProfile(overrideId?: string):
|
|
13
|
+
export declare function useStudioProfile(overrideId?: string): UseStudioProfileResult;
|
|
14
|
+
export {};
|
|
10
15
|
//# sourceMappingURL=useStudioProfile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStudioProfile.d.ts","sourceRoot":"","sources":["../../src/hooks/useStudioProfile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useStudioProfile.d.ts","sourceRoot":"","sources":["../../src/hooks/useStudioProfile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAqC5E"}
|
|
@@ -1,18 +1,55 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.useStudioProfile = useStudioProfile;
|
|
4
|
-
const
|
|
13
|
+
const react_1 = require("react");
|
|
5
14
|
const BailayaProvider_1 = require("../context/BailayaProvider");
|
|
6
15
|
/**
|
|
7
16
|
* Hook to fetch the studio profile.
|
|
8
17
|
*
|
|
9
18
|
* @param overrideId - Optional studio ID to override the default configured ID.
|
|
10
|
-
* @returns A React Query result with the `StudioProfile` object.
|
|
11
19
|
*/
|
|
12
20
|
function useStudioProfile(overrideId) {
|
|
13
21
|
const client = (0, BailayaProvider_1.useBailayaClient)();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
// Stable dependency key so effect only fires on meaningful changes
|
|
23
|
+
const idKey = (0, react_1.useMemo)(() => overrideId !== null && overrideId !== void 0 ? overrideId : 'default', [overrideId]);
|
|
24
|
+
const [data, setData] = (0, react_1.useState)(null);
|
|
25
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
26
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
27
|
+
// Prevent stale state updates if inputs change quickly or on unmount
|
|
28
|
+
const seqRef = (0, react_1.useRef)(0);
|
|
29
|
+
const doFetch = () => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const seq = ++seqRef.current;
|
|
31
|
+
setLoading(true);
|
|
32
|
+
setError(null);
|
|
33
|
+
try {
|
|
34
|
+
const profile = yield client.getStudioProfile(overrideId);
|
|
35
|
+
if (seq === seqRef.current)
|
|
36
|
+
setData(profile);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
if (seq === seqRef.current)
|
|
40
|
+
setError(err);
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
if (seq === seqRef.current)
|
|
44
|
+
setLoading(false);
|
|
45
|
+
}
|
|
17
46
|
});
|
|
47
|
+
(0, react_1.useEffect)(() => {
|
|
48
|
+
doFetch();
|
|
49
|
+
return () => {
|
|
50
|
+
// invalidate any in-flight promise
|
|
51
|
+
seqRef.current++;
|
|
52
|
+
};
|
|
53
|
+
}, [client, idKey]);
|
|
54
|
+
return { data, error, loading, refetch: doFetch };
|
|
18
55
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
1
|
import type { UserProfile } from '@bailaya/core';
|
|
2
|
+
type UseUserProfileResult = {
|
|
3
|
+
data: UserProfile | null;
|
|
4
|
+
error: Error | null;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
refetch: () => Promise<void>;
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
9
|
* Hook to fetch a user’s profile by their ID.
|
|
5
10
|
*
|
|
6
|
-
* Wraps the BailayaClient.getUserProfile call in React Query.
|
|
7
|
-
*
|
|
8
11
|
* @param userId - The ID of the user to fetch.
|
|
9
|
-
* @returns
|
|
12
|
+
* @returns { data, error, loading, refetch }
|
|
10
13
|
*/
|
|
11
|
-
export declare function useUserProfile(userId: string):
|
|
14
|
+
export declare function useUserProfile(userId: string): UseUserProfileResult;
|
|
15
|
+
export {};
|
|
12
16
|
//# sourceMappingURL=useUserProfile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUserProfile.d.ts","sourceRoot":"","sources":["../../src/hooks/useUserProfile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUserProfile.d.ts","sourceRoot":"","sources":["../../src/hooks/useUserProfile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CA6CnE"}
|
|
@@ -1,20 +1,62 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.useUserProfile = useUserProfile;
|
|
4
|
-
const
|
|
13
|
+
const react_1 = require("react");
|
|
5
14
|
const BailayaProvider_1 = require("../context/BailayaProvider");
|
|
6
15
|
/**
|
|
7
16
|
* Hook to fetch a user’s profile by their ID.
|
|
8
17
|
*
|
|
9
|
-
* Wraps the BailayaClient.getUserProfile call in React Query.
|
|
10
|
-
*
|
|
11
18
|
* @param userId - The ID of the user to fetch.
|
|
12
|
-
* @returns
|
|
19
|
+
* @returns { data, error, loading, refetch }
|
|
13
20
|
*/
|
|
14
21
|
function useUserProfile(userId) {
|
|
15
22
|
const client = (0, BailayaProvider_1.useBailayaClient)();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
// Stable key so the effect only re-runs on meaningful change
|
|
24
|
+
const idKey = (0, react_1.useMemo)(() => userId || 'missing', [userId]);
|
|
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 on quick param changes / unmount
|
|
29
|
+
const seqRef = (0, react_1.useRef)(0);
|
|
30
|
+
const doFetch = () => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const seq = ++seqRef.current;
|
|
32
|
+
if (!userId) {
|
|
33
|
+
setData(null);
|
|
34
|
+
setError(new Error('useUserProfile requires a userId'));
|
|
35
|
+
setLoading(false);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
setLoading(true);
|
|
39
|
+
setError(null);
|
|
40
|
+
try {
|
|
41
|
+
const profile = yield client.getUserProfile(userId);
|
|
42
|
+
if (seq === seqRef.current)
|
|
43
|
+
setData(profile);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (seq === seqRef.current)
|
|
47
|
+
setError(err);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
if (seq === seqRef.current)
|
|
51
|
+
setLoading(false);
|
|
52
|
+
}
|
|
19
53
|
});
|
|
54
|
+
(0, react_1.useEffect)(() => {
|
|
55
|
+
doFetch();
|
|
56
|
+
return () => {
|
|
57
|
+
// invalidate any in-flight request
|
|
58
|
+
seqRef.current++;
|
|
59
|
+
};
|
|
60
|
+
}, [client, idKey]);
|
|
61
|
+
return { data, error, loading, refetch: doFetch };
|
|
20
62
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,8 +2,4 @@
|
|
|
2
2
|
* Core API data structures re-exported from @bailaya/core for convenience.
|
|
3
3
|
*/
|
|
4
4
|
export type { RawStudioProfile, StudioProfile, RawStudioType, StudioType, RawUserProfile, UserProfile, RawInstructor, Instructor, RawStudioClass, StudioClass, } from '@bailaya/core';
|
|
5
|
-
/**
|
|
6
|
-
* React Query result types for library hooks.
|
|
7
|
-
*/
|
|
8
|
-
export type { UseQueryResult, } from '@tanstack/react-query';
|
|
9
5
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,EACX,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,GACZ,MAAM,eAAe,CAAC
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,EACX,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,GACZ,MAAM,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bailaya/react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
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",
|
|
@@ -13,11 +13,9 @@
|
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"react": ">=17.0.0 <20.0.0",
|
|
16
|
-
"react-dom": ">=17.0.0 <20.0.0"
|
|
17
|
-
"@tanstack/react-query": ">=5"
|
|
16
|
+
"react-dom": ">=17.0.0 <20.0.0"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
|
-
"@tanstack/react-query": "^5.84.1",
|
|
21
19
|
"@types/jest": "^30.0.0",
|
|
22
20
|
"@types/react": "^18.0.0",
|
|
23
21
|
"@types/react-dom": "^18.0.0",
|