import { AvatarCustom, ButtonCenteredOnly, ButtonCustom, SelectCustom, Spacing, StackCustom, TextInputCustom, ViewWrapper, } from "@/components"; import BoxButtonOnFooter from "@/components/Box/BoxButtonOnFooter"; import InformationBox from "@/components/Box/InformationBox"; import LandscapeFrameUploaded from "@/components/Image/LandscapeFrameUploaded"; import { useAuth } from "@/hooks/use-auth"; import { apiCreateProfile } from "@/service/api-client/api-profile"; import { router, useFocusEffect } from "expo-router"; import { useCallback, useState } from "react"; import { View } from "react-native"; import Toast from "react-native-toast-message"; export default function CreateProfile() { const { user } = useAuth(); const [isLoading, setIsLoading] = useState(false); const [data, setData] = useState({ id: user?.id, name: "", email: "", alamat: "", jenisKelamin: "", }); useFocusEffect( useCallback(() => { Toast.show({ type: "info", text1: "Lengkapi Profile Anda", text2: "Untuk menjelajahi fitur-fitur yang ada", }); }, []) ); const handlerSave = async () => { if (!data.name || !data.email || !data.alamat || !data.jenisKelamin) { Toast.show({ type: "info", text1: "Info", text2: "Harap isi semua data", }); return; } try { setIsLoading(true); const response = await apiCreateProfile(data); if (response.status === 400) { Toast.show({ type: "error", text1: "Email sudah terdaftar", text2: "Gunakan email lain", }); return; } Toast.show({ type: "success", text1: "Sukses", text2: "Profile berhasil dibuat", }); router.push("/(application)/(user)/home"); } catch (error) { console.log("error create profile >>", error); } finally { setIsLoading(false); } }; const footerComponent = ( Simpan ); return ( router.navigate(`/take-picture/${user?.id}`)} > Upload router.navigate(`/take-picture/${user?.id}`)} > Upload setData({ ...data, name: text })} /> setData({ ...data, email: text })} /> setData({ ...data, alamat: text })} /> setData({ ...(data as any), jenisKelamin: value }) } /> ); }