2025-12-11 22:20:23 +00:00
|
|
|
import { SetStateAction } from "react";
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
import FolderPlusIcon from "@assets/fontawesome/svg/folder-plus.svg?react";
|
|
|
|
|
// @ts-ignore
|
2025-12-18 18:12:23 +00:00
|
|
|
import TagsIcon from "@assets/fontawesome/svg/tags.svg?react";
|
|
|
|
|
// @ts-ignore
|
2025-12-11 22:20:23 +00:00
|
|
|
import FileCirclePlusIcon from "@assets/fontawesome/svg/file-circle-plus.svg?react";
|
2025-12-18 18:12:23 +00:00
|
|
|
import { useUIStore } from "@/stores/uiStore";
|
2025-12-22 15:23:40 +00:00
|
|
|
import { useCreateNote } from "@/hooks/useFolders";
|
|
|
|
|
import { NoteCreate } from "@/api/notes";
|
2025-12-11 22:20:23 +00:00
|
|
|
|
|
|
|
|
export const SidebarHeader = ({
|
|
|
|
|
setNewFolder,
|
|
|
|
|
}: {
|
|
|
|
|
setNewFolder: React.Dispatch<SetStateAction<boolean>>;
|
|
|
|
|
}) => {
|
2025-12-30 22:36:48 +00:00
|
|
|
const { selectedFolder } = useUIStore();
|
2025-12-22 15:23:40 +00:00
|
|
|
const createNote = useCreateNote();
|
2025-12-11 22:20:23 +00:00
|
|
|
const handleCreate = async () => {
|
2025-12-22 15:23:40 +00:00
|
|
|
createNote.mutate({
|
2025-12-11 22:20:23 +00:00
|
|
|
title: "Untitled",
|
|
|
|
|
content: "",
|
|
|
|
|
folder_id: selectedFolder,
|
2025-12-22 15:23:40 +00:00
|
|
|
} as NoteCreate);
|
2025-12-11 22:20:23 +00:00
|
|
|
};
|
|
|
|
|
return (
|
2025-12-22 15:23:40 +00:00
|
|
|
<div className="w-full p-2 border-b border-ctp-surface2 bg-ctp-mantle">
|
2025-12-22 22:47:28 +00:00
|
|
|
<div className="flex items-center justify-around bg-ctp-surface0 rounded-lg p-1 gap-1">
|
2025-12-22 15:23:40 +00:00
|
|
|
<button
|
|
|
|
|
onClick={() => setNewFolder(true)}
|
2025-12-22 22:47:28 +00:00
|
|
|
className="hover:bg-ctp-mauve active:scale-95 group transition-all duration-200 rounded-md p-2 hover:shadow-md"
|
2025-12-22 15:23:40 +00:00
|
|
|
title="New folder"
|
|
|
|
|
>
|
2025-12-22 22:47:28 +00:00
|
|
|
<FolderPlusIcon className="w-5 h-5 group-hover:fill-ctp-base transition-all duration-200 fill-ctp-mauve" />
|
2025-12-22 15:23:40 +00:00
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
onClick={handleCreate}
|
2025-12-22 22:47:28 +00:00
|
|
|
className="hover:bg-ctp-mauve active:scale-95 group transition-all duration-200 rounded-md p-2 hover:shadow-md"
|
2025-12-22 15:23:40 +00:00
|
|
|
title="New note"
|
|
|
|
|
>
|
2025-12-22 22:47:28 +00:00
|
|
|
<FileCirclePlusIcon className="w-5 h-5 group-hover:fill-ctp-base transition-all duration-200 fill-ctp-mauve" />
|
2025-12-22 15:23:40 +00:00
|
|
|
</button>
|
|
|
|
|
</div>
|
2025-12-11 22:20:23 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|