forked from fga-eps-mds/2024-1-GEROcuidado-Front
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from fga-eps-mds/feat/esqueci-minha-senha
Feat/esqueci minha senha
- Loading branch information
Showing
4 changed files
with
174 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,47 @@ | ||
import React from "react"; | ||
import { ActivityIndicator, Pressable, StyleSheet, Text } from "react-native"; | ||
import { ActivityIndicator, StyleSheet, Text } from "react-native"; | ||
import { router } from "expo-router"; | ||
import { View } from 'react-native'; | ||
|
||
interface Props { | ||
title: string; | ||
callbackFn: () => unknown; | ||
backgroundColor?: string; | ||
showLoading?: boolean; | ||
} | ||
|
||
export default function ForgetButton({ | ||
title, | ||
callbackFn, | ||
backgroundColor, | ||
showLoading, | ||
}: Readonly<Props>) { | ||
const background = backgroundColor ?? "#2CCDB5"; | ||
|
||
const handlePress = () => { | ||
router.push("/private/pages/esqueciSenha"); | ||
}; | ||
|
||
return ( | ||
<Pressable | ||
testID="customButtonId" | ||
style={styles(background).button} | ||
onPress={() => callbackFn()} | ||
> | ||
<View> | ||
{showLoading ? ( | ||
<ActivityIndicator size="small" color="#fff" /> | ||
<ActivityIndicator size="small" color="#0000ff" /> | ||
) : ( | ||
<Text style={styles(background).buttonText}>{title}</Text> | ||
<Text | ||
style={styles.linkText} | ||
onPress={handlePress} | ||
> | ||
{title} | ||
</Text> | ||
)} | ||
</Pressable> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = (backgroundColor: string) => | ||
StyleSheet.create({ | ||
buttonText: { | ||
fontSize: 13, | ||
color: "white", | ||
fontWeight: "300", | ||
}, | ||
button: { | ||
width: "30%", | ||
maxWidth: 150, | ||
paddingVertical: 10, | ||
paddingHorizontal: 10, | ||
backgroundColor, | ||
alignItems: "center", | ||
borderRadius: 15, | ||
const styles = StyleSheet.create({ | ||
linkText: { | ||
width: "40%", | ||
color: "#2CCDB5", | ||
maxWidth: 300, | ||
textDecorationLine: "underline", | ||
paddingVertical: 12, | ||
paddingHorizontal: 18, | ||
textAlign: "left", | ||
borderRadius: 20, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import React, { useState } from "react"; | ||
import { forgotPassword } from "../../services/user.service"; | ||
import { Alert, Text, View, TextInput, StyleSheet, TouchableOpacity } from "react-native"; | ||
import axios from 'axios'; | ||
//import BackButton from "/components/BackButton.tsx"; Não consigo achar esse caminho, preciso fazer rodar... (é o botão q volta pra outra pag) | ||
|
||
export default function EsqueciSenha() { | ||
const API_URL = process.env.EXPO_PUBLIC_API_URL; | ||
const API_PORT = process.env.EXPO_PUBLIC_API_USUARIO_PORT; | ||
const BASE_URL = `${API_URL}:${API_PORT}/api/usuario/esqueci-senha`; | ||
const [email, setEmail] = useState(""); | ||
|
||
const handleRecuperarSenha = async () => { | ||
if (!email) { | ||
Alert.alert("Erro", "Por favor, insira um email válido."); | ||
return; | ||
} | ||
try { | ||
const response = await forgotPassword(email); | ||
console.log("E-mail de recuperação enviado:", response); | ||
} catch (error) { | ||
console.error("Erro ao solicitar recuperação de senha:", error.message); | ||
} | ||
}; | ||
return ( | ||
|
||
<View style={styles.container}> | ||
{/* Logo deveria estar aqui, mas não consegui encaixá-la */} | ||
|
||
<Text style={styles.title}>Esqueceu sua senha? </Text> | ||
<Text style={styles.subtitle}>Calma, a GERO te ajuda!! </Text> | ||
|
||
<View style={styles.inputContainer}> | ||
<TextInput | ||
style={styles.input} | ||
placeholder="Email" | ||
value={email} | ||
onChangeText={setEmail} | ||
keyboardType="email-address" | ||
placeholderTextColor="black" | ||
/> | ||
</View> | ||
|
||
<TouchableOpacity style={styles.button} onPress={handleRecuperarSenha}> | ||
<Text style={styles.buttonText}>Recuperar senha</Text> | ||
</TouchableOpacity> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: "center", | ||
alignItems: "center", | ||
backgroundColor: "#FFF", | ||
padding: 16, | ||
}, | ||
logo: { | ||
width: 280, | ||
height: 90, | ||
marginBottom: 40, | ||
}, | ||
title: { | ||
fontSize: 28, | ||
fontWeight: "300", | ||
textAlign: "center", | ||
marginBottom: 19, | ||
}, | ||
subtitle: { | ||
fontSize: 18, | ||
fontWeight: "300", | ||
textAlign: "center", | ||
marginBottom: 10, | ||
}, | ||
inputContainer: { | ||
width: "90%", | ||
maxWidth: 400, | ||
borderBottomWidth: 1, | ||
borderBottomColor: "#CCC", | ||
marginBottom: 20, | ||
}, | ||
input: { | ||
fontSize: 16, | ||
paddingVertical: 8, | ||
paddingHorizontal: 10, | ||
color: "#333", | ||
width: "100%", | ||
}, | ||
button: { | ||
width: "90%", | ||
maxWidth: 200, | ||
backgroundColor: "#2CCDB5", | ||
paddingVertical: 12, | ||
borderRadius: 8, | ||
alignItems: "center", | ||
}, | ||
buttonText: { | ||
color: "#FFF", | ||
fontSize: 16, | ||
fontWeight: "600", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters