folder control
This commit is contained in:
@@ -6,13 +6,8 @@ import {
|
|||||||
DropdownItem,
|
DropdownItem,
|
||||||
} from "@nextui-org/react";
|
} from "@nextui-org/react";
|
||||||
import { MoreVertical } from "lucide-react";
|
import { MoreVertical } from "lucide-react";
|
||||||
import { FolderType } from "./layout";
|
|
||||||
|
|
||||||
export default function FolderEditMenu(
|
export default function FolderEditMenu({ folder, onEditClick, onDeleteClick }) {
|
||||||
folder: FolderType,
|
|
||||||
onEditClick: (folder: FolderType) => void,
|
|
||||||
onDeleteClick: (folderId: number) => void
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
<Dropdown>
|
<Dropdown>
|
||||||
<DropdownTrigger>
|
<DropdownTrigger>
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ export default function FoldersLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
params: { projectId: number };
|
params: { projectId: number };
|
||||||
}) {
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
const [folders, setFolders] = useState([]);
|
const [folders, setFolders] = useState([]);
|
||||||
const [selectedFolder, setSelectedFolder] = useState<FolderType>({});
|
const [selectedFolder, setSelectedFolder] = useState<FolderType>({});
|
||||||
|
|
||||||
@@ -205,6 +206,11 @@ export default function FoldersLayout({
|
|||||||
setIsFolderDialogOpen(true);
|
setIsFolderDialogOpen(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onDeleteClick = async (folderId: number) => {
|
||||||
|
await deleteFolder(folderId);
|
||||||
|
router.push(`/projects/${params.projectId}/folders`);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchDataEffect() {
|
async function fetchDataEffect() {
|
||||||
try {
|
try {
|
||||||
@@ -223,7 +229,6 @@ export default function FoldersLayout({
|
|||||||
fetchDataEffect();
|
fetchDataEffect();
|
||||||
}, [folderId]);
|
}, [folderId]);
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
return (
|
return (
|
||||||
<div className="flex w-full">
|
<div className="flex w-full">
|
||||||
<div className="w-64 min-h-screen border-r-1">
|
<div className="w-64 min-h-screen border-r-1">
|
||||||
@@ -253,10 +258,9 @@ export default function FoldersLayout({
|
|||||||
}
|
}
|
||||||
endContent={
|
endContent={
|
||||||
<FolderEditMenu
|
<FolderEditMenu
|
||||||
key={index}
|
|
||||||
folder={folder}
|
folder={folder}
|
||||||
onEditClick={onEditClick}
|
onEditClick={onEditClick}
|
||||||
onDeleteClick={() => console.log("TODO")}
|
onDeleteClick={onDeleteClick}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user