@kiosinc/commons-rn 0.1.48 → 0.1.49

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 (68) hide show
  1. package/lib/commonjs/assets/icons/appLogo.svg +2 -8
  2. package/lib/commonjs/assets/icons/tick.svg +1 -1
  3. package/lib/commonjs/auth/screens/Login.js +17 -30
  4. package/lib/commonjs/auth/screens/Login.js.map +1 -1
  5. package/lib/commonjs/auth/screens/LoginWithEmail.js +18 -13
  6. package/lib/commonjs/auth/screens/LoginWithEmail.js.map +1 -1
  7. package/lib/commonjs/auth/screens/LoginWithPhoneNumber.js +24 -13
  8. package/lib/commonjs/auth/screens/LoginWithPhoneNumber.js.map +1 -1
  9. package/lib/commonjs/auth/screens/ResetPassword.js +4 -9
  10. package/lib/commonjs/auth/screens/ResetPassword.js.map +1 -1
  11. package/lib/commonjs/auth/screens/SignUp.js +6 -19
  12. package/lib/commonjs/auth/screens/SignUp.js.map +1 -1
  13. package/lib/commonjs/auth/screens/VerifyPhoneNumberForLogin.js +1 -1
  14. package/lib/commonjs/auth/screens/VerifyPhoneNumberForLogin.js.map +1 -1
  15. package/lib/commonjs/components/OtpInputs.js +7 -5
  16. package/lib/commonjs/components/OtpInputs.js.map +1 -1
  17. package/lib/commonjs/components/ParentView.js +1 -10
  18. package/lib/commonjs/components/ParentView.js.map +1 -1
  19. package/lib/commonjs/selectBusiness/SelectBusiness.js +13 -2
  20. package/lib/commonjs/selectBusiness/SelectBusiness.js.map +1 -1
  21. package/lib/commonjs/selectBusiness/useBusinesses.js +25 -18
  22. package/lib/commonjs/selectBusiness/useBusinesses.js.map +1 -1
  23. package/lib/module/assets/icons/appLogo.svg +2 -8
  24. package/lib/module/assets/icons/tick.svg +1 -1
  25. package/lib/module/auth/screens/Login.js +19 -32
  26. package/lib/module/auth/screens/Login.js.map +1 -1
  27. package/lib/module/auth/screens/LoginWithEmail.js +19 -14
  28. package/lib/module/auth/screens/LoginWithEmail.js.map +1 -1
  29. package/lib/module/auth/screens/LoginWithPhoneNumber.js +24 -14
  30. package/lib/module/auth/screens/LoginWithPhoneNumber.js.map +1 -1
  31. package/lib/module/auth/screens/ResetPassword.js +5 -10
  32. package/lib/module/auth/screens/ResetPassword.js.map +1 -1
  33. package/lib/module/auth/screens/SignUp.js +6 -19
  34. package/lib/module/auth/screens/SignUp.js.map +1 -1
  35. package/lib/module/auth/screens/VerifyPhoneNumberForLogin.js +1 -1
  36. package/lib/module/auth/screens/VerifyPhoneNumberForLogin.js.map +1 -1
  37. package/lib/module/components/OtpInputs.js +8 -5
  38. package/lib/module/components/OtpInputs.js.map +1 -1
  39. package/lib/module/components/ParentView.js +1 -10
  40. package/lib/module/components/ParentView.js.map +1 -1
  41. package/lib/module/selectBusiness/SelectBusiness.js +14 -3
  42. package/lib/module/selectBusiness/SelectBusiness.js.map +1 -1
  43. package/lib/module/selectBusiness/useBusinesses.js +25 -18
  44. package/lib/module/selectBusiness/useBusinesses.js.map +1 -1
  45. package/lib/typescript/src/auth/screens/Login.d.ts.map +1 -1
  46. package/lib/typescript/src/auth/screens/LoginWithEmail.d.ts.map +1 -1
  47. package/lib/typescript/src/auth/screens/LoginWithPhoneNumber.d.ts.map +1 -1
  48. package/lib/typescript/src/auth/screens/ResetPassword.d.ts.map +1 -1
  49. package/lib/typescript/src/auth/screens/SignUp.d.ts.map +1 -1
  50. package/lib/typescript/src/components/OtpInputs.d.ts +862 -9
  51. package/lib/typescript/src/components/OtpInputs.d.ts.map +1 -1
  52. package/lib/typescript/src/components/ParentView.d.ts +1 -2
  53. package/lib/typescript/src/components/ParentView.d.ts.map +1 -1
  54. package/lib/typescript/src/selectBusiness/SelectBusiness.d.ts.map +1 -1
  55. package/lib/typescript/src/selectBusiness/useBusinesses.d.ts.map +1 -1
  56. package/package.json +2 -1
  57. package/src/assets/icons/appLogo.svg +2 -8
  58. package/src/assets/icons/tick.svg +1 -1
  59. package/src/auth/screens/Login.tsx +17 -45
  60. package/src/auth/screens/LoginWithEmail.tsx +24 -9
  61. package/src/auth/screens/LoginWithPhoneNumber.tsx +29 -10
  62. package/src/auth/screens/ResetPassword.tsx +39 -44
  63. package/src/auth/screens/SignUp.tsx +109 -119
  64. package/src/auth/screens/VerifyPhoneNumberForLogin.tsx +1 -1
  65. package/src/components/OtpInputs.tsx +4 -4
  66. package/src/components/ParentView.tsx +0 -17
  67. package/src/selectBusiness/SelectBusiness.tsx +28 -4
  68. package/src/selectBusiness/useBusinesses.ts +6 -2
