@kiosinc/commons-rn 0.1.55 → 0.1.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/lib/commonjs/auth/hooks/useTermsOfService.js +60 -0
  2. package/lib/commonjs/auth/hooks/useTermsOfService.js.map +1 -0
  3. package/lib/commonjs/auth/index.js +14 -0
  4. package/lib/commonjs/auth/index.js.map +1 -1
  5. package/lib/commonjs/auth/screens/TermsOfService.js +129 -0
  6. package/lib/commonjs/auth/screens/TermsOfService.js.map +1 -0
  7. package/lib/commonjs/selectBusiness/queryKeys.js +2 -1
  8. package/lib/commonjs/selectBusiness/queryKeys.js.map +1 -1
  9. package/lib/commonjs/utils/index.js +9 -1
  10. package/lib/commonjs/utils/index.js.map +1 -1
  11. package/lib/module/auth/hooks/useTermsOfService.js +52 -0
  12. package/lib/module/auth/hooks/useTermsOfService.js.map +1 -0
  13. package/lib/module/auth/index.js +2 -0
  14. package/lib/module/auth/index.js.map +1 -1
  15. package/lib/module/auth/screens/TermsOfService.js +120 -0
  16. package/lib/module/auth/screens/TermsOfService.js.map +1 -0
  17. package/lib/module/selectBusiness/queryKeys.js +2 -1
  18. package/lib/module/selectBusiness/queryKeys.js.map +1 -1
  19. package/lib/module/utils/index.js +6 -0
  20. package/lib/module/utils/index.js.map +1 -1
  21. package/lib/typescript/src/auth/hooks/useTermsOfService.d.ts +5 -0
  22. package/lib/typescript/src/auth/hooks/useTermsOfService.d.ts.map +1 -0
  23. package/lib/typescript/src/auth/index.d.ts +2 -0
  24. package/lib/typescript/src/auth/index.d.ts.map +1 -1
  25. package/lib/typescript/src/auth/screens/TermsOfService.d.ts +9 -0
  26. package/lib/typescript/src/auth/screens/TermsOfService.d.ts.map +1 -0
  27. package/lib/typescript/src/selectBusiness/queryKeys.d.ts +1 -0
  28. package/lib/typescript/src/selectBusiness/queryKeys.d.ts.map +1 -1
  29. package/lib/typescript/src/utils/index.d.ts +1 -0
  30. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  31. package/package.json +3 -1
  32. package/src/auth/hooks/useTermsOfService.ts +70 -0
  33. package/src/auth/index.ts +2 -0
  34. package/src/auth/screens/TermsOfService.tsx +130 -0
  35. package/src/selectBusiness/queryKeys.ts +1 -0
  36. package/src/utils/index.ts +8 -0
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useTermsOfService = void 0;
7
+ var _reactQuery = require("@tanstack/react-query");
8
+ var _firestore = _interopRequireDefault(require("@react-native-firebase/firestore"));
9
+ var _queryKeys = require("../../selectBusiness/queryKeys");
10
+ var _authentication = require("../providers/authentication");
11
+ var _utils = require("../../utils");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ const useTermsOfService = () => {
14
+ const queryClient = (0, _reactQuery.useQueryClient)();
15
+ const {
16
+ user
17
+ } = (0, _authentication.useAuthentication)();
18
+ return {
19
+ useShouldShowTermsOfService: () => (0, _reactQuery.useQuery)([user?.uid, _queryKeys.queryKeys.TERMS_AND_CONDITIONS], async () => {
20
+ if (!user?.uid) return false;
21
+ const customerSnapshot = await (0, _firestore.default)().doc(`customers/${user.uid}`).get();
22
+ if (customerSnapshot.exists) {
23
+ const customer = customerSnapshot.data();
24
+ if (!customer.agreementsUpdated) {
25
+ return true;
26
+ } else {
27
+ const system = (await (0, _firestore.default)().doc('_firebase_ext_/agreements').get()).data();
28
+ if (new Date(system.updated) > new Date(customer.agreementsUpdated)) {
29
+ return true;
30
+ }
31
+ }
32
+ } else {
33
+ return true;
34
+ }
35
+ return false;
36
+ }, {
37
+ staleTime: _queryKeys.DEFAULT_STALE_TIME
38
+ }),
39
+ useAgreeTermsOfService: () => (0, _reactQuery.useMutation)(async () => {
40
+ if (!user?.uid) return;
41
+ const query = await (0, _firestore.default)().doc(`customers/${user.uid}`);
42
+ const customerSnapshot = await query.get();
43
+ if (customerSnapshot.exists) {
44
+ await query.update({
45
+ updated: (0, _utils.getCurrentTimestamp)(),
46
+ agreementsUpdated: new Date().toISOString()
47
+ });
48
+ } else {
49
+ await query.set({
50
+ uid: user.uid,
51
+ created: (0, _utils.getCurrentTimestamp)(),
52
+ agreementsUpdated: new Date().toISOString()
53
+ });
54
+ }
55
+ await queryClient.invalidateQueries([user.uid, _queryKeys.queryKeys.TERMS_AND_CONDITIONS]);
56
+ })
57
+ };
58
+ };
59
+ exports.useTermsOfService = useTermsOfService;
60
+ //# sourceMappingURL=useTermsOfService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactQuery","require","_firestore","_interopRequireDefault","_queryKeys","_authentication","_utils","obj","__esModule","default","useTermsOfService","queryClient","useQueryClient","user","useAuthentication","useShouldShowTermsOfService","useQuery","uid","queryKeys","TERMS_AND_CONDITIONS","customerSnapshot","firestore","doc","get","exists","customer","data","agreementsUpdated","system","Date","updated","staleTime","DEFAULT_STALE_TIME","useAgreeTermsOfService","useMutation","query","update","getCurrentTimestamp","toISOString","set","created","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;AAAkD,SAAAE,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3C,MAAMG,iBAAiB,GAAGA,CAAA,KAAM;EACrC,MAAMC,WAAW,GAAG,IAAAC,0BAAc,EAAC,CAAC;EACpC,MAAM;IAAEC;EAAK,CAAC,GAAG,IAAAC,iCAAiB,EAAC,CAAC;EAEpC,OAAO;IACLC,2BAA2B,EAAEA,CAAA,KAC3B,IAAAC,oBAAQ,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AE,IAAAO,0BAAmB,EAAC,CAAC;UAC9BV,iBAAiB,EAAE,IAAIE,IAAI,CAAC,CAAC,CAACS,WAAW,CAAC;QAC5C,CAAC,CAAC;MACJ,CAAC,MAAM;QACL,MAAMH,KAAK,CAACI,GAAG,CAAC;UACdtB,GAAG,EAAEJ,IAAI,CAACI,GAAG;UACbuB,OAAO,EAAE,IAAAH,0BAAmB,EAAC,CAAC;UAC9BV,iBAAiB,EAAE,IAAIE,IAAI,CAAC,CAAC,CAACS,WAAW,CAAC;QAC5C,CAAC,CAAC;MACJ;MACA,MAAM3B,WAAW,CAAC8B,iBAAiB,CAAC,CAClC5B,IAAI,CAACI,GAAG,EACRC,oBAAS,CAACC,oBAAoB,CAC/B,CAAC;IACJ,CAAC;EACL,CAAC;AACH,CAAC;AAACuB,OAAA,CAAAhC,iBAAA,GAAAA,iBAAA"}
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "AuthenticationProvider", {
9
9
  return _authentication.AuthenticationProvider;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "TermsOfService", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _TermsOfService.TermsOfService;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "changeUser", {
13
19
  enumerable: true,
14
20
  get: function () {
@@ -45,7 +51,15 @@ Object.defineProperty(exports, "useDeactivateAccount", {
45
51
  return _useDeactivateAccount.useDeactivateAccount;
46
52
  }
47
53
  });
54
+ Object.defineProperty(exports, "useTermsOfService", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _useTermsOfService.useTermsOfService;
58
+ }
59
+ });
48
60
  var _screens = require("./screens");
