From 748f1cb76885d5a400ab127604c7e2d98c662d4c Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 06:06:07 +0000 Subject: [PATCH] Load tags from database Updated the sidebar to dynamically load tags and their corresponding colors from the database using the tags table. The tag and color attributes are now fetched and displayed in the sidebar. [skip gpt_engineer] --- src/components/Sidebar.jsx | 51 +++++++++++---------- src/integrations/supabase/hooks/useNotes.js | 26 +++-------- src/integrations/supabase/index.js | 5 +- 3 files changed, 37 insertions(+), 45 deletions(-) diff --git a/src/components/Sidebar.jsx b/src/components/Sidebar.jsx index 01c5050..24d3d21 100644 --- a/src/components/Sidebar.jsx +++ b/src/components/Sidebar.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { CircleUserRound, ChevronLeft, ChevronRight, Check, X, Plus } from 'lucide-react'; -import { useSupabaseAuth, useNotes } from '../integrations/supabase'; +import { useSupabaseAuth, useNotes, useTags } from '../integrations/supabase'; import { useNavigate } from 'react-router-dom'; import { DropdownMenu, @@ -20,7 +20,7 @@ import { Button } from "@/components/ui/button"; import { format } from 'date-fns'; import AddTagModal from './AddTagModal'; -const Sidebar = ({ activeFilters, toggleFilter, clearFilters, categories, addNewCategory }) => { +const Sidebar = ({ activeFilters, toggleFilter, clearFilters, addNewCategory }) => { const [isCollapsed, setIsCollapsed] = useState(false); const { session, logout } = useSupabaseAuth(); const navigate = useNavigate(); @@ -28,6 +28,7 @@ const Sidebar = ({ activeFilters, toggleFilter, clearFilters, categories, addNew const [isProfileDialogOpen, setIsProfileDialogOpen] = useState(false); const [isAddTagModalOpen, setIsAddTagModalOpen] = useState(false); const { data: notes, isLoading: notesLoading } = useNotes(); + const { data: tags, isLoading: tagsLoading } = useTags(); useEffect(() => { const handleResize = () => { @@ -91,27 +92,31 @@ const Sidebar = ({ activeFilters, toggleFilter, clearFilters, categories, addNew