From 77cd07ad7a9d318df90ad5f9483e224ac1683375 Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Fri, 29 Aug 2025 16:52:08 +0800 Subject: [PATCH] upd: upd new folder Deskripsi: - bisa membuat folder baru saat salin atau pindah file pada fitur dokumen divisi No Issues --- components/document/modalNewFolder.tsx | 65 ++++++++++++++++++++++++++ components/document/modalSalinMove.tsx | 5 +- 2 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 components/document/modalNewFolder.tsx diff --git a/components/document/modalNewFolder.tsx b/components/document/modalNewFolder.tsx new file mode 100644 index 0000000..43927ac --- /dev/null +++ b/components/document/modalNewFolder.tsx @@ -0,0 +1,65 @@ +import Styles from "@/constants/Styles"; +import { apiCreateFolderDocument } from "@/lib/api"; +import { useAuthSession } from "@/providers/AuthProvider"; +import { useLocalSearchParams } from "expo-router"; +import { useState } from "react"; +import { Pressable, View } from "react-native"; +import Toast from "react-native-toast-message"; +import Text from "../Text"; +import { InputForm } from "../inputForm"; +import ModalFloat from "../modalFloat"; + +export function ModalNewFolder({ path, onCreated }: { path: string, onCreated: () => void }) { + const { token, decryptToken } = useAuthSession() + const [newFolder, setNewFolder] = useState(false) + const [name, setName] = useState("") + const [loadingFolder, setLoadingFolder] = useState(false) + const { id } = useLocalSearchParams<{ id: string }>(); + + + async function handleCreateFolder() { + try { + setLoadingFolder(true) + const hasil = await decryptToken(String(token?.current)) + const response = await apiCreateFolderDocument({ data: { user: hasil, name, path, idDivision: id } }) + if (response.success) { + Toast.show({ type: 'small', text1: 'Berhasil membuat folder baru', }) + } else { + Toast.show({ type: 'small', text1: response.message, }) + } + } catch (error) { + console.error(error) + Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } finally { + onCreated() + setLoadingFolder(false) + setNewFolder(false) + } + } + + return ( + <> + setNewFolder(true)}> + FOLDER BARU + + + { setNewFolder(false) }} + disableSubmit={name == "" || loadingFolder} + onSubmit={() => { handleCreateFolder() }} + > + + { setName(value) }} + /> + + + + ) +} \ No newline at end of file diff --git a/components/document/modalSalinMove.tsx b/components/document/modalSalinMove.tsx index 670eb8e..01a4e96 100644 --- a/components/document/modalSalinMove.tsx +++ b/components/document/modalSalinMove.tsx @@ -8,6 +8,7 @@ import { Pressable, View } from "react-native" import BorderBottomItem from "../borderBottomItem" import DrawerBottom from "../drawerBottom" import Text from "../Text" +import { ModalNewFolder } from "./modalNewFolder" type Props = { open: boolean @@ -106,9 +107,7 @@ export default function ModalSalinMove({ open, close, category, onConfirm, dataC } - close(false)}> - BATAL - + getData()} /> onConfirm(path)}> {category == 'copy' ? 'SALIN' : 'PINDAH'}