diff --git a/components/document/headerDocument.tsx b/components/document/headerDocument.tsx
index 90d42da..32441e1 100644
--- a/components/document/headerDocument.tsx
+++ b/components/document/headerDocument.tsx
@@ -6,7 +6,7 @@ import { MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
import * as DocumentPicker from "expo-document-picker";
import { useLocalSearchParams } from "expo-router";
import { useState } from "react";
-import { View } from "react-native";
+import { ActivityIndicator, View } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
import ButtonMenuHeader from "../buttonMenuHeader";
@@ -46,26 +46,31 @@ export default function HeaderRightDocument({ path }: { path: string }) {
const pickDocumentAsync = async () => {
let result = await DocumentPicker.getDocumentAsync({
type: ["*/*"],
- multiple: false,
+ multiple: true,
});
if (!result.canceled) {
- if (result.assets?.[0].uri) {
- handleUploadFile(result.assets?.[0])
+ let file: any[] = []
+ for (let i = 0; i < result.assets?.length; i++) {
+ if (result.assets?.[i].uri) {
+ file.push(result.assets?.[i])
+ }
}
+ handleUploadFile(file)
}
};
- async function handleUploadFile(file: any) {
+ async function handleUploadFile(file: any[]) {
try {
setLoading(true)
const hasil = await decryptToken(String(token?.current))
const fd = new FormData()
- fd.append("file", {
- uri: file.uri,
- type: "application/octet-stream",
- name: file.name,
- } as any);
-
+ for (let i = 0; i < file.length; i++) {
+ fd.append(`file${i}`, {
+ uri: file[i].uri,
+ type: "application/octet-stream",
+ name: file[i].name,
+ } as any);
+ }
fd.append(
"data",
JSON.stringify({
@@ -73,7 +78,7 @@ export default function HeaderRightDocument({ path }: { path: string }) {
idDivision: id,
user: hasil,
})
- );
+ )
const response = await apiUploadFileDocument({ data: fd })
if (response.success) {
@@ -106,28 +111,37 @@ export default function HeaderRightDocument({ path }: { path: string }) {
title="Menu"
>
-
- }
- title="Tambah Folder"
- onPress={() => {
- setVisible(false);
- setTimeout(() => {
- setNewFolder(true);
- }, 600);
- }}
- />
+ {
+ loading ?
+
+
+
+ :
+ <>
+
+ }
+ title="Tambah Folder"
+ onPress={() => {
+ setVisible(false);
+ setTimeout(() => {
+ setNewFolder(true);
+ }, 600);
+ }}
+ />
- }
- title="Upload File"
- onPress={pickDocumentAsync}
- />
+ }
+ title="Upload File"
+ onPress={pickDocumentAsync}
+ />
+ >
+ }