import Styles from "@/constants/Styles"; import { apiGetProjectOne } from "@/lib/api"; import { useAuthSession } from "@/providers/AuthProvider"; import { MaterialCommunityIcons } from "@expo/vector-icons"; import { router, useLocalSearchParams } from "expo-router"; import { useEffect, useState } from "react"; import { Text, ToastAndroid, View } from "react-native"; import AlertKonfirmasi from "../alertKonfirmasi"; import BorderBottomItem from "../borderBottomItem"; import DrawerBottom from "../drawerBottom"; import ImageUser from "../imageNew"; import MenuItemRow from "../menuItemRow"; type Props = { id: string; idUser: string; name: string; email: string; img: string; position: string; }; export default function SectionMember() { const [isModal, setModal] = useState(false); const { token, decryptToken } = useAuthSession(); const { id } = useLocalSearchParams<{ id: string }>(); const [data, setData] = useState([]); async function handleLoad() { try { const hasil = await decryptToken(String(token?.current)); const response = await apiGetProjectOne({ user: hasil, cat: "member", id: id, }); setData(response.data); } catch (error) { console.error(error); } } useEffect(() => { handleLoad(); }, []); return ( <> Anggota Total {data.length} Anggota { data.length > 0 ? data.map((item, index) => { return ( } title={item.name} subtitle={item.position} rightTopInfo="Anggota" onPress={() => { setModal(true); }} /> ); }) : Tidak ada anggota } } title="Lihat Profil" onPress={() => { setModal(false); router.push("/member/123"); }} /> } title="Keluarkan" onPress={() => { AlertKonfirmasi({ title: "Konfirmasi", desc: "Apakah Anda yakin ingin mengeluarkan anggota?", onPress: () => { setModal(false); ToastAndroid.show( "Berhasil mengeluarkan anggota", ToastAndroid.SHORT ); }, }); }} /> ); }