@kiosinc/commons-rn 0.1.61 → 0.1.62
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/lib/commonjs/api/customer.js +75 -0
- package/lib/commonjs/api/customer.js.map +1 -0
- package/lib/commonjs/auth/hooks/useAuthentication.js +6 -0
- package/lib/commonjs/auth/hooks/useAuthentication.js.map +1 -1
- package/lib/commonjs/auth/hooks/useTermsOfService.js +8 -10
- package/lib/commonjs/auth/hooks/useTermsOfService.js.map +1 -1
- package/lib/commonjs/hooks/useCheckCustomer.js +57 -0
- package/lib/commonjs/hooks/useCheckCustomer.js.map +1 -0
- package/lib/commonjs/hooks/useCustomer.js +251 -0
- package/lib/commonjs/hooks/useCustomer.js.map +1 -0
- package/lib/commonjs/index.js +32 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/screens/SavedCards/CardRow.js +79 -0
- package/lib/commonjs/screens/SavedCards/CardRow.js.map +1 -0
- package/lib/commonjs/screens/SavedCards/SavedCards.js +180 -0
- package/lib/commonjs/screens/SavedCards/SavedCards.js.map +1 -0
- package/lib/commonjs/selectBusiness/queryKeys.js +6 -1
- package/lib/commonjs/selectBusiness/queryKeys.js.map +1 -1
- package/lib/commonjs/types/customer.d.js +7 -0
- package/lib/commonjs/types/customer.d.js.map +1 -0
- package/lib/commonjs/utils/checkout.js +11 -0
- package/lib/commonjs/utils/checkout.js.map +1 -0
- package/lib/commonjs/utils/currency.js +17 -0
- package/lib/commonjs/utils/currency.js.map +1 -0
- package/lib/commonjs/utils/square.js +39 -0
- package/lib/commonjs/utils/square.js.map +1 -0
- package/lib/module/api/customer.js +59 -0
- package/lib/module/api/customer.js.map +1 -0
- package/lib/module/auth/hooks/useAuthentication.js +6 -0
- package/lib/module/auth/hooks/useAuthentication.js.map +1 -1
- package/lib/module/auth/hooks/useTermsOfService.js +8 -10
- package/lib/module/auth/hooks/useTermsOfService.js.map +1 -1
- package/lib/module/hooks/useCheckCustomer.js +50 -0
- package/lib/module/hooks/useCheckCustomer.js.map +1 -0
- package/lib/module/hooks/useCustomer.js +243 -0
- package/lib/module/hooks/useCustomer.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/SavedCards/CardRow.js +71 -0
- package/lib/module/screens/SavedCards/CardRow.js.map +1 -0
- package/lib/module/screens/SavedCards/SavedCards.js +170 -0
- package/lib/module/screens/SavedCards/SavedCards.js.map +1 -0
- package/lib/module/selectBusiness/queryKeys.js +6 -1
- package/lib/module/selectBusiness/queryKeys.js.map +1 -1
- package/lib/module/types/customer.d.js +5 -0
- package/lib/module/types/customer.d.js.map +1 -0
- package/lib/module/utils/checkout.js +4 -0
- package/lib/module/utils/checkout.js.map +1 -0
- package/lib/module/utils/currency.js +10 -0
- package/lib/module/utils/currency.js.map +1 -0
- package/lib/module/utils/square.js +36 -0
- package/lib/module/utils/square.js.map +1 -0
- package/lib/typescript/src/api/customer.d.ts +23 -0
- package/lib/typescript/src/api/customer.d.ts.map +1 -0
- package/lib/typescript/src/auth/hooks/useAuthentication.d.ts.map +1 -1
- package/lib/typescript/src/auth/hooks/useTermsOfService.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCheckCustomer.d.ts +4 -0
- package/lib/typescript/src/hooks/useCheckCustomer.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCustomer.d.ts +58 -0
- package/lib/typescript/src/hooks/useCustomer.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/SavedCards/CardRow.d.ts +11 -0
- package/lib/typescript/src/screens/SavedCards/CardRow.d.ts.map +1 -0
- package/lib/typescript/src/screens/SavedCards/SavedCards.d.ts +7 -0
- package/lib/typescript/src/screens/SavedCards/SavedCards.d.ts.map +1 -0
- package/lib/typescript/src/selectBusiness/queryKeys.d.ts +5 -0
- package/lib/typescript/src/selectBusiness/queryKeys.d.ts.map +1 -1
- package/lib/typescript/src/utils/checkout.d.ts +3 -0
- package/lib/typescript/src/utils/checkout.d.ts.map +1 -0
- package/lib/typescript/src/utils/currency.d.ts +5 -0
- package/lib/typescript/src/utils/currency.d.ts.map +1 -0
- package/lib/typescript/src/utils/square.d.ts +6 -0
- package/lib/typescript/src/utils/square.d.ts.map +1 -0
- package/package.json +3 -1
- package/src/api/customer.ts +112 -0
- package/src/auth/hooks/useAuthentication.ts +4 -0
- package/src/auth/hooks/useTermsOfService.ts +8 -11
- package/src/hooks/useCheckCustomer.ts +42 -0
- package/src/hooks/useCustomer.ts +331 -0
- package/src/index.tsx +6 -0
- package/src/screens/SavedCards/CardRow.tsx +94 -0
- package/src/screens/SavedCards/SavedCards.tsx +197 -0
- package/src/selectBusiness/queryKeys.ts +5 -0
- package/src/types/customer.d.ts +70 -0
- package/src/utils/checkout.ts +5 -0
- package/src/utils/currency.ts +10 -0
- package/src/utils/square.ts +50 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Address, ConnectSquareCustomerRequest, CustomerProfileProps, SaveCardRequest } from '../types/customer';
|
|
2
|
+
export declare const getCustomer: (userId: string) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
3
|
+
export declare const createCustomer: ({ uid, address, }: {
|
|
4
|
+
uid: string;
|
|
5
|
+
address?: Address | null | undefined;
|
|
6
|
+
}) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
7
|
+
export declare const updateCustomerProfile: ({ uid, props, }: {
|
|
8
|
+
uid: string;
|
|
9
|
+
props: CustomerProfileProps;
|
|
10
|
+
}) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
11
|
+
export declare const saveCustomerAddress: ({ uid, address, }: {
|
|
12
|
+
uid: string;
|
|
13
|
+
address: Address;
|
|
14
|
+
}) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
15
|
+
export declare const saveCustomerCard: ({ uid, props, }: {
|
|
16
|
+
uid: string;
|
|
17
|
+
props: SaveCardRequest;
|
|
18
|
+
}) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
19
|
+
export declare const connectSquareLoyalty: (uid: string, props: ConnectSquareCustomerRequest) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
20
|
+
export declare const connectSquareCustomer: (uid: string, props: ConnectSquareCustomerRequest) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
21
|
+
export declare const fetchSquareLoyalty: (uid: string, businessId: string) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
22
|
+
export declare const fetchLoyaltyRewards: (businessId: string) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
23
|
+
//# sourceMappingURL=customer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer.d.ts","sourceRoot":"","sources":["../../../../src/api/customer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,4BAA4B,EAC5B,oBAAoB,EACpB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAK3B,eAAO,MAAM,WAAW,WAAkB,MAAM,qDAE/C,CAAC;AAEF,eAAO,MAAM,cAAc;SAIpB,MAAM;;sDASZ,CAAC;AAEF,eAAO,MAAM,qBAAqB;SAI3B,MAAM;WACJ,oBAAoB;sDAQ5B,CAAC;AAEF,eAAO,MAAM,mBAAmB;SAIzB,MAAM;aACF,OAAO;sDAQjB,CAAC;AAEF,eAAO,MAAM,gBAAgB;SAItB,MAAM;WACJ,eAAe;sDAQvB,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAC1B,MAAM,SACJ,4BAA4B,qDAQpC,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAC3B,MAAM,SACJ,4BAA4B,qDAQpC,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAe,MAAM,cAAc,MAAM,qDAOvE,CAAC;AAEF,eAAO,MAAM,mBAAmB,eAAsB,MAAM,qDAI3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthentication.d.ts","sourceRoot":"","sources":["../../../../../src/auth/hooks/useAuthentication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuthentication.d.ts","sourceRoot":"","sources":["../../../../../src/auth/hooks/useAuthentication.ts"],"names":[],"mappings":"AAsBA,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;gBAQa,SAAS;cAAQ,MAAM;;;;;;;;;cAuDvB,MAAM;;;qBAOQ,MAAM;;;;eAmClB,MAAM;;CAgBlD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTermsOfService.d.ts","sourceRoot":"","sources":["../../../../../src/auth/hooks/useTermsOfService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTermsOfService.d.ts","sourceRoot":"","sources":["../../../../../src/auth/hooks/useTermsOfService.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB;;;;CA0E7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCheckCustomer.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCheckCustomer.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB;;CAqC5B,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Address, CustomerProfileProps, SaveCardRequest } from '../types/customer';
|
|
2
|
+
export declare const useCustomerQueries: () => {
|
|
3
|
+
useFetchCustomer: () => import("@tanstack/react-query").UseQueryResult<any, unknown>;
|
|
4
|
+
useCreateCustomer: () => {
|
|
5
|
+
createCustomerHook: import("@tanstack/react-query").UseMutateAsyncFunction<void, {
|
|
6
|
+
code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}, void, unknown>;
|
|
9
|
+
createCustomerLoading: boolean;
|
|
10
|
+
};
|
|
11
|
+
useUpdateCustomer: () => {
|
|
12
|
+
updateCustomer: import("@tanstack/react-query").UseMutateFunction<void, {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}, CustomerProfileProps, unknown>;
|
|
16
|
+
updateCustomerLoading: boolean;
|
|
17
|
+
};
|
|
18
|
+
useSaveCustomerAddress: () => {
|
|
19
|
+
useSaveAddress: import("@tanstack/react-query").UseMutateFunction<void, {
|
|
20
|
+
code: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}, Address, unknown>;
|
|
23
|
+
saveAddressLoading: boolean;
|
|
24
|
+
};
|
|
25
|
+
useFetchSavedCards: () => import("@tanstack/react-query").UseQueryResult<any, unknown>;
|
|
26
|
+
useFetchSquareProgram: (queryOptions?: object) => import("@tanstack/react-query").UseQueryResult<any, unknown>;
|
|
27
|
+
useFetchSquareLoyalty: (queryOptions?: object) => import("@tanstack/react-query").UseQueryResult<any, unknown>;
|
|
28
|
+
useSaveCustomerCard: () => {
|
|
29
|
+
saveCard: import("@tanstack/react-query").UseMutateFunction<void, {
|
|
30
|
+
code: string;
|
|
31
|
+
message: string;
|
|
32
|
+
}, SaveCardRequest, unknown>;
|
|
33
|
+
saveCardLoading: boolean;
|
|
34
|
+
};
|
|
35
|
+
useDisableCard: () => {
|
|
36
|
+
disableCard: import("@tanstack/react-query").UseMutateFunction<any, {
|
|
37
|
+
code: string;
|
|
38
|
+
message: string;
|
|
39
|
+
}, string, unknown>;
|
|
40
|
+
disableCardLoading: boolean;
|
|
41
|
+
};
|
|
42
|
+
useConnectSquareLoyalty: () => {
|
|
43
|
+
connectSquareLoyalty: import("@tanstack/react-query").UseMutateFunction<void, {
|
|
44
|
+
code: string;
|
|
45
|
+
message: string;
|
|
46
|
+
}, void, unknown>;
|
|
47
|
+
connectLoyaltyLoading: boolean;
|
|
48
|
+
};
|
|
49
|
+
useConnectSquareCustomer: () => {
|
|
50
|
+
connectSquare: import("@tanstack/react-query").UseMutateFunction<void, {
|
|
51
|
+
code: string;
|
|
52
|
+
message: string;
|
|
53
|
+
}, void, unknown>;
|
|
54
|
+
connectSquareLoading: boolean;
|
|
55
|
+
};
|
|
56
|
+
useFetchLoyaltyRewards: () => import("@tanstack/react-query").UseQueryResult<any, unknown>;
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=useCustomer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCustomer.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCustomer.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAK3B,eAAO,MAAM,kBAAkB;;;;kBAyCE,MAAM;qBAAW,MAAM;;;;;;kBA4BvB,MAAM;qBAAW,MAAM;;;;;;kBA4BvB,MAAM;qBAAW,MAAM;;;;;2CAsCb,MAAM;2CAwBN,MAAM;;;kBA4BhB,MAAM;qBAAW,MAAM;;;;;;kBA6BvB,MAAM;qBAAW,MAAM;;;;;;kBA4BvB,MAAM;qBAAW,MAAM;;;;;;kBA4BvB,MAAM;qBAAW,MAAM;;;;;CA+BvD,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export { Currency } from './utils/currency';
|
|
2
|
+
export { useCustomerQueries } from './hooks/useCustomer';
|
|
3
|
+
export { useCheckCustomer } from './hooks/useCheckCustomer';
|
|
4
|
+
export { SavedCards } from './screens/SavedCards/SavedCards';
|
|
1
5
|
export { useMultiSnapBottomSheetRef, TMultiSnapBottomSheetRef, } from './utils/useMultiSnapBottomSheetRef';
|
|
2
6
|
export { useSingleSnapBottomSheetRef, TSingleSnapBottomSheetRef, } from './utils/useSingleSnapBottomSheetRef';
|
|
3
7
|
export declare function multiply(a: number, b: number): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,qCAAqC,CAAC;AAE7C,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9D;AACD,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,qCAAqC,CAAC;AAE7C,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9D;AACD,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CustomerCardPayment } from '../../types/customer';
|
|
3
|
+
export declare const CardRow: ({ card, onDelete, onSelect, isSelectable, isSelected, isDisabled, }: {
|
|
4
|
+
card: CustomerCardPayment;
|
|
5
|
+
onDelete: (id: string) => void;
|
|
6
|
+
onSelect: (linkedObjectId: string) => void;
|
|
7
|
+
isSelectable: boolean;
|
|
8
|
+
isSelected: boolean;
|
|
9
|
+
isDisabled: boolean;
|
|
10
|
+
}) => JSX.Element;
|
|
11
|
+
//# sourceMappingURL=CardRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardRow.d.ts","sourceRoot":"","sources":["../../../../../src/screens/SavedCards/CardRow.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,eAAO,MAAM,OAAO;UAQZ,mBAAmB;mBACV,MAAM,KAAK,IAAI;+BACH,MAAM,KAAK,IAAI;kBAC5B,OAAO;gBACT,OAAO;gBACP,OAAO;iBAyEpB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CustomerCardPayment } from '../../types/customer';
|
|
3
|
+
export declare const SavedCards: ({ onCheckout, total, }: {
|
|
4
|
+
onCheckout?: ((selectedCard: CustomerCardPayment) => void) | undefined;
|
|
5
|
+
total?: string | undefined;
|
|
6
|
+
}) => JSX.Element;
|
|
7
|
+
//# sourceMappingURL=SavedCards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SavedCards.d.ts","sourceRoot":"","sources":["../../../../../src/screens/SavedCards/SavedCards.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,eAAO,MAAM,UAAU;iCAIO,mBAAmB,KAAK,IAAI;;iBA6KzD,CAAC"}
|
|
@@ -2,6 +2,11 @@ export declare const queryKeys: {
|
|
|
2
2
|
BUSINESSES: string;
|
|
3
3
|
TERMS_AND_CONDITIONS: string;
|
|
4
4
|
TERMS_AND_CONDITIONS_URL: string;
|
|
5
|
+
CARDS: string;
|
|
6
|
+
CUSTOMER: string;
|
|
7
|
+
PROGRAM: string;
|
|
8
|
+
LOYALTY: string;
|
|
9
|
+
REWARDS: string;
|
|
5
10
|
};
|
|
6
11
|
export declare const DEFAULT_STALE_TIME: number;
|
|
7
12
|
//# sourceMappingURL=queryKeys.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryKeys.d.ts","sourceRoot":"","sources":["../../../../src/selectBusiness/queryKeys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"queryKeys.d.ts","sourceRoot":"","sources":["../../../../src/selectBusiness/queryKeys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;;;;CASrB,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../../../src/utils/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,eAAO,MAAM,WAAW,SAAU,mBAAmB,WAEpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../../src/utils/currency.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,MAAM,CAAC,YAAY,oBAGhB;IAEH,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM;CAGlC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CardDetails } from 'react-native-square-in-app-payments';
|
|
2
|
+
/**
|
|
3
|
+
* An event listener to start card entry flow
|
|
4
|
+
*/
|
|
5
|
+
export declare function onStartCardEntry(onSuccessCallback: (cardDetails: CardDetails) => void, onCancelCallback: () => void): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=square.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"square.d.ts","sourceRoot":"","sources":["../../../../src/utils/square.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAGZ,MAAM,qCAAqC,CAAC;AA6B7C;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,iBAAiB,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,EACrD,gBAAgB,EAAE,MAAM,IAAI,iBAW7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiosinc/commons-rn",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.62",
|
|
4
4
|
"description": "Common Code",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"react-native-mmkv": "^2.10.2",
|
|
83
83
|
"react-native-reanimated": "^3.5.4",
|
|
84
84
|
"react-native-safe-area-context": "^4.7.4",
|
|
85
|
+
"react-native-square-in-app-payments": "^1.7.5",
|
|
85
86
|
"react-native-webview": "^13.10.2",
|
|
86
87
|
"release-it": "^15.0.0",
|
|
87
88
|
"typescript": "^5.0.2"
|
|
@@ -200,6 +201,7 @@
|
|
|
200
201
|
"react-native-international-phone-number": "^0.7.6",
|
|
201
202
|
"react-native-paper": "^5.11.1",
|
|
202
203
|
"react-native-size-matters": "^0.4.2",
|
|
204
|
+
"react-native-uuid": "^2.0.2",
|
|
203
205
|
"react-native-video": "^5.2.1",
|
|
204
206
|
"yup": "^1.3.2"
|
|
205
207
|
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Address,
|
|
3
|
+
ConnectSquareCustomerRequest,
|
|
4
|
+
CustomerProfileProps,
|
|
5
|
+
SaveCardRequest,
|
|
6
|
+
} from '../types/customer';
|
|
7
|
+
|
|
8
|
+
import axios from 'axios';
|
|
9
|
+
import Config from 'react-native-config';
|
|
10
|
+
|
|
11
|
+
export const getCustomer = async (userId: string) => {
|
|
12
|
+
return await axios.get(`${Config.CHILDS_SERVER_ENV}/customers/${userId}`);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const createCustomer = async ({
|
|
16
|
+
uid,
|
|
17
|
+
address = null,
|
|
18
|
+
}: {
|
|
19
|
+
uid: string;
|
|
20
|
+
address?: Address | null;
|
|
21
|
+
}) => {
|
|
22
|
+
return await axios.post(`${Config.CHILDS_SERVER_ENV}/customers/create`, {
|
|
23
|
+
uid,
|
|
24
|
+
props: {
|
|
25
|
+
Address: address,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const updateCustomerProfile = async ({
|
|
31
|
+
uid,
|
|
32
|
+
props,
|
|
33
|
+
}: {
|
|
34
|
+
uid: string;
|
|
35
|
+
props: CustomerProfileProps;
|
|
36
|
+
}) => {
|
|
37
|
+
return await axios.post(
|
|
38
|
+
`${Config.CHILDS_SERVER_ENV}/customers/${uid}/update`,
|
|
39
|
+
{
|
|
40
|
+
props,
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const saveCustomerAddress = async ({
|
|
46
|
+
uid,
|
|
47
|
+
address,
|
|
48
|
+
}: {
|
|
49
|
+
uid: string;
|
|
50
|
+
address: Address;
|
|
51
|
+
}) => {
|
|
52
|
+
return await axios.post(
|
|
53
|
+
`${Config.CHILDS_SERVER_ENV}/customers/${uid}/address/create`,
|
|
54
|
+
{
|
|
55
|
+
address,
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const saveCustomerCard = async ({
|
|
61
|
+
uid,
|
|
62
|
+
props,
|
|
63
|
+
}: {
|
|
64
|
+
uid: string;
|
|
65
|
+
props: SaveCardRequest;
|
|
66
|
+
}) => {
|
|
67
|
+
return await axios.post(
|
|
68
|
+
`${Config.CHILDS_SERVER_ENV}/customers/${uid}/square/card/save`,
|
|
69
|
+
{
|
|
70
|
+
...props,
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const connectSquareLoyalty = async (
|
|
76
|
+
uid: string,
|
|
77
|
+
props: ConnectSquareCustomerRequest
|
|
78
|
+
) => {
|
|
79
|
+
return await axios.post(
|
|
80
|
+
`${Config.CHILDS_SERVER_ENV}/customers/${uid}/square/loyalty/connect`,
|
|
81
|
+
{
|
|
82
|
+
props,
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const connectSquareCustomer = async (
|
|
88
|
+
uid: string,
|
|
89
|
+
props: ConnectSquareCustomerRequest
|
|
90
|
+
) => {
|
|
91
|
+
return await axios.post(
|
|
92
|
+
`${Config.CHILDS_SERVER_ENV}/customers/${uid}/square/customer/connect`,
|
|
93
|
+
{
|
|
94
|
+
props,
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const fetchSquareLoyalty = async (uid: string, businessId: string) => {
|
|
100
|
+
return await axios.post(
|
|
101
|
+
`${Config.CHILDS_SERVER_ENV}/customers/${uid}/square/loyalty/refresh`,
|
|
102
|
+
{
|
|
103
|
+
businessId,
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const fetchLoyaltyRewards = async (businessId: string) => {
|
|
109
|
+
return await axios.get(
|
|
110
|
+
`${Config.SQUARE_BASE_URL}/customers/loyalty/mainProgram/${businessId}`
|
|
111
|
+
);
|
|
112
|
+
};
|
|
@@ -16,6 +16,7 @@ import { checkIsRegisteredAPI, signUpAPI } from '../api/authentication';
|
|
|
16
16
|
import Config from 'react-native-config';
|
|
17
17
|
import { analytics } from '../../utils/analytics';
|
|
18
18
|
import { analyticsKeys } from '../../constants/analyticsKeys';
|
|
19
|
+
import { createCustomer } from '../../api/customer';
|
|
19
20
|
|
|
20
21
|
let confirmationResult: FirebaseAuthTypes.ConfirmationResult;
|
|
21
22
|
|
|
@@ -64,6 +65,9 @@ export const useAuthentication = () => {
|
|
|
64
65
|
analytics.profile.set(analyticsKeys.registrationDate, now);
|
|
65
66
|
analytics.profile.set(analyticsKeys.app, Config.APP_NAME);
|
|
66
67
|
analytics.track(analyticsKeys.signupCompleted);
|
|
68
|
+
|
|
69
|
+
// Create new customer in customer collections
|
|
70
|
+
await createCustomer({ uid: auth().currentUser.uid });
|
|
67
71
|
} catch (error: any) {
|
|
68
72
|
console.log('error', error);
|
|
69
73
|
// Sign out user if something goes wrong
|
|
@@ -4,6 +4,7 @@ import { DEFAULT_STALE_TIME, queryKeys } from '../../selectBusiness/queryKeys';
|
|
|
4
4
|
import { useAuthentication } from '../providers/authentication';
|
|
5
5
|
import { getCurrentTimestamp } from '../../utils';
|
|
6
6
|
import { analytics } from '../../utils/analytics';
|
|
7
|
+
import { createCustomer } from '../../api/customer';
|
|
7
8
|
|
|
8
9
|
export const useTermsOfService = () => {
|
|
9
10
|
const queryClient = useQueryClient();
|
|
@@ -64,18 +65,14 @@ export const useTermsOfService = () => {
|
|
|
64
65
|
const query = await firestore().doc(`customers/${user.uid}`);
|
|
65
66
|
const customerSnapshot = await query.get();
|
|
66
67
|
|
|
67
|
-
if (customerSnapshot.exists) {
|
|
68
|
-
await
|
|
69
|
-
updated: getCurrentTimestamp(),
|
|
70
|
-
agreementsUpdated: new Date().toISOString(),
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
await query.set({
|
|
74
|
-
uid: user.uid,
|
|
75
|
-
created: getCurrentTimestamp(),
|
|
76
|
-
agreementsUpdated: new Date().toISOString(),
|
|
77
|
-
});
|
|
68
|
+
if (!customerSnapshot.exists) {
|
|
69
|
+
await createCustomer({ uid: user!.uid });
|
|
78
70
|
}
|
|
71
|
+
await query.update({
|
|
72
|
+
updated: getCurrentTimestamp(),
|
|
73
|
+
agreementsUpdated: new Date().toISOString(),
|
|
74
|
+
});
|
|
75
|
+
|
|
79
76
|
analytics.track('term_of_service_accepted');
|
|
80
77
|
await queryClient.invalidateQueries([
|
|
81
78
|
user.uid,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
|
+
import { useCustomerQueries } from './useCustomer';
|
|
3
|
+
import { useAuthentication } from '../auth';
|
|
4
|
+
|
|
5
|
+
export const useCheckCustomer = () => {
|
|
6
|
+
const { user } = useAuthentication();
|
|
7
|
+
const isLoggedIn = user && !user.isAnonymous;
|
|
8
|
+
const {
|
|
9
|
+
useFetchCustomer,
|
|
10
|
+
useCreateCustomer,
|
|
11
|
+
useFetchSquareProgram,
|
|
12
|
+
useConnectSquareCustomer,
|
|
13
|
+
} = useCustomerQueries();
|
|
14
|
+
const { connectSquare } = useConnectSquareCustomer();
|
|
15
|
+
|
|
16
|
+
const { createCustomerHook } = useCreateCustomer();
|
|
17
|
+
const { data: customer } = useFetchCustomer();
|
|
18
|
+
const { refetch: fetchSquareProgram } = useFetchSquareProgram({
|
|
19
|
+
enabled: false,
|
|
20
|
+
refetchOnWindowFocus: false,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const checkIfprogramPresent = useCallback(() => {
|
|
24
|
+
fetchSquareProgram().then((res) => {
|
|
25
|
+
if (res.data === null) {
|
|
26
|
+
connectSquare();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}, [connectSquare, fetchSquareProgram]);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (isLoggedIn) {
|
|
33
|
+
if (customer?.customer === null) {
|
|
34
|
+
createCustomerHook();
|
|
35
|
+
} else if (customer?.uid) {
|
|
36
|
+
checkIfprogramPresent();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}, [customer, createCustomerHook, isLoggedIn, checkIfprogramPresent]);
|
|
40
|
+
|
|
41
|
+
return { customer };
|
|
42
|
+
};
|