@bailaya/react 1.0.6 → 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.
Files changed (47) hide show
  1. package/README.md +36 -30
  2. package/dist/components/ClassSchedule.d.ts +40 -0
  3. package/dist/components/ClassSchedule.d.ts.map +1 -0
  4. package/dist/components/ClassSchedule.js +65 -0
  5. package/dist/components/ClassScheduleByType.d.ts +42 -0
  6. package/dist/components/ClassScheduleByType.d.ts.map +1 -0
  7. package/dist/components/ClassScheduleByType.js +68 -0
  8. package/dist/components/InstructorList.d.ts +34 -0
  9. package/dist/components/InstructorList.d.ts.map +1 -0
  10. package/dist/components/InstructorList.js +39 -0
  11. package/dist/components/StudioDescription.d.ts +26 -0
  12. package/dist/components/StudioDescription.d.ts.map +1 -0
  13. package/dist/components/StudioDescription.js +51 -0
  14. package/dist/components/StudioProfileCard.d.ts +47 -0
  15. package/dist/components/StudioProfileCard.d.ts.map +1 -0
  16. package/dist/components/StudioProfileCard.js +59 -0
  17. package/dist/components/UserProfileCard.d.ts +47 -0
  18. package/dist/components/UserProfileCard.d.ts.map +1 -0
  19. package/dist/components/UserProfileCard.js +61 -0
  20. package/dist/components/ui/LoadingIcon.d.ts +3 -0
  21. package/dist/components/ui/LoadingIcon.d.ts.map +1 -0
  22. package/dist/components/ui/LoadingIcon.js +13 -0
  23. package/dist/context/BailayaProvider.d.ts +8 -0
  24. package/dist/context/BailayaProvider.d.ts.map +1 -0
  25. package/dist/context/BailayaProvider.js +52 -0
  26. package/dist/hooks/useClasses.d.ts +16 -0
  27. package/dist/hooks/useClasses.d.ts.map +1 -0
  28. package/dist/hooks/useClasses.js +60 -0
  29. package/dist/hooks/useClassesByType.d.ts +17 -0
  30. package/dist/hooks/useClassesByType.d.ts.map +1 -0
  31. package/dist/hooks/useClassesByType.js +61 -0
  32. package/dist/hooks/useInstructors.d.ts +15 -0
  33. package/dist/hooks/useInstructors.d.ts.map +1 -0
  34. package/dist/hooks/useInstructors.js +55 -0
  35. package/dist/hooks/useStudioProfile.d.ts +15 -0
  36. package/dist/hooks/useStudioProfile.d.ts.map +1 -0
  37. package/dist/hooks/useStudioProfile.js +55 -0
  38. package/dist/hooks/useUserProfile.d.ts +16 -0
  39. package/dist/hooks/useUserProfile.d.ts.map +1 -0
  40. package/dist/hooks/useUserProfile.js +62 -0
  41. package/dist/index.d.ts +30 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +58 -0
  44. package/dist/types.d.ts +5 -0
  45. package/dist/types.d.ts.map +1 -0
  46. package/dist/types.js +2 -0
  47. package/package.json +3 -5
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import type { UserProfile } from '@bailaya/core';
3
+ export interface UserProfileCardProps {
4
+ /** The user ID to fetch */
5
+ userId: string;
6
+ /** Locale code (e.g. "en", "es") for picking the bio */
7
+ locale?: string;
8
+ /** Root container wrapper */
9
+ className?: string;
10
+ /** Wrapper for the entire "card" */
11
+ itemClassName?: string;
12
+ /** Wrapper around the profile image */
13
+ imageWrapperClassName?: string;
14
+ /** The `<img>` element itself */
15
+ imageClassName?: string;
16
+ /** Container for the name + bio + labels */
17
+ bodyClassName?: string;
18
+ /** Heading for the user’s name */
19
+ nameClassName?: string;
20
+ /** Paragraph for the bio */
21
+ bioClassName?: string;
22
+ /** Label/value lines (occupation, experience) */
23
+ labelClassName?: string;
24
+ /**
25
+ * If provided, completely overrides the default card render.
26
+ */
27
+ renderProfile?: (profile: UserProfile) => React.ReactNode;
28
+ /**
29
+ * Custom text labels (useful for localization):
30
+ * - occupationLabel
31
+ * - experienceLabel
32
+ */
33
+ labels?: {
34
+ occupationLabel?: string;
35
+ experienceLabel?: string;
36
+ };
37
+ }
38
+ /**
39
+ * Displays a single user's profile as a "card":
40
+ * - photo
41
+ * - full name
42
+ * - localized bio
43
+ * - occupation
44
+ * - years of experience
45
+ */
46
+ export declare const UserProfileCard: React.FC<UserProfileCardProps>;
47
+ //# sourceMappingURL=UserProfileCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserProfileCard.d.ts","sourceRoot":"","sources":["../../src/components/UserProfileCard.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,MAAM,WAAW,oBAAoB;IACnC,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IAEf,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,oCAAoC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,uCAAuC;IACvC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,kCAAkC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,4BAA4B;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,KAAK,CAAC,SAAS,CAAC;IAE1D;;;;OAIG;IACH,MAAM,CAAC,EAAE;QACP,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA8E1D,CAAC"}
@@ -0,0 +1,61 @@
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.UserProfileCard = void 0;
8
+ const react_1 = __importDefault(require("react"));
9
+ const useUserProfile_1 = require("../hooks/useUserProfile");
10
+ const LoadingIcon_1 = require("./ui/LoadingIcon");
11
+ /**
12
+ * Displays a single user's profile as a "card":
13
+ * - photo
14
+ * - full name
15
+ * - localized bio
16
+ * - occupation
17
+ * - years of experience
18
+ */
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
+ var _a, _b;
21
+ const { data: profile, loading: isLoading, error } = (0, useUserProfile_1.useUserProfile)(userId);
22
+ if (isLoading) {
23
+ return react_1.default.createElement("div", { className: className },
24
+ react_1.default.createElement(LoadingIcon_1.LoadingIcon, null));
25
+ }
26
+ if (error) {
27
+ return react_1.default.createElement("div", { className: className }, error.message);
28
+ }
29
+ if (!profile) {
30
+ return null;
31
+ }
32
+ // pick bio by locale, fallback to first
33
+ const bioMap = profile.bio || {};
34
+ const locales = Object.keys(bioMap);
35
+ const selectedBio = (locale && bioMap[locale]) ||
36
+ bioMap[locales[0]] ||
37
+ '';
38
+ if (renderProfile) {
39
+ return react_1.default.createElement(react_1.default.Fragment, null, renderProfile(profile));
40
+ }
41
+ const occLabel = (_a = labels === null || labels === void 0 ? void 0 : labels.occupationLabel) !== null && _a !== void 0 ? _a : (locale === 'es' ? 'Ocupación' : 'Occupation');
42
+ const expLabel = (_b = labels === null || labels === void 0 ? void 0 : labels.experienceLabel) !== null && _b !== void 0 ? _b : (locale === 'es' ? 'Años de experiencia' : 'Years of experience');
43
+ return (react_1.default.createElement("div", { className: className },
44
+ react_1.default.createElement("div", { className: itemClassName },
45
+ profile.image && (react_1.default.createElement("div", { className: imageWrapperClassName },
46
+ react_1.default.createElement("img", { src: profile.image, alt: `${profile.name}${profile.lastname ? ' ' + profile.lastname : ''}`, className: imageClassName }))),
47
+ react_1.default.createElement("div", { className: bodyClassName },
48
+ react_1.default.createElement("h3", { className: nameClassName },
49
+ profile.name,
50
+ profile.lastname ? ` ${profile.lastname}` : ''),
51
+ selectedBio && (react_1.default.createElement("p", { className: bioClassName }, selectedBio)),
52
+ profile.occupation && (react_1.default.createElement("p", { className: labelClassName },
53
+ occLabel,
54
+ ": ",
55
+ profile.occupation)),
56
+ profile.yearsOfExperience != null && (react_1.default.createElement("p", { className: labelClassName },
57
+ expLabel,
58
+ ": ",
59
+ profile.yearsOfExperience))))));
60
+ };
61
+ exports.UserProfileCard = UserProfileCard;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ export declare const LoadingIcon: () => React.JSX.Element;
3
+ //# sourceMappingURL=LoadingIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoadingIcon.d.ts","sourceRoot":"","sources":["../../../src/components/ui/LoadingIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,eAAO,MAAM,WAAW,yBAMvB,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LoadingIcon = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const lucide_react_1 = require("lucide-react");
9
+ const LoadingIcon = () => {
10
+ return (react_1.default.createElement("div", { className: "flex items-center justify-center h-screen" },
11
+ react_1.default.createElement(lucide_react_1.Loader, { className: "animate-spin w-12 h-12 text-blue-500" })));
12
+ };
13
+ exports.LoadingIcon = LoadingIcon;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { BailayaClient, BailayaClientOptions } from '@bailaya/core';
3
+ export declare const BailayaProvider: React.FC<{
4
+ children: React.ReactNode;
5
+ config: BailayaClientOptions;
6
+ }>;
7
+ export declare const useBailayaClient: () => BailayaClient;
8
+ //# sourceMappingURL=BailayaProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BailayaProvider.d.ts","sourceRoot":"","sources":["../../src/context/BailayaProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAIpE,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE,oBAAoB,CAAC;CAC9B,CAOA,CAAC;AAEF,eAAO,MAAM,gBAAgB,qBAI5B,CAAC"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ "use client";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.useBailayaClient = exports.BailayaProvider = void 0;
38
+ const react_1 = __importStar(require("react"));
39
+ const core_1 = require("@bailaya/core");
40
+ const BailayaContext = (0, react_1.createContext)(null);
41
+ const BailayaProvider = ({ children, config }) => {
42
+ const client = new core_1.BailayaClient(config);
43
+ return (react_1.default.createElement(BailayaContext.Provider, { value: client }, children));
44
+ };
45
+ exports.BailayaProvider = BailayaProvider;
46
+ const useBailayaClient = () => {
47
+ const ctx = (0, react_1.useContext)(BailayaContext);
48
+ if (!ctx)
49
+ throw new Error('useBailayaClient must be used inside a BailayaProvider');
50
+ return ctx;
51
+ };
52
+ exports.useBailayaClient = useBailayaClient;
@@ -0,0 +1,16 @@
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
+ };
8
+ /**
9
+ * Hook to fetch upcoming classes 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 useClasses(from?: Date, overrideId?: string): UseClassesResult;
15
+ export {};
16
+ //# sourceMappingURL=useClasses.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -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.useClasses = useClasses;
13
+ const react_1 = require("react");
14
+ const BailayaProvider_1 = require("../context/BailayaProvider");
15
+ /**
16
+ * Hook to fetch upcoming classes 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 useClasses(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 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
+ }
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
+ }
@@ -0,0 +1,17 @@
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
+ };
8
+ /**
9
+ * Hook to fetch upcoming classes of a specific dance type for a studio within a 7-day window.
10
+ *
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.
13
+ * @param overrideId - Optional studio ID to override the default configured ID.
14
+ */
15
+ export declare function useClassesByType(typeName: string, from?: Date, overrideId?: string): UseClassesByTypeResult;
16
+ export {};
17
+ //# sourceMappingURL=useClassesByType.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,61 @@
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.useClassesByType = useClassesByType;
13
+ const react_1 = require("react");
14
+ const BailayaProvider_1 = require("../context/BailayaProvider");
15
+ /**
16
+ * Hook to fetch upcoming classes of a specific dance type for a studio within a 7-day window.
17
+ *
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.
20
+ * @param overrideId - Optional studio ID to override the default configured ID.
21
+ */
22
+ function useClassesByType(typeName, from, overrideId) {
23
+ if (!typeName) {
24
+ throw new Error('useClassesByType requires a typeName argument');
25
+ }
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
+ }
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 };
61
+ }
@@ -0,0 +1,15 @@
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
+ };
8
+ /**
9
+ * Hook to fetch the list of instructors for a studio.
10
+ *
11
+ * @param overrideId - Optional studio ID to override the default configured ID.
12
+ */
13
+ export declare function useInstructors(overrideId?: string): UseInstructorsResult;
14
+ export {};
15
+ //# sourceMappingURL=useInstructors.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,55 @@
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.useInstructors = useInstructors;
13
+ const react_1 = require("react");
14
+ const BailayaProvider_1 = require("../context/BailayaProvider");
15
+ /**
16
+ * Hook to fetch the list of instructors for a studio.
17
+ *
18
+ * @param overrideId - Optional studio ID to override the default configured ID.
19
+ */
20
+ function useInstructors(overrideId) {
21
+ const client = (0, BailayaProvider_1.useBailayaClient)();
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
+ }
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 };
55
+ }
@@ -0,0 +1,15 @@
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
+ };
8
+ /**
9
+ * Hook to fetch the studio profile.
10
+ *
11
+ * @param overrideId - Optional studio ID to override the default configured ID.
12
+ */
13
+ export declare function useStudioProfile(overrideId?: string): UseStudioProfileResult;
14
+ export {};
15
+ //# sourceMappingURL=useStudioProfile.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,55 @@
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.useStudioProfile = useStudioProfile;
13
+ const react_1 = require("react");
14
+ const BailayaProvider_1 = require("../context/BailayaProvider");
15
+ /**
16
+ * Hook to fetch the studio profile.
17
+ *
18
+ * @param overrideId - Optional studio ID to override the default configured ID.
19
+ */
20
+ function useStudioProfile(overrideId) {
21
+ const client = (0, BailayaProvider_1.useBailayaClient)();
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
+ }
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 };
55
+ }
@@ -0,0 +1,16 @@
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
+ };
8
+ /**
9
+ * Hook to fetch a user’s profile by their ID.
10
+ *
11
+ * @param userId - The ID of the user to fetch.
12
+ * @returns { data, error, loading, refetch }
13
+ */
14
+ export declare function useUserProfile(userId: string): UseUserProfileResult;
15
+ export {};
16
+ //# sourceMappingURL=useUserProfile.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,62 @@
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.useUserProfile = useUserProfile;
13
+ const react_1 = require("react");
14
+ const BailayaProvider_1 = require("../context/BailayaProvider");
15
+ /**
16
+ * Hook to fetch a user’s profile by their ID.
17
+ *
18
+ * @param userId - The ID of the user to fetch.
19
+ * @returns { data, error, loading, refetch }
20
+ */
21
+ function useUserProfile(userId) {
22
+ const client = (0, BailayaProvider_1.useBailayaClient)();
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
+ }
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 };
62
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Exports all components and hooks for interacting with the Bailaya API.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ /**
7
+ * Re-exported context and hooks for easy import
8
+ */
9
+ export { BailayaProvider, useBailayaClient } from './context/BailayaProvider';
10
+ /**
11
+ * Data hooks
12
+ */
13
+ export { useStudioProfile } from './hooks/useStudioProfile';
14
+ export { useInstructors } from './hooks/useInstructors';
15
+ export { useClasses } from './hooks/useClasses';
16
+ export { useClassesByType } from './hooks/useClassesByType';
17
+ /**
18
+ * React components
19
+ */
20
+ export { ClassSchedule, ClassScheduleProps } from './components/ClassSchedule';
21
+ export { ClassScheduleByType, ClassScheduleByTypeProps } from './components/ClassScheduleByType';
22
+ export { InstructorList, InstructorListProps } from './components/InstructorList';
23
+ export { StudioProfileCard, StudioProfileCardProps } from './components/StudioProfileCard';
24
+ export { UserProfileCard, UserProfileCardProps } from './components/UserProfileCard';
25
+ export { StudioDescription } from './components/StudioDescription';
26
+ /**
27
+ * Types re-exported for consumer convenience
28
+ */
29
+ export * from './types';
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;AAE5D;;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,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,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;GAEG;AACH,cAAc,SAAS,CAAC"}