From 92a4c06bff58a59d41cdbf78149367d9fc68b4f6 Mon Sep 17 00:00:00 2001 From: amel Date: Thu, 22 Aug 2024 11:24:06 +0800 Subject: [PATCH 1/4] upd: document Deskripsi: - pindah item No Issues --- src/app/api/document/more/route.ts | 31 +++++++++++++++++ src/app/api/document/route.ts | 23 ++++++++++--- src/module/document/lib/api_document.ts | 13 +++++++- src/module/document/lib/type_document.ts | 10 ++++++ .../document/ui/drawer_cut_documents.tsx | 33 ++++++++++++------- src/module/document/ui/drawer_more.tsx | 32 +++++++++++++++--- .../document/ui/navbar_document_division.tsx | 7 +++- 7 files changed, 126 insertions(+), 23 deletions(-) diff --git a/src/app/api/document/more/route.ts b/src/app/api/document/more/route.ts index f4a77c7..8127fab 100644 --- a/src/app/api/document/more/route.ts +++ b/src/app/api/document/more/route.ts @@ -1,6 +1,8 @@ +import { prisma } from "@/module/_global"; import { funGetUserByCookies } from "@/module/auth"; import { NextResponse } from "next/server"; + // MOVE ITEM export async function POST(request: Request) { try { @@ -9,6 +11,35 @@ export async function POST(request: Request) { return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 }); } + const { path, dataItem } = (await request.json()); + + + if (path != "home") { + const cekPath = await prisma.divisionDocumentFolderFile.count({ + where: { + isActive: true, + id: path + } + }) + + if (cekPath == 0) { + return NextResponse.json({ success: false, message: "Gagal mendapatkan path, data tidak ditemukan" }, { status: 404 }); + } + } + + for (let i = 0; i < dataItem.length; i++) { + const id = dataItem[i].id; + const cekFile = await prisma.divisionDocumentFolderFile.update({ + where: { + id: id + }, + data: { + path: path + } + }) + } + + return NextResponse.json({ success: true, message: "Berhasil memindahkan item" }, { status: 200 }); } catch (error) { console.log(error); diff --git a/src/app/api/document/route.ts b/src/app/api/document/route.ts index 331595d..0667c34 100644 --- a/src/app/api/document/route.ts +++ b/src/app/api/document/route.ts @@ -17,6 +17,7 @@ export async function GET(request: Request) { const { searchParams } = new URL(request.url); const idDivision = searchParams.get("division"); const path = searchParams.get("path"); + const category = searchParams.get("category"); const cekDivision = await prisma.division.count({ where: { @@ -43,14 +44,26 @@ export async function GET(request: Request) { } + let kondisi: any = { + isActive: true, + idDivision: String(idDivision), + path: (path == "undefined" || path == "null" || path == "" || path == null) ? "home" : path + } + + if (category == "folder") { + kondisi = { + isActive: true, + idDivision: String(idDivision), + path: (path == "undefined" || path == "null" || path == "" || path == null) ? "home" : path, + category: "FOLDER" + } + } + + const data = await prisma.divisionDocumentFolderFile.findMany({ - where: { - isActive: true, - idDivision: String(idDivision), - path: (path == "undefined" || path == "null" || path == "" || path == null) ? "home" : path - }, + where: kondisi, select: { id: true, category: true, diff --git a/src/module/document/lib/api_document.ts b/src/module/document/lib/api_document.ts index afc3e86..de4f8b5 100644 --- a/src/module/document/lib/api_document.ts +++ b/src/module/document/lib/api_document.ts @@ -1,4 +1,4 @@ -import { IFormEditItem, IFormFolder } from "./type_document"; +import { IFormEditItem, IFormFolder, IFormMoreItem } from "./type_document"; export const funGetAllDocument = async (path?: string) => { const response = await fetch(`/api/document${(path) ? path : ''}`, { next: { tags: ['document'] } }); @@ -43,4 +43,15 @@ export const funDeleteDocument = async (data: []) => { body: JSON.stringify(data), }); return await response.json().catch(() => null); +}; + +export const funMoveDocument = async (data: IFormMoreItem) => { + const response = await fetch("/api/document/more", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(data), + }); + return await response.json().catch(() => null); }; \ No newline at end of file diff --git a/src/module/document/lib/type_document.ts b/src/module/document/lib/type_document.ts index 9f2dbb0..d5b06cd 100644 --- a/src/module/document/lib/type_document.ts +++ b/src/module/document/lib/type_document.ts @@ -23,4 +23,14 @@ export interface IFormEditItem { path: string idDivision: string extension: string +} + +export interface IFormDetailMoreItem { + id: string + name: string +} + +export interface IFormMoreItem { + path: string, + dataItem: IFormDetailMoreItem[] } \ No newline at end of file diff --git a/src/module/document/ui/drawer_cut_documents.tsx b/src/module/document/ui/drawer_cut_documents.tsx index 7677160..69298ea 100644 --- a/src/module/document/ui/drawer_cut_documents.tsx +++ b/src/module/document/ui/drawer_cut_documents.tsx @@ -3,12 +3,16 @@ import { Box, Button, Divider, Flex, Grid, Group, Modal, Text, TextInput } from import React, { useState } from 'react'; import toast from 'react-hot-toast'; import { FcDocument, FcFolder, FcImageFile } from 'react-icons/fc'; -import { funCreateFolder, funGetAllDocument } from '../lib/api_document'; +import { funCreateFolder, funGetAllDocument, funMoveDocument } from '../lib/api_document'; import { useParams } from 'next/navigation'; -import { IDataDocument } from '../lib/type_document'; +import { IDataDocument, IFormDetailMoreItem } from '../lib/type_document'; import { useShallowEffect } from '@mantine/hooks'; +import { FaFolder } from 'react-icons/fa6'; +import { IoMdFolder } from 'react-icons/io'; +import { MdFolder } from 'react-icons/md'; -export default function DrawerCutDocuments() { + +export default function DrawerCutDocuments({ onChoosePath, data }: { data: IFormDetailMoreItem[], onChoosePath: (val: string) => void }) { const [opened, setOpened] = useState(false); const param = useParams<{ id: string }>() const [path, setPath] = useState('home') @@ -36,10 +40,9 @@ export default function DrawerCutDocuments() { setOpened(false) } - async function getOneData() { try { - const respon = await funGetAllDocument("?division=" + param.id + "&path=" + path); + const respon = await funGetAllDocument("?division=" + param.id + "&path=" + path + "&category=folder"); if (respon.success) { setDataDocument(respon.data); } else { @@ -66,29 +69,35 @@ export default function DrawerCutDocuments() { - + {dataDocument.map((v, i) => { + const found = data.some((i: any) => i.id == v.id) return ( - setPath(v.id)}> + { + if (!found) { + setPath(v.id) + } + }}> { - (v.category == "FOLDER") ? - : - (v.extension == "pdf" || v.extension == "csv") ? - : - + (found) ? + : + } {(v.category == "FOLDER") ? v.name : v.name + '.' + v.extension} + { + (found) && Tidak bisa memilih folder ini + } diff --git a/src/module/document/ui/drawer_more.tsx b/src/module/document/ui/drawer_more.tsx index 9db2302..6f35338 100644 --- a/src/module/document/ui/drawer_more.tsx +++ b/src/module/document/ui/drawer_more.tsx @@ -4,10 +4,36 @@ import React, { useState } from "react"; import { LuFolders, LuFolderSymlink } from "react-icons/lu"; import DrawerCutDocuments from "./drawer_cut_documents"; import DrawerCopyDocuments from "./drawer_copy_documents"; +import { IFormDetailMoreItem } from "../lib/type_document"; +import toast from "react-hot-toast"; +import { funMoveDocument } from "../lib/api_document"; +import { useHookstate } from "@hookstate/core"; +import { globalRefreshDocument } from "../lib/val_document"; -export default function DrawerMore() { +export default function DrawerMore({ data }: { data: IFormDetailMoreItem[] }) { const [isCut, setIsCut] = useState(false) const [isCopy, setIsCopy] = useState(false) + const refresh = useHookstate(globalRefreshDocument) + + + async function onMoveItem(path: string) { + try { + const res = await funMoveDocument({ path, dataItem: data }) + if (res.success) { + toast.success(res.message) + refresh.set(true) + } else { + toast.error(res.message) + } + } catch (error) { + console.log(error) + toast.error("Gagal memindahkan item, coba lagi nanti") + } + setIsCut(false) + } + + + return ( @@ -35,11 +61,9 @@ export default function DrawerMore() { setIsCut(false)} title={'Pilih Lokasi Pemindahan'} size="lg"> - + { onMoveItem(val) }} /> - - setIsCopy(false)} title={'Pilih Lokasi Salin'} size="lg"> diff --git a/src/module/document/ui/navbar_document_division.tsx b/src/module/document/ui/navbar_document_division.tsx index 0f0a319..97b5e96 100644 --- a/src/module/document/ui/navbar_document_division.tsx +++ b/src/module/document/ui/navbar_document_division.tsx @@ -166,6 +166,8 @@ export default function NavbarDocumentDivision() { function resetRefresh() { refresh.set(false) setOpen(false) + setMore(false) + handleBatal() } useShallowEffect(() => { @@ -397,8 +399,11 @@ export default function NavbarDocumentDivision() { + + + setMore(false)}> - + ); From 3d513c0d08a88be5d2ee8c4560c0c1930708a18a Mon Sep 17 00:00:00 2001 From: amel Date: Thu, 22 Aug 2024 14:30:46 +0800 Subject: [PATCH 2/4] upd : document Deskripsi: - copy item nb : baru setengah selesai, aku nyerah aja lahh nanti aja pikirin nya No Issues --- src/app/api/document/more/route.ts | 145 +++++++++++++++++- src/module/document/lib/api_document.ts | 13 +- src/module/document/lib/type_document.ts | 6 + .../document/ui/drawer_cut_documents.tsx | 10 +- src/module/document/ui/drawer_more.tsx | 29 +++- .../document/ui/navbar_document_division.tsx | 6 +- 6 files changed, 196 insertions(+), 13 deletions(-) diff --git a/src/app/api/document/more/route.ts b/src/app/api/document/more/route.ts index 8127fab..60cead8 100644 --- a/src/app/api/document/more/route.ts +++ b/src/app/api/document/more/route.ts @@ -28,13 +28,38 @@ export async function POST(request: Request) { } for (let i = 0; i < dataItem.length; i++) { + + let status = false + let numb = 1 + let name = dataItem[i].name + do { + const cekName = await prisma.divisionDocumentFolderFile.count({ + where: { + path: path, + isActive: true, + extension: dataItem[i].extension, + name + } + }) + + if (cekName > 0) { + name = dataItem[i].name + " (" + numb + ")" + numb++ + status = false + } else { + status = true + } + } while (status == false); + + const id = dataItem[i].id; - const cekFile = await prisma.divisionDocumentFolderFile.update({ + const update = await prisma.divisionDocumentFolderFile.update({ where: { - id: id + id }, data: { - path: path + path, + name } }) } @@ -45,4 +70,118 @@ export async function POST(request: Request) { console.log(error); return NextResponse.json({ success: false, message: "Gagal memindahkan item, coba lagi nanti", reason: (error as Error).message, }, { status: 500 }); } +}; + + +// COPY ITEM +export async function PUT(request: Request) { + try { + const user = await funGetUserByCookies() + if (user.id == undefined) { + return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 }); + } + + const { idDivision, path, dataItem } = (await request.json()); + + + if (path != "home") { + const cekPath = await prisma.divisionDocumentFolderFile.count({ + where: { + isActive: true, + id: path + } + }) + + if (cekPath == 0) { + return NextResponse.json({ success: false, message: "Gagal mendapatkan path, data tidak ditemukan" }, { status: 404 }); + } + } + + for (let i = 0; i < dataItem.length; i++) { + let name = dataItem[i].name; + const category = dataItem[i].category; + const extension = dataItem[i].extension; + + let status = false + let numb = 1 + do { + const cekName = await prisma.divisionDocumentFolderFile.count({ + where: { + path: path, + isActive: true, + extension, + name + } + }) + + if (cekName > 0) { + name = dataItem[i].name + " (" + numb + ")" + numb++ + status = false + } else { + status = true + } + } while (status == false); + + + const create = await prisma.divisionDocumentFolderFile.create({ + data: { + name, + path, + idDivision, + category, + extension, + createdBy: user.id + }, + select: { + id: true + } + }) + + // let newPath = create.id + // let idPath = dataItem[i].id; + // let statusCek = false + // do { + // const cekFolder = await prisma.divisionDocumentFolderFile.findMany({ + // where: { + // isActive: true, + // path: idPath + // } + // }) + + // if (cekFolder.length == 0) { + // statusCek = true + // } else { + // for (let index = 0; index < cekFolder.length; index++) { + // const addChildren = await prisma.divisionDocumentFolderFile.create({ + // data: { + // name: cekFolder[index].name, + // path: newPath, + // idDivision, + // category: cekFolder[index].category, + // extension: cekFolder[index].extension, + // createdBy: user.id + // }, + // select: { + // id: true + // } + // }) + + // newPath = create.id + // } + + + // } + + + // } while (statusCek == false); + + } + + + return NextResponse.json({ success: true, message: "Berhasil salin item" }, { status: 200 }); + } catch (error) { + console.log(error); + return NextResponse.json({ success: false, message: "Gagal salin item, coba lagi nanti", reason: (error as Error).message, }, { status: 500 }); + } }; \ No newline at end of file diff --git a/src/module/document/lib/api_document.ts b/src/module/document/lib/api_document.ts index de4f8b5..93f419f 100644 --- a/src/module/document/lib/api_document.ts +++ b/src/module/document/lib/api_document.ts @@ -1,4 +1,4 @@ -import { IFormEditItem, IFormFolder, IFormMoreItem } from "./type_document"; +import { IFormEditItem, IFormFolder, IFormMoreCopyItem, IFormMoreItem } from "./type_document"; export const funGetAllDocument = async (path?: string) => { const response = await fetch(`/api/document${(path) ? path : ''}`, { next: { tags: ['document'] } }); @@ -54,4 +54,15 @@ export const funMoveDocument = async (data: IFormMoreItem) => { body: JSON.stringify(data), }); return await response.json().catch(() => null); +}; + +export const funCopyDocument = async (data: IFormMoreCopyItem) => { + const response = await fetch("/api/document/more", { + method: "PUT", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(data), + }); + return await response.json().catch(() => null); }; \ No newline at end of file diff --git a/src/module/document/lib/type_document.ts b/src/module/document/lib/type_document.ts index d5b06cd..97dcd7d 100644 --- a/src/module/document/lib/type_document.ts +++ b/src/module/document/lib/type_document.ts @@ -33,4 +33,10 @@ export interface IFormDetailMoreItem { export interface IFormMoreItem { path: string, dataItem: IFormDetailMoreItem[] +} + +export interface IFormMoreCopyItem { + idDivision: string, + path: string, + dataItem: IDataDocument[] } \ No newline at end of file diff --git a/src/module/document/ui/drawer_cut_documents.tsx b/src/module/document/ui/drawer_cut_documents.tsx index 69298ea..07e099c 100644 --- a/src/module/document/ui/drawer_cut_documents.tsx +++ b/src/module/document/ui/drawer_cut_documents.tsx @@ -12,7 +12,7 @@ import { IoMdFolder } from 'react-icons/io'; import { MdFolder } from 'react-icons/md'; -export default function DrawerCutDocuments({ onChoosePath, data }: { data: IFormDetailMoreItem[], onChoosePath: (val: string) => void }) { +export default function DrawerCutDocuments({ category, onChoosePath, data }: { category: string, data: IFormDetailMoreItem[], onChoosePath: (val: string) => void }) { const [opened, setOpened] = useState(false); const param = useParams<{ id: string }>() const [path, setPath] = useState('home') @@ -69,7 +69,13 @@ export default function DrawerCutDocuments({ onChoosePath, data }: { data: IForm - + diff --git a/src/module/document/ui/drawer_more.tsx b/src/module/document/ui/drawer_more.tsx index 6f35338..f27ecad 100644 --- a/src/module/document/ui/drawer_more.tsx +++ b/src/module/document/ui/drawer_more.tsx @@ -4,16 +4,18 @@ import React, { useState } from "react"; import { LuFolders, LuFolderSymlink } from "react-icons/lu"; import DrawerCutDocuments from "./drawer_cut_documents"; import DrawerCopyDocuments from "./drawer_copy_documents"; -import { IFormDetailMoreItem } from "../lib/type_document"; +import { IDataDocument, IFormDetailMoreItem } from "../lib/type_document"; import toast from "react-hot-toast"; -import { funMoveDocument } from "../lib/api_document"; +import { funCopyDocument, funMoveDocument } from "../lib/api_document"; import { useHookstate } from "@hookstate/core"; import { globalRefreshDocument } from "../lib/val_document"; +import { useParams } from "next/navigation"; -export default function DrawerMore({ data }: { data: IFormDetailMoreItem[] }) { +export default function DrawerMore({ data }: { data: IDataDocument[] }) { const [isCut, setIsCut] = useState(false) const [isCopy, setIsCopy] = useState(false) const refresh = useHookstate(globalRefreshDocument) + const param = useParams<{ id: string }>() async function onMoveItem(path: string) { @@ -33,6 +35,23 @@ export default function DrawerMore({ data }: { data: IFormDetailMoreItem[] }) { } + async function onCopyItem(path: string) { + try { + const res = await funCopyDocument({ idDivision: param.id, path, dataItem: data }) + if (res.success) { + toast.success(res.message) + refresh.set(true) + } else { + toast.error(res.message) + } + } catch (error) { + console.log(error) + toast.error("Gagal memindahkan item, coba lagi nanti") + } + setIsCopy(false) + } + + return ( @@ -61,11 +80,11 @@ export default function DrawerMore({ data }: { data: IFormDetailMoreItem[] }) { setIsCut(false)} title={'Pilih Lokasi Pemindahan'} size="lg"> - { onMoveItem(val) }} /> + { onMoveItem(val) }} category="move" /> setIsCopy(false)} title={'Pilih Lokasi Salin'} size="lg"> - + { onCopyItem(val) }} category="copy" /> ); diff --git a/src/module/document/ui/navbar_document_division.tsx b/src/module/document/ui/navbar_document_division.tsx index 97b5e96..f11f688 100644 --- a/src/module/document/ui/navbar_document_division.tsx +++ b/src/module/document/ui/navbar_document_division.tsx @@ -57,7 +57,8 @@ export default function NavbarDocumentDivision() { id: dataDocument[index].id, name: dataDocument[index].name, path: dataDocument[index].path, - extension: dataDocument[index].extension + extension: dataDocument[index].extension, + category: dataDocument[index].category, } ]) } @@ -81,7 +82,8 @@ export default function NavbarDocumentDivision() { id: dataDocument[index].id, name: dataDocument[index].name, path: dataDocument[index].path, - extension: dataDocument[index].extension + extension: dataDocument[index].extension, + category: dataDocument[index].category, } setSelectedFiles((selectedFiles: any) => [...selectedFiles, newArr]) } From 364a8b1bb8f03744b4596c6358621ada1ac1b355 Mon Sep 17 00:00:00 2001 From: amel Date: Thu, 22 Aug 2024 15:11:56 +0800 Subject: [PATCH 3/4] upd: document Deskripsi: - breadcumbs No Issues --- src/app/api/document/route.ts | 32 ++++- src/module/document/lib/type_document.ts | 5 + .../document/ui/drawer_copy_documents.tsx | 110 ------------------ .../document/ui/drawer_cut_documents.tsx | 25 +++- src/module/document/ui/drawer_more.tsx | 1 - .../document/ui/navbar_document_division.tsx | 20 +++- 6 files changed, 72 insertions(+), 121 deletions(-) delete mode 100644 src/module/document/ui/drawer_copy_documents.tsx diff --git a/src/app/api/document/route.ts b/src/app/api/document/route.ts index 0667c34..6c21827 100644 --- a/src/app/api/document/route.ts +++ b/src/app/api/document/route.ts @@ -60,8 +60,6 @@ export async function GET(request: Request) { } - - const data = await prisma.divisionDocumentFolderFile.findMany({ where: kondisi, select: { @@ -91,7 +89,35 @@ export async function GET(request: Request) { })) - return NextResponse.json({ success: true, message: "Berhasil mendapatkan item", data: allData, }, { status: 200 }); + let pathNow = path + let jalur = [] + + if (path != "home" && path != "null" && path != "undefined" && path != "") { + do { + const dataPath = await prisma.divisionDocumentFolderFile.findUnique({ + where: { + id: String(pathNow) + } + }) + + if (dataPath) { + const fix = { + id: String(pathNow), + name: dataPath.name, + } + jalur.push(fix) + pathNow = dataPath.path + } else { + pathNow = "home" + } + } while (pathNow != "home"); + + } + + jalur.push({ id: 'home', name: 'home' }) + jalur = [...jalur].reverse() + + return NextResponse.json({ success: true, message: "Berhasil mendapatkan item", data: allData, jalur }, { status: 200 }); } catch (error) { console.log(error); diff --git a/src/module/document/lib/type_document.ts b/src/module/document/lib/type_document.ts index 97dcd7d..635bb18 100644 --- a/src/module/document/lib/type_document.ts +++ b/src/module/document/lib/type_document.ts @@ -16,6 +16,11 @@ export interface IFormFolder { idDivision: string } +export interface IJalurItem { + id: string + name: string +} + export interface IFormEditItem { id: string diff --git a/src/module/document/ui/drawer_copy_documents.tsx b/src/module/document/ui/drawer_copy_documents.tsx deleted file mode 100644 index 0eea0a8..0000000 --- a/src/module/document/ui/drawer_copy_documents.tsx +++ /dev/null @@ -1,110 +0,0 @@ -import { WARNA } from '@/module/_global'; -import { Box, Button, Divider, Flex, Grid, Group, Modal, Text, TextInput } from '@mantine/core'; -import React, { useState } from 'react'; -import toast from 'react-hot-toast'; -import { FcFolder } from 'react-icons/fc'; -const dataDocuments = [ - { - id: 1, - name: 'Administrasi', - date: '18/06/2024 14.00 PM', - icon: - }, - { - id: 2, - name: 'Administrasi', - date: '18/06/2024 14.00 PM', - icon: - }, - { - id: 3, - name: 'Administrasi', - date: '18/06/2024 14.00 PM', - icon: - }, -] - -export default function DrawerCopyDocuments() { - const [opened, setOpened] = useState(false); - function onCreate(val: boolean) { - if (val) { - toast.success("Sukses! Membuat Folder"); - } - setOpened(false) - } - return ( - - - - - - - - - - - - - {dataDocuments.map((v, i) => { - return ( - - - - - - - {v.icon} - - - {v.name} - {v.date} - - - - - - - - ) - })} - - setOpened(false)} centered withCloseButton={false}> - - Buat Folder - - - - - - - - - - - - - - - ); -} diff --git a/src/module/document/ui/drawer_cut_documents.tsx b/src/module/document/ui/drawer_cut_documents.tsx index 07e099c..35eb093 100644 --- a/src/module/document/ui/drawer_cut_documents.tsx +++ b/src/module/document/ui/drawer_cut_documents.tsx @@ -1,15 +1,15 @@ import { WARNA } from '@/module/_global'; -import { Box, Button, Divider, Flex, Grid, Group, Modal, Text, TextInput } from '@mantine/core'; +import { Box, Breadcrumbs, Button, Divider, Flex, Grid, Group, Modal, Text, TextInput } from '@mantine/core'; import React, { useState } from 'react'; import toast from 'react-hot-toast'; -import { FcDocument, FcFolder, FcImageFile } from 'react-icons/fc'; +import { FcFolder } from 'react-icons/fc'; import { funCreateFolder, funGetAllDocument, funMoveDocument } from '../lib/api_document'; import { useParams } from 'next/navigation'; -import { IDataDocument, IFormDetailMoreItem } from '../lib/type_document'; +import { IDataDocument, IFormDetailMoreItem, IJalurItem } from '../lib/type_document'; import { useShallowEffect } from '@mantine/hooks'; -import { FaFolder } from 'react-icons/fa6'; -import { IoMdFolder } from 'react-icons/io'; import { MdFolder } from 'react-icons/md'; +import router from 'next/router'; +import { GoChevronRight } from 'react-icons/go'; export default function DrawerCutDocuments({ category, onChoosePath, data }: { category: string, data: IFormDetailMoreItem[], onChoosePath: (val: string) => void }) { @@ -17,6 +17,7 @@ export default function DrawerCutDocuments({ category, onChoosePath, data }: { c const param = useParams<{ id: string }>() const [path, setPath] = useState('home') const [dataDocument, setDataDocument] = useState([]) + const [dataJalur, setDataJalur] = useState([]) const [valName, setValName] = useState('') @@ -45,6 +46,7 @@ export default function DrawerCutDocuments({ category, onChoosePath, data }: { c const respon = await funGetAllDocument("?division=" + param.id + "&path=" + path + "&category=folder"); if (respon.success) { setDataDocument(respon.data); + setDataJalur(respon.jalur); } else { toast.error(respon.message); } @@ -80,6 +82,19 @@ export default function DrawerCutDocuments({ category, onChoosePath, data }: { c + + } separatorMargin="md" mt="xs"> + { + dataJalur.map((v, i) => { + return ( + setPath(v.id)} key={i} style={{ cursor: 'pointer' }}> + {v.name} + + ) + }) + } + + {dataDocument.map((v, i) => { const found = data.some((i: any) => i.id == v.id) return ( diff --git a/src/module/document/ui/drawer_more.tsx b/src/module/document/ui/drawer_more.tsx index f27ecad..e378ac1 100644 --- a/src/module/document/ui/drawer_more.tsx +++ b/src/module/document/ui/drawer_more.tsx @@ -3,7 +3,6 @@ import { Box, Flex, Group, SimpleGrid, Stack, Text } from "@mantine/core"; import React, { useState } from "react"; import { LuFolders, LuFolderSymlink } from "react-icons/lu"; import DrawerCutDocuments from "./drawer_cut_documents"; -import DrawerCopyDocuments from "./drawer_copy_documents"; import { IDataDocument, IFormDetailMoreItem } from "../lib/type_document"; import toast from "react-hot-toast"; import { funCopyDocument, funMoveDocument } from "../lib/api_document"; diff --git a/src/module/document/ui/navbar_document_division.tsx b/src/module/document/ui/navbar_document_division.tsx index f11f688..ddf16d7 100644 --- a/src/module/document/ui/navbar_document_division.tsx +++ b/src/module/document/ui/navbar_document_division.tsx @@ -1,6 +1,6 @@ 'use client' import { LayoutDrawer, LayoutNavbarNew, WARNA } from '@/module/_global'; -import { ActionIcon, Box, Button, Checkbox, Divider, Flex, Grid, Group, Modal, Select, SimpleGrid, Text, TextInput } from '@mantine/core'; +import { ActionIcon, Anchor, Box, Breadcrumbs, Button, Checkbox, Divider, Flex, Grid, Group, Modal, Select, SimpleGrid, Text, TextInput } from '@mantine/core'; import React, { useState } from 'react'; import { HiMenu } from 'react-icons/hi'; import { FcDocument, FcFolder, FcImageFile } from 'react-icons/fc'; @@ -17,10 +17,11 @@ import DrawerMore from './drawer_more'; import { funGetDivisionById } from '@/module/division_new'; import { useShallowEffect } from '@mantine/hooks'; import { funDeleteDocument, funGetAllDocument, funRenameDocument } from '../lib/api_document'; -import { IDataDocument } from '../lib/type_document'; +import { IDataDocument, IJalurItem } from '../lib/type_document'; import { useHookstate } from '@hookstate/core'; import { globalRefreshDocument } from '../lib/val_document'; import { RiListCheck } from 'react-icons/ri'; +import { GoChevronRight } from 'react-icons/go'; export default function NavbarDocumentDivision() { const router = useRouter() @@ -34,6 +35,7 @@ export default function NavbarDocumentDivision() { const searchParams = useSearchParams() const path = searchParams.get('path') const [dataDocument, setDataDocument] = useState([]) + const [dataJalur, setDataJalur] = useState([]) const refresh = useHookstate(globalRefreshDocument) const [selectedFiles, setSelectedFiles] = useState([]) const [selectAll, setSelectAll] = useState(false) @@ -148,6 +150,7 @@ export default function NavbarDocumentDivision() { const respon = await funGetAllDocument("?division=" + param.id + "&path=" + path); if (respon.success) { setDataDocument(respon.data); + setDataJalur(respon.jalur); } else { toast.error(respon.message); } @@ -262,6 +265,19 @@ export default function NavbarDocumentDivision() { + + } separatorMargin="md" mt="xs"> + { + dataJalur.map((v, i) => { + return ( + router.push('?path=' + v.id)} key={i} style={{ cursor: 'pointer' }}> + {v.name} + + ) + }) + } + + {dataDocument.map((v, i) => { const isSelected = selectedFiles.some((i: any) => i?.id == v.id); return ( From b4697c8b3257a2574e55cc551db73239c1bd4cf1 Mon Sep 17 00:00:00 2001 From: amel Date: Thu, 22 Aug 2024 15:27:21 +0800 Subject: [PATCH 4/4] upd: document Deskripsi: - klik saat select No Issues --- src/module/document/ui/navbar_document_division.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/document/ui/navbar_document_division.tsx b/src/module/document/ui/navbar_document_division.tsx index ddf16d7..cae6f92 100644 --- a/src/module/document/ui/navbar_document_division.tsx +++ b/src/module/document/ui/navbar_document_division.tsx @@ -286,7 +286,7 @@ export default function NavbarDocumentDivision() { { - if (v.category == "FOLDER") + if (v.category == "FOLDER" && selectedFiles.length == 0 && !dariSelectAll) router.push('?path=' + v.id) }} >