@@ -67,127 +67,117 @@ export const SignUp = () => {
67
67
 
68
68
  return (
69
69
  <ParentView px="16">
70
- <Header left={10} position={'absolute'} zIndex={'100'} />
71
- <View flex={1} justifyContent={'center'}>
72
- <KeyboardAvoidingView
73
- flex={1}
74
- behavior="padding"
75
- alignSelf="center"
76
- justifyContent={'center'}
77
- width={{ phone: '100%', tablet: 372 }}
78
- >
79
- <View alignItems="center">
80
- <Text pb="40" variant="titleLarge">
81
- {t('authentication.createAccountTitle')}
82
- </Text>
83
- </View>
84
- <View justifyContent="center">
85
- <Controller
86
- control={control}
87
- render={({ field: { onChange, onBlur, value } }) => {
88
- return (
89
- <TextInput
90
- my="5"
91
- mode="outlined"
92
- error={!!errors.displayName?.message}
93
- errorMessage={errors.displayName?.message}
94
- onBlur={onBlur}
95
- onChangeText={onChange}
96
- value={value}
97
- label={t('authentication.displayName')}
98
- />
99
- );
100
- }}
101
- name="displayName"
102
- />
103
- {Config.APP_NAME !== 'gusteau' && (
104
- <Controller
105
- control={control}
106
- render={({ field: { onChange, onBlur, value } }) => {
107
- return (
108
- <TextInput
109
- my="5"
110
- mode="outlined"
111
- error={!!errors.name?.message}
112
- errorMessage={errors.name?.message}
113
- onBlur={onBlur}
114
- onChangeText={onChange}
115
- value={value}
116
- label={t('authentication.businessName')}
117
- />
118
- );
119
- }}
120
- name="name"
70
+ <Header title={t('authentication.createAccountTitle')} />
71
+ <KeyboardAvoidingView
72
+ flex={1}
73
+ behavior="padding"
74
+ width={{ phone: '100%', tablet: 372 }}
75
+ >
76
+ <Controller
77
+ control={control}
78
+ render={({ field: { onChange, onBlur, value } }) => {
79
+ return (
80
+ <TextInput
81
+ autoFocus
82
+ my="5"
83
+ mode="outlined"
84
+ error={!!errors.displayName?.message}
85
+ errorMessage={errors.displayName?.message}
86
+ onBlur={onBlur}
87
+ onChangeText={onChange}
88
+ value={value}
89
+ label={t('authentication.displayName')}
90
+ />
91
+ );
92
+ }}
93
+ name="displayName"
94
+ />
95
+ {Config.APP_NAME !== 'gusteau' && (
96
+ <Controller
97
+ control={control}
98
+ render={({ field: { onChange, onBlur, value } }) => {
99
+ return (
100
+ <TextInput
101
+ my="5"
102
+ mode="outlined"
103
+ error={!!errors.name?.message}
104
+ errorMessage={errors.name?.message}
105
+ onBlur={onBlur}
106
+ onChangeText={onChange}
107
+ value={value}
108
+ label={t('authentication.businessName')}
109
+ />
110
+ );
111
+ }}
112
+ name="name"
113
+ />
114
+ )}
115
+ <Controller
116
+ control={control}
117
+ render={({ field: { onChange, onBlur, value } }) => {
118
+ return (
119
+ <TextInput
120
+ my="5"
121
+ autoCapitalize="none"
122
+ keyboardType="email-address"
123
+ mode="outlined"
124
+ autoComplete="email"
125
+ error={!!errors.email?.message}
126
+ errorMessage={errors.email?.message}
127
+ onBlur={onBlur}
128
+ onChangeText={onChange}
129
+ value={value}
130
+ label={t('authentication.email')}
131
+ />
132
+ );
133
+ }}
134
+ name="email"
135
+ />
136
+ <Controller
137
+ control={control}
138
+ render={({ field: { onChange, onBlur, value } }) => {
139
+ return (
140
+ <PhoneInput
141
+ placeholder="Phone Number"
142
+ onBlur={onBlur}
143
+ onChangePhoneNumber={onChange}
144
+ value={value}
145
+ defaultCountry="US"
146
+ errorMessage={errors.phoneNumber?.message}
147
+ selectedCountry={selectedCountry as ICountry}
148
+ onChangeSelectedCountry={setSelectedCountry}
121
149
  />
122
- )}
123
- <Controller
124
- control={control}
125
- render={({ field: { onChange, onBlur, value } }) => {
126
- return (
127
- <TextInput
128
- my="5"
129
- autoCapitalize="none"
130
- keyboardType="email-address"
131
- mode="outlined"
132
- autoComplete="email"
133
- error={!!errors.email?.message}
134
- errorMessage={errors.email?.message}
135
- onBlur={onBlur}
136
- onChangeText={onChange}
137
- value={value}
138
- label={t('authentication.email')}
139
- />
140
- );
141
- }}
142
- name="email"
143
- />
144
- <Controller
145
- control={control}
146
- render={({ field: { onChange, onBlur, value } }) => {
147
- return (
148
- <PhoneInput
149
- placeholder="Phone Number"
150
- onBlur={onBlur}
151
- onChangePhoneNumber={onChange}
152
- value={value}
153
- defaultCountry="US"
154
- errorMessage={errors.phoneNumber?.message}
155
- selectedCountry={selectedCountry as ICountry}
156
- onChangeSelectedCountry={setSelectedCountry}
157
- />
158
- );
159
- }}
160
- name="phoneNumber"
161
- />
162
- </View>
163
- <Button
164
- loading={isCheckingIsRegistered}
165
- mt="48"
166
- onPress={handleSubmit(onSubmit)}
167
- mode="contained"
150
+ );
151
+ }}
152
+ name="phoneNumber"
153
+ />
154
+ <Button
155
+ loading={isCheckingIsRegistered}
156
+ mt="24"
157
+ onPress={handleSubmit(onSubmit)}
158
+ mode="contained"
159
+ >
160
+ {t('authentication.createAccount')}
161
+ </Button>
162
+ <View flexDirection="row" flexWrap="wrap" pt="10">
163
+ <Text variant="bodyMedium">{t('authentication.byContinue')} </Text>
164
+ <LinkButton
165
+ labelStyle={style.linkButton}
166
+ mode="text"
167
+ onPress={() => Linking.openURL(TERMS_OF_SERVICE)}
168
+ >
169
+ {t('authentication.termsAndConditions')}
170
+ </LinkButton>
171
+ <Text variant="bodyMedium"> {t('authentication.and')} </Text>
172
+ <LinkButton
173
+ labelStyle={style.linkButton}
174
+ mode="text"
175
+ onPress={() => Linking.openURL(PRIVACY_POLICY)}
168
176
  >
169
- {t('authentication.createAccount')}
170
- </Button>
171
- <View flexDirection="row" flexWrap="wrap" pt="10">
172
- <Text variant="bodyMedium">{t('authentication.byContinue')} </Text>
173
- <LinkButton
174
- labelStyle={style.linkButton}
175
- mode="text"
176
- onPress={() => Linking.openURL(TERMS_OF_SERVICE)}
177
- >
178
- {t('authentication.termsAndConditions')}
179
- </LinkButton>
180
- <Text variant="bodyMedium"> {t('authentication.and')} </Text>
181
- <LinkButton
182
- labelStyle={style.linkButton}
183
- mode="text"
184
- onPress={() => Linking.openURL(PRIVACY_POLICY)}
185
- >
186
- {t('authentication.privacyPolicy')}
187
- </LinkButton>
188
- </View>
189
- </KeyboardAvoidingView>
190
- </View>
177
+ {t('authentication.privacyPolicy')}
178
+ </LinkButton>
179
+ </View>
180
+ </KeyboardAvoidingView>
191
181
  </ParentView>
192
182
  );
193
183
  };
@@ -69,7 +69,7 @@ export const VerifyPhoneNumberForLogin: React.FC<
69
69
  >
70
70
  {t('authentication.codeSent', {
71
71
  phoneNumber: params.phoneNumber,
72
- })}{' '}
72
+ })}
73
73
  </Text>
74
74
  </View>
75
75
  <Controller
@@ -1,5 +1,5 @@
1
1
  import { InteractionManager, Keyboard, StyleSheet } from 'react-native';
2
- import React, { useEffect } from 'react';
2
+ import React, { forwardRef, useEffect } from 'react';
3
3
  import {
4
4
  TextInput as T,
5
5
  type TextInputProps,
@@ -49,11 +49,11 @@ type Props = RestyleProps &
49
49
  errorMessage?: string;
50
50
  };
51
51
 
52
- export const TextInput = ({ ...rest }: Props) => {
52
+ export const TextInput = forwardRef(({ ...rest }: Props, ref: any) => {
53
53
  const props = useRestyle(restyleFunctions as any, rest);
54
54
 
55
- return <T {...props} />;
56
- };
55
+ return <T {...props} ref={ref} />;
56
+ });
57
57
 
58
58
  type OtpInputsPropsType = {
59
59
  handleChange?: (value: string) => void;
@@ -59,7 +59,6 @@ type Props = RestyleProps &
59
59
  ViewProps & {
60
60
  barStyle?: StatusBarStyle;
61
61
  children?: React.ReactNode;
62
- shouldDismissKeyboardOnTap?: boolean;
63
62
  topInset?: boolean;
64
63
  rightInset?: boolean;
65
64
  leftInset?: boolean;
@@ -103,12 +102,10 @@ export const ParentView = ({
103
102
  rightInset = true,
104
103
  leftInset = true,
105
104
  bottomInset = true,
106
- shouldDismissKeyboardOnTap = true,
107
105
  ...rest
108
106
  }: Props) => {
109
107
  const props = useRestyle(restyleFunctions as any, rest);
110
108
 
111
- const keyboardHeight = useKeyboard();
112
109
  const safeAreaViewProps = {
113
110
  edges: [
114
111
  ...(topInset ? ['top'] : []),
@@ -119,17 +116,6 @@ export const ParentView = ({
119
116
 
120
117
  const insets = useSafeAreaInsets();
121
118
 
122
- const handleOnTouchStart = (e: any) => {
123
- if (
124
- keyboardHeight &&
125
- e?.target?._internalFiberInstanceHandleDEV?.elementType?.indexOf(
126
- 'TextInput'
127
- ) === -1
128
- ) {
129
- Keyboard.dismiss();
130
- }
131
- };
132
-
133
119
  const theme = useTheme();
134
120
 
135
121
  return (
@@ -147,9 +133,6 @@ export const ParentView = ({
147
133
  bg={bg ?? 'background'}
148
134
  {...(props as any)}
149
135
  {...(bottomInset && { pb: insets.bottom })}
150
- {...(shouldDismissKeyboardOnTap
151
- ? { onTouchStart: handleOnTouchStart }
152
- : {})}
153
136
  >
154
137
  {children}
155
138
  </View>
@@ -13,7 +13,7 @@ import {
13
13
  } from '../components';
14
14
  import { FlashList } from '@shopify/flash-list';
15
15
  import { useTranslation } from 'react-i18next';
16
- import { useTheme } from 'react-native-paper';
16
+ import { ActivityIndicator, useTheme } from 'react-native-paper';
17
17
  import { useMMKVString } from 'react-native-mmkv';
18
18
  import { type NavigationProp, useNavigation } from '@react-navigation/native';
19
19
  import { useQueryClient } from '@tanstack/react-query';
@@ -53,7 +53,7 @@ const BusinessCard = ({
53
53
  >
54
54
  <Text variant="bodyMedium">{business.name}</Text>
55
55
  {isSelectedBusiness && (
56
- <Tick height={20} width={20} color={theme.colors.onBackground} />
56
+ <Tick height={20} width={20} fill={theme.colors.onBackground} />
57
57
  )}
58
58
  </View>
59
59
  </Card>
@@ -66,7 +66,13 @@ export const SelectBusiness = () => {
66
66
  MMKV_KEYS.BUSINESS_ID
67
67
  );
68
68
  const [searchText, setSearchText] = useState('');
69
- const { data = [], isFetching, isRefetching, refetch } = useBusinesses();
69
+ const {
70
+ data = [],
71
+ isLoading,
72
+ isFetching,
73
+ isRefetching,
74
+ refetch,
75
+ } = useBusinesses();
70
76
 
71
77
  const navigation = useNavigation<NavigationProp<RootStackType>>();
72
78
  const queryClient = useQueryClient();
@@ -98,6 +104,24 @@ export const SelectBusiness = () => {
98
104
  }
99
105
  }, [searchText, data]);
100
106
 
107
+ useEffect(() => {
108
+ if (!selectedBusinessId && data.length === 1) {
109
+ setBusinessId((data[0] as any).id);
110
+ }
111
+ }, [data, selectedBusinessId, setBusinessId]);
112
+
113
+ if (isLoading || (!selectedBusinessId && data.length === 1))
114
+ return (
115
+ <ParentView
116
+ flex={1}
117
+ backgroundColor="background"
118
+ justifyContent={'center'}
119
+ alignItems={'center'}
120
+ >
121
+ <ActivityIndicator />
122
+ </ParentView>
123
+ );
124
+
101
125
  return (
102
126
  <ParentView flex={1} backgroundColor="background">
103
127
  <Header title={t('home.selectBusiness')} />
@@ -155,7 +179,7 @@ export const SelectBusiness = () => {
155
179
  )}
156
180
  </View>
157
181
  {!selectedBusinessId && (
158
- <View flex={1} justifyContent="flex-end">
182
+ <View justifyContent="flex-end">
159
183
  <LinkButton mode="text" onPress={handleLogout}>
160
184
  {t('profile.logout')}
161
185
  </LinkButton>
@@ -1,13 +1,16 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
2
  import { DEFAULT_STALE_TIME, queryKeys } from './queryKeys';
3
3
  import axios from 'axios';
4
+ import { useAuthentication } from '../auth';
4
5
 
5
6
  export const getBusinessData = () => {
6
7
  return axios.get('/user/businessData');
7
8
  };
8
9
 
9
- export const useBusinesses = () =>
10
- useQuery([queryKeys.BUSINESSES], getBusinessData, {
10
+ export const useBusinesses = () => {
11
+ const { user } = useAuthentication();
12
+ return useQuery([queryKeys.BUSINESSES], getBusinessData, {
13
+ enabled: Boolean(user),
11
14
  staleTime: DEFAULT_STALE_TIME,
12
15
  select: (response) => {
13
16
  const businesses = response?.data?.businesses as Array<{
@@ -31,3 +34,4 @@ export const useBusinesses = () =>
31
34
  return businesses;
32
35
  },
33
36
  });
37
+ };