@kiosinc/commons-rn 0.1.43 → 0.1.44

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 (80) hide show
  1. package/lib/commonjs/auth/api/authentication.js.map +1 -1
  2. package/lib/commonjs/auth/hooks/useAuthentication.js +26 -1
  3. package/lib/commonjs/auth/hooks/useAuthentication.js.map +1 -1
  4. package/lib/commonjs/auth/screens/Login.js +130 -0
  5. package/lib/commonjs/auth/screens/Login.js.map +1 -0
  6. package/lib/commonjs/auth/screens/{LoginScreen.js → LoginWithEmail.js} +12 -57
  7. package/lib/commonjs/auth/screens/LoginWithEmail.js.map +1 -0
  8. package/lib/commonjs/auth/screens/LoginWithPhoneNumber.js +87 -0
  9. package/lib/commonjs/auth/screens/LoginWithPhoneNumber.js.map +1 -0
  10. package/lib/commonjs/auth/screens/ResetPassword.js +3 -3
  11. package/lib/commonjs/auth/screens/ResetPassword.js.map +1 -1
  12. package/lib/commonjs/auth/screens/SignUp.js +3 -3
  13. package/lib/commonjs/auth/screens/SignUp.js.map +1 -1
  14. package/lib/commonjs/auth/screens/VerifyPhoneNumber.js +6 -4
  15. package/lib/commonjs/auth/screens/VerifyPhoneNumber.js.map +1 -1
  16. package/lib/commonjs/auth/screens/VerifyPhoneNumberForLogin.js +109 -0
  17. package/lib/commonjs/auth/screens/VerifyPhoneNumberForLogin.js.map +1 -0
  18. package/lib/commonjs/auth/screens/index.js +10 -6
  19. package/lib/commonjs/auth/screens/index.js.map +1 -1
  20. package/lib/commonjs/auth/screens/validators.js +5 -1
  21. package/lib/commonjs/auth/screens/validators.js.map +1 -1
  22. package/lib/module/auth/api/authentication.js.map +1 -1
  23. package/lib/module/auth/hooks/useAuthentication.js +26 -1
  24. package/lib/module/auth/hooks/useAuthentication.js.map +1 -1
  25. package/lib/module/auth/screens/Login.js +120 -0
  26. package/lib/module/auth/screens/Login.js.map +1 -0
  27. package/lib/module/auth/screens/{LoginScreen.js → LoginWithEmail.js} +12 -57
  28. package/lib/module/auth/screens/LoginWithEmail.js.map +1 -0
  29. package/lib/module/auth/screens/LoginWithPhoneNumber.js +78 -0
  30. package/lib/module/auth/screens/LoginWithPhoneNumber.js.map +1 -0
  31. package/lib/module/auth/screens/ResetPassword.js +1 -1
  32. package/lib/module/auth/screens/ResetPassword.js.map +1 -1
  33. package/lib/module/auth/screens/SignUp.js +1 -1
  34. package/lib/module/auth/screens/SignUp.js.map +1 -1
  35. package/lib/module/auth/screens/VerifyPhoneNumber.js +4 -2
  36. package/lib/module/auth/screens/VerifyPhoneNumber.js.map +1 -1
  37. package/lib/module/auth/screens/VerifyPhoneNumberForLogin.js +101 -0
  38. package/lib/module/auth/screens/VerifyPhoneNumberForLogin.js.map +1 -0
  39. package/lib/module/auth/screens/index.js +12 -8
  40. package/lib/module/auth/screens/index.js.map +1 -1
  41. package/lib/module/auth/screens/validators.js +3 -0
  42. package/lib/module/auth/screens/validators.js.map +1 -1
  43. package/lib/typescript/src/auth/api/authentication.d.ts +6 -1
  44. package/lib/typescript/src/auth/api/authentication.d.ts.map +1 -1
  45. package/lib/typescript/src/auth/hooks/useAuthentication.d.ts +12 -1
  46. package/lib/typescript/src/auth/hooks/useAuthentication.d.ts.map +1 -1
  47. package/lib/typescript/src/auth/screens/Login.d.ts +3 -0
  48. package/lib/typescript/src/auth/screens/Login.d.ts.map +1 -0
  49. package/lib/typescript/src/auth/screens/LoginWithEmail.d.ts +3 -0
  50. package/lib/typescript/src/auth/screens/LoginWithEmail.d.ts.map +1 -0
  51. package/lib/typescript/src/auth/screens/LoginWithPhoneNumber.d.ts +3 -0
  52. package/lib/typescript/src/auth/screens/LoginWithPhoneNumber.d.ts.map +1 -0
  53. package/lib/typescript/src/auth/screens/ResetPassword.d.ts +1 -1
  54. package/lib/typescript/src/auth/screens/ResetPassword.d.ts.map +1 -1
  55. package/lib/typescript/src/auth/screens/SignUp.d.ts +1 -1
  56. package/lib/typescript/src/auth/screens/SignUp.d.ts.map +1 -1
  57. package/lib/typescript/src/auth/screens/VerifyPhoneNumber.d.ts +2 -2
  58. package/lib/typescript/src/auth/screens/VerifyPhoneNumber.d.ts.map +1 -1
  59. package/lib/typescript/src/auth/screens/VerifyPhoneNumberForLogin.d.ts +8 -0
  60. package/lib/typescript/src/auth/screens/VerifyPhoneNumberForLogin.d.ts.map +1 -0
  61. package/lib/typescript/src/auth/screens/index.d.ts.map +1 -1
  62. package/lib/typescript/src/auth/screens/validators.d.ts +5 -0
  63. package/lib/typescript/src/auth/screens/validators.d.ts.map +1 -1
  64. package/package.json +2 -1
  65. package/src/auth/api/authentication.ts +6 -1
  66. package/src/auth/hooks/useAuthentication.ts +20 -1
  67. package/src/auth/screens/Login.tsx +140 -0
  68. package/src/auth/screens/LoginWithEmail.tsx +120 -0
  69. package/src/auth/screens/LoginWithPhoneNumber.tsx +78 -0
  70. package/src/auth/screens/ResetPassword.tsx +1 -1
  71. package/src/auth/screens/SignUp.tsx +1 -1
  72. package/src/auth/screens/VerifyPhoneNumber.tsx +8 -6
  73. package/src/auth/screens/VerifyPhoneNumberForLogin.tsx +112 -0
  74. package/src/auth/screens/index.tsx +13 -8
  75. package/src/auth/screens/validators.ts +5 -0
  76. package/lib/commonjs/auth/screens/LoginScreen.js.map +0 -1
  77. package/lib/module/auth/screens/LoginScreen.js.map +0 -1
  78. package/lib/typescript/src/auth/screens/LoginScreen.d.ts +0 -3
  79. package/lib/typescript/src/auth/screens/LoginScreen.d.ts.map +0 -1
  80. package/src/auth/screens/LoginScreen.tsx +0 -172
@@ -1,172 +0,0 @@
1
- import {
2
- ParentView,
3
- Text,
4
- View,
5
- TextInput,
6
- Button,
7
- LinkButton,
8
- KeyboardAvoidingView,
9
- Snackbar,
10
- Header,
11
- } from '../../components';
12
- import { type NavigationProp, useNavigation } from '@react-navigation/native';
13
- import React, { useEffect, useState } from 'react';
14
- import { useTranslation } from 'react-i18next';
15
- import AppLogo from '../../assets/icons/appLogo.svg';
16
- import { Controller, useForm } from 'react-hook-form';
17
- import { yupResolver } from '@hookform/resolvers/yup';
18
- import { loginValidationSchema } from './validators';
19
- import auth from '@react-native-firebase/auth';
20
- import { useMMKVString } from 'react-native-mmkv';
21
- import { MMKV_KEYS } from '../../constants';
22
- import FastImage from 'react-native-fast-image';
23
- import Config from 'react-native-config';
24
- import { useQueryClient } from '@tanstack/react-query';
25
- import { StyleSheet } from 'react-native';
26
-
27
- type FormData = {
28
- email: string;
29
- password: string;
30
- };
31
-
32
- export const LoginScreen = () => {
33
- const { t } = useTranslation();
34
- const navigation = useNavigation<NavigationProp<RootStackType>>();
35
- const [isLoading, setIsLoading] = useState(false);
36
-
37
- const [_, setBusinessId] = useMMKVString(MMKV_KEYS.BUSINESS_ID);
38
- const queryClient = useQueryClient();
39
- useEffect(() => {
40
- queryClient.invalidateQueries();
41
- setBusinessId(undefined);
42
- FastImage.clearMemoryCache();
43
- FastImage.clearDiskCache();
44
- }, [queryClient, setBusinessId]);
45
-
46
- const {
47
- handleSubmit,
48
- control,
49
- formState: { errors },
50
- } = useForm<FormData>({
51
- resolver: yupResolver(loginValidationSchema(t)),
52
- defaultValues: {
53
- email: '',
54
- password: '',
55
- },
56
- });
57
-
58
- const onSubmit = (data: FormData) => {
59
- setIsLoading(true);
60
- auth()
61
- .signInWithEmailAndPassword(data.email, data.password)
62
- .catch(() => {
63
- Snackbar.show({ title: t('authentication.wrongCredentials') });
64
- })
65
- .finally(() => {
66
- setIsLoading(false);
67
- });
68
- };
69
-
70
- return (
71
- <ParentView px="16">
72
- <Header left={10} position={'absolute'} zIndex={'100'} />
73
- <View flex={1} justifyContent={'center'}>
74
- <KeyboardAvoidingView
75
- flex={1}
76
- behavior="padding"
77
- alignSelf="center"
78
- justifyContent={'center'}
79
- width={{ phone: '100%', tablet: 372 }}
80
- >
81
- <View alignItems="center">
82
- <AppLogo />
83
- <Text style={styles.text} variant="titleLarge">
84
- {t('authentication.logIn')}
85
- </Text>
86
- </View>
87
- <Controller
88
- control={control}
89
- render={({ field: { onChange, onBlur, value } }) => {
90
- return (
91
- <TextInput
92
- my="5"
93
- keyboardType="email-address"
94
- autoCapitalize="none"
95
- mode="outlined"
96
- autoComplete="email"
97
- error={!!errors.email?.message}
98
- errorMessage={errors.email?.message}
99
- onBlur={onBlur}
100
- onChangeText={onChange}
101
- value={value}
102
- label={t('authentication.email')}
103
- />
104
- );
105
- }}
106
- name="email"
107
- />
108
- <Controller
109
- control={control}
110
- render={({ field: { onChange, onBlur, value } }) => {
111
- return (
112
- <TextInput
113
- my="5"
114
- secureTextEntry={true}
115
- mode="outlined"
116
- autoComplete="current-password"
117
- error={!!errors.password?.message}
118
- errorMessage={errors.password?.message}
119
- onBlur={onBlur}
120
- onChangeText={onChange}
121
- value={value}
122
- label={t('authentication.password')}
123
- />
124
- );
125
- }}
126
- name="password"
127
- />
128
- <LinkButton
129
- alignSelf="flex-end"
130
- mode="text"
131
- onPress={() => {
132
- navigation.navigate('ResetPassword');
133
- }}
134
- >
135
- {t('authentication.forgotPassword')}
136
- </LinkButton>
137
- <Button
138
- loading={isLoading}
139
- style={styles.button}
140
- mode="contained"
141
- onPress={handleSubmit(onSubmit)}
142
- >
143
- {t('authentication.logIn')}
144
- </Button>
145
- {Config.APP_NAME !== 'git' && (
146
- <View
147
- alignItems="center"
148
- justifyContent="center"
149
- pt="8"
150
- flexDirection="row"
151
- >
152
- <Text variant="labelLarge">{t('authentication.newToApp')}</Text>
153
- <LinkButton
154
- mode="text"
155
- onPress={() => {
156
- navigation.navigate('SignUp');
157
- }}
158
- >
159
- {t('authentication.signUp')}
160
- </LinkButton>
161
- </View>
162
- )}
163
- </KeyboardAvoidingView>
164
- </View>
165
- </ParentView>
166
- );
167
- };
168
-
169
- const styles = StyleSheet.create({
170
- button: { marginVertical: '5%' },
171
- text: { paddingVertical: '5%' },
172
- });