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 InputContact({ route, navigation }) { const { method } = route.params; // Mendapatkan 'method' yang diteruskan dari halaman sebelumnya const [contactInfo, setContactInfo] = useState(""); // Input untuk nomor WhatsApp atau email const handleSubmit = async () => { // Validasi input berdasarkan metode if (!contactInfo) { Alert.alert( "Peringatan", "Nomor WhatsApp atau Email tidak boleh kosong!" ); return; } if (method === "whatsapp" && !/^\d+$/.test(contactInfo)) { Alert.alert("Peringatan", "Masukkan nomor WhatsApp yang valid!"); return; } if (method === "email" && !/\S+@\S+\.\S+/.test(contactInfo)) { Alert.alert("Peringatan", "Masukkan email yang valid!"); return; } try { // Kirim nomor WhatsApp atau email ke API untuk verifikasi (sesuaikan dengan backend) // await sendContactInfo(contactInfo, method); // Navigasi ke halaman verifikasi kode navigation.navigate("VerifyCode"); // Pastikan halaman "VerifyCode" sudah terdaftar dalam navigator } catch (error) { Alert.alert("Error", "Terjadi kesalahan saat mengirim data."); } }; return ( {/* Header dengan tombol kembali */} navigation.goBack()} style={styles.backButton} > LUPA KATA SANDI Masukkan {method === "whatsapp" ? "Nomor WhatsApp" : "Email"} navigation.navigate("VerifyCode")} > KIRIM KODE ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: "flex-start", alignItems: "center", backgroundColor: "#FFF", }, header: { flexDirection: "row", alignItems: "center", justifyContent: "flex-start", width: "100%", padding: 10, backgroundColor: "#FFF", borderBottomWidth: 0, borderBottomColor: "#e0e0e0", 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", }, input: { width: "90%", padding: 15, marginBottom: 20, borderWidth: 1, borderRadius: 15, borderColor: "#8e8e8e", fontSize: 16, }, button: { width: "90%", padding: 15, backgroundColor: "#2D572C", // Warna hijau untuk tombol kirim alignItems: "center", borderRadius: 15, }, buttonText: { color: "#fff", fontSize: 16, fontWeight: "bold", }, });