autumn-js 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +0 -0
  2. package/dist/react/client/AutumnContext.d.mts +9 -0
  3. package/dist/react/client/AutumnContext.d.ts +9 -0
  4. package/dist/react/client/AutumnContext.js +18 -0
  5. package/dist/react/client/AutumnContext.mjs +18 -0
  6. package/dist/react/client/AutumnProvider.d.mts +12 -0
  7. package/dist/react/client/AutumnProvider.d.ts +12 -0
  8. package/dist/react/client/AutumnProvider.js +22 -0
  9. package/dist/react/client/AutumnProvider.mjs +22 -0
  10. package/dist/react/client/cusTypes-BT7wlTNj.d.mts +67 -0
  11. package/dist/react/client/cusTypes-BT7wlTNj.d.ts +67 -0
  12. package/dist/react/client/error-TNbN4XE4.d.mts +6 -0
  13. package/dist/react/client/error-TNbN4XE4.d.ts +6 -0
  14. package/dist/react/client/hooks/useAutumn.d.mts +65 -0
  15. package/dist/react/client/hooks/useAutumn.d.ts +65 -0
  16. package/dist/react/client/hooks/useAutumn.js +74 -0
  17. package/dist/react/client/hooks/useAutumn.mjs +74 -0
  18. package/dist/react/client/hooks/useCustomer.d.mts +14 -0
  19. package/dist/react/client/hooks/useCustomer.d.ts +14 -0
  20. package/dist/react/client/hooks/useCustomer.js +44 -0
  21. package/dist/react/client/hooks/useCustomer.mjs +44 -0
  22. package/dist/react/index.d.mts +157 -0
  23. package/dist/react/index.d.ts +157 -0
  24. package/dist/react/index.js +28 -0
  25. package/dist/react/index.mjs +4 -0
  26. package/dist/react/server/cusActions.d.mts +140 -0
  27. package/dist/react/server/cusActions.d.ts +140 -0
  28. package/dist/react/server/cusActions.js +26 -0
  29. package/dist/react/server/cusActions.mjs +26 -0
  30. package/dist/react/server/genActions.d.mts +42 -0
  31. package/dist/react/server/genActions.d.ts +42 -0
  32. package/dist/react/server/genActions.js +41 -0
  33. package/dist/react/server/genActions.mjs +41 -0
  34. package/dist/react/server/genTypes-RkqyS6Mn.d.mts +152 -0
  35. package/dist/react/server/genTypes-RkqyS6Mn.d.ts +152 -0
  36. package/dist/sdk/cusTypes-B9fUPd5R.d.ts +68 -0
  37. package/dist/sdk/cusTypes-DEdFHlrl.d.mts +68 -0
  38. package/dist/sdk/customers.d.mts +2 -0
  39. package/dist/sdk/customers.d.ts +2 -0
  40. package/dist/sdk/general.d.mts +60 -0
  41. package/dist/sdk/general.d.ts +60 -0
  42. package/dist/sdk/index.d.mts +97 -0
  43. package/dist/sdk/index.d.ts +97 -0
  44. package/dist/sdk/index.js +245 -0
  45. package/dist/sdk/index.mjs +237 -0
  46. package/dist/sdk/prodEnums-BnhKkH4e.d.mts +26 -0
  47. package/dist/sdk/prodEnums-BnhKkH4e.d.ts +26 -0
  48. package/dist/sdk/products.d.mts +45 -0
  49. package/dist/sdk/products.d.ts +45 -0
  50. package/package.json +46 -0
  51. package/tsconfig.json +25 -0
  52. package/tsup.config.ts +78 -0
package/README.md ADDED
File without changes
@@ -0,0 +1,9 @@
1
+ import * as react from 'react';
2
+ import { AutumnContextParams } from './AutumnProvider.mjs';
3
+ import 'react/jsx-runtime';
4
+ import './cusTypes-BT7wlTNj.mjs';
5
+
6
+ declare const AutumnContext: react.Context<AutumnContextParams>;
7
+ declare const useAutumnContext: () => AutumnContextParams;
8
+
9
+ export { AutumnContext, useAutumnContext };
@@ -0,0 +1,9 @@
1
+ import * as react from 'react';
2
+ import { AutumnContextParams } from './AutumnProvider.js';
3
+ import 'react/jsx-runtime';
4
+ import './cusTypes-BT7wlTNj.js';
5
+
6
+ declare const AutumnContext: react.Context<AutumnContextParams>;
7
+ declare const useAutumnContext: () => AutumnContextParams;
8
+
9
+ export { AutumnContext, useAutumnContext };
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { createContext, useContext } from "react";
3
+ const AutumnContext = createContext({
4
+ customerId: ""
5
+ });
6
+ const useAutumnContext = () => {
7
+ const context = useContext(AutumnContext);
8
+ if (context === void 0) {
9
+ throw new Error(
10
+ "useAutumnContext must be used within a AutumnContextProvider"
11
+ );
12
+ }
13
+ return context;
14
+ };
15
+ export {
16
+ AutumnContext,
17
+ useAutumnContext
18
+ };
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { createContext, useContext } from "react";
3
+ const AutumnContext = createContext({
4
+ customerId: ""
5
+ });
6
+ const useAutumnContext = () => {
7
+ const context = useContext(AutumnContext);
8
+ if (context === void 0) {
9
+ throw new Error(
10
+ "useAutumnContext must be used within a AutumnContextProvider"
11
+ );
12
+ }
13
+ return context;
14
+ };
15
+ export {
16
+ AutumnContext,
17
+ useAutumnContext
18
+ };
@@ -0,0 +1,12 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { C as CustomerData } from './cusTypes-BT7wlTNj.mjs';
3
+
4
+ interface AutumnContextParams {
5
+ customerId: string;
6
+ customerData?: CustomerData;
7
+ }
8
+ declare const AutumnProvider: ({ children, customerId, customerData, }: AutumnContextParams & {
9
+ children?: React.ReactNode;
10
+ }) => react_jsx_runtime.JSX.Element;
11
+
12
+ export { type AutumnContextParams, AutumnProvider };
@@ -0,0 +1,12 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { C as CustomerData } from './cusTypes-BT7wlTNj.js';
3
+
4
+ interface AutumnContextParams {
5
+ customerId: string;
6
+ customerData?: CustomerData;
7
+ }
8
+ declare const AutumnProvider: ({ children, customerId, customerData, }: AutumnContextParams & {
9
+ children?: React.ReactNode;
10
+ }) => react_jsx_runtime.JSX.Element;
11
+
12
+ export { type AutumnContextParams, AutumnProvider };
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { AutumnContext } from "./AutumnContext";
4
+ const AutumnProvider = ({
5
+ children,
6
+ customerId,
7
+ customerData
8
+ }) => {
9
+ return /* @__PURE__ */ jsx(
10
+ AutumnContext.Provider,
11
+ {
12
+ value: {
13
+ customerId,
14
+ customerData
15
+ },
16
+ children
17
+ }
18
+ );
19
+ };
20
+ export {
21
+ AutumnProvider
22
+ };
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { AutumnContext } from "./AutumnContext";
4
+ const AutumnProvider = ({
5
+ children,
6
+ customerId,
7
+ customerData
8
+ }) => {
9
+ return /* @__PURE__ */ jsx(
10
+ AutumnContext.Provider,
11
+ {
12
+ value: {
13
+ customerId,
14
+ customerData
15
+ },
16
+ children
17
+ }
18
+ );
19
+ };
20
+ export {
21
+ AutumnProvider
22
+ };
@@ -0,0 +1,67 @@
1
+ declare enum AppEnv {
2
+ Sandbox = "sandbox",
3
+ Live = "live"
4
+ }
5
+
6
+ declare enum ProductItemInterval {
7
+ Minute = "minute",
8
+ Hour = "hour",
9
+ Day = "day",
10
+ Week = "week",
11
+ Month = "month",
12
+ Quarter = "quarter",
13
+ SemiAnnual = "semi_annual",
14
+ Year = "year"
15
+ }
16
+
17
+ declare enum ProductStatus {
18
+ Active = "active",
19
+ Expired = "expired",
20
+ Trialing = "trialing",
21
+ Scheduled = "scheduled"
22
+ }
23
+
24
+ interface CustomerFeature {
25
+ feature_id: string;
26
+ unlimited?: boolean;
27
+ interval?: ProductItemInterval | null;
28
+ balance?: number;
29
+ usage?: number;
30
+ included_usage?: number;
31
+ next_reset_at?: number;
32
+ }
33
+ interface CustomerProduct {
34
+ id: string;
35
+ name: string | null;
36
+ group: string | null;
37
+ status: ProductStatus;
38
+ started_at: number;
39
+ canceled_at: number | null;
40
+ subscription_ids?: string[] | null;
41
+ current_period_start?: number | null;
42
+ current_period_end?: number | null;
43
+ }
44
+ interface Customer {
45
+ autumn_id: string;
46
+ created_at: number;
47
+ env: AppEnv;
48
+ id: string | null;
49
+ name: string | null;
50
+ email: string | null;
51
+ fingerprint: string | null;
52
+ stripe_id: string | null;
53
+ products: CustomerProduct[];
54
+ add_ons: CustomerProduct[];
55
+ features: CustomerFeature[];
56
+ }
57
+ interface CustomerData {
58
+ name?: string;
59
+ email?: string;
60
+ fingerprint?: string;
61
+ }
62
+ interface BillingPortalResponse {
63
+ customer_id: string;
64
+ url: string;
65
+ }
66
+
67
+ export type { BillingPortalResponse as B, CustomerData as C, Customer as a };
@@ -0,0 +1,67 @@
1
+ declare enum AppEnv {
2
+ Sandbox = "sandbox",
3
+ Live = "live"
4
+ }
5
+
6
+ declare enum ProductItemInterval {
7
+ Minute = "minute",
8
+ Hour = "hour",
9
+ Day = "day",
10
+ Week = "week",
11
+ Month = "month",
12
+ Quarter = "quarter",
13
+ SemiAnnual = "semi_annual",
14
+ Year = "year"
15
+ }
16
+
17
+ declare enum ProductStatus {
18
+ Active = "active",
19
+ Expired = "expired",
20
+ Trialing = "trialing",
21
+ Scheduled = "scheduled"
22
+ }
23
+
24
+ interface CustomerFeature {
25
+ feature_id: string;
26
+ unlimited?: boolean;
27
+ interval?: ProductItemInterval | null;
28
+ balance?: number;
29
+ usage?: number;
30
+ included_usage?: number;
31
+ next_reset_at?: number;
32
+ }
33
+ interface CustomerProduct {
34
+ id: string;
35
+ name: string | null;
36
+ group: string | null;
37
+ status: ProductStatus;
38
+ started_at: number;
39
+ canceled_at: number | null;
40
+ subscription_ids?: string[] | null;
41
+ current_period_start?: number | null;
42
+ current_period_end?: number | null;
43
+ }
44
+ interface Customer {
45
+ autumn_id: string;
46
+ created_at: number;
47
+ env: AppEnv;
48
+ id: string | null;
49
+ name: string | null;
50
+ email: string | null;
51
+ fingerprint: string | null;
52
+ stripe_id: string | null;
53
+ products: CustomerProduct[];
54
+ add_ons: CustomerProduct[];
55
+ features: CustomerFeature[];
56
+ }
57
+ interface CustomerData {
58
+ name?: string;
59
+ email?: string;
60
+ fingerprint?: string;
61
+ }
62
+ interface BillingPortalResponse {
63
+ customer_id: string;
64
+ url: string;
65
+ }
66
+
67
+ export type { BillingPortalResponse as B, CustomerData as C, Customer as a };
@@ -0,0 +1,6 @@
1
+ interface AutumnError {
2
+ message: string;
3
+ code: string;
4
+ }
5
+
6
+ export type { AutumnError as A };
@@ -0,0 +1,6 @@
1
+ interface AutumnError {
2
+ message: string;
3
+ code: string;
4
+ }
5
+
6
+ export type { AutumnError as A };
@@ -0,0 +1,65 @@
1
+ import { A as AutumnError } from '../error-TNbN4XE4.mjs';
2
+ import { a as Customer, B as BillingPortalResponse } from '../cusTypes-BT7wlTNj.mjs';
3
+
4
+ interface AttachResult {
5
+ checkout_url?: string;
6
+ customer_id: string;
7
+ product_ids: string[];
8
+ code: string;
9
+ message: string;
10
+ }
11
+ interface EventResult {
12
+ id: string;
13
+ code: string;
14
+ customer_id: string;
15
+ feature_id?: string;
16
+ event_name?: string;
17
+ }
18
+ interface EntitledBalance {
19
+ feature_id: string;
20
+ unlimited: boolean;
21
+ usage_allowed: boolean;
22
+ required_quantity: number | null;
23
+ balance: number | null;
24
+ }
25
+ interface EntitledResult {
26
+ customer_id: string;
27
+ feature_id: string;
28
+ code: string;
29
+ allowed: boolean;
30
+ balances: EntitledBalance[];
31
+ }
32
+
33
+ interface UseAutumnOptions {
34
+ autoCreate?: boolean;
35
+ }
36
+ declare const useAutumn: (options?: UseAutumnOptions) => {
37
+ customer: Customer | null;
38
+ loading: boolean;
39
+ error: AutumnError | null;
40
+ attach: ({ productId }: {
41
+ productId: string;
42
+ }) => Promise<AttachResult | undefined>;
43
+ sendEvent: ({ featureId, value, }: {
44
+ featureId: string;
45
+ value: number;
46
+ }) => Promise<{
47
+ data: null;
48
+ error: AutumnError;
49
+ } | {
50
+ data: EventResult;
51
+ error: null;
52
+ }>;
53
+ entitled: ({ featureId }: {
54
+ featureId: string;
55
+ }) => Promise<{
56
+ data: null;
57
+ error: AutumnError;
58
+ } | {
59
+ data: EntitledResult;
60
+ error: null;
61
+ }>;
62
+ openBillingPortal: () => Promise<BillingPortalResponse | null>;
63
+ };
64
+
65
+ export { type UseAutumnOptions, useAutumn };
@@ -0,0 +1,65 @@
1
+ import { A as AutumnError } from '../error-TNbN4XE4.js';
2
+ import { a as Customer, B as BillingPortalResponse } from '../cusTypes-BT7wlTNj.js';
3
+
4
+ interface AttachResult {
5
+ checkout_url?: string;
6
+ customer_id: string;
7
+ product_ids: string[];
8
+ code: string;
9
+ message: string;
10
+ }
11
+ interface EventResult {
12
+ id: string;
13
+ code: string;
14
+ customer_id: string;
15
+ feature_id?: string;
16
+ event_name?: string;
17
+ }
18
+ interface EntitledBalance {
19
+ feature_id: string;
20
+ unlimited: boolean;
21
+ usage_allowed: boolean;
22
+ required_quantity: number | null;
23
+ balance: number | null;
24
+ }
25
+ interface EntitledResult {
26
+ customer_id: string;
27
+ feature_id: string;
28
+ code: string;
29
+ allowed: boolean;
30
+ balances: EntitledBalance[];
31
+ }
32
+
33
+ interface UseAutumnOptions {
34
+ autoCreate?: boolean;
35
+ }
36
+ declare const useAutumn: (options?: UseAutumnOptions) => {
37
+ customer: Customer | null;
38
+ loading: boolean;
39
+ error: AutumnError | null;
40
+ attach: ({ productId }: {
41
+ productId: string;
42
+ }) => Promise<AttachResult | undefined>;
43
+ sendEvent: ({ featureId, value, }: {
44
+ featureId: string;
45
+ value: number;
46
+ }) => Promise<{
47
+ data: null;
48
+ error: AutumnError;
49
+ } | {
50
+ data: EventResult;
51
+ error: null;
52
+ }>;
53
+ entitled: ({ featureId }: {
54
+ featureId: string;
55
+ }) => Promise<{
56
+ data: null;
57
+ error: AutumnError;
58
+ } | {
59
+ data: EntitledResult;
60
+ error: null;
61
+ }>;
62
+ openBillingPortal: () => Promise<BillingPortalResponse | null>;
63
+ };
64
+
65
+ export { type UseAutumnOptions, useAutumn };
@@ -0,0 +1,74 @@
1
+ "use client";
2
+ import {
3
+ attachAction,
4
+ entitledAction,
5
+ getBillingPortalAction
6
+ } from "../../server/genActions";
7
+ import { sendEventAction } from "../../server/genActions";
8
+ import { useAutumnContext } from "../AutumnContext";
9
+ import { useCustomer } from "./useCustomer";
10
+ const useAutumn = (options) => {
11
+ const { customerId } = useAutumnContext();
12
+ if (!customerId) {
13
+ throw new Error("Customer ID is required");
14
+ }
15
+ const {
16
+ customer,
17
+ isLoading: loading,
18
+ error
19
+ } = useCustomer({
20
+ autoCreate: options?.autoCreate
21
+ });
22
+ const entitled = ({ featureId }) => {
23
+ return entitledAction({ customerId, featureId });
24
+ };
25
+ const sendEvent = ({
26
+ featureId,
27
+ value
28
+ }) => {
29
+ return sendEventAction({ customerId, featureId, value });
30
+ };
31
+ const attach = async ({ productId }) => {
32
+ const { data, error: error2 } = await attachAction({
33
+ customerId,
34
+ productId
35
+ });
36
+ if (error2) {
37
+ throw error2;
38
+ }
39
+ if (data?.checkout_url && typeof window !== "undefined") {
40
+ window.open(data.checkout_url, "_blank");
41
+ } else {
42
+ return data;
43
+ }
44
+ };
45
+ const openBillingPortal = async () => {
46
+ const { data, error: error2 } = await getBillingPortalAction({
47
+ customerId,
48
+ params: {
49
+ return_url: "https://example.com"
50
+ }
51
+ });
52
+ if (error2) {
53
+ throw error2;
54
+ }
55
+ if (data?.url && typeof window !== "undefined") {
56
+ window.open(data.url, "_blank");
57
+ return data;
58
+ } else {
59
+ return data;
60
+ }
61
+ };
62
+ return {
63
+ customer,
64
+ loading,
65
+ error,
66
+ attach,
67
+ sendEvent,
68
+ entitled,
69
+ openBillingPortal
70
+ };
71
+ };
72
+ export {
73
+ useAutumn
74
+ };
@@ -0,0 +1,74 @@
1
+ "use client";
2
+ import {
3
+ attachAction,
4
+ entitledAction,
5
+ getBillingPortalAction
6
+ } from "../../server/genActions";
7
+ import { sendEventAction } from "../../server/genActions";
8
+ import { useAutumnContext } from "../AutumnContext";
9
+ import { useCustomer } from "./useCustomer";
10
+ const useAutumn = (options) => {
11
+ const { customerId } = useAutumnContext();
12
+ if (!customerId) {
13
+ throw new Error("Customer ID is required");
14
+ }
15
+ const {
16
+ customer,
17
+ isLoading: loading,
18
+ error
19
+ } = useCustomer({
20
+ autoCreate: options?.autoCreate
21
+ });
22
+ const entitled = ({ featureId }) => {
23
+ return entitledAction({ customerId, featureId });
24
+ };
25
+ const sendEvent = ({
26
+ featureId,
27
+ value
28
+ }) => {
29
+ return sendEventAction({ customerId, featureId, value });
30
+ };
31
+ const attach = async ({ productId }) => {
32
+ const { data, error: error2 } = await attachAction({
33
+ customerId,
34
+ productId
35
+ });
36
+ if (error2) {
37
+ throw error2;
38
+ }
39
+ if (data?.checkout_url && typeof window !== "undefined") {
40
+ window.open(data.checkout_url, "_blank");
41
+ } else {
42
+ return data;
43
+ }
44
+ };
45
+ const openBillingPortal = async () => {
46
+ const { data, error: error2 } = await getBillingPortalAction({
47
+ customerId,
48
+ params: {
49
+ return_url: "https://example.com"
50
+ }
51
+ });
52
+ if (error2) {
53
+ throw error2;
54
+ }
55
+ if (data?.url && typeof window !== "undefined") {
56
+ window.open(data.url, "_blank");
57
+ return data;
58
+ } else {
59
+ return data;
60
+ }
61
+ };
62
+ return {
63
+ customer,
64
+ loading,
65
+ error,
66
+ attach,
67
+ sendEvent,
68
+ entitled,
69
+ openBillingPortal
70
+ };
71
+ };
72
+ export {
73
+ useAutumn
74
+ };
@@ -0,0 +1,14 @@
1
+ import { A as AutumnError } from '../error-TNbN4XE4.mjs';
2
+ import { C as CustomerData, a as Customer } from '../cusTypes-BT7wlTNj.mjs';
3
+
4
+ interface UseCustomerProps {
5
+ autoCreate?: boolean;
6
+ customerData?: CustomerData;
7
+ }
8
+ declare const useCustomer: ({ autoCreate }: UseCustomerProps) => {
9
+ customer: Customer | null;
10
+ error: AutumnError | null;
11
+ isLoading: boolean;
12
+ };
13
+
14
+ export { type UseCustomerProps, useCustomer };
@@ -0,0 +1,14 @@
1
+ import { A as AutumnError } from '../error-TNbN4XE4.js';
2
+ import { C as CustomerData, a as Customer } from '../cusTypes-BT7wlTNj.js';
3
+
4
+ interface UseCustomerProps {
5
+ autoCreate?: boolean;
6
+ customerData?: CustomerData;
7
+ }
8
+ declare const useCustomer: ({ autoCreate }: UseCustomerProps) => {
9
+ customer: Customer | null;
10
+ error: AutumnError | null;
11
+ isLoading: boolean;
12
+ };
13
+
14
+ export { type UseCustomerProps, useCustomer };
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { useEffect, useState } from "react";
3
+ import { useAutumnContext } from "../AutumnContext";
4
+ import { getOrCreateCustomer, getCustomer } from "../../server/cusActions";
5
+ const useCustomer = ({ autoCreate = true }) => {
6
+ const { customerId, customerData } = useAutumnContext();
7
+ const [customer, setCustomer] = useState(null);
8
+ const [error, setError] = useState(null);
9
+ const [isLoading, setIsLoading] = useState(false);
10
+ const fetchCustomer = async () => {
11
+ setIsLoading(true);
12
+ try {
13
+ let data = null;
14
+ let error2 = null;
15
+ if (autoCreate) {
16
+ const result = await getOrCreateCustomer({
17
+ customerId,
18
+ customerData
19
+ });
20
+ data = result.data;
21
+ error2 = result.error;
22
+ } else {
23
+ const result = await getCustomer({ customerId });
24
+ data = result.data;
25
+ error2 = result.error;
26
+ }
27
+ if (error2) {
28
+ setError(error2);
29
+ } else {
30
+ setCustomer(data);
31
+ }
32
+ } catch (error2) {
33
+ setError(error2);
34
+ }
35
+ setIsLoading(false);
36
+ };
37
+ useEffect(() => {
38
+ fetchCustomer();
39
+ }, []);
40
+ return { customer, error, isLoading };
41
+ };
42
+ export {
43
+ useCustomer
44
+ };
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { useEffect, useState } from "react";
3
+ import { useAutumnContext } from "../AutumnContext";
4
+ import { getOrCreateCustomer, getCustomer } from "../../server/cusActions";
5
+ const useCustomer = ({ autoCreate = true }) => {
6
+ const { customerId, customerData } = useAutumnContext();
7
+ const [customer, setCustomer] = useState(null);
8
+ const [error, setError] = useState(null);
9
+ const [isLoading, setIsLoading] = useState(false);
10
+ const fetchCustomer = async () => {
11
+ setIsLoading(true);
12
+ try {
13
+ let data = null;
14
+ let error2 = null;
15
+ if (autoCreate) {
16
+ const result = await getOrCreateCustomer({
17
+ customerId,
18
+ customerData
19
+ });
20
+ data = result.data;
21
+ error2 = result.error;
22
+ } else {
23
+ const result = await getCustomer({ customerId });
24
+ data = result.data;
25
+ error2 = result.error;
26
+ }
27
+ if (error2) {
28
+ setError(error2);
29
+ } else {
30
+ setCustomer(data);
31
+ }
32
+ } catch (error2) {
33
+ setError(error2);
34
+ }
35
+ setIsLoading(false);
36
+ };
37
+ useEffect(() => {
38
+ fetchCustomer();
39
+ }, []);
40
+ return { customer, error, isLoading };
41
+ };
42
+ export {
43
+ useCustomer
44
+ };