diff --git a/src/components/Sidebar.jsx b/src/components/Sidebar.jsx index 1f34806..eab0b3d 100644 --- a/src/components/Sidebar.jsx +++ b/src/components/Sidebar.jsx @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; import { CircleUserRound, ChevronLeft, ChevronRight, Check, X, Plus } from 'lucide-react'; import { useSupabaseAuth } from '../integrations/supabase'; import { useNavigate } from 'react-router-dom'; -import { useNotes, useTags, useAddTag } from '../integrations/supabase'; +import { useNotes } from '../integrations/supabase'; import { DropdownMenu, DropdownMenuContent, @@ -21,16 +21,14 @@ import { Button } from "@/components/ui/button"; import { format } from 'date-fns'; import AddTagModal from './AddTagModal'; -const Sidebar = ({ activeFilters, toggleFilter, clearFilters, addNewCategory }) => { +const Sidebar = ({ activeFilters, toggleFilter, clearFilters, categories, addNewCategory }) => { const [isCollapsed, setIsCollapsed] = useState(false); const { session, logout } = useSupabaseAuth(); const navigate = useNavigate(); const [isLogoutDialogOpen, setIsLogoutDialogOpen] = useState(false); const [isProfileDialogOpen, setIsProfileDialogOpen] = useState(false); const [isAddTagModalOpen, setIsAddTagModalOpen] = useState(false); - const { data: notes, isLoading: notesLoading } = useNotes(); - const { data: tags, isLoading: tagsLoading } = useTags(); - const addTag = useAddTag(); + const { data: notes, isLoading } = useNotes(); useEffect(() => { const handleResize = () => { @@ -58,21 +56,17 @@ const Sidebar = ({ activeFilters, toggleFilter, clearFilters, addNewCategory }) }; const getCategoryCount = (categoryName) => { - if (notesLoading || !notes) return 0; + if (isLoading || !notes) return 0; return notes.filter(note => note.tag === categoryName).length; }; const handleAddNewTag = (newTag) => { - addTag.mutate({ name: newTag.name, color: newTag.color }); + addNewCategory(newTag); setIsAddTagModalOpen(false); }; - if (tagsLoading) { - return