@kiosinc/commons-rn 0.15.7 → 0.17.0
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 +20 -0
- package/lib/commonjs/constants/index.js +1 -1
- package/lib/commonjs/constants/index.js.map +1 -1
- package/lib/commonjs/hooks/index.js +0 -7
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useAuth.js +6 -0
- package/lib/commonjs/hooks/useAuth.js.map +1 -1
- package/lib/commonjs/hooks/useCustomer.js +0 -86
- package/lib/commonjs/hooks/useCustomer.js.map +1 -1
- package/lib/commonjs/providers/customer/CustomerProvider.js +214 -0
- package/lib/commonjs/providers/customer/CustomerProvider.js.map +1 -0
- package/lib/commonjs/providers/customer/README.md +122 -0
- package/lib/commonjs/providers/customer/classifyLoyaltyError.js +19 -0
- package/lib/commonjs/providers/customer/classifyLoyaltyError.js.map +1 -0
- package/lib/commonjs/providers/customer/index.js +27 -0
- package/lib/commonjs/providers/customer/index.js.map +1 -0
- package/lib/commonjs/providers/customer/types.js +2 -0
- package/lib/commonjs/providers/customer/types.js.map +1 -0
- package/lib/commonjs/providers/customer/useLoyalty.js +25 -0
- package/lib/commonjs/providers/customer/useLoyalty.js.map +1 -0
- package/lib/commonjs/providers/customer/useSquareCustomer.js +21 -0
- package/lib/commonjs/providers/customer/useSquareCustomer.js.map +1 -0
- package/lib/commonjs/providers/index.js +19 -0
- package/lib/commonjs/providers/index.js.map +1 -1
- package/lib/commonjs/screens/SavedCards/SavedCards.js +9 -4
- package/lib/commonjs/screens/SavedCards/SavedCards.js.map +1 -1
- package/lib/commonjs/utils/analytics.js +21 -0
- package/lib/commonjs/utils/analytics.js.map +1 -1
- package/lib/module/constants/index.js +1 -1
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/hooks/index.js +0 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useAuth.js +6 -0
- package/lib/module/hooks/useAuth.js.map +1 -1
- package/lib/module/hooks/useCustomer.js +1 -87
- package/lib/module/hooks/useCustomer.js.map +1 -1
- package/lib/module/providers/customer/CustomerProvider.js +204 -0
- package/lib/module/providers/customer/CustomerProvider.js.map +1 -0
- package/lib/module/providers/customer/README.md +122 -0
- package/lib/module/providers/customer/classifyLoyaltyError.js +13 -0
- package/lib/module/providers/customer/classifyLoyaltyError.js.map +1 -0
- package/lib/module/providers/customer/index.js +4 -0
- package/lib/module/providers/customer/index.js.map +1 -0
- package/lib/module/providers/customer/types.js +2 -0
- package/lib/module/providers/customer/types.js.map +1 -0
- package/lib/module/providers/customer/useLoyalty.js +18 -0
- package/lib/module/providers/customer/useLoyalty.js.map +1 -0
- package/lib/module/providers/customer/useSquareCustomer.js +14 -0
- package/lib/module/providers/customer/useSquareCustomer.js.map +1 -0
- package/lib/module/providers/index.js +1 -0
- package/lib/module/providers/index.js.map +1 -1
- package/lib/module/screens/SavedCards/SavedCards.js +10 -5
- package/lib/module/screens/SavedCards/SavedCards.js.map +1 -1
- package/lib/module/utils/analytics.js +22 -0
- package/lib/module/utils/analytics.js.map +1 -1
- package/lib/typescript/src/constants/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/index.d.ts +0 -1
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useAuth.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCustomer.d.ts +0 -13
- package/lib/typescript/src/hooks/useCustomer.d.ts.map +1 -1
- package/lib/typescript/src/providers/customer/CustomerProvider.d.ts +9 -0
- package/lib/typescript/src/providers/customer/CustomerProvider.d.ts.map +1 -0
- package/lib/typescript/src/providers/customer/classifyLoyaltyError.d.ts +3 -0
- package/lib/typescript/src/providers/customer/classifyLoyaltyError.d.ts.map +1 -0
- package/lib/typescript/src/providers/customer/index.d.ts +5 -0
- package/lib/typescript/src/providers/customer/index.d.ts.map +1 -0
- package/lib/typescript/src/providers/customer/types.d.ts +25 -0
- package/lib/typescript/src/providers/customer/types.d.ts.map +1 -0
- package/lib/typescript/src/providers/customer/useLoyalty.d.ts +11 -0
- package/lib/typescript/src/providers/customer/useLoyalty.d.ts.map +1 -0
- package/lib/typescript/src/providers/customer/useSquareCustomer.d.ts +7 -0
- package/lib/typescript/src/providers/customer/useSquareCustomer.d.ts.map +1 -0
- package/lib/typescript/src/providers/index.d.ts +2 -0
- package/lib/typescript/src/providers/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/SavedCards/SavedCards.d.ts.map +1 -1
- package/lib/typescript/src/utils/analytics.d.ts +2 -0
- package/lib/typescript/src/utils/analytics.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants/index.ts +1 -1
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useAuth.ts +6 -0
- package/src/hooks/useCustomer.ts +0 -129
- package/src/providers/customer/CustomerProvider.tsx +272 -0
- package/src/providers/customer/README.md +122 -0
- package/src/providers/customer/classifyLoyaltyError.ts +25 -0
- package/src/providers/customer/index.ts +4 -0
- package/src/providers/customer/types.ts +34 -0
- package/src/providers/customer/useLoyalty.ts +27 -0
- package/src/providers/customer/useSquareCustomer.ts +19 -0
- package/src/providers/index.ts +6 -0
- package/src/screens/SavedCards/SavedCards.tsx +10 -3
- package/src/utils/analytics.ts +20 -0
- package/lib/commonjs/hooks/useCheckCustomer.js +0 -57
- package/lib/commonjs/hooks/useCheckCustomer.js.map +0 -1
- package/lib/module/hooks/useCheckCustomer.js +0 -49
- package/lib/module/hooks/useCheckCustomer.js.map +0 -1
- package/lib/typescript/src/hooks/useCheckCustomer.d.ts +0 -5
- package/lib/typescript/src/hooks/useCheckCustomer.d.ts.map +0 -1
- package/src/hooks/useCheckCustomer.ts +0 -49
|
@@ -2,7 +2,6 @@ export { useDeactivateAccount } from './useDeactivateAccount';
|
|
|
2
2
|
export { useTermsOfService, acceptTOS } from './useTermsOfService';
|
|
3
3
|
export { useAuth } from './useAuth';
|
|
4
4
|
export { useCustomerQueries } from './useCustomer';
|
|
5
|
-
export { useCheckCustomer } from './useCheckCustomer';
|
|
6
5
|
export { useAppVersionCheck } from './useAppVersionCheck';
|
|
7
6
|
export { useBusinesses } from './useBusinesses';
|
|
8
7
|
export { useLogout } from './useLogout';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAuBA,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,OAAO;;gBAUuB,SAAS;cAAQ,MAAM;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAuBA,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,OAAO;;gBAUuB,SAAS;cAAQ,MAAM;;;;;;;;;cAgFvB,MAAM;;;qBAmBQ,MAAM;;;;eAmClB,MAAM;;CAqBlD,CAAC"}
|
|
@@ -27,8 +27,6 @@ export declare const useCustomerQueries: () => {
|
|
|
27
27
|
saveAddressLoading: boolean;
|
|
28
28
|
};
|
|
29
29
|
useFetchSavedCards: () => import("@tanstack/react-query").UseQueryResult<any, unknown>;
|
|
30
|
-
useFetchSquareProgram: (queryOptions?: object) => import("@tanstack/react-query").UseQueryResult<any, unknown>;
|
|
31
|
-
useFetchSquareLoyalty: (queryOptions?: object) => import("@tanstack/react-query").UseQueryResult<any, unknown>;
|
|
32
30
|
useSaveCustomerCard: () => {
|
|
33
31
|
saveCard: import("@tanstack/react-query").UseMutateFunction<void, {
|
|
34
32
|
code: string;
|
|
@@ -43,17 +41,6 @@ export declare const useCustomerQueries: () => {
|
|
|
43
41
|
}, string, unknown>;
|
|
44
42
|
disableCardLoading: boolean;
|
|
45
43
|
};
|
|
46
|
-
useConnectSquareLoyalty: () => {
|
|
47
|
-
connectSquareLoyalty: import("@tanstack/react-query").UseMutateFunction<import("axios").AxiosResponse<any, any> | null, unknown, void, unknown>;
|
|
48
|
-
connectLoyaltyLoading: boolean;
|
|
49
|
-
};
|
|
50
|
-
useConnectSquareCustomer: () => {
|
|
51
|
-
connectSquare: import("@tanstack/react-query").UseMutateFunction<void, {
|
|
52
|
-
code: string;
|
|
53
|
-
message: string;
|
|
54
|
-
}, void, unknown>;
|
|
55
|
-
connectSquareLoading: boolean;
|
|
56
|
-
};
|
|
57
44
|
useFetchLoyaltyRewards: (options?: {
|
|
58
45
|
enabled?: boolean;
|
|
59
46
|
}) => import("@tanstack/react-query").UseQueryResult<any, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCustomer.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCustomer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCustomer.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCustomer.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE5D,eAAO,MAAM,kBAAkB;;;;kBAmCE,MAAM;qBAAW,MAAM;;;;;;kBAgCvB,MAAM;qBAAW,MAAM;;uBAhBnC,MAAM,GAAG,IAAI;uBACb,MAAM,GAAG,IAAI;8BACN,MAAM,GAAG,IAAI;;;;;;kBA0CR,MAAM;qBAAW,MAAM;;;;;;;kBAiDvB,MAAM;qBAAW,MAAM;;;;;;kBA6BvB,MAAM;qBAAW,MAAM;;;;uCAgBjB;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;CAgB3D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { type FC, type PropsWithChildren } from 'react';
|
|
2
|
+
import type { CustomerContextValue } from './types';
|
|
3
|
+
export interface CustomerProviderProps {
|
|
4
|
+
autoEnroll: boolean;
|
|
5
|
+
loyaltyEnabled: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const CustomerContext: React.Context<CustomerContextValue | null>;
|
|
8
|
+
export declare const CustomerProvider: FC<PropsWithChildren<CustomerProviderProps>>;
|
|
9
|
+
//# sourceMappingURL=CustomerProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomerProvider.d.ts","sourceRoot":"","sources":["../../../../../src/providers/customer/CustomerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAKZ,KAAK,EAAE,EACP,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAC;AAiBf,OAAO,KAAK,EACV,oBAAoB,EAIrB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;CACzB;AAID,eAAO,MAAM,eAAe,4CAAmD,CAAC;AAEhF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,CAuOzE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classifyLoyaltyError.d.ts","sourceRoot":"","sources":["../../../../../src/providers/customer/classifyLoyaltyError.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,SAAS,GACT,WAAW,GACX,YAAY,GACZ,OAAO,CAAC;AAEZ,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAkB3E"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CustomerProvider } from './CustomerProvider';
|
|
2
|
+
export { useSquareCustomer } from './useSquareCustomer';
|
|
3
|
+
export { useLoyalty } from './useLoyalty';
|
|
4
|
+
export type { CustomerStatus, LoyaltyStatus, CustomerLoyalty } from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/providers/customer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type CustomerStatus = 'idle' | 'loading' | 'ready' | 'error';
|
|
2
|
+
export type LoyaltyStatus = 'idle' | 'loading' | 'not_enrolled' | 'enrolling' | 'ready' | 'no_loyalty' | 'error';
|
|
3
|
+
export interface CustomerLoyalty {
|
|
4
|
+
programId?: string;
|
|
5
|
+
program?: {
|
|
6
|
+
linkedObjectId?: string;
|
|
7
|
+
loyaltyDetails?: {
|
|
8
|
+
points?: number;
|
|
9
|
+
customerId?: string;
|
|
10
|
+
mainProgramId?: string;
|
|
11
|
+
};
|
|
12
|
+
} | null;
|
|
13
|
+
}
|
|
14
|
+
export interface CustomerContextValue {
|
|
15
|
+
customerStatus: CustomerStatus;
|
|
16
|
+
squareCustomerId: string | null;
|
|
17
|
+
customerError: string | null;
|
|
18
|
+
loyaltyStatus: LoyaltyStatus;
|
|
19
|
+
loyalty: CustomerLoyalty | null;
|
|
20
|
+
points: number;
|
|
21
|
+
loyaltyError: string | null;
|
|
22
|
+
enroll: () => void;
|
|
23
|
+
refetchLoyalty: () => void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/providers/customer/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAEpE,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,SAAS,GACT,cAAc,GACd,WAAW,GACX,OAAO,GACP,YAAY,GACZ,OAAO,CAAC;AAEZ,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE;QACR,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE;YACf,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,UAAU,CAAC,EAAE,MAAM,CAAC;YACpB,aAAa,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC;KACH,GAAG,IAAI,CAAC;CACV;AAED,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CustomerLoyalty, LoyaltyStatus } from './types';
|
|
2
|
+
export declare const useLoyalty: () => {
|
|
3
|
+
loyaltyStatus: LoyaltyStatus;
|
|
4
|
+
isReady: boolean;
|
|
5
|
+
loyalty: CustomerLoyalty | null;
|
|
6
|
+
points: number;
|
|
7
|
+
loyaltyError: string | null;
|
|
8
|
+
enroll: () => void;
|
|
9
|
+
refetchLoyalty: () => void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useLoyalty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLoyalty.d.ts","sourceRoot":"","sources":["../../../../../src/providers/customer/useLoyalty.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,UAAU,QAAO;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,cAAc,EAAE,MAAM,IAAI,CAAC;CAe5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSquareCustomer.d.ts","sourceRoot":"","sources":["../../../../../src/providers/customer/useSquareCustomer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,eAAO,MAAM,iBAAiB,QAAO;IACnC,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAW9B,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { changeUser } from './authentication/actions/authentication.actions';
|
|
2
2
|
export { useAuthentication, useAuthenticationDispatch, AuthenticationProvider, } from './authentication/AuthenticationProvider';
|
|
3
|
+
export { CustomerProvider, useSquareCustomer, useLoyalty } from './customer';
|
|
4
|
+
export type { CustomerStatus, LoyaltyStatus, CustomerLoyalty, } from './customer';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAC7E,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,yCAAyC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAC7E,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7E,YAAY,EACV,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SavedCards.d.ts","sourceRoot":"","sources":["../../../../../src/screens/SavedCards/SavedCards.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,eAAO,MAAM,UAAU;iCAKO,mBAAmB,GAAG,UAAU,KAAK,IAAI;;;
|
|
1
|
+
{"version":3,"file":"SavedCards.d.ts","sourceRoot":"","sources":["../../../../../src/screens/SavedCards/SavedCards.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,eAAO,MAAM,UAAU;iCAKO,mBAAmB,GAAG,UAAU,KAAK,IAAI;;;iBA4LtE,CAAC"}
|
|
@@ -33,6 +33,7 @@ export declare const Analytics: {
|
|
|
33
33
|
unregisterSuperProperty: (propertyName: string) => void;
|
|
34
34
|
track: (params: CommonEventTypes | T) => void;
|
|
35
35
|
identify: (userId: string) => void;
|
|
36
|
+
aliasOnce: (userId: string) => Promise<void>;
|
|
36
37
|
profile: {
|
|
37
38
|
set: (key: string, value?: any) => void;
|
|
38
39
|
};
|
|
@@ -47,6 +48,7 @@ export declare const analytics: {
|
|
|
47
48
|
properties?: any;
|
|
48
49
|
}) => void;
|
|
49
50
|
identify: (userId: string) => void;
|
|
51
|
+
aliasOnce: (userId: string) => Promise<void>;
|
|
50
52
|
profile: {
|
|
51
53
|
set: (key: string, value?: any) => void;
|
|
52
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../../src/utils/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../../src/utils/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAUrE,KAAK,gBAAgB,GACjB;IAAE,SAAS,EAAE,iBAAiB,CAAC;IAAC,UAAU,EAAE;QAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAA;KAAE,CAAA;CAAE,GAC3E;IAAE,SAAS,EAAE,mBAAmB,CAAA;CAAE,GAClC;IAAE,SAAS,EAAE,iBAAiB,CAAA;CAAE,GAChC;IAAE,SAAS,EAAE,iBAAiB,CAAA;CAAE,GAChC;IAAE,SAAS,EAAE,wBAAwB,CAAA;CAAE,GACvC;IAAE,SAAS,EAAE,0BAA0B,CAAC;IAAC,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACxE;IAAE,SAAS,EAAE,mBAAmB,CAAA;CAAE,GAClC;IAAE,SAAS,EAAE,KAAK,CAAA;CAAE,GACpB;IAAE,SAAS,EAAE,0BAA0B,CAAA;CAAE,CAAC;AAe9C,eAAO,MAAM,SAAS;;mBACU,MAAM;qBAAe,GAAG;;8CAiDZ,kBAAkB;gDAEhB,MAAM;;2BAjCtB,MAAM;4BASC,MAAM;;uBA8BxB,MAAM,UAAU,GAAG;;;;CAWrC,CAAC;AAEF,eAAO,MAAM,SAAS;0CArBsB,kBAAkB;4CAEhB,MAAM;;mBAnDpB,MAAM;qBAAe,GAAG;;uBAkB1B,MAAM;wBASC,MAAM;;mBA8BxB,MAAM,UAAU,GAAG;;;CAaG,CAAC"}
|
package/package.json
CHANGED
package/src/constants/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const EMAIL_REGEX =
|
|
2
|
-
/^[a-zA-Z0-9.!#$%&'
|
|
2
|
+
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$|^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[^@\s]+\.[^@\s]+$/;
|
|
3
3
|
|
|
4
4
|
export const MMKV_KEYS = {
|
|
5
5
|
BUSINESS_ID: 'BUSINESS_ID',
|
package/src/hooks/index.ts
CHANGED
|
@@ -2,7 +2,6 @@ export { useDeactivateAccount } from './useDeactivateAccount';
|
|
|
2
2
|
export { useTermsOfService, acceptTOS } from './useTermsOfService';
|
|
3
3
|
export { useAuth } from './useAuth';
|
|
4
4
|
export { useCustomerQueries } from './useCustomer';
|
|
5
|
-
export { useCheckCustomer } from './useCheckCustomer';
|
|
6
5
|
export { useAppVersionCheck } from './useAppVersionCheck';
|
|
7
6
|
export { useBusinesses } from './useBusinesses';
|
|
8
7
|
export { useLogout } from './useLogout';
|
package/src/hooks/useAuth.ts
CHANGED
|
@@ -63,6 +63,9 @@ export const useAuth = () => {
|
|
|
63
63
|
dispatch(changeUser(auth().currentUser));
|
|
64
64
|
|
|
65
65
|
// On completing sign up
|
|
66
|
+
// Alias before identify so pre-sign-up anonymous activity merges
|
|
67
|
+
// into the new user profile; aliasOnce is a no-op after the first call.
|
|
68
|
+
await analytics.aliasOnce(auth().currentUser.uid);
|
|
66
69
|
analytics.identify(auth().currentUser.uid);
|
|
67
70
|
const now = new Date().toISOString();
|
|
68
71
|
analytics.profile.set(analyticsKeys.registrationDate, now);
|
|
@@ -119,6 +122,9 @@ export const useAuth = () => {
|
|
|
119
122
|
useMutation(async ({ code }: { code: string }) => {
|
|
120
123
|
try {
|
|
121
124
|
await confirmationResult.confirm(code);
|
|
125
|
+
// Alias before identify so pre-sign-up anonymous activity merges into
|
|
126
|
+
// the user profile; aliasOnce is a no-op after the first call.
|
|
127
|
+
await analytics.aliasOnce(auth().currentUser.uid);
|
|
122
128
|
analytics.identify(auth().currentUser.uid);
|
|
123
129
|
analytics.profile.set(analyticsKeys.app, Config.URL_SCHEME);
|
|
124
130
|
analytics.track({
|
package/src/hooks/useCustomer.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
1
|
import { Alert } from '../components';
|
|
3
2
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
3
|
import firestore from '@react-native-firebase/firestore';
|
|
5
|
-
import uuid from 'react-native-uuid';
|
|
6
|
-
|
|
7
4
|
import {
|
|
8
|
-
connectSquareCustomer,
|
|
9
|
-
connectSquareLoyalty,
|
|
10
5
|
createCustomer,
|
|
11
6
|
fetchLoyaltyRewards,
|
|
12
|
-
fetchSquareLoyalty,
|
|
13
7
|
getCustomer,
|
|
14
8
|
saveCustomerAddress,
|
|
15
9
|
saveCustomerCard,
|
|
@@ -27,12 +21,6 @@ export const useCustomerQueries = () => {
|
|
|
27
21
|
const [selectedBusinessId] = useMMKVString(MMKV_KEYS.BUSINESS_ID);
|
|
28
22
|
const isLoggedIn = user && !user.isAnonymous;
|
|
29
23
|
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (!isLoggedIn) {
|
|
32
|
-
queryClient.invalidateQueries([queryKeys.LOYALTY, user?.uid]);
|
|
33
|
-
}
|
|
34
|
-
}, [isLoggedIn, queryClient, user?.uid]);
|
|
35
|
-
|
|
36
24
|
return {
|
|
37
25
|
useFetchCustomer: () =>
|
|
38
26
|
useQuery(
|
|
@@ -160,63 +148,6 @@ export const useCustomerQueries = () => {
|
|
|
160
148
|
enabled: Boolean(isLoggedIn),
|
|
161
149
|
}
|
|
162
150
|
),
|
|
163
|
-
useFetchSquareProgram: (queryOptions?: object) =>
|
|
164
|
-
useQuery(
|
|
165
|
-
[queryKeys.PROGRAM, user?.uid, selectedBusinessId],
|
|
166
|
-
async () => {
|
|
167
|
-
if (isLoggedIn) {
|
|
168
|
-
const programs = await firestore()
|
|
169
|
-
.collection(`customers/${user?.uid}/programs`)
|
|
170
|
-
.where('type', '==', 'customer')
|
|
171
|
-
.where('businessId', '==', selectedBusinessId)
|
|
172
|
-
.orderBy('updated', 'asc')
|
|
173
|
-
.get();
|
|
174
|
-
if (programs.docs.length > 0) {
|
|
175
|
-
return programs.docs.map((program: any) => program.data())[0];
|
|
176
|
-
} else {
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
return null;
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
enabled: Boolean(isLoggedIn && selectedBusinessId),
|
|
185
|
-
...queryOptions,
|
|
186
|
-
}
|
|
187
|
-
),
|
|
188
|
-
useFetchSquareLoyalty: (queryOptions?: object) =>
|
|
189
|
-
useQuery(
|
|
190
|
-
[
|
|
191
|
-
queryKeys.LOYALTY,
|
|
192
|
-
user?.uid ?? 'no-user',
|
|
193
|
-
selectedBusinessId ?? 'no-biz',
|
|
194
|
-
],
|
|
195
|
-
async () => {
|
|
196
|
-
const response = await fetchSquareLoyalty(
|
|
197
|
-
user!.uid,
|
|
198
|
-
selectedBusinessId!
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
if (response?.data?.error) {
|
|
202
|
-
throw new Error(
|
|
203
|
-
response.data.error.message || 'Unknown error occurred'
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
return response;
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
enabled: Boolean(isLoggedIn && user?.uid && selectedBusinessId),
|
|
210
|
-
refetchOnWindowFocus: false,
|
|
211
|
-
refetchOnReconnect: false,
|
|
212
|
-
refetchOnMount: false,
|
|
213
|
-
staleTime: 5 * 60 * 1000,
|
|
214
|
-
cacheTime: 30 * 60 * 1000,
|
|
215
|
-
retry: 0,
|
|
216
|
-
select: (res) => res?.data,
|
|
217
|
-
...(queryOptions || {}),
|
|
218
|
-
}
|
|
219
|
-
),
|
|
220
151
|
useSaveCustomerCard: () => {
|
|
221
152
|
const mutation = useMutation(
|
|
222
153
|
async (data: SaveCardRequest) => {
|
|
@@ -273,66 +204,6 @@ export const useCustomerQueries = () => {
|
|
|
273
204
|
disableCardLoading: mutation.isLoading,
|
|
274
205
|
};
|
|
275
206
|
},
|
|
276
|
-
useConnectSquareLoyalty: () => {
|
|
277
|
-
const mutation = useMutation(
|
|
278
|
-
async () => {
|
|
279
|
-
if (isLoggedIn && selectedBusinessId) {
|
|
280
|
-
const response = await connectSquareLoyalty(user?.uid, {
|
|
281
|
-
businessId: selectedBusinessId,
|
|
282
|
-
idempotentKey: uuid.v4() as string,
|
|
283
|
-
uid: user?.uid,
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
if (response?.data?.error) {
|
|
287
|
-
throw new Error(
|
|
288
|
-
response.data.error.message || 'Unknown error occurred'
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
return response;
|
|
293
|
-
}
|
|
294
|
-
return null;
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
onSuccess: () => {
|
|
298
|
-
queryClient.invalidateQueries([queryKeys.LOYALTY, user?.uid]);
|
|
299
|
-
},
|
|
300
|
-
}
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
return {
|
|
304
|
-
connectSquareLoyalty: mutation.mutate,
|
|
305
|
-
connectLoyaltyLoading: mutation.isLoading,
|
|
306
|
-
};
|
|
307
|
-
},
|
|
308
|
-
useConnectSquareCustomer: () => {
|
|
309
|
-
const mutation = useMutation(
|
|
310
|
-
async () => {
|
|
311
|
-
if (isLoggedIn && selectedBusinessId) {
|
|
312
|
-
await connectSquareCustomer(user?.uid, {
|
|
313
|
-
businessId: selectedBusinessId,
|
|
314
|
-
idempotentKey: uuid.v4() as string,
|
|
315
|
-
uid: user?.uid,
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
onError: (err: { code: string; message: string }) =>
|
|
321
|
-
Alert.show({
|
|
322
|
-
title: 'Code ' + err?.code,
|
|
323
|
-
description: err?.message,
|
|
324
|
-
}),
|
|
325
|
-
onSuccess: () => {
|
|
326
|
-
queryClient.invalidateQueries([queryKeys.PROGRAM, user?.uid]);
|
|
327
|
-
},
|
|
328
|
-
}
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
return {
|
|
332
|
-
connectSquare: mutation.mutate,
|
|
333
|
-
connectSquareLoading: mutation.isLoading,
|
|
334
|
-
};
|
|
335
|
-
},
|
|
336
207
|
useFetchLoyaltyRewards: (options?: { enabled?: boolean }) =>
|
|
337
208
|
useQuery(
|
|
338
209
|
[queryKeys.REWARDS, selectedBusinessId],
|