import Styles from "@/constants/Styles" import { apiGetDocument } from "@/lib/api" import { useAuthSession } from "@/providers/AuthProvider" import { AntDesign, Ionicons } from "@expo/vector-icons" import { useLocalSearchParams } from "expo-router" import { useEffect, useState } from "react" import { Pressable, View } from "react-native" import BorderBottomItem from "../borderBottomItem" import DrawerBottom from "../drawerBottom" import Text from "../Text" type Props = { open: boolean close: (value: boolean) => void category: 'copy' | 'move' onConfirm: (value: string) => void dataChoose: any[] } type DataProps = { id: string; category: string; name: string; extension: string; idStorage: string; path: string; createdBy: string; share: boolean; createdAt: string; updatedAt: string; } type PropsPath = { id: string; name: string; }; export default function ModalSalinMove({ open, close, category, onConfirm, dataChoose }: Props) { const [data, setData] = useState([]) const { token, decryptToken } = useAuthSession() const [path, setPath] = useState('home') const { id } = useLocalSearchParams<{ id: string }>(); const [dataJalur, setDataJalur] = useState([]) async function getData() { try { const hasil = await decryptToken(String(token?.current)) const response = await apiGetDocument({ user: hasil, path, division: id, category: 'folder' }) if (response.success) { setData(response.data) setDataJalur(response.jalur) } } catch (error) { console.error(error) } } useEffect(() => { getData() }, [path]) return ( { dataJalur.map((item, index) => ( { setPath(item.id); }} > {item.id != "home" && ( )} {item.name} )) } { data.length > 0 ? data.map((item, index) => { const found = dataChoose.some((i: any) => i.id == item.id); return ( } title={item.name} titleWeight="normal" onPress={() => { if (found) return; setPath(item.id); }} subtitle={found ? Tidak dapat memilih folder ini : ''} /> ) } ) : Tidak ada data } close(false)}> BATAL onConfirm(path)}> {category == 'copy' ? 'SALIN' : 'PINDAH'} ) }