import React, { useState } from "react"; import { View, Text, StyleSheet, Alert, ActivityIndicator, ScrollView, KeyboardAvoidingView, Platform, SafeAreaView, TouchableOpacity, } from "react-native"; import * as Keychain from "react-native-keychain"; import { CustomInput, CustomButton } from "../../components/common/Custom"; import colors from "../../components/colors"; import { useNavigation } from "@react-navigation/native"; import AppView from "../../components/AppView"; import Ionicons from "@react-native-vector-icons/ionicons"; const BecomeOrg = () => { const navigation = useNavigation(); const [bankAccountNumber, setBankAccountNumber] = useState(""); const [bankName, setBankName] = useState(""); const [branchCode, setBranchCode] = useState(""); const [loading, setLoading] = useState(false); const handleSubmit = async () => { if (!bankAccountNumber || !bankName || !branchCode) { Alert.alert("Error", "Please fill all fields"); return; } try { setLoading(true); const credentials = await Keychain.getGenericPassword(); if (!credentials) { Alert.alert("Error", "You are not logged in"); return; } const token = credentials.password; const response = await fetch( "https://api.godemo.in/FundCollect/api/organizer/registration/apply", { method: "POST", headers: { Accept: "*/*", "Content-Type": "application/json", Authorization: `Bearer ${token}`, }, body: JSON.stringify({ bankAccountNumber, bankName, branchCode, }), } ); const result = await response.json(); if (result.status === "success") { Alert.alert("Success", "Organizer registration applied successfully"); setBankAccountNumber(""); setBankName(""); setBranchCode(""); navigation.navigate("Home" as never); } else { Alert.alert("Error", result.message || "Failed to apply"); } } catch (error) { console.error("❌ Registration error:", error); Alert.alert("Error", "Something went wrong"); } finally { setLoading(false); } }; return ( navigation.replace("Home" as never)} > User Profile Organizer Registration {loading && ( )} ); }; export default BecomeOrg; const styles = StyleSheet.create({ container: { flexGrow: 1, padding: 20, justifyContent: "center", }, title: { fontSize: 22, fontWeight: "700", marginBottom: 20, textAlign: "center", color: colors.textDark, }, header: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", padding: 16, borderBottomLeftRadius: 20, borderBottomRightRadius: 20, }, headerTitle: { fontSize: 22, fontWeight: "700", color: "#000" }, });