@kiosinc/commons-rn 0.1.48 → 0.1.50
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/assets/icons/appLogo.svg +2 -8
- package/lib/commonjs/assets/icons/tick.svg +1 -1
- package/lib/commonjs/auth/screens/ChangePassword.js +24 -9
- package/lib/commonjs/auth/screens/ChangePassword.js.map +1 -1
- package/lib/commonjs/auth/screens/Login.js +17 -30
- package/lib/commonjs/auth/screens/Login.js.map +1 -1
- package/lib/commonjs/auth/screens/LoginWithEmail.js +18 -13
- package/lib/commonjs/auth/screens/LoginWithEmail.js.map +1 -1
- package/lib/commonjs/auth/screens/LoginWithPhoneNumber.js +24 -13
- package/lib/commonjs/auth/screens/LoginWithPhoneNumber.js.map +1 -1
- package/lib/commonjs/auth/screens/ResetPassword.js +4 -9
- package/lib/commonjs/auth/screens/ResetPassword.js.map +1 -1
- package/lib/commonjs/auth/screens/SignUp.js +6 -19
- package/lib/commonjs/auth/screens/SignUp.js.map +1 -1
- package/lib/commonjs/auth/screens/VerifyPhoneNumberForLogin.js +1 -1
- package/lib/commonjs/auth/screens/VerifyPhoneNumberForLogin.js.map +1 -1
- package/lib/commonjs/components/OtpInputs.js +7 -5
- package/lib/commonjs/components/OtpInputs.js.map +1 -1
- package/lib/commonjs/components/ParentView.js +1 -10
- package/lib/commonjs/components/ParentView.js.map +1 -1
- package/lib/commonjs/selectBusiness/SelectBusiness.js +13 -2
- package/lib/commonjs/selectBusiness/SelectBusiness.js.map +1 -1
- package/lib/commonjs/selectBusiness/useBusinesses.js +25 -18
- package/lib/commonjs/selectBusiness/useBusinesses.js.map +1 -1
- package/lib/module/assets/icons/appLogo.svg +2 -8
- package/lib/module/assets/icons/tick.svg +1 -1
- package/lib/module/auth/screens/ChangePassword.js +24 -9
- package/lib/module/auth/screens/ChangePassword.js.map +1 -1
- package/lib/module/auth/screens/Login.js +19 -32
- package/lib/module/auth/screens/Login.js.map +1 -1
- package/lib/module/auth/screens/LoginWithEmail.js +19 -14
- package/lib/module/auth/screens/LoginWithEmail.js.map +1 -1
- package/lib/module/auth/screens/LoginWithPhoneNumber.js +24 -14
- package/lib/module/auth/screens/LoginWithPhoneNumber.js.map +1 -1
- package/lib/module/auth/screens/ResetPassword.js +5 -10
- package/lib/module/auth/screens/ResetPassword.js.map +1 -1
- package/lib/module/auth/screens/SignUp.js +6 -19
- package/lib/module/auth/screens/SignUp.js.map +1 -1
- package/lib/module/auth/screens/VerifyPhoneNumberForLogin.js +1 -1
- package/lib/module/auth/screens/VerifyPhoneNumberForLogin.js.map +1 -1
- package/lib/module/components/OtpInputs.js +8 -5
- package/lib/module/components/OtpInputs.js.map +1 -1
- package/lib/module/components/ParentView.js +1 -10
- package/lib/module/components/ParentView.js.map +1 -1
- package/lib/module/selectBusiness/SelectBusiness.js +14 -3
- package/lib/module/selectBusiness/SelectBusiness.js.map +1 -1
- package/lib/module/selectBusiness/useBusinesses.js +25 -18
- package/lib/module/selectBusiness/useBusinesses.js.map +1 -1
- package/lib/typescript/src/auth/screens/ChangePassword.d.ts.map +1 -1
- package/lib/typescript/src/auth/screens/Login.d.ts.map +1 -1
- package/lib/typescript/src/auth/screens/LoginWithEmail.d.ts.map +1 -1
- package/lib/typescript/src/auth/screens/LoginWithPhoneNumber.d.ts.map +1 -1
- package/lib/typescript/src/auth/screens/ResetPassword.d.ts.map +1 -1
- package/lib/typescript/src/auth/screens/SignUp.d.ts.map +1 -1
- package/lib/typescript/src/components/OtpInputs.d.ts +862 -9
- package/lib/typescript/src/components/OtpInputs.d.ts.map +1 -1
- package/lib/typescript/src/components/ParentView.d.ts +1 -2
- package/lib/typescript/src/components/ParentView.d.ts.map +1 -1
- package/lib/typescript/src/selectBusiness/SelectBusiness.d.ts.map +1 -1
- package/lib/typescript/src/selectBusiness/useBusinesses.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/assets/icons/appLogo.svg +2 -8
- package/src/assets/icons/tick.svg +1 -1
- package/src/auth/screens/ChangePassword.tsx +50 -14
- package/src/auth/screens/Login.tsx +17 -45
- package/src/auth/screens/LoginWithEmail.tsx +24 -9
- package/src/auth/screens/LoginWithPhoneNumber.tsx +29 -10
- package/src/auth/screens/ResetPassword.tsx +39 -44
- package/src/auth/screens/SignUp.tsx +109 -119
- package/src/auth/screens/VerifyPhoneNumberForLogin.tsx +1 -1
- package/src/components/OtpInputs.tsx +4 -4
- package/src/components/ParentView.tsx +0 -17
- package/src/selectBusiness/SelectBusiness.tsx +28 -4
- package/src/selectBusiness/useBusinesses.ts +6 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ParentView,
|
|
3
3
|
Text,
|
|
4
|
-
View,
|
|
5
4
|
TextInput,
|
|
6
5
|
Button,
|
|
7
6
|
KeyboardAvoidingView,
|
|
@@ -43,50 +42,46 @@ export const ResetPassword = () => {
|
|
|
43
42
|
return (
|
|
44
43
|
<ParentView px="16">
|
|
45
44
|
<Header left={10} position={'absolute'} zIndex={'100'} />
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
<KeyboardAvoidingView
|
|
46
|
+
justifyContent={'center'}
|
|
47
|
+
width={{ phone: '100%', tablet: 372 }}
|
|
48
|
+
>
|
|
49
|
+
<Text py="48" textAlign="center" variant="titleLarge">
|
|
50
|
+
{t('authentication.enterYour')}
|
|
51
|
+
</Text>
|
|
52
|
+
<Controller
|
|
53
|
+
control={control}
|
|
54
|
+
render={({ field: { onChange, onBlur, value } }) => {
|
|
55
|
+
return (
|
|
56
|
+
<TextInput
|
|
57
|
+
autoFocus
|
|
58
|
+
keyboardType="email-address"
|
|
59
|
+
autoCapitalize="none"
|
|
60
|
+
mode="outlined"
|
|
61
|
+
autoComplete="email"
|
|
62
|
+
error={!!errors.email?.message}
|
|
63
|
+
errorMessage={errors.email?.message}
|
|
64
|
+
onBlur={onBlur}
|
|
65
|
+
onChangeText={onChange}
|
|
66
|
+
value={value}
|
|
67
|
+
label={t('authentication.email')}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}}
|
|
71
|
+
name="email"
|
|
72
|
+
/>
|
|
73
|
+
<Button
|
|
74
|
+
loading={isLoading}
|
|
75
|
+
mt="16"
|
|
76
|
+
mode="contained"
|
|
77
|
+
onPress={handleSubmit(onSubmit)}
|
|
51
78
|
>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
control={control}
|
|
59
|
-
render={({ field: { onChange, onBlur, value } }) => {
|
|
60
|
-
return (
|
|
61
|
-
<TextInput
|
|
62
|
-
keyboardType="email-address"
|
|
63
|
-
autoCapitalize="none"
|
|
64
|
-
mode="outlined"
|
|
65
|
-
autoComplete="email"
|
|
66
|
-
error={!!errors.email?.message}
|
|
67
|
-
errorMessage={errors.email?.message}
|
|
68
|
-
onBlur={onBlur}
|
|
69
|
-
onChangeText={onChange}
|
|
70
|
-
value={value}
|
|
71
|
-
label={t('authentication.email')}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
}}
|
|
75
|
-
name="email"
|
|
76
|
-
/>
|
|
77
|
-
<Button
|
|
78
|
-
loading={isLoading}
|
|
79
|
-
mt="16"
|
|
80
|
-
mode="contained"
|
|
81
|
-
onPress={handleSubmit(onSubmit)}
|
|
82
|
-
>
|
|
83
|
-
{t('authentication.resetPassword')}
|
|
84
|
-
</Button>
|
|
85
|
-
<Button mt="48" mode="outlined" onPress={navigation.goBack}>
|
|
86
|
-
{t('cancel')}
|
|
87
|
-
</Button>
|
|
88
|
-
</KeyboardAvoidingView>
|
|
89
|
-
</View>
|
|
79
|
+
{t('authentication.resetPassword')}
|
|
80
|
+
</Button>
|
|
81
|
+
<Button mt="48" mode="outlined" onPress={navigation.goBack}>
|
|
82
|
+
{t('cancel')}
|
|
83
|
+
</Button>
|
|
84
|
+
</KeyboardAvoidingView>
|
|
90
85
|
</ParentView>
|
|
91
86
|
);
|
|
92
87
|
};
|
|
@@ -67,127 +67,117 @@ export const SignUp = () => {
|
|
|
67
67
|
|
|
68
68
|
return (
|
|
69
69
|
<ParentView px="16">
|
|
70
|
-
<Header
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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.
|
|
170
|
-
</
|
|
171
|
-
|
|
172
|
-
|
|
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
|
};
|
|
@@ -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}
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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
|
+
};
|