Skip to content

Commit

Permalink
Fix export issues in supabase integration
Browse files Browse the repository at this point in the history
Resolved export errors for `useAddTag` and `useTags` in `src/integrations/supabase/index.js`. Updated imports in `src/components/Sidebar.jsx` to ensure successful builds and prevent runtime errors.
[skip gpt_engineer]
  • Loading branch information
lovable-dev[bot] committed Oct 12, 2024
1 parent 47a306f commit 12d0070
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
21 changes: 13 additions & 8 deletions src/components/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useState, useEffect } from 'react';
import { CircleUserRound, ChevronLeft, ChevronRight, Check, X, Plus } from 'lucide-react';
import { useSupabaseAuth } from '../integrations/supabase';
import { useSupabaseAuth, useNotes, useTags, useAddTag } from '../integrations/supabase';
import { useNavigate } from 'react-router-dom';
import { useNotes } from '../integrations/supabase';
import {
DropdownMenu,
DropdownMenuContent,
Expand All @@ -21,14 +20,16 @@ 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();
const [isLogoutDialogOpen, setIsLogoutDialogOpen] = useState(false);
const [isProfileDialogOpen, setIsProfileDialogOpen] = useState(false);
const [isAddTagModalOpen, setIsAddTagModalOpen] = useState(false);
const { data: notes, isLoading } = useNotes();
const { data: notes, isLoading: notesLoading } = useNotes();
const { data: tags, isLoading: tagsLoading } = useTags();
const addTag = useAddTag();

useEffect(() => {
const handleResize = () => {
Expand Down Expand Up @@ -56,17 +57,21 @@ const Sidebar = ({ activeFilters, toggleFilter, clearFilters, categories, addNew
};

const getCategoryCount = (categoryName) => {
if (isLoading || !notes) return 0;
if (notesLoading || !notes) return 0;
return notes.filter(note => note.tag === categoryName).length;
};

const handleAddNewTag = (newTag) => {
addNewCategory(newTag);
addTag.mutate({ name: newTag.name, color: newTag.color });
setIsAddTagModalOpen(false);
};

if (tagsLoading) {
return <div>Loading tags...</div>;
}

return (
<div className={`bg-gray-900 text-white p-6 flex flex-col h-screen transition-all duration-300 ${isCollapsed ? 'w-10 sm:w-20' : 'w-32 sm:w-64'}`}>
<div className={`bg-gray-900 text-white p-6 flex flex-col h-screen transition-all duration-300 ease-in-out ${isCollapsed ? 'w-10 sm:w-20' : 'w-32 sm:w-64'}`}>
<div className="flex items-center mb-8 justify-between">
{!isCollapsed && (
<DropdownMenu>
Expand All @@ -92,7 +97,7 @@ const Sidebar = ({ activeFilters, toggleFilter, clearFilters, categories, addNew
</button>
</div>
<nav className="flex-grow">
{categories.map((category) => (
{tags && tags.map((category) => (
<div
key={category.name}
className="flex items-center mb-2 cursor-pointer hover:bg-gray-800 rounded-md p-2 transition-colors"
Expand Down
5 changes: 4 additions & 1 deletion src/integrations/supabase/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { supabase } from './supabase';
import { SupabaseAuthProvider, useSupabaseAuth, SupabaseAuthUI } from './auth';
import { useNote, useNotes, useAddNote, useUpdateNote, useDeleteNote } from './hooks/useNotes';
import { useTags, useAddTag } from './hooks/useTags';

export {
supabase,
Expand All @@ -11,5 +12,7 @@ export {
useNotes,
useAddNote,
useUpdateNote,
useDeleteNote
useDeleteNote,
useTags,
useAddTag
};

0 comments on commit 12d0070

Please sign in to comment.