import { ButtonCustom, SelectCustom, StackCustom, TextInputCustom, ViewWrapper, } from "@/components"; import BoxButtonOnFooter from "@/components/Box/BoxButtonOnFooter"; import { apiProfile, apiUpdateProfile } from "@/service/api-client/api-profile"; import { IProfile } from "@/types/Type-Profile"; import { router, useLocalSearchParams } from "expo-router"; import { useEffect, useState } from "react"; import Toast from "react-native-toast-message"; export default function ProfileEdit() { const { id } = useLocalSearchParams(); const [data, setData] = useState(); const [isLoading, setIsLoading] = useState(false); const options = [ { label: "Laki-laki", value: "laki-laki" }, { label: "Perempuan", value: "perempuan" }, ]; useEffect(() => { onLoadData(id as string); }, [id]); async function onLoadData(id: string) { try { const response = await apiProfile({ id }); setData(response.data); } catch (error) { console.log("error get profile >>", error); } } const handleUpdate = async () => { try { setIsLoading(true); const response = await apiUpdateProfile({ id: id as string, data, category: "profile", }); if (!response.success) { Toast.show({ type: "info", text1: "Info", text2: response.message, }); return; } Toast.show({ type: "success", text1: "Sukses", text2: "Profile berhasil diupdate", }); return router.back(); } catch (error) { console.log("error update profile >>", error); } finally { setIsLoading(false); } }; return ( Update } > { setData({ ...data, name: text }); }} required /> { setData({ ...data, email: text }); }} required /> { setData({ ...data, alamat: text }); }} required /> { setData({ ...(data as any), jenisKelamin: value }); }} /> ); }