49
61
  var _authentication = require("./providers/authentication");
50
62
  var _useDeactivateAccount = require("./hooks/useDeactivateAccount");
63
+ var _useTermsOfService = require("./hooks/useTermsOfService");
64
+ var _TermsOfService = require("./screens/TermsOfService");
51
65
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_screens","require","_authentication","_useDeactivateAccount"],"sourceRoot":"../../../src","sources":["auth/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAMA,IAAAE,qBAAA,GAAAF,OAAA"}
1
+ {"version":3,"names":["_screens","require","_authentication","_useDeactivateAccount","_useTermsOfService","_TermsOfService"],"sourceRoot":"../../../src","sources":["auth/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAMA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA"}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TermsOfService = exports.CloseBottomSheet = void 0;
7
+ var _commonsRn = require("@kiosinc/commons-rn");
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactI18next = require("react-i18next");
10
+ var _reactNativePaper = require("react-native-paper");
11
+ var _reactNativeWebview = _interopRequireDefault(require("react-native-webview"));
12
+ var _reactNative = require("react-native");
13
+ var _useTermsOfService = require("../hooks/useTermsOfService");
14
+ var _constants = require("../../constants");
15
+ var _auth = _interopRequireDefault(require("@react-native-firebase/auth"));
16
+ var _reactNativeFastImage = _interopRequireDefault(require("react-native-fast-image"));
17
+ var _reactQuery = require("@tanstack/react-query");
18
+ var _reactNativeMmkv = require("react-native-mmkv");
19
+ var _reactNativeConfig = _interopRequireDefault(require("react-native-config"));
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+ const CloseBottomSheet = ({
22
+ bottomSheetRef
23
+ }) => {
24
+ const [_, setBusinessId] = (0, _reactNativeMmkv.useMMKVString)(_constants.MMKV_KEYS.BUSINESS_ID);
25
+ const {
26
+ t
27
+ } = (0, _reactI18next.useTranslation)();
28
+ const queryClient = (0, _reactQuery.useQueryClient)();
29
+ const handleLogout = () => {
30
+ (0, _auth.default)().signOut().finally(() => {
31
+ _reactNativeConfig.default.APP_NAME !== 'gusteau' && queryClient.clear();
32
+ _reactNativeFastImage.default.clearMemoryCache();
33
+ _reactNativeFastImage.default.clearDiskCache();
34
+ setBusinessId(undefined);
35
+ });
36
+ };
37
+ return /*#__PURE__*/_react.default.createElement(_commonsRn.BottomSheet, {
38
+ close: bottomSheetRef.close,
39
+ pressBehavior: "close",
40
+ ref: bottomSheetRef.ref
41
+ }, /*#__PURE__*/_react.default.createElement(_commonsRn.View, {
42
+ px: "16",
43
+ bg: "background",
44
+ flex: 1,
45
+ my: "16"
46
+ }, /*#__PURE__*/_react.default.createElement(_commonsRn.Text, {
47
+ variant: "titleLarge"
48
+ }, t('home.termsOfServiceModal.title')), /*#__PURE__*/_react.default.createElement(_commonsRn.Text, {
49
+ pt: "16",
50
+ variant: "bodyMedium",
51
+ color: "secondary"
52
+ }, t('home.termsOfServiceModal.description')), /*#__PURE__*/_react.default.createElement(_commonsRn.Button, {
53
+ mode: "contained",
54
+ my: "16",
55
+ onPress: bottomSheetRef.close
56
+ }, t('home.termsOfServiceModal.review')), /*#__PURE__*/_react.default.createElement(_commonsRn.Button, {
57
+ mode: "outlined",
58
+ onPress: handleLogout
59
+ }, t('profile.logout'))));
60
+ };
61
+ exports.CloseBottomSheet = CloseBottomSheet;
62
+ const TermsOfService = () => {
63
+ const {
64
+ useAgreeTermsOfService
65
+ } = (0, _useTermsOfService.useTermsOfService)();
66
+ const {
67
+ mutate: agreeTermsOfService,
68
+ isLoading
69
+ } = useAgreeTermsOfService();
70
+ const theme = (0, _reactNativePaper.useTheme)();
71
+ const bottomSheetRef = (0, _commonsRn.useSingleSnapBottomSheetRef)();
72
+ const {
73
+ t
74
+ } = (0, _reactI18next.useTranslation)();
75
+ return /*#__PURE__*/_react.default.createElement(_commonsRn.ParentView, {
76
+ flex: 1
77
+ }, /*#__PURE__*/_react.default.createElement(_commonsRn.View, {
78
+ flexDirection: "row",
79
+ alignItems: "center"
80
+ }, /*#__PURE__*/_react.default.createElement(_commonsRn.IconButton, {
81
+ iconColor: theme.colors.onSurfaceVariant,
82
+ backgroundColor: "transparent",
83
+ icon: "close",
84
+ onPress: bottomSheetRef.expand
85
+ }), /*#__PURE__*/_react.default.createElement(_commonsRn.Text, {
86
+ variant: "labelLarge"
87
+ }, t('home.termsTitle'))), /*#__PURE__*/_react.default.createElement(_commonsRn.View, {
88
+ style: styles.view,
89
+ mx: "16",
90
+ flex: 1,
91
+ borderWidth: 1,
92
+ borderColor: "onSurfaceDisabled",
93
+ borderRadius: "12",
94
+ padding: "8"
95
+ }, /*#__PURE__*/_react.default.createElement(_reactNativeWebview.default, {
96
+ startInLoadingState: true,
97
+ renderLoading: () => /*#__PURE__*/_react.default.createElement(_commonsRn.View, {
98
+ alignItems: "center",
99
+ bottom: 0,
100
+ justifyContent: "center",
101
+ left: 0,
102
+ position: "absolute",
103
+ right: 0,
104
+ top: 0
105
+ }, /*#__PURE__*/_react.default.createElement(_reactNativePaper.ActivityIndicator, {
106
+ size: "large"
107
+ })),
108
+ javaScriptEnabled: true,
109
+ source: {
110
+ uri: _constants.TERMS_OF_SERVICE
111
+ }
112
+ })), /*#__PURE__*/_react.default.createElement(_commonsRn.Button, {
113
+ mx: "16",
114
+ mode: "contained",
115
+ my: "16",
116
+ height: 40,
117
+ onPress: () => agreeTermsOfService(),
118
+ loading: isLoading
119
+ }, t('home.acceptTerms')), /*#__PURE__*/_react.default.createElement(CloseBottomSheet, {
120
+ bottomSheetRef: bottomSheetRef
121
+ }));
122
+ };
123
+ exports.TermsOfService = TermsOfService;
124
+ const styles = _reactNative.StyleSheet.create({
125
+ view: {
126
+ backgroundColor: 'white'
127
+ }
128
+ });
129
+ //# sourceMappingURL=TermsOfService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_commonsRn","require","_react","_interopRequireDefault","_reactI18next","_reactNativePaper","_reactNativeWebview","_reactNative","_useTermsOfService","_constants","_auth","_reactNativeFastImage","_reactQuery","_reactNativeMmkv","_reactNativeConfig","obj","__esModule","default","CloseBottomSheet","bottomSheetRef","_","setBusinessId","useMMKVString","MMKV_KEYS","BUSINESS_ID","t","useTranslation","queryClient","useQueryClient","handleLogout","auth","signOut","finally","Config","APP_NAME","clear","FastImage","clearMemoryCache","clearDiskCache","undefined","createElement","BottomSheet","close","pressBehavior","ref","View","px","bg","flex","my","Text","variant","pt","color","Button","mode","onPress","exports","TermsOfService","useAgreeTermsOfService","useTermsOfService","mutate","agreeTermsOfService","isLoading","theme","useTheme","useSingleSnapBottomSheetRef","ParentView","flexDirection","alignItems","IconButton","iconColor","colors","onSurfaceVariant","backgroundColor","icon","expand","style","styles","view","mx","borderWidth","borderColor","borderRadius","padding","startInLoadingState","renderLoading","bottom","justifyContent","left","position","right","top","ActivityIndicator","size","javaScriptEnabled","source","uri","TERMS_OF_SERVICE","height","loading","StyleSheet","create"],"sourceRoot":"../../../../src","sources":["auth/screens/TermsOfService.tsx"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAUA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,qBAAA,GAAAR,sBAAA,CAAAF,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,gBAAA,GAAAZ,OAAA;AACA,IAAAa,kBAAA,GAAAX,sBAAA,CAAAF,OAA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EAAC,IAAI;IACPzB,IAAI,EAAC,WAAW;IAChBN,EAAE,EAAC,IAAI;IACPkD,MAAM,EAAE,EAAG;IACX3C,OAAO,EAAEA,CAAA,KAAMM,mBAAmB,CAAC,CAAE;IACrCsC,OAAO,EAAErC;EAAU,GAElBtC,CAAC,CAAC,kBAAkB,CACf,CAAC,eACTvB,MAAA,CAAAe,OAAA,CAAAuB,aAAA,CAACtB,gBAAgB;IAACC,cAAc,EAAEA;EAAe,CAAE,CACzC,CAAC;AAEjB,CAAC;AAACsC,OAAA,CAAAC,cAAA,GAAAA,cAAA;AAEF,MAAMoB,MAAM,GAAGuB,uBAAU,CAACC,MAAM,CAAC;EAC/BvB,IAAI,EAAE;IAAEL,eAAe,EAAE;EAAQ;AACnC,CAAC,CAAC"}
@@ -5,7 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.queryKeys = exports.DEFAULT_STALE_TIME = void 0;
7
7
  const queryKeys = exports.queryKeys = {
8
- BUSINESSES: 'BUSINESSES'
8
+ BUSINESSES: 'BUSINESSES',
9
+ TERMS_AND_CONDITIONS: 'TERMS_AND_CONDITIONS'
9
10
  };
10
11
  const DEFAULT_STALE_TIME = exports.DEFAULT_STALE_TIME = 60 * (60 * 1000); // 60 mins
11
12
  //# sourceMappingURL=queryKeys.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["queryKeys","exports","BUSINESSES","DEFAULT_STALE_TIME"],"sourceRoot":"../../../src","sources":["selectBusiness/queryKeys.ts"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACvBE,UAAU,EAAE;AACd,CAAC;AAEM,MAAMC,kBAAkB,GAAAF,OAAA,CAAAE,kBAAA,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC"}
1
+ {"version":3,"names":["queryKeys","exports","BUSINESSES","TERMS_AND_CONDITIONS","DEFAULT_STALE_TIME"],"sourceRoot":"../../../src","sources":["selectBusiness/queryKeys.ts"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACvBE,UAAU,EAAE,YAAY;EACxBC,oBAAoB,EAAE;AACxB,CAAC;AAEM,MAAMC,kBAAkB,GAAAH,OAAA,CAAAG,kBAAA,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC"}
@@ -3,12 +3,20 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getPercentageFromHeight = void 0;
6
+ exports.getPercentageFromHeight = exports.getCurrentTimestamp = void 0;
7
7
  var _reactNative = require("react-native");
8
8
  var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
9
+ var _firestore = _interopRequireDefault(require("@react-native-firebase/firestore"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
11
  const getPercentageFromHeight = height => {
10
12
  const totalHeight = _reactNative.Dimensions.get('window').height - (_reactNativeSafeAreaContext.initialWindowMetrics?.insets?.top ?? 0) - (_reactNativeSafeAreaContext.initialWindowMetrics?.insets?.bottom ?? 0);
11
13
  return Math.ceil(height / totalHeight * 100) + '%';
12
14
  };
13
15
  exports.getPercentageFromHeight = getPercentageFromHeight;
16
+ const getCurrentTimestamp = () => {
17
+ const firestoreTimestamp = _firestore.default.Timestamp.now().toDate();
18
+ const formattedTimestamp = firestoreTimestamp.toISOString();
19
+ return formattedTimestamp;
20
+ };
21
+ exports.getCurrentTimestamp = getCurrentTimestamp;
14
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_reactNativeSafeAreaContext","getPercentageFromHeight","height","totalHeight","Dimensions","get","initialWindowMetrics","insets","top","bottom","Math","ceil","exports"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAD,OAAA;AAEO,MAAME,uBAAuB,GAAIC,MAAc,IAAa;EACjE,MAAMC,WAAW,GACfC,uBAAU,CAACC,GAAG,CAAC,QAAQ,CAAC,CAACH,MAAM,IAC9BI,gDAAoB,EAAEC,MAAM,EAAEC,GAAG,IAAI,CAAC,CAAC,IACvCF,gDAAoB,EAAEC,MAAM,EAAEE,MAAM,IAAI,CAAC,CAAC;EAE7C,OAAOC,IAAI,CAACC,IAAI,CAAET,MAAM,GAAGC,WAAW,GAAI,GAAG,CAAC,GAAG,GAAG;AACtD,CAAC;AAACS,OAAA,CAAAX,uBAAA,GAAAA,uBAAA"}
1
+ {"version":3,"names":["_reactNative","require","_reactNativeSafeAreaContext","_firestore","_interopRequireDefault","obj","__esModule","default","getPercentageFromHeight","height","totalHeight","Dimensions","get","initialWindowMetrics","insets","top","bottom","Math","ceil","exports","getCurrentTimestamp","firestoreTimestamp","firestore","Timestamp","now","toDate","formattedTimestamp","toISOString"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAyD,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAElD,MAAMG,uBAAuB,GAAIC,MAAc,IAAa;EACjE,MAAMC,WAAW,GACfC,uBAAU,CAACC,GAAG,CAAC,QAAQ,CAAC,CAACH,MAAM,IAC9BI,gDAAoB,EAAEC,MAAM,EAAEC,GAAG,IAAI,CAAC,CAAC,IACvCF,gDAAoB,EAAEC,MAAM,EAAEE,MAAM,IAAI,CAAC,CAAC;EAE7C,OAAOC,IAAI,CAACC,IAAI,CAAET,MAAM,GAAGC,WAAW,GAAI,GAAG,CAAC,GAAG,GAAG;AACtD,CAAC;AAACS,OAAA,CAAAX,uBAAA,GAAAA,uBAAA;AAEK,MAAMY,mBAAmB,GAAGA,CAAA,KAAM;EACvC,MAAMC,kBAAkB,GAAGC,kBAAS,CAACC,SAAS,CAACC,GAAG,CAAC,CAAC,CAACC,MAAM,CAAC,CAAC;EAC7D,MAAMC,kBAAkB,GAAGL,kBAAkB,CAACM,WAAW,CAAC,CAAC;EAE3D,OAAOD,kBAAkB;AAC3B,CAAC;AAACP,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}
@@ -0,0 +1,52 @@
1
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
2
+ import firestore from '@react-native-firebase/firestore';
3
+ import { DEFAULT_STALE_TIME, queryKeys } from '../../selectBusiness/queryKeys';
4
+ import { useAuthentication } from '../providers/authentication';
5
+ import { getCurrentTimestamp } from '../../utils';
6
+ export const useTermsOfService = () => {
7
+ const queryClient = useQueryClient();
8
+ const {
9
+ user
10
+ } = useAuthentication();
11
+ return {
12
+ useShouldShowTermsOfService: () => useQuery([user?.uid, queryKeys.TERMS_AND_CONDITIONS], async () => {
13
+ if (!user?.uid) return false;
14
+ const customerSnapshot = await firestore().doc(`customers/${user.uid}`).get();
15
+ if (customerSnapshot.exists) {
16
+ const customer = customerSnapshot.data();
17
+ if (!customer.agreementsUpdated) {
18
+ return true;
19
+ } else {
20
+ const system = (await firestore().doc('_firebase_ext_/agreements').get()).data();
21
+ if (new Date(system.updated) > new Date(customer.agreementsUpdated)) {
22
+ return true;
23
+ }
24
+ }
25
+ } else {
26
+ return true;
27
+ }
28
+ return false;
29
+ }, {
30
+ staleTime: DEFAULT_STALE_TIME
31
+ }),
32
+ useAgreeTermsOfService: () => useMutation(async () => {
33
+ if (!user?.uid) return;
34
+ const query = await firestore().doc(`customers/${user.uid}`);
35
+ const customerSnapshot = await query.get();
36
+ if (customerSnapshot.exists) {
37
+ await query.update({
38
+ updated: getCurrentTimestamp(),
39
+ agreementsUpdated: new Date().toISOString()
40
+ });
41
+ } else {
42
+ await query.set({
43
+ uid: user.uid,
44
+ created: getCurrentTimestamp(),
45
+ agreementsUpdated: new Date().toISOString()
46
+ });
47
+ }
48
+ await queryClient.invalidateQueries([user.uid, queryKeys.TERMS_AND_CONDITIONS]);
49
+ })
50
+ };
51
+ };
52
+ //# sourceMappingURL=useTermsOfService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMutation","useQuery","useQueryClient","firestore","DEFAULT_STALE_TIME","queryKeys","useAuthentication","getCurrentTimestamp","useTermsOfService","queryClient","user","useShouldShowTermsOfService","uid","TERMS_AND_CONDITIONS","customerSnapshot","doc","get","exists","customer","data","agreementsUpdated","system","Date","updated","staleTime","useAgreeTermsOfService","query","update","toISOString","set","created","invalidateQueries"],"sourceRoot":"../../../../src","sources":["auth/hooks/useTermsOfService.ts"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,uBAAuB;AAC7E,OAAOC,SAAS,MAAM,kCAAkC;AACxD,SAASC,kBAAkB,EAAEC,SAAS,QAAQ,gCAAgC;AAC9E,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,OAAO,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EACrC,MAAMC,WAAW,GAAGP,cAAc,CAAC,CAAC;EACpC,MAAM;IAAEQ;EAAK,CAAC,GAAGJ,iBAAiB,CAAC,CAAC;EAEpC,OAAO;IACLK,2BAA2B,EAAEA,CAAA,KAC3BV,QAAQ,CACN,CAACS,IAAI,EAAEE,GAAG,EAAEP,SAAS,CAACQ,oBAAoB,CAAC,EAC3C,YAAY;MACV,IAAI,CAACH,IAAI,EAAEE,GAAG,EAAE,OAAO,KAAK;MAC5B,MAAME,gBAAgB,GAAG,MAAMX,SAAS,CAAC,CAAC,CACvCY,GAAG,CAAE,aAAYL,IAAI,CAACE,GAAI,EAAC,CAAC,CAC5BI,GAAG,CAAC,CAAC;MAER,IAAIF,gBAAgB,CAACG,MAAM,EAAE;QAC3B,MAAMC,QAAQ,GAAGJ,gBAAgB,CAACK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AAC,CAClCrB,IAAI,CAACE,GAAG,EACRP,SAAS,CAACQ,oBAAoB,CAC/B,CAAC;IACJ,CAAC;EACL,CAAC;AACH,CAAC"}
@@ -2,4 +2,6 @@ export { renderAuthNavigator, renderAppNavigator } from './screens';
2
2
  export { useAuthentication, useAuthenticationDispatch, changeUser } from './providers/authentication';
3
3
  export { AuthenticationProvider } from './providers/authentication';
4
4
  export { useDeactivateAccount } from './hooks/useDeactivateAccount';
5
+ export { useTermsOfService } from './hooks/useTermsOfService';
6
+ export { TermsOfService } from './screens/TermsOfService';
5
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["renderAuthNavigator","renderAppNavigator","useAuthentication","useAuthenticationDispatch","changeUser","AuthenticationProvider","useDeactivateAccount"],"sourceRoot":"../../../src","sources":["auth/index.ts"],"mappings":"AAAA,SAASA,mBAAmB,EAAEC,kBAAkB,QAAQ,WAAW;AACnE,SACEC,iBAAiB,EACjBC,yBAAyB,EACzBC,UAAU,QACL,4BAA4B;AACnC,SAASC,sBAAsB,QAAQ,4BAA4B;AACnE,SAASC,oBAAoB,QAAQ,8BAA8B"}
1
+ {"version":3,"names":["renderAuthNavigator","renderAppNavigator","useAuthentication","useAuthenticationDispatch","changeUser","AuthenticationProvider","useDeactivateAccount","useTermsOfService","TermsOfService"],"sourceRoot":"../../../src","sources":["auth/index.ts"],"mappings":"AAAA,SAASA,mBAAmB,EAAEC,kBAAkB,QAAQ,WAAW;AACnE,SACEC,iBAAiB,EACjBC,yBAAyB,EACzBC,UAAU,QACL,4BAA4B;AACnC,SAASC,sBAAsB,QAAQ,4BAA4B;AACnE,SAASC,oBAAoB,QAAQ,8BAA8B;AACnE,SAASC,iBAAiB,QAAQ,2BAA2B;AAC7D,SAASC,cAAc,QAAQ,0BAA0B"}
@@ -0,0 +1,120 @@
1
+ import { BottomSheet, Button, IconButton, ParentView, Text, View, useSingleSnapBottomSheetRef } from '@kiosinc/commons-rn';
2
+ import React from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { ActivityIndicator, useTheme } from 'react-native-paper';
5
+ import WebView from 'react-native-webview';
6
+ import { StyleSheet } from 'react-native';
7
+ import { useTermsOfService } from '../hooks/useTermsOfService';
8
+ import { MMKV_KEYS, TERMS_OF_SERVICE } from '../../constants';
9
+ import auth from '@react-native-firebase/auth';
10
+ import FastImage from 'react-native-fast-image';
11
+ import { useQueryClient } from '@tanstack/react-query';
12
+ import { useMMKVString } from 'react-native-mmkv';
13
+ import Config from 'react-native-config';
14
+ export const CloseBottomSheet = ({
15
+ bottomSheetRef
16
+ }) => {
17
+ const [_, setBusinessId] = useMMKVString(MMKV_KEYS.BUSINESS_ID);
18
+ const {
19
+ t
20
+ } = useTranslation();
21
+ const queryClient = useQueryClient();
22
+ const handleLogout = () => {
23
+ auth().signOut().finally(() => {
24
+ Config.APP_NAME !== 'gusteau' && queryClient.clear();
25
+ FastImage.clearMemoryCache();
26
+ FastImage.clearDiskCache();
27
+ setBusinessId(undefined);
28
+ });
29
+ };
30
+ return /*#__PURE__*/React.createElement(BottomSheet, {
31
+ close: bottomSheetRef.close,
32
+ pressBehavior: "close",
33
+ ref: bottomSheetRef.ref
34
+ }, /*#__PURE__*/React.createElement(View, {
35
+ px: "16",
36
+ bg: "background",
37
+ flex: 1,
38
+ my: "16"
39
+ }, /*#__PURE__*/React.createElement(Text, {
40
+ variant: "titleLarge"
41
+ }, t('home.termsOfServiceModal.title')), /*#__PURE__*/React.createElement(Text, {
42
+ pt: "16",
43
+ variant: "bodyMedium",
44
+ color: "secondary"
45
+ }, t('home.termsOfServiceModal.description')), /*#__PURE__*/React.createElement(Button, {
46
+ mode: "contained",
47
+ my: "16",
48
+ onPress: bottomSheetRef.close
49
+ }, t('home.termsOfServiceModal.review')), /*#__PURE__*/React.createElement(Button, {
50
+ mode: "outlined",
51
+ onPress: handleLogout
52
+ }, t('profile.logout'))));
53
+ };
54
+ export const TermsOfService = () => {
55
+ const {
56
+ useAgreeTermsOfService
57
+ } = useTermsOfService();
58
+ const {
59
+ mutate: agreeTermsOfService,
60
+ isLoading
61
+ } = useAgreeTermsOfService();
62
+ const theme = useTheme();
63
+ const bottomSheetRef = useSingleSnapBottomSheetRef();
64
+ const {
65
+ t
66
+ } = useTranslation();
67
+ return /*#__PURE__*/React.createElement(ParentView, {
68
+ flex: 1
69
+ }, /*#__PURE__*/React.createElement(View, {
70
+ flexDirection: "row",
71
+ alignItems: "center"
72
+ }, /*#__PURE__*/React.createElement(IconButton, {
73
+ iconColor: theme.colors.onSurfaceVariant,
74
+ backgroundColor: "transparent",
75
+ icon: "close",
76
+ onPress: bottomSheetRef.expand
77
+ }), /*#__PURE__*/React.createElement(Text, {
78
+ variant: "labelLarge"
79
+ }, t('home.termsTitle'))), /*#__PURE__*/React.createElement(View, {
80
+ style: styles.view,
81
+ mx: "16",
82
+ flex: 1,
83
+ borderWidth: 1,
84
+ borderColor: "onSurfaceDisabled",
85
+ borderRadius: "12",
86
+ padding: "8"
87
+ }, /*#__PURE__*/React.createElement(WebView, {
88
+ startInLoadingState: true,
89
+ renderLoading: () => /*#__PURE__*/React.createElement(View, {
90
+ alignItems: "center",
91
+ bottom: 0,
92
+ justifyContent: "center",
93
+ left: 0,
94
+ position: "absolute",
95
+ right: 0,
96
+ top: 0
97
+ }, /*#__PURE__*/React.createElement(ActivityIndicator, {
98
+ size: "large"
99
+ })),
100
+ javaScriptEnabled: true,
101
+ source: {
102
+ uri: TERMS_OF_SERVICE
103
+ }
104
+ })), /*#__PURE__*/React.createElement(Button, {
105
+ mx: "16",
106
+ mode: "contained",
107
+ my: "16",
108
+ height: 40,
109
+ onPress: () => agreeTermsOfService(),
110
+ loading: isLoading
111
+ }, t('home.acceptTerms')), /*#__PURE__*/React.createElement(CloseBottomSheet, {
112
+ bottomSheetRef: bottomSheetRef
113
+ }));
114
+ };
115
+ const styles = StyleSheet.create({
116
+ view: {
117
+ backgroundColor: 'white'
118
+ }
119
+ });
120
+ //# sourceMappingURL=TermsOfService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BottomSheet","Button","IconButton","ParentView","Text","View","useSingleSnapBottomSheetRef","React","useTranslation","ActivityIndicator","useTheme","WebView","StyleSheet","useTermsOfService","MMKV_KEYS","TERMS_OF_SERVICE","auth","FastImage","useQueryClient","useMMKVString","Config","CloseBottomSheet","bottomSheetRef","_","setBusinessId","BUSINESS_ID","t","queryClient","handleLogout","signOut","finally","APP_NAME","clear","clearMemoryCache","clearDiskCache","undefined","createElement","close","pressBehavior","ref","px","bg","flex","my","variant","pt","color","mode","onPress","TermsOfService","useAgreeTermsOfService","mutate","agreeTermsOfService","isLoading","theme","flexDirection","alignItems","iconColor","colors","onSurfaceVariant","backgroundColor","icon","expand","style","styles","view","mx","borderWidth","borderColor","borderRadius","padding","startInLoadingState","renderLoading","bottom","justifyContent","left","position","right","top","size","javaScriptEnabled","source","uri","height","loading","create"],"sourceRoot":"../../../../src","sources":["auth/screens/TermsOfService.tsx"],"mappings":"AAAA,SACEA,WAAW,EACXC,MAAM,EACNC,UAAU,EACVC,UAAU,EAEVC,IAAI,EACJC,IAAI,EACJC,2BAA2B,QACtB,qBAAqB;AAC5B,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,iBAAiB,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,OAAOC,OAAO,MAAM,sBAAsB;AAC1C,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,SAAS,EAAEC,gBAAgB,QAAQ,iBAAiB;AAC7D,OAAOC,IAAI,MAAM,6BAA6B;AAC9C,OAAOC,SAAS,MAAM,yBAAyB;AAC/C,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,aAAa,QAAQ,mBAAmB;AACjD,OAAOC,MAAM,MAAM,qBAAqB;AAMxC,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC;AAAsC,CAAC,KAAK;EAC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OAAO,EAAC;EAAG,gBAEX/D,KAAA,CAAA6B,aAAA,CAACzB,OAAO;IACN4D,mBAAmB;IACnBC,aAAa,EAAEA,CAAA,kBACbjE,KAAA,CAAA6B,aAAA,CAAC/B,IAAI;MACHmD,UAAU,EAAC,QAAQ;MACnBiB,MAAM,EAAE,CAAE;MACVC,cAAc,EAAC,QAAQ;MACvBC,IAAI,EAAE,CAAE;MACRC,QAAQ,EAAC,UAAU;MACnBC,KAAK,EAAE,CAAE;MACTC,GAAG,EAAE;IAAE,gBAEPvE,KAAA,CAAA6B,aAAA,CAAC3B,iBAAiB;MAACsE,IAAI,EAAC;IAAO,CAAE,CAC7B,CACN;IACFC,iBAAiB,EAAE,IAAK;IACxBC,MAAM,EAAE;MACNC,GAAG,EAAEnE;IACP;EAAE,CACH,CACG,CAAC,eACPR,KAAA,CAAA6B,aAAA,CAACnC,MAAM;IACLiE,EAAE,EAAC,IAAI;IACPnB,IAAI,EAAC,WAAW;IAChBJ,EAAE,EAAC,IAAI;IACPwC,MAAM,EAAE,EAAG;IACXnC,OAAO,EAAEA,CAAA,KAAMI,mBAAmB,CAAC,CAAE;IACrCgC,OAAO,EAAE/B;EAAU,GAElB3B,CAAC,CAAC,kBAAkB,CACf,CAAC,eACTnB,KAAA,CAAA6B,aAAA,CAACf,gBAAgB;IAACC,cAAc,EAAEA;EAAe,CAAE,CACzC,CAAC;AAEjB,CAAC;AAED,MAAM0C,MAAM,GAAGpD,UAAU,CAACyE,MAAM,CAAC;EAC/BpB,IAAI,EAAE;IAAEL,eAAe,EAAE;EAAQ;AACnC,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export const queryKeys = {
2
- BUSINESSES: 'BUSINESSES'
2
+ BUSINESSES: 'BUSINESSES',
3
+ TERMS_AND_CONDITIONS: 'TERMS_AND_CONDITIONS'
3
4
  };
4
5
  export const DEFAULT_STALE_TIME = 60 * (60 * 1000); // 60 mins
5
6
  //# sourceMappingURL=queryKeys.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["queryKeys","BUSINESSES","DEFAULT_STALE_TIME"],"sourceRoot":"../../../src","sources":["selectBusiness/queryKeys.ts"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAG;EACvBC,UAAU,EAAE;AACd,CAAC;AAED,OAAO,MAAMC,kBAAkB,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC"}
1
+ {"version":3,"names":["queryKeys","BUSINESSES","TERMS_AND_CONDITIONS","DEFAULT_STALE_TIME"],"sourceRoot":"../../../src","sources":["selectBusiness/queryKeys.ts"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAG;EACvBC,UAAU,EAAE,YAAY;EACxBC,oBAAoB,EAAE;AACxB,CAAC;AAED,OAAO,MAAMC,kBAAkB,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC"}
@@ -1,7 +1,13 @@
1
1
  import { Dimensions } from 'react-native';
2
2
  import { initialWindowMetrics } from 'react-native-safe-area-context';
3
+ import firestore from '@react-native-firebase/firestore';
3
4
  export const getPercentageFromHeight = height => {
4
5
  const totalHeight = Dimensions.get('window').height - (initialWindowMetrics?.insets?.top ?? 0) - (initialWindowMetrics?.insets?.bottom ?? 0);
5
6
  return Math.ceil(height / totalHeight * 100) + '%';
6
7
  };
8
+ export const getCurrentTimestamp = () => {
9
+ const firestoreTimestamp = firestore.Timestamp.now().toDate();
10
+ const formattedTimestamp = firestoreTimestamp.toISOString();
11
+ return formattedTimestamp;
12
+ };
7
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Dimensions","initialWindowMetrics","getPercentageFromHeight","height","totalHeight","get","insets","top","bottom","Math","ceil"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,oBAAoB,QAAQ,gCAAgC;AAErE,OAAO,MAAMC,uBAAuB,GAAIC,MAAc,IAAa;EACjE,MAAMC,WAAW,GACfJ,UAAU,CAACK,GAAG,CAAC,QAAQ,CAAC,CAACF,MAAM,IAC9BF,oBAAoB,EAAEK,MAAM,EAAEC,GAAG,IAAI,CAAC,CAAC,IACvCN,oBAAoB,EAAEK,MAAM,EAAEE,MAAM,IAAI,CAAC,CAAC;EAE7C,OAAOC,IAAI,CAACC,IAAI,CAAEP,MAAM,GAAGC,WAAW,GAAI,GAAG,CAAC,GAAG,GAAG;AACtD,CAAC"}
1
+ {"version":3,"names":["Dimensions","initialWindowMetrics","firestore","getPercentageFromHeight","height","totalHeight","get","insets","top","bottom","Math","ceil","getCurrentTimestamp","firestoreTimestamp","Timestamp","now","toDate","formattedTimestamp","toISOString"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,oBAAoB,QAAQ,gCAAgC;AACrE,OAAOC,SAAS,MAAM,kCAAkC;AAExD,OAAO,MAAMC,uBAAuB,GAAIC,MAAc,IAAa;EACjE,MAAMC,WAAW,GACfL,UAAU,CAACM,GAAG,CAAC,QAAQ,CAAC,CAACF,MAAM,IAC9BH,oBAAoB,EAAEM,MAAM,EAAEC,GAAG,IAAI,CAAC,CAAC,IACvCP,oBAAoB,EAAEM,MAAM,EAAEE,MAAM,IAAI,CAAC,CAAC;EAE7C,OAAOC,IAAI,CAACC,IAAI,CAAEP,MAAM,GAAGC,WAAW,GAAI,GAAG,CAAC,GAAG,GAAG;AACtD,CAAC;AAED,OAAO,MAAMO,mBAAmB,GAAGA,CAAA,KAAM;EACvC,MAAMC,kBAAkB,GAAGX,SAAS,CAACY,SAAS,CAACC,GAAG,CAAC,CAAC,CAACC,MAAM,CAAC,CAAC;EAC7D,MAAMC,kBAAkB,GAAGJ,kBAAkB,CAACK,WAAW,CAAC,CAAC;EAE3D,OAAOD,kBAAkB;AAC3B,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const useTermsOfService: () => {
2
+ useShouldShowTermsOfService: () => import("@tanstack/react-query").UseQueryResult<boolean, unknown>;
3
+ useAgreeTermsOfService: () => import("@tanstack/react-query").UseMutationResult<void, unknown, void, unknown>;
4
+ };
5
+ //# sourceMappingURL=useTermsOfService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTermsOfService.d.ts","sourceRoot":"","sources":["../../../../../src/auth/hooks/useTermsOfService.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB;;;CA+D7B,CAAC"}
@@ -2,4 +2,6 @@ export { renderAuthNavigator, renderAppNavigator } from './screens';
2
2
  export { useAuthentication, useAuthenticationDispatch, changeUser, } from './providers/authentication';
3
3
  export { AuthenticationProvider } from './providers/authentication';
4
4
  export { useDeactivateAccount } from './hooks/useDeactivateAccount';
5
+ export { useTermsOfService } from './hooks/useTermsOfService';
6
+ export { TermsOfService } from './screens/TermsOfService';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { TSingleSnapBottomSheetRef } from '@kiosinc/commons-rn';
3
+ type CloseBottomSheetProps = {
4
+ bottomSheetRef: TSingleSnapBottomSheetRef;
5
+ };
6
+ export declare const CloseBottomSheet: ({ bottomSheetRef }: CloseBottomSheetProps) => JSX.Element;
7
+ export declare const TermsOfService: () => JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=TermsOfService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TermsOfService.d.ts","sourceRoot":"","sources":["../../../../../src/auth/screens/TermsOfService.tsx"],"names":[],"mappings":";AAAA,OAAO,EAKL,yBAAyB,EAI1B,MAAM,qBAAqB,CAAC;AAc7B,KAAK,qBAAqB,GAAG;IAC3B,cAAc,EAAE,yBAAyB,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,gBAAgB,uBAAwB,qBAAqB,gBAmCzE,CAAC;AAEF,eAAO,MAAM,cAAc,mBA6D1B,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export declare const queryKeys: {
2
2
  BUSINESSES: string;
3
+ TERMS_AND_CONDITIONS: string;
3
4
  };
4
5
  export declare const DEFAULT_STALE_TIME: number;
5
6
  //# 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;;CAErB,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAmB,CAAC"}
1
+ {"version":3,"file":"queryKeys.d.ts","sourceRoot":"","sources":["../../../../src/selectBusiness/queryKeys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;CAGrB,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAmB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export declare const getPercentageFromHeight: (height: number) => string;
2
+ export declare const getCurrentTimestamp: () => any;
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,WAAY,MAAM,KAAG,MAOxD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,uBAAuB,WAAY,MAAM,KAAG,MAOxD,CAAC;AAEF,eAAO,MAAM,mBAAmB,WAK/B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiosinc/commons-rn",
3
- "version": "0.1.55",
3
+ "version": "0.1.56",
4
4
  "description": "Common Code",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -183,6 +183,7 @@
183
183
  "dependencies": {
184
184
  "@gorhom/bottom-sheet": "^4.6.1",
185
185
  "@hookform/resolvers": "^3.3.2",
186
+ "@react-native-firebase/firestore": "^19.2.2",
186
187
  "@react-navigation/material-top-tabs": "^6.6.13",
187
188
  "@shopify/restyle": "^2.4.2",
188
189
  "@tanstack/react-query": "^4.32.6",
@@ -199,6 +200,7 @@
199
200
  "react-native-paper": "^5.11.1",
200
201
  "react-native-size-matters": "^0.4.2",
201
202
  "react-native-video": "^5.2.1",
203
+ "react-native-webview": "^13.10.2",
202
204
  "yup": "^1.3.2"
203
205
  }
204
206
  }
@@ -0,0 +1,70 @@
1
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
2
+ import firestore from '@react-native-firebase/firestore';
3
+ import { DEFAULT_STALE_TIME, queryKeys } from '../../selectBusiness/queryKeys';
4
+ import { useAuthentication } from '../providers/authentication';
5
+ import { getCurrentTimestamp } from '../../utils';
6
+
7
+ export const useTermsOfService = () => {
8
+ const queryClient = useQueryClient();
9
+ const { user } = useAuthentication();
10
+
11
+ return {
12
+ useShouldShowTermsOfService: () =>
13
+ useQuery(
14
+ [user?.uid, queryKeys.TERMS_AND_CONDITIONS],
15
+ async () => {
16
+ if (!user?.uid) return false;
17
+ const customerSnapshot = await firestore()
18
+ .doc(`customers/${user.uid}`)
19
+ .get();
20
+
21
+ if (customerSnapshot.exists) {
22
+ const customer = customerSnapshot.data();
23
+
24
+ if (!customer.agreementsUpdated) {
25
+ return true;
26
+ } else {
27
+ const system = (
28
+ await firestore().doc('_firebase_ext_/agreements').get()
29
+ ).data() as { updated: string };
30
+
31
+ if (
32
+ new Date(system.updated) > new Date(customer.agreementsUpdated)
33
+ ) {
34
+ return true;
35
+ }
36
+ }
37
+ } else {
38
+ return true;
39
+ }
40
+ return false;
41
+ },
42
+ {
43
+ staleTime: DEFAULT_STALE_TIME,
44
+ }
45
+ ),
46
+ useAgreeTermsOfService: () =>
47
+ useMutation(async () => {
48
+ if (!user?.uid) return;
49
+ const query = await firestore().doc(`customers/${user.uid}`);
50
+ const customerSnapshot = await query.get();
51
+
52
+ if (customerSnapshot.exists) {
53
+ await query.update({
54
+ updated: getCurrentTimestamp(),
55
+ agreementsUpdated: new Date().toISOString(),
56
+ });
57
+ } else {
58
+ await query.set({
59
+ uid: user.uid,
60
+ created: getCurrentTimestamp(),
61
+ agreementsUpdated: new Date().toISOString(),
62
+ });
63
+ }
64
+ await queryClient.invalidateQueries([
65
+ user.uid,
66
+ queryKeys.TERMS_AND_CONDITIONS,
67
+ ]);
68
+ }),
69
+ };
70
+ };
package/src/auth/index.ts CHANGED
@@ -6,3 +6,5 @@ export {
6
6
  } from './providers/authentication';
7
7
  export { AuthenticationProvider } from './providers/authentication';
8
8
  export { useDeactivateAccount } from './hooks/useDeactivateAccount';
9
+ export { useTermsOfService } from './hooks/useTermsOfService';
10
+ export { TermsOfService } from './screens/TermsOfService';
@@ -0,0 +1,130 @@
1
+ import {
2
+ BottomSheet,
3
+ Button,
4
+ IconButton,
5
+ ParentView,
6
+ TSingleSnapBottomSheetRef,
7
+ Text,
8
+ View,
9
+ useSingleSnapBottomSheetRef,
10
+ } from '@kiosinc/commons-rn';
11
+ import React from 'react';
12
+ import { useTranslation } from 'react-i18next';
13
+ import { ActivityIndicator, useTheme } from 'react-native-paper';
14
+ import WebView from 'react-native-webview';
15
+ import { StyleSheet } from 'react-native';
16
+ import { useTermsOfService } from '../hooks/useTermsOfService';
17
+ import { MMKV_KEYS, TERMS_OF_SERVICE } from '../../constants';
18
+ import auth from '@react-native-firebase/auth';
19
+ import FastImage from 'react-native-fast-image';
20
+ import { useQueryClient } from '@tanstack/react-query';
21
+ import { useMMKVString } from 'react-native-mmkv';
22
+ import Config from 'react-native-config';
23
+
24
+ type CloseBottomSheetProps = {
25
+ bottomSheetRef: TSingleSnapBottomSheetRef;
26
+ };
27
+
28
+ export const CloseBottomSheet = ({ bottomSheetRef }: CloseBottomSheetProps) => {
29
+ const [_, setBusinessId] = useMMKVString(MMKV_KEYS.BUSINESS_ID);
30
+ const { t } = useTranslation();
31
+ const queryClient = useQueryClient();
32
+
33
+ const handleLogout = () => {
34
+ auth()
35
+ .signOut()
36
+ .finally(() => {
37
+ Config.APP_NAME !== 'gusteau' && queryClient.clear();
38
+ FastImage.clearMemoryCache();
39
+ FastImage.clearDiskCache();
40
+ setBusinessId(undefined);
41
+ });
42
+ };
43
+ return (
44
+ <BottomSheet
45
+ close={bottomSheetRef.close}
46
+ pressBehavior="close"
47
+ ref={bottomSheetRef.ref}
48
+ >
49
+ <View px="16" bg="background" flex={1} my="16">
50
+ <Text variant="titleLarge">{t('home.termsOfServiceModal.title')}</Text>
51
+ <Text pt="16" variant="bodyMedium" color="secondary">
52
+ {t('home.termsOfServiceModal.description')}
53
+ </Text>
54
+ <Button mode="contained" my="16" onPress={bottomSheetRef.close}>
55
+ {t('home.termsOfServiceModal.review')}
56
+ </Button>
57
+ <Button mode="outlined" onPress={handleLogout}>
58
+ {t('profile.logout')}
59
+ </Button>
60
+ </View>
61
+ </BottomSheet>
62
+ );
63
+ };
64
+
65
+ export const TermsOfService = () => {
66
+ const { useAgreeTermsOfService } = useTermsOfService();
67
+ const { mutate: agreeTermsOfService, isLoading } = useAgreeTermsOfService();
68
+ const theme = useTheme();
69
+ const bottomSheetRef = useSingleSnapBottomSheetRef();
70
+ const { t } = useTranslation();
71
+
72
+ return (
73
+ <ParentView flex={1}>
74
+ <View flexDirection="row" alignItems="center">
75
+ <IconButton
76
+ iconColor={theme.colors.onSurfaceVariant}
77
+ backgroundColor="transparent"
78
+ icon="close"
79
+ onPress={bottomSheetRef.expand}
80
+ />
81
+ <Text variant="labelLarge">{t('home.termsTitle')}</Text>
82
+ </View>
83
+ <View
84
+ style={styles.view}
85
+ mx="16"
86
+ flex={1}
87
+ borderWidth={1}
88
+ borderColor="onSurfaceDisabled"
89
+ borderRadius="12"
90
+ padding="8"
91
+ >
92
+ <WebView
93
+ startInLoadingState
94
+ renderLoading={() => (
95
+ <View
96
+ alignItems="center"
97
+ bottom={0}
98
+ justifyContent="center"
99
+ left={0}
100
+ position="absolute"
101
+ right={0}
102
+ top={0}
103
+ >
104
+ <ActivityIndicator size="large" />
105
+ </View>
106
+ )}
107
+ javaScriptEnabled={true}
108
+ source={{
109
+ uri: TERMS_OF_SERVICE,
110
+ }}
111
+ />
112
+ </View>
113
+ <Button
114
+ mx="16"
115
+ mode="contained"
116
+ my="16"
117
+ height={40}
118
+ onPress={() => agreeTermsOfService()}
119
+ loading={isLoading}
120
+ >
121
+ {t('home.acceptTerms')}
122
+ </Button>
123
+ <CloseBottomSheet bottomSheetRef={bottomSheetRef} />
124
+ </ParentView>
125
+ );
126
+ };
127
+
128
+ const styles = StyleSheet.create({
129
+ view: { backgroundColor: 'white' },
130
+ });
@@ -1,5 +1,6 @@
1
1
  export const queryKeys = {
2
2
  BUSINESSES: 'BUSINESSES',
3
+ TERMS_AND_CONDITIONS: 'TERMS_AND_CONDITIONS',
3
4
  };
4
5
 
5
6
  export const DEFAULT_STALE_TIME = 60 * (60 * 1000); // 60 mins
@@ -1,5 +1,6 @@
1
1
  import { Dimensions } from 'react-native';
2
2
  import { initialWindowMetrics } from 'react-native-safe-area-context';
3
+ import firestore from '@react-native-firebase/firestore';
3
4
 
4
5
  export const getPercentageFromHeight = (height: number): string => {
5
6
  const totalHeight =
@@ -9,3 +10,10 @@ export const getPercentageFromHeight = (height: number): string => {
9
10
 
10
11
  return Math.ceil((height / totalHeight) * 100) + '%';
11
12
  };
13
+
14
+ export const getCurrentTimestamp = () => {
15
+ const firestoreTimestamp = firestore.Timestamp.now().toDate();
16
+ const formattedTimestamp = firestoreTimestamp.toISOString();
17
+
18
+ return formattedTimestamp;
19
+ };