@kiosinc/commons-rn 0.1.61 → 0.1.63
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/auth/providers/authentication/AuthenticationProvider.js +2 -1
- package/lib/commonjs/auth/providers/authentication/AuthenticationProvider.js.map +1 -1
- package/lib/commonjs/auth/providers/authentication/reducer/authentication.reducer.js +19 -1
- package/lib/commonjs/auth/providers/authentication/reducer/authentication.reducer.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/auth/providers/authentication/AuthenticationProvider.js +2 -1
- package/lib/module/auth/providers/authentication/AuthenticationProvider.js.map +1 -1
- package/lib/module/auth/providers/authentication/reducer/authentication.reducer.js +19 -1
- package/lib/module/auth/providers/authentication/reducer/authentication.reducer.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/auth/providers/authentication/AuthenticationProvider.d.ts.map +1 -1
- package/lib/typescript/src/auth/providers/authentication/reducer/authentication.reducer.d.ts.map +1 -1
- package/lib/typescript/src/auth/providers/authentication/types/authentication.types.d.ts +1 -0
- package/lib/typescript/src/auth/providers/authentication/types/authentication.types.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/auth/providers/authentication/AuthenticationProvider.tsx +1 -0
- package/src/auth/providers/authentication/reducer/authentication.reducer.ts +20 -0
- package/src/auth/providers/authentication/types/authentication.types.ts +1 -0
- 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,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateCustomerProfile = exports.saveCustomerCard = exports.saveCustomerAddress = exports.getCustomer = exports.fetchSquareLoyalty = exports.fetchLoyaltyRewards = exports.createCustomer = exports.connectSquareLoyalty = exports.connectSquareCustomer = void 0;
|
|
7
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
+
var _reactNativeConfig = _interopRequireDefault(require("react-native-config"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
const getCustomer = async userId => {
|
|
11
|
+
return await _axios.default.get(`${_reactNativeConfig.default.CHILDS_SERVER_ENV}/customers/${userId}`);
|
|
12
|
+
};
|
|
13
|
+
exports.getCustomer = getCustomer;
|
|
14
|
+
const createCustomer = async ({
|
|
15
|
+
uid,
|
|
16
|
+
address = null
|
|
17
|
+
}) => {
|
|
18
|
+
return await _axios.default.post(`${_reactNativeConfig.default.CHILDS_SERVER_ENV}/customers/create`, {
|
|
19
|
+
uid,
|
|
20
|
+
props: {
|
|
21
|
+
Address: address
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.createCustomer = createCustomer;
|
|
26
|
+
const updateCustomerProfile = async ({
|
|
27
|
+
uid,
|
|
28
|
+
props
|
|
29
|
+
}) => {
|
|
30
|
+
return await _axios.default.post(`${_reactNativeConfig.default.CHILDS_SERVER_ENV}/customers/${uid}/update`, {
|
|
31
|
+
props
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
exports.updateCustomerProfile = updateCustomerProfile;
|
|
35
|
+
const saveCustomerAddress = async ({
|
|
36
|
+
uid,
|
|
37
|
+
address
|
|
38
|
+
}) => {
|
|
39
|
+
return await _axios.default.post(`${_reactNativeConfig.default.CHILDS_SERVER_ENV}/customers/${uid}/address/create`, {
|
|
40
|
+
address
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.saveCustomerAddress = saveCustomerAddress;
|
|
44
|
+
const saveCustomerCard = async ({
|
|
45
|
+
uid,
|
|
46
|
+
props
|
|
47
|
+
}) => {
|
|
48
|
+
return await _axios.default.post(`${_reactNativeConfig.default.CHILDS_SERVER_ENV}/customers/${uid}/square/card/save`, {
|
|
49
|
+
...props
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
exports.saveCustomerCard = saveCustomerCard;
|
|
53
|
+
const connectSquareLoyalty = async (uid, props) => {
|
|
54
|
+
return await _axios.default.post(`${_reactNativeConfig.default.CHILDS_SERVER_ENV}/customers/${uid}/square/loyalty/connect`, {
|
|
55
|
+
props
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
exports.connectSquareLoyalty = connectSquareLoyalty;
|
|
59
|
+
const connectSquareCustomer = async (uid, props) => {
|
|
60
|
+
return await _axios.default.post(`${_reactNativeConfig.default.CHILDS_SERVER_ENV}/customers/${uid}/square/customer/connect`, {
|
|
61
|
+
props
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
exports.connectSquareCustomer = connectSquareCustomer;
|
|
65
|
+
const fetchSquareLoyalty = async (uid, businessId) => {
|
|
66
|
+
return await _axios.default.post(`${_reactNativeConfig.default.CHILDS_SERVER_ENV}/customers/${uid}/square/loyalty/refresh`, {
|
|
67
|
+
businessId
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
exports.fetchSquareLoyalty = fetchSquareLoyalty;
|
|
71
|
+
const fetchLoyaltyRewards = async businessId => {
|
|
72
|
+
return await _axios.default.get(`${_reactNativeConfig.default.SQUARE_BASE_URL}/customers/loyalty/mainProgram/${businessId}`);
|
|
73
|
+
};
|
|
74
|
+
exports.fetchLoyaltyRewards = fetchLoyaltyRewards;
|
|
75
|
+
//# sourceMappingURL=customer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_axios","_interopRequireDefault","require","_reactNativeConfig","obj","__esModule","default","getCustomer","userId","axios","get","Config","CHILDS_SERVER_ENV","exports","createCustomer","uid","address","post","props","Address","updateCustomerProfile","saveCustomerAddress","saveCustomerCard","connectSquareLoyalty","connectSquareCustomer","fetchSquareLoyalty","businessId","fetchLoyaltyRewards","SQUARE_BASE_URL"],"sourceRoot":"../../../src","sources":["api/customer.ts"],"mappings":";;;;;;AAOA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAyC,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAElC,MAAMG,WAAW,GAAG,MAAOC,MAAc,IAAK;EACnD,OAAO,MAAMC,cAAK,CAACC,GAAG,CAAE,GAAEC,0BAAM,CAACC,iBAAkB,cAAaJ,MAAO,EAAC,CAAC;AAC3E,CAAC;AAACK,OAAA,CAAAN,WAAA,GAAAA,WAAA;AAEK,MAAMO,cAAc,GAAG,MAAAA,CAAO;EACnCC,GAAG;EACHC,OAAO,GAAG;AAIZ,CAAC,KAAK;EACJ,OAAO,MAAMP,cAAK,CAACQ,IAAI,CAAE,GAAEN,0BAAM,CAACC,iBAAkB,mBAAkB,EAAE;IACtEG,GAAG;IACHG,KAAK,EAAE;MACLC,OAAO,EAAEH;IACX;EACF,CAAC,CAAC;AACJ,CAAC;AAACH,OAAA,CAAAC,cAAA,GAAAA,cAAA;AAEK,MAAMM,qBAAqB,GAAG,MAAAA,CAAO;EAC1CL,GAAG;EACHG;AAIF,CAAC,KAAK;EACJ,OAAO,MAAMT,cAAK,CAACQ,IAAI,CACpB,GAAEN,0BAAM,CAACC,iBAAkB,cAAaG,GAAI,SAAQ,EACrD;IACEG;EACF,CACF,CAAC;AACH,CAAC;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ACH,CAAC;AAACb,OAAA,CAAAY,kBAAA,GAAAA,kBAAA;AAEK,MAAME,mBAAmB,GAAG,MAAOD,UAAkB,IAAK;EAC/D,OAAO,MAAMjB,cAAK,CAACC,GAAG,CACnB,GAAEC,0BAAM,CAACiB,eAAgB,kCAAiCF,UAAW,EACxE,CAAC;AACH,CAAC;AAACb,OAAA,CAAAc,mBAAA,GAAAA,mBAAA"}
|
|
@@ -14,6 +14,7 @@ var _authentication2 = require("../api/authentication");
|
|
|
14
14
|
var _reactNativeConfig = _interopRequireDefault(require("react-native-config"));
|
|
15
15
|
var _analytics = require("../../utils/analytics");
|
|
16
16
|
var _analyticsKeys = require("../../constants/analyticsKeys");
|
|
17
|
+
var _customer = require("../../api/customer");
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
19
|
let confirmationResult;
|
|
19
20
|
const useAuthentication = () => {
|
|
@@ -51,6 +52,11 @@ const useAuthentication = () => {
|
|
|
51
52
|
_analytics.analytics.profile.set(_analyticsKeys.analyticsKeys.registrationDate, now);
|
|
52
53
|
_analytics.analytics.profile.set(_analyticsKeys.analyticsKeys.app, _reactNativeConfig.default.APP_NAME);
|
|
53
54
|
_analytics.analytics.track(_analyticsKeys.analyticsKeys.signupCompleted);
|
|
55
|
+
|
|
56
|
+
// Create new customer in customer collections
|
|
57
|
+
await (0, _customer.createCustomer)({
|
|
58
|
+
uid: (0, _auth.default)().currentUser.uid
|
|
59
|
+
});
|
|
54
60
|
} catch (error) {
|
|
55
61
|
console.log('error', error);
|
|
56
62
|
// Sign out user if something goes wrong
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactQuery","require","_auth","_interopRequireDefault","_authentication","_native","_reactI18next","_components","_authentication2","_reactNativeConfig","_analytics","_analyticsKeys","obj","__esModule","default","confirmationResult","useAuthentication","dispatch","useAuthenticationDispatch","navigation","useNavigation","t","useTranslation","useSignUp","useMutation","params","code","confirm","signUpAPI","onError","error","Alert","show","title","console","log","onSuccess","_","payload","credential","auth","EmailAuthProvider","email","password","currentUser","reauthenticateWithCredential","reload","changeUser","analytics","identify","uid","now","Date","toISOString","profile","set","analyticsKeys","registrationDate","app","Config","APP_NAME","track","signupCompleted","signOut","catch","StackActions","popToTop","useIsCheckRegistered","checkIsRegisteredAPI","response","data","isRegistered","navigate","useConfirmPhoneNumber","loginCompleted","method","useVerifyPhoneNumberForLogin","phoneNumber","signInWithPhoneNumber","description","emailOrPhoneNumber","message","useVerifyPhoneNumber","useResetPassword","sendPasswordResetEmail","resetPasswordCompleted","exports"],"sourceRoot":"../../../../src","sources":["auth/hooks/useAuthentication.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAIA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AACA,IAAAU,cAAA,GAAAV,OAAA;
|
|
1
|
+
{"version":3,"names":["_reactQuery","require","_auth","_interopRequireDefault","_authentication","_native","_reactI18next","_components","_authentication2","_reactNativeConfig","_analytics","_analyticsKeys","_customer","obj","__esModule","default","confirmationResult","useAuthentication","dispatch","useAuthenticationDispatch","navigation","useNavigation","t","useTranslation","useSignUp","useMutation","params","code","confirm","signUpAPI","onError","error","Alert","show","title","console","log","onSuccess","_","payload","credential","auth","EmailAuthProvider","email","password","currentUser","reauthenticateWithCredential","reload","changeUser","analytics","identify","uid","now","Date","toISOString","profile","set","analyticsKeys","registrationDate","app","Config","APP_NAME","track","signupCompleted","createCustomer","signOut","catch","StackActions","popToTop","useIsCheckRegistered","checkIsRegisteredAPI","response","data","isRegistered","navigate","useConfirmPhoneNumber","loginCompleted","method","useVerifyPhoneNumberForLogin","phoneNumber","signInWithPhoneNumber","description","emailOrPhoneNumber","message","useVerifyPhoneNumber","useResetPassword","sendPasswordResetEmail","resetPasswordCompleted","exports"],"sourceRoot":"../../../../src","sources":["auth/hooks/useAuthentication.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAIA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AACA,IAAAU,cAAA,GAAAV,OAAA;AACA,IAAAW,SAAA,GAAAX,OAAA;AAAoD,SAAAE,uBAAAU,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEpD,IAAIG,kBAAwD;AAUrD,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EACrC,MAAMC,QAAQ,GAAG,IAAAC,yCAAyB,EAAC,CAAC;EAC5C,MAAMC,UAAU,GAAG,IAAAC,qBAAa,EAAgC,CAAC;EACjE,MAAM;IAAEC;EAAE,CAAC,GAAG,IAAAC,4BAAc,EAAC,CAAC;EAE9B,OAAO;IACLC,SAAS,EAAEA,CAAA,KACT,IAAAC,uBAAW,EACT,OAAO;MAAEC,MAAM;MAAEC;IAA0C,CAAC,KAAK;MAC/D,MAAMX,kBAAkB,CAACY,OAAO,CAACD,IAAI,CAAC;MACtC,MAAM,IAAAE,0BAAS,EAACH,MAAM,CAAC;IACzB,CAAC,EACD;MACEI,OAAO,EAAGC,KAAY,IAAK;QACzBC,iBAAK,CAACC,IAAI,CAAC;UACTC,KAAK,EAAEZ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UAAE5C;QAAM,CAAC,CAAC;MAClE,CAAC,CAAC,MAAM;QACNX,iBAAK,CAACC,IAAI,CAAC;UACTgD,WAAW,EAAE3D,CAAC,CAAC,iCAAiC,EAAE;YAChD4D,kBAAkB,EAAEvC;UACtB,CAAC;QACH,CAAC,CAAC;MACJ;IACF,CAAC;EACL,CAAC;AACH,CAAC;AAAC6C,OAAA,CAAAvE,iBAAA,GAAAA,iBAAA"}
|
|
@@ -10,6 +10,7 @@ var _queryKeys = require("../../selectBusiness/queryKeys");
|
|
|
10
10
|
var _authentication = require("../providers/authentication");
|
|
11
11
|
var _utils = require("../../utils");
|
|
12
12
|
var _analytics = require("../../utils/analytics");
|
|
13
|
+
var _customer = require("../../api/customer");
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
const useTermsOfService = () => {
|
|
15
16
|
const queryClient = (0, _reactQuery.useQueryClient)();
|
|
@@ -47,18 +48,15 @@ const useTermsOfService = () => {
|
|
|
47
48
|
if (!user?.uid) return;
|
|
48
49
|
const query = await (0, _firestore.default)().doc(`customers/${user.uid}`);
|
|
49
50
|
const customerSnapshot = await query.get();
|
|
50
|
-
if (customerSnapshot.exists) {
|
|
51
|
-
await
|
|
52
|
-
|
|
53
|
-
agreementsUpdated: new Date().toISOString()
|
|
54
|
-
});
|
|
55
|
-
} else {
|
|
56
|
-
await query.set({
|
|
57
|
-
uid: user.uid,
|
|
58
|
-
created: (0, _utils.getCurrentTimestamp)(),
|
|
59
|
-
agreementsUpdated: new Date().toISOString()
|
|
51
|
+
if (!customerSnapshot.exists) {
|
|
52
|
+
await (0, _customer.createCustomer)({
|
|
53
|
+
uid: user.uid
|
|
60
54
|
});
|
|
61
55
|
}
|
|
56
|
+
await query.update({
|
|
57
|
+
updated: (0, _utils.getCurrentTimestamp)(),
|
|
58
|
+
agreementsUpdated: new Date().toISOString()
|
|
59
|
+
});
|
|
62
60
|
_analytics.analytics.track('term_of_service_accepted');
|
|
63
61
|
await queryClient.invalidateQueries([user.uid, _queryKeys.queryKeys.TERMS_AND_CONDITIONS]);
|
|
64
62
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactQuery","require","_firestore","_interopRequireDefault","_queryKeys","_authentication","_utils","_analytics","obj","__esModule","default","useTermsOfService","queryClient","useQueryClient","user","useAuthentication","useTermsOfServiceURL","useQuery","queryKeys","TERMS_AND_CONDITIONS_URL","system","firestore","doc","get","data","url","staleTime","Infinity","useShouldShowTermsOfService","uid","TERMS_AND_CONDITIONS","customerSnapshot","exists","customer","agreementsUpdated","Date","updated","DEFAULT_STALE_TIME","useAgreeTermsOfService","useMutation","query","update","getCurrentTimestamp","toISOString","
|
|
1
|
+
{"version":3,"names":["_reactQuery","require","_firestore","_interopRequireDefault","_queryKeys","_authentication","_utils","_analytics","_customer","obj","__esModule","default","useTermsOfService","queryClient","useQueryClient","user","useAuthentication","useTermsOfServiceURL","useQuery","queryKeys","TERMS_AND_CONDITIONS_URL","system","firestore","doc","get","data","url","staleTime","Infinity","useShouldShowTermsOfService","uid","TERMS_AND_CONDITIONS","customerSnapshot","exists","customer","agreementsUpdated","Date","updated","DEFAULT_STALE_TIME","useAgreeTermsOfService","useMutation","query","createCustomer","update","getCurrentTimestamp","toISOString","analytics","track","invalidateQueries","exports"],"sourceRoot":"../../../../src","sources":["auth/hooks/useTermsOfService.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAAoD,SAAAE,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE7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QAAQ,CAACC,iBAAiB,CAAC,EAC/D;YACA,OAAO,IAAI;UACb;QACF;MACF,CAAC,MAAM;QACL,OAAO,IAAI;MACb;MACA,OAAO,KAAK;IACd,CAAC,EACD;MACER,SAAS,EAAEW;IACb,CACF,CAAC;IACHC,sBAAsB,EAAEA,CAAA,KACtB,IAAAC,uBAAW,EAAC,YAAY;MACtB,IAAI,CAACzB,IAAI,EAAEe,GAAG,EAAE;MAChB,MAAMW,KAAK,GAAG,MAAM,IAAAnB,kBAAS,EAAC,CAAC,CAACC,GAAG,CAAE,aAAYR,IAAI,CAACe,GAAI,EAAC,CAAC;MAC5D,MAAME,gBAAgB,GAAG,MAAMS,KAAK,CAACjB,GAAG,CAAC,CAAC;MAE1C,IAAI,CAACQ,gBAAgB,CAACC,MAAM,EAAE;QAC5B,MAAM,IAAAS,wBAAc,EAAC;UAAEZ,GAAG,EAAEf,IAAI,CAAEe;QAAI,CAAC,CAAC;MAC1C;MACA,MAAMW,KAAK,CAACE,MAAM,CAAC;QACjBN,OAAO,EAAE,IAAAO,0BAAmB,EAAC,CAAC;QAC9BT,iBAAiB,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACS,WAAW,CAAC;MAC5C,CAAC,CAAC;MAEFC,oBAAS,CAACC,KAAK,CAAC,0BAA0B,CAAC;MAC3C,MAAMlC,WAAW,CAACmC,iBAAiB,CAAC,CAClCjC,IAAI,CAACe,GAAG,EACRX,oBAAS,CAACY,oBAAoB,CAC/B,CAAC;IACJ,CAAC;EACL,CAAC;AACH,CAAC;AAACkB,OAAA,CAAArC,iBAAA,GAAAA,iBAAA"}
|
|
@@ -23,7 +23,8 @@ const AuthenticationProvider = ({
|
|
|
23
23
|
}) => {
|
|
24
24
|
const [authentication, dispatch] = (0, _react.useReducer)(_authentication.authenticationReducer, {
|
|
25
25
|
initializing: true,
|
|
26
|
-
user: null
|
|
26
|
+
user: null,
|
|
27
|
+
isSignedIn: false
|
|
27
28
|
});
|
|
28
29
|
const getToken = (0, _react.useCallback)(async () => {
|
|
29
30
|
if (authentication.user) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_auth","_interopRequireDefault","_authentication","_useAuthenticateRequests","_authentication2","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","AuthenticationContext","createContext","AuthenticationDispatchContext","useAuthentication","useContext","exports","useAuthenticationDispatch","AuthenticationProvider","children","authentication","dispatch","useReducer","authenticationReducer","initializing","user","getToken","useCallback","getIdToken","isAnonymous","useAuthenticateRequests","useEffect","auth","signInAnonymously","onAuthStateChanged","changeUser","subscriber","createElement","Provider","value"],"sourceRoot":"../../../../../src","sources":["auth/providers/authentication/AuthenticationProvider.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AAMA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,wBAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AAA8D,SAAAE,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAA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AI;IAClBC,IAAI,EAAE;
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_auth","_interopRequireDefault","_authentication","_useAuthenticateRequests","_authentication2","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","AuthenticationContext","createContext","AuthenticationDispatchContext","useAuthentication","useContext","exports","useAuthenticationDispatch","AuthenticationProvider","children","authentication","dispatch","useReducer","authenticationReducer","initializing","user","isSignedIn","getToken","useCallback","getIdToken","isAnonymous","useAuthenticateRequests","useEffect","auth","signInAnonymously","onAuthStateChanged","changeUser","subscriber","createElement","Provider","value"],"sourceRoot":"../../../../../src","sources":["auth/providers/authentication/AuthenticationProvider.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AAMA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,wBAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AAA8D,SAAAE,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,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Module", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.authenticationReducer = void 0;
|
|
7
7
|
var _authentication = require("../types/authentication.types");
|
|
8
|
+
const isSignedIn = user => {
|
|
9
|
+
if (user.isAnonymous) {
|
|
10
|
+
// User is anonymous; prompt login process.
|
|
11
|
+
return false;
|
|
12
|
+
} else if (user.email) {
|
|
13
|
+
// User has an email; verify if phone number is also provided to proceed.
|
|
14
|
+
if (user.phoneNumber) {
|
|
15
|
+
return true;
|
|
16
|
+
} else {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
} else if (user.phoneNumber) {
|
|
20
|
+
// User lacks email but has a phone number; allow sign-in.
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
8
25
|
const authenticationReducer = (state, action) => {
|
|
9
26
|
switch (action.type) {
|
|
10
27
|
case _authentication.AuthenticationActionType.ChangeUser:
|
|
11
28
|
return {
|
|
12
29
|
...state,
|
|
13
30
|
initializing: false,
|
|
14
|
-
user: action.user
|
|
31
|
+
user: action.user,
|
|
32
|
+
isSignedIn: action.user ? isSignedIn(action.user) : false
|
|
15
33
|
};
|
|
16
34
|
default:
|
|
17
35
|
return state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_authentication","require","authenticationReducer","state","action","type","AuthenticationActionType","ChangeUser","initializing","
|
|
1
|
+
{"version":3,"names":["_authentication","require","isSignedIn","user","isAnonymous","email","phoneNumber","authenticationReducer","state","action","type","AuthenticationActionType","ChangeUser","initializing","exports"],"sourceRoot":"../../../../../../src","sources":["auth/providers/authentication/reducer/authentication.reducer.ts"],"mappings":";;;;;;AACA,IAAAA,eAAA,GAAAC,OAAA;AAMA,MAAMC,UAAU,GAAIC,IAA4B,IAAK;EACnD,IAAIA,IAAI,CAACC,WAAW,EAAE;IACpB;IACA,OAAO,KAAK;EACd,CAAC,MAAM,IAAID,IAAI,CAACE,KAAK,EAAE;IACrB;IACA,IAAIF,IAAI,CAACG,WAAW,EAAE;MACpB,OAAO,IAAI;IACb,CAAC,MAAM;MACL,OAAO,KAAK;IACd;EACF,CAAC,MAAM,IAAIH,IAAI,CAACG,WAAW,EAAE;IAC3B;IACA,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd,CAAC;AAEM,MAAMC,qBAAqB,GAAGA,CACnCC,KAA0B,EAC1BC,MAA4B,KACJ;EACxB,QAAQA,MAAM,CAACC,IAAI;IACjB,KAAKC,wCAAwB,CAACC,UAAU;MACtC,OAAO;QACL,GAAGJ,KAAK;QACRK,YAAY,EAAE,KAAK;QACnBV,IAAI,EAAEM,MAAM,CAACN,IAAI;QACjBD,UAAU,EAAEO,MAAM,CAACN,IAAI,GAAGD,UAAU,CAACO,MAAM,CAACN,IAAI,CAAC,GAAG;MACtD,CAAC;IACH;MACE,OAAOK,KAAK;EAChB;AACF,CAAC;AAACM,OAAA,CAAAP,qBAAA,GAAAA,qBAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useCheckCustomer = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _useCustomer = require("./useCustomer");
|
|
9
|
+
var _auth = require("../auth");
|
|
10
|
+
const useCheckCustomer = () => {
|
|
11
|
+
const {
|
|
12
|
+
user
|
|
13
|
+
} = (0, _auth.useAuthentication)();
|
|
14
|
+
const isLoggedIn = user && !user.isAnonymous;
|
|
15
|
+
const {
|
|
16
|
+
useFetchCustomer,
|
|
17
|
+
useCreateCustomer,
|
|
18
|
+
useFetchSquareProgram,
|
|
19
|
+
useConnectSquareCustomer
|
|
20
|
+
} = (0, _useCustomer.useCustomerQueries)();
|
|
21
|
+
const {
|
|
22
|
+
connectSquare
|
|
23
|
+
} = useConnectSquareCustomer();
|
|
24
|
+
const {
|
|
25
|
+
createCustomerHook
|
|
26
|
+
} = useCreateCustomer();
|
|
27
|
+
const {
|
|
28
|
+
data: customer
|
|
29
|
+
} = useFetchCustomer();
|
|
30
|
+
const {
|
|
31
|
+
refetch: fetchSquareProgram
|
|
32
|
+
} = useFetchSquareProgram({
|
|
33
|
+
enabled: false,
|
|
34
|
+
refetchOnWindowFocus: false
|
|
35
|
+
});
|
|
36
|
+
const checkIfprogramPresent = (0, _react.useCallback)(() => {
|
|
37
|
+
fetchSquareProgram().then(res => {
|
|
38
|
+
if (res.data === null) {
|
|
39
|
+
connectSquare();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}, [connectSquare, fetchSquareProgram]);
|
|
43
|
+
(0, _react.useEffect)(() => {
|
|
44
|
+
if (isLoggedIn) {
|
|
45
|
+
if (customer?.customer === null) {
|
|
46
|
+
createCustomerHook();
|
|
47
|
+
} else if (customer?.uid) {
|
|
48
|
+
checkIfprogramPresent();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}, [customer, createCustomerHook, isLoggedIn, checkIfprogramPresent]);
|
|
52
|
+
return {
|
|
53
|
+
customer
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports.useCheckCustomer = useCheckCustomer;
|
|
57
|
+
//# sourceMappingURL=useCheckCustomer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_useCustomer","_auth","useCheckCustomer","user","useAuthentication","isLoggedIn","isAnonymous","useFetchCustomer","useCreateCustomer","useFetchSquareProgram","useConnectSquareCustomer","useCustomerQueries","connectSquare","createCustomerHook","data","customer","refetch","fetchSquareProgram","enabled","refetchOnWindowFocus","checkIfprogramPresent","useCallback","then","res","useEffect","uid","exports"],"sourceRoot":"../../../src","sources":["hooks/useCheckCustomer.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEO,MAAMG,gBAAgB,GAAGA,CAAA,K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BAAA"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useCustomerQueries = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _auth = require("../auth");
|
|
9
|
+
var _components = require("../components");
|
|
10
|
+
var _reactQuery = require("@tanstack/react-query");
|
|
11
|
+
var _firestore = _interopRequireDefault(require("@react-native-firebase/firestore"));
|
|
12
|
+
var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
|
|
13
|
+
var _customer = require("../api/customer");
|
|
14
|
+
var _reactNativeMmkv = require("react-native-mmkv");
|
|
15
|
+
var _constants = require("../constants");
|
|
16
|
+
var _queryKeys = require("../selectBusiness/queryKeys");
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
const useCustomerQueries = () => {
|
|
19
|
+
const queryClient = (0, _reactQuery.useQueryClient)();
|
|
20
|
+
const {
|
|
21
|
+
user
|
|
22
|
+
} = (0, _auth.useAuthentication)();
|
|
23
|
+
const [selectedBusinessId] = (0, _reactNativeMmkv.useMMKVString)(_constants.MMKV_KEYS.BUSINESS_ID);
|
|
24
|
+
const isLoggedIn = user && !user.isAnonymous;
|
|
25
|
+
(0, _react.useEffect)(() => {
|
|
26
|
+
if (!isLoggedIn) {
|
|
27
|
+
queryClient.invalidateQueries([_queryKeys.queryKeys.LOYALTY, user?.uid]);
|
|
28
|
+
}
|
|
29
|
+
}, [isLoggedIn, queryClient, user?.uid]);
|
|
30
|
+
return {
|
|
31
|
+
useFetchCustomer: () => (0, _reactQuery.useQuery)([_queryKeys.queryKeys.CUSTOMER, user?.uid], async () => {
|
|
32
|
+
if (isLoggedIn) {
|
|
33
|
+
return await (0, _customer.getCustomer)(user.uid);
|
|
34
|
+
} else {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
38
|
+
select: data => data?.data?.customer
|
|
39
|
+
}),
|
|
40
|
+
useCreateCustomer: () => {
|
|
41
|
+
const mutation = (0, _reactQuery.useMutation)(async () => {
|
|
42
|
+
if (isLoggedIn) {
|
|
43
|
+
const response = await (0, _customer.createCustomer)({
|
|
44
|
+
uid: user.uid
|
|
45
|
+
});
|
|
46
|
+
if (response?.data?.customer) {
|
|
47
|
+
await queryClient.invalidateQueries([_queryKeys.queryKeys.CUSTOMER, user?.uid]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
onError: err => _components.Alert.show({
|
|
52
|
+
title: 'Code ' + err?.code,
|
|
53
|
+
description: err?.message
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
createCustomerHook: mutation.mutateAsync,
|
|
58
|
+
createCustomerLoading: mutation.isLoading
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
useUpdateCustomer: () => {
|
|
62
|
+
const mutation = (0, _reactQuery.useMutation)(async props => {
|
|
63
|
+
if (isLoggedIn) {
|
|
64
|
+
const response = await (0, _customer.updateCustomerProfile)({
|
|
65
|
+
uid: user.uid,
|
|
66
|
+
props
|
|
67
|
+
});
|
|
68
|
+
if (response?.data?.customer) {
|
|
69
|
+
queryClient.invalidateQueries([_queryKeys.queryKeys.CUSTOMER, user?.uid]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
onError: err => _components.Alert.show({
|
|
74
|
+
title: 'Code ' + err?.code,
|
|
75
|
+
description: err?.message
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
updateCustomer: mutation.mutate,
|
|
80
|
+
updateCustomerLoading: mutation.isLoading
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
useSaveCustomerAddress: () => {
|
|
84
|
+
const mutation = (0, _reactQuery.useMutation)(async address => {
|
|
85
|
+
if (isLoggedIn) {
|
|
86
|
+
const response = await (0, _customer.saveCustomerAddress)({
|
|
87
|
+
uid: user.uid,
|
|
88
|
+
address
|
|
89
|
+
});
|
|
90
|
+
if (response?.data?.customer) {
|
|
91
|
+
queryClient.invalidateQueries([_queryKeys.queryKeys.CUSTOMER, user?.uid]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
onError: err => _components.Alert.show({
|
|
96
|
+
title: 'Code ' + err?.code,
|
|
97
|
+
description: err?.message
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
useSaveAddress: mutation.mutate,
|
|
102
|
+
saveAddressLoading: mutation.isLoading
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
useFetchSavedCards: () => (0, _reactQuery.useQuery)([_queryKeys.queryKeys.CARDS, user?.uid], async () => {
|
|
106
|
+
if (isLoggedIn) {
|
|
107
|
+
const payments = await (0, _firestore.default)().collection(`customers/${user?.uid}/payments`).orderBy('updated', 'desc').where('isActive', '==', true).get();
|
|
108
|
+
if (payments.docs.length > 0) {
|
|
109
|
+
return payments.docs.map(payment => {
|
|
110
|
+
return {
|
|
111
|
+
...payment.data(),
|
|
112
|
+
id: payment.id
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
enabled: Boolean(isLoggedIn)
|
|
123
|
+
}),
|
|
124
|
+
useFetchSquareProgram: queryOptions => (0, _reactQuery.useQuery)([_queryKeys.queryKeys.PROGRAM, user?.uid, selectedBusinessId], async () => {
|
|
125
|
+
if (isLoggedIn) {
|
|
126
|
+
const programs = await (0, _firestore.default)().collection(`customers/${user?.uid}/programs`).where('type', '==', 'customer').where('businessId', '==', selectedBusinessId).orderBy('updated', 'asc').get();
|
|
127
|
+
if (programs.docs.length > 0) {
|
|
128
|
+
return programs.docs.map(program => program.data())[0];
|
|
129
|
+
} else {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}, {
|
|
136
|
+
...queryOptions
|
|
137
|
+
}),
|
|
138
|
+
useFetchSquareLoyalty: queryOptions => (0, _reactQuery.useQuery)([_queryKeys.queryKeys.LOYALTY, user?.uid, selectedBusinessId], async () => {
|
|
139
|
+
if (isLoggedIn && selectedBusinessId) {
|
|
140
|
+
return await (0, _customer.fetchSquareLoyalty)(user.uid, selectedBusinessId);
|
|
141
|
+
} else {
|
|
142
|
+
return {
|
|
143
|
+
data: null
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
select: res => res?.data,
|
|
148
|
+
...queryOptions
|
|
149
|
+
}),
|
|
150
|
+
useSaveCustomerCard: () => {
|
|
151
|
+
const mutation = (0, _reactQuery.useMutation)(async data => {
|
|
152
|
+
if (isLoggedIn) {
|
|
153
|
+
console.log('here in useSaveCustomerCard');
|
|
154
|
+
const response = await (0, _customer.saveCustomerCard)({
|
|
155
|
+
uid: user?.uid,
|
|
156
|
+
props: data
|
|
157
|
+
});
|
|
158
|
+
console.log('here in useSaveCustomerCard response', response.data);
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
onError: err => _components.Alert.show({
|
|
162
|
+
title: 'Code ' + err?.code,
|
|
163
|
+
description: err?.message
|
|
164
|
+
}),
|
|
165
|
+
onSuccess: () => {
|
|
166
|
+
queryClient.invalidateQueries([_queryKeys.queryKeys.CARDS, user?.uid]);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
saveCard: mutation.mutate,
|
|
171
|
+
saveCardLoading: mutation.isLoading
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
useDisableCard: () => {
|
|
175
|
+
const mutation = (0, _reactQuery.useMutation)(async documentId => {
|
|
176
|
+
if (isLoggedIn) {
|
|
177
|
+
return await (0, _firestore.default)().collection(`customers/${user?.uid}/payments`).doc(documentId).update({
|
|
178
|
+
isActive: false
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}, {
|
|
182
|
+
onError: err => _components.Alert.show({
|
|
183
|
+
title: 'Code ' + err?.code,
|
|
184
|
+
description: err?.message
|
|
185
|
+
}),
|
|
186
|
+
onSuccess: () => {
|
|
187
|
+
queryClient.invalidateQueries([_queryKeys.queryKeys.CARDS, user?.uid]);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return {
|
|
191
|
+
disableCard: mutation.mutate,
|
|
192
|
+
disableCardLoading: mutation.isLoading
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
useConnectSquareLoyalty: () => {
|
|
196
|
+
const mutation = (0, _reactQuery.useMutation)(async () => {
|
|
197
|
+
if (isLoggedIn && selectedBusinessId) {
|
|
198
|
+
await (0, _customer.connectSquareLoyalty)(user?.uid, {
|
|
199
|
+
businessId: selectedBusinessId,
|
|
200
|
+
idempotentKey: _reactNativeUuid.default.v4(),
|
|
201
|
+
uid: user?.uid
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}, {
|
|
205
|
+
onError: err => _components.Alert.show({
|
|
206
|
+
title: 'Code ' + err?.code,
|
|
207
|
+
description: err?.message
|
|
208
|
+
}),
|
|
209
|
+
onSuccess: () => {
|
|
210
|
+
queryClient.invalidateQueries([_queryKeys.queryKeys.LOYALTY, user?.uid]);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return {
|
|
214
|
+
connectSquareLoyalty: mutation.mutate,
|
|
215
|
+
connectLoyaltyLoading: mutation.isLoading
|
|
216
|
+
};
|
|
217
|
+
},
|
|
218
|
+
useConnectSquareCustomer: () => {
|
|
219
|
+
const mutation = (0, _reactQuery.useMutation)(async () => {
|
|
220
|
+
if (isLoggedIn && selectedBusinessId) {
|
|
221
|
+
await (0, _customer.connectSquareCustomer)(user?.uid, {
|
|
222
|
+
businessId: selectedBusinessId,
|
|
223
|
+
idempotentKey: _reactNativeUuid.default.v4(),
|
|
224
|
+
uid: user?.uid
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}, {
|
|
228
|
+
onError: err => _components.Alert.show({
|
|
229
|
+
title: 'Code ' + err?.code,
|
|
230
|
+
description: err?.message
|
|
231
|
+
}),
|
|
232
|
+
onSuccess: () => {
|
|
233
|
+
queryClient.invalidateQueries([_queryKeys.queryKeys.PROGRAM, user?.uid]);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
return {
|
|
237
|
+
connectSquare: mutation.mutate,
|
|
238
|
+
connectSquareLoading: mutation.isLoading
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
useFetchLoyaltyRewards: () => (0, _reactQuery.useQuery)([_queryKeys.queryKeys.REWARDS, selectedBusinessId], async () => {
|
|
242
|
+
if (selectedBusinessId) return await (0, _customer.fetchLoyaltyRewards)(selectedBusinessId);else {
|
|
243
|
+
return {};
|
|
244
|
+
}
|
|
245
|
+
}, {
|
|
246
|
+
select: data => data?.data
|
|
247
|
+
})
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
exports.useCustomerQueries = useCustomerQueries;
|
|
251
|
+
//# sourceMappingURL=useCustomer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_auth","_components","_reactQuery","_firestore","_interopRequireDefault","_reactNativeUuid","_customer","_reactNativeMmkv","_constants","_queryKeys","obj","__esModule","default","useCustomerQueries","queryClient","useQueryClient","user","useAuthentication","selectedBusinessId","useMMKVString","MMKV_KEYS","BUSINESS_ID","isLoggedIn","isAnonymous","useEffect","invalidateQueries","queryKeys","LOYALTY","uid","useFetchCustomer","useQuery","CUSTOMER","getCustomer","select","data","customer","useCreateCustomer","mutation","useMutation","response","createCustomer","onError","err","Alert","show","title","code","description","message","createCustomerHook","mutateAsync","createCustomerLoading","isLoading","useUpdateCustomer","props","updateCustomerProfile","updateCustomer","mutate","updateCustomerLoading","useSaveCustomerAddress","address","saveCustomerAddress","useSaveAddress","saveAddressLoading","useFetchSavedCards","CARDS","payments","firestore","collection","orderBy","where","get","docs","length","map","payment","id","enabled","Boolean","useFetchSquareProgram","queryOptions","PROGRAM","programs","program","useFetchSquareLoyalty","fetchSquareLoyalty","res","useSaveCustomerCard","console","log","saveCustomerCard","onSuccess","saveCard","saveCardLoading","useDisableCard","documentId","doc","update","isActive","disableCard","disableCardLoading","useConnectSquareLoyalty","connectSquareLoyalty","businessId","idempotentKey","uuid","v4","connectLoyaltyLoading","useConnectSquareCustomer","connectSquareCustomer","connectSquare","connectSquareLoading","useFetchLoyaltyRewards","REWARDS","fetchLoyaltyRewards","exports"],"sourceRoot":"../../../src","sources":["hooks/useCustomer.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAD,sBAAA,CAAAL,OAAA;AAEA,IAAAO,SAAA,GAAAP,OAAA;AAgBA,IAAAQ,gBAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AAAwD,SAAAK,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEjD,MAAMG,kBAAkB,GAAGA,CAAA,KAAM;EACtC,MAAMC,WAAW,GAAG,IAAAC,0BAAc,EAAC,CAAC;EACpC,MAAM;IAAEC;EAAK,CAAC,GAAG,IAAAC,uBAAiB,EAAC,CAAC;EACpC,MAAM,CAACC,kBAAkB,CAAC,GAAG,IAAAC,8BAAa,EAACC,oBAAS,CAACC,WAAW,CAAC;EACjE,MAAMC,UAAU,GAAGN,IAAI,IA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