TIF_NGANJUK_E41212433/screens/password/VerifyCode.js

141 lines
3.5 KiB
JavaScript

import React, { useState } from "react";
import {
View,
Text,
TextInput,
TouchableOpacity,
StyleSheet,
Alert,
} from "react-native";
import { Ionicons } from "@expo/vector-icons"; // Import Ionicons untuk ikon
export default function VerifyCode({ navigation }) {
const [verificationCode, setVerificationCode] = useState(""); // Input untuk kode verifikasi
const handleSubmit = async () => {
if (!verificationCode) {
Alert.alert("Peringatan", "Kode verifikasi tidak boleh kosong!");
return;
}
// Validasi kode verifikasi (ini hanya contoh, sesuaikan dengan backend)
if (verificationCode !== "123456") {
// Asumsikan kode valid adalah "123456"
Alert.alert("Peringatan", "Kode verifikasi salah!");
return;
}
try {
// Lanjutkan proses setelah verifikasi kode (misalnya, reset password)
navigation.navigate("ResetPassword"); // Ganti dengan halaman yang sesuai, seperti halaman reset password
} catch (error) {
Alert.alert("Error", "Terjadi kesalahan saat memverifikasi kode.");
}
};
return (
<View style={styles.container}>
{/* Header dengan tombol kembali */}
<View style={styles.header}>
<TouchableOpacity
onPress={() => navigation.goBack()}
style={styles.backButton}
>
<Ionicons name="arrow-back" size={24} color="#000" />
</TouchableOpacity>
<View style={styles.headerTextContainer}>
<Text style={styles.title}>KODE VERIFIKASI</Text>
</View>
</View>
{/* Subtitle */}
<Text style={styles.subtitle}>
Masukkan kode verifikasi yang telah dikirim
</Text>
{/* Input untuk kode verifikasi */}
<TextInput
style={styles.input}
placeholder="Kode Verifikasi"
value={verificationCode}
onChangeText={setVerificationCode}
keyboardType="numeric"
maxLength={6} // Asumsi kode verifikasi 6 digit
/>
{/* Tombol Verifikasi */}
<TouchableOpacity
style={styles.button}
// onPress={handleSubmit}
onPress={() => navigation.navigate("notifikasisukses")}
>
<Text style={styles.buttonText}>KIRIM</Text>
</TouchableOpacity>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "flex-start",
alignItems: "center",
backgroundColor: "#FFF",
padding: 0,
},
header: {
flexDirection: "row",
alignItems: "center",
justifyContent: "flex-start",
width: "100%",
padding: 10,
backgroundColor: "#FFF",
borderBottomWidth: 0,
borderBottomColor: "#FFFS",
marginTop: 30,
},
backButton: {
padding: 10,
},
headerTextContainer: {
flex: 1,
alignItems: "flex-start",
justifyContent: "center",
},
title: {
fontSize: 20,
fontWeight: "bold",
color: "#000",
},
subtitle: {
fontSize: 16,
marginVertical: 20,
color: "#8e8e8e",
textAlign: "center",
paddingHorizontal: 10,
},
input: {
width: "90%",
padding: 15,
marginBottom: 20,
borderWidth: 1,
borderRadius: 15,
borderColor: "#BBBBBB",
fontSize: 16,
textAlign: "center",
backgroundColor: "#f9f9f9", // Light background for the input
},
button: {
width: "90%",
padding: 15,
backgroundColor: "#2D572C", // Green color for submit button
alignItems: "center",
borderRadius: 15,
},
buttonText: {
color: "#fff",
fontSize: 16,
fontWeight: "bold",
},
});