@ha_tecno/live-id-sdk 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/index.js +0 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/screens/FingerAuth/FingerAuth.js +3 -6
- package/lib/commonjs/screens/FingerAuth/FingerAuth.js.map +1 -1
- package/lib/commonjs/screens/FingerRegister/FingerRegister.js +3 -6
- package/lib/commonjs/screens/FingerRegister/FingerRegister.js.map +1 -1
- package/lib/commonjs/screens/LifeCertificate/LifeCertificate.js +3 -7
- package/lib/commonjs/screens/LifeCertificate/LifeCertificate.js.map +1 -1
- package/lib/commonjs/utils/hooks/useIsForeground.js +23 -0
- package/lib/commonjs/utils/hooks/useIsForeground.js.map +1 -0
- package/lib/commonjs/utils/index.js +7 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/index.js +0 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/FingerAuth/FingerAuth.js +3 -6
- package/lib/module/screens/FingerAuth/FingerAuth.js.map +1 -1
- package/lib/module/screens/FingerRegister/FingerRegister.js +3 -6
- package/lib/module/screens/FingerRegister/FingerRegister.js.map +1 -1
- package/lib/module/screens/LifeCertificate/LifeCertificate.js +3 -7
- package/lib/module/screens/LifeCertificate/LifeCertificate.js.map +1 -1
- package/lib/module/utils/hooks/useIsForeground.js +16 -0
- package/lib/module/utils/hooks/useIsForeground.js.map +1 -0
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/FingerAuth/FingerAuth.d.ts +1 -2
- package/lib/typescript/src/screens/FingerAuth/FingerAuth.d.ts.map +1 -1
- package/lib/typescript/src/screens/FingerRegister/FingerRegister.d.ts +1 -2
- package/lib/typescript/src/screens/FingerRegister/FingerRegister.d.ts.map +1 -1
- package/lib/typescript/src/screens/LifeCertificate/LifeCertificate.d.ts.map +1 -1
- package/lib/typescript/src/utils/hooks/useIsForeground.d.ts +2 -0
- package/lib/typescript/src/utils/hooks/useIsForeground.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +2 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/index.tsx +0 -4
- package/src/screens/FingerAuth/FingerAuth.tsx +4 -7
- package/src/screens/FingerRegister/FingerRegister.tsx +4 -7
- package/src/screens/LifeCertificate/LifeCertificate.tsx +2 -6
- package/src/utils/hooks/useIsForeground.ts +18 -0
- package/src/utils/index.ts +2 -1
- package/lib/commonjs/screens/CadastroScreen/CadastroScreen.js +0 -186
- package/lib/commonjs/screens/CadastroScreen/CadastroScreen.js.map +0 -1
- package/lib/module/screens/CadastroScreen/CadastroScreen.js +0 -177
- package/lib/module/screens/CadastroScreen/CadastroScreen.js.map +0 -1
- package/lib/typescript/src/screens/CadastroScreen/CadastroScreen.d.ts +0 -12
- package/lib/typescript/src/screens/CadastroScreen/CadastroScreen.d.ts.map +0 -1
- package/src/screens/CadastroScreen/CadastroScreen.tsx +0 -195
@@ -1,195 +0,0 @@
|
|
1
|
-
/* eslint-disable react-native/no-inline-styles */
|
2
|
-
import React, { useEffect, useState } from "react";
|
3
|
-
import { View, Text, TextInput, TouchableOpacity, StyleSheet, Alert, Image } from "react-native";
|
4
|
-
import { cadastro } from "../../services";
|
5
|
-
import Modal, { type ModalProps } from "react-native-modal";
|
6
|
-
|
7
|
-
interface CadastroScreenProps {
|
8
|
-
isVisible: boolean;
|
9
|
-
onCloseModal?: () => void;
|
10
|
-
onError?: (response?: any) => void;
|
11
|
-
onSuccess?: (response?: any) => void;
|
12
|
-
ModalParams?: ModalProps;
|
13
|
-
}
|
14
|
-
|
15
|
-
export const CadastroScreen: React.FC<CadastroScreenProps> = ({
|
16
|
-
isVisible = false,
|
17
|
-
onCloseModal,
|
18
|
-
onError,
|
19
|
-
onSuccess,
|
20
|
-
ModalParams
|
21
|
-
}) => {
|
22
|
-
const [cpf, setCpf] = useState("");
|
23
|
-
const [nome, setNome] = useState("");
|
24
|
-
const [senha, setSenha] = useState("");
|
25
|
-
const [confirmarSenha, setConfirmarSenha] = useState("");
|
26
|
-
|
27
|
-
const generateRandomElevenDigits = () => {
|
28
|
-
let cpf = "";
|
29
|
-
for (let i = 0; i < 11; i++) {
|
30
|
-
cpf += Math.floor(Math.random() * 9);
|
31
|
-
}
|
32
|
-
return cpf;
|
33
|
-
};
|
34
|
-
|
35
|
-
const generateRandomName = () => {
|
36
|
-
// uma strin aleatória de 10 caracteres a 14 caracteres
|
37
|
-
let name = "";
|
38
|
-
const length = Math.floor(Math.random() * 5) + 10;
|
39
|
-
for (let i = 0; i < length; i++) {
|
40
|
-
name += String.fromCharCode(Math.floor(Math.random() * 26) + 97);
|
41
|
-
}
|
42
|
-
return name;
|
43
|
-
};
|
44
|
-
|
45
|
-
useEffect(() => {
|
46
|
-
generateRnadomUser();
|
47
|
-
}, []);
|
48
|
-
|
49
|
-
const generateRnadomUser = () => {
|
50
|
-
setCpf(generateRandomElevenDigits());
|
51
|
-
setNome(generateRandomName());
|
52
|
-
setSenha("123");
|
53
|
-
setConfirmarSenha("123");
|
54
|
-
};
|
55
|
-
|
56
|
-
const handleCadastro = async () => {
|
57
|
-
try {
|
58
|
-
if (senha === confirmarSenha) {
|
59
|
-
const response = await cadastro(cpf, nome, senha);
|
60
|
-
|
61
|
-
console.log(response);
|
62
|
-
var jsonString = JSON.stringify(response);
|
63
|
-
onSuccess && onSuccess(response);
|
64
|
-
|
65
|
-
onCloseModalHandler();
|
66
|
-
if (jsonString.includes("person_id")) {
|
67
|
-
if (response.finger === false) {
|
68
|
-
// openModal({
|
69
|
-
// type: 'ajuda',
|
70
|
-
// screenProps: {
|
71
|
-
// id: response.person_id,
|
72
|
-
// },
|
73
|
-
// });
|
74
|
-
} else {
|
75
|
-
// openModal({
|
76
|
-
// type: 'login',
|
77
|
-
// });
|
78
|
-
}
|
79
|
-
} else if (jsonString.includes("User exists")) {
|
80
|
-
Alert.alert("Usuário já cadastrado!");
|
81
|
-
// openModal({
|
82
|
-
// type: 'login',
|
83
|
-
// });
|
84
|
-
} else if (jsonString.includes("erro")) {
|
85
|
-
Alert.alert("Usuário não cadastrado", "Por favor, cadastre-se!");
|
86
|
-
} else {
|
87
|
-
Alert.alert("Erro", "Ocorreu um erro ao fazer o Cadastro. Por favor, tente novamente mais tarde.");
|
88
|
-
}
|
89
|
-
} else {
|
90
|
-
Alert.alert("Erro", "As senhas não coincidem. Por favor, tente novamente.");
|
91
|
-
return;
|
92
|
-
}
|
93
|
-
} catch (error) {
|
94
|
-
onError && onError(error);
|
95
|
-
console.error(error);
|
96
|
-
}
|
97
|
-
};
|
98
|
-
|
99
|
-
const onCloseModalHandler = () => {
|
100
|
-
onCloseModal && onCloseModal();
|
101
|
-
generateRnadomUser();
|
102
|
-
};
|
103
|
-
|
104
|
-
return (
|
105
|
-
<Modal
|
106
|
-
style={{ margin: 0 }}
|
107
|
-
isVisible={isVisible}
|
108
|
-
swipeDirection="down"
|
109
|
-
propagateSwipe={true}
|
110
|
-
onSwipeComplete={onCloseModalHandler}
|
111
|
-
{...ModalParams}
|
112
|
-
>
|
113
|
-
<View style={styles.container}>
|
114
|
-
<Image source={require("../../assets/logo.png")} style={styles.logo} />
|
115
|
-
<Text style={styles.title}>Cadastro de usuário</Text>
|
116
|
-
<TextInput
|
117
|
-
style={styles.input}
|
118
|
-
placeholder="CPF"
|
119
|
-
placeholderTextColor="#000"
|
120
|
-
keyboardType="numeric"
|
121
|
-
value={cpf}
|
122
|
-
onChangeText={setCpf}
|
123
|
-
/>
|
124
|
-
<TextInput
|
125
|
-
style={styles.input}
|
126
|
-
placeholder="Nome"
|
127
|
-
placeholderTextColor="#000"
|
128
|
-
value={nome}
|
129
|
-
onChangeText={setNome}
|
130
|
-
/>
|
131
|
-
<TextInput
|
132
|
-
style={styles.input}
|
133
|
-
placeholder="Digite a senha"
|
134
|
-
placeholderTextColor="#000"
|
135
|
-
secureTextEntry={true}
|
136
|
-
value={senha}
|
137
|
-
onChangeText={(text) => setSenha(text)}
|
138
|
-
/>
|
139
|
-
<TextInput
|
140
|
-
style={styles.input}
|
141
|
-
placeholderTextColor="#000"
|
142
|
-
placeholder="Digite a senha novamente"
|
143
|
-
secureTextEntry={true}
|
144
|
-
value={confirmarSenha}
|
145
|
-
onChangeText={(text) => setConfirmarSenha(text)}
|
146
|
-
/>
|
147
|
-
<TouchableOpacity style={styles.button} onPress={handleCadastro}>
|
148
|
-
<Text style={styles.buttonText}>Cadastrar</Text>
|
149
|
-
</TouchableOpacity>
|
150
|
-
</View>
|
151
|
-
</Modal>
|
152
|
-
);
|
153
|
-
};
|
154
|
-
|
155
|
-
const styles = StyleSheet.create({
|
156
|
-
container: {
|
157
|
-
flex: 1,
|
158
|
-
alignItems: "center",
|
159
|
-
justifyContent: "center",
|
160
|
-
backgroundColor: "#fff"
|
161
|
-
},
|
162
|
-
title: {
|
163
|
-
fontSize: 24,
|
164
|
-
marginBottom: 16,
|
165
|
-
color: "#00bfff"
|
166
|
-
},
|
167
|
-
input: {
|
168
|
-
width: "80%",
|
169
|
-
height: 50,
|
170
|
-
padding: 10,
|
171
|
-
borderWidth: 1,
|
172
|
-
borderColor: "#ccc",
|
173
|
-
borderRadius: 4,
|
174
|
-
marginBottom: 16,
|
175
|
-
fontSize: 16,
|
176
|
-
color: "#000"
|
177
|
-
},
|
178
|
-
button: {
|
179
|
-
width: "80%",
|
180
|
-
height: 50,
|
181
|
-
backgroundColor: "#00bfff",
|
182
|
-
borderRadius: 4,
|
183
|
-
alignItems: "center",
|
184
|
-
justifyContent: "center"
|
185
|
-
},
|
186
|
-
buttonText: {
|
187
|
-
fontSize: 16,
|
188
|
-
color: "#fff"
|
189
|
-
},
|
190
|
-
logo: {
|
191
|
-
width: 500,
|
192
|
-
height: 250,
|
193
|
-
resizeMode: "contain"
|
194
|
-
}
|
195
|
-
});
|