From 24448890988543dd211d63ca7045e29569c3a767 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:51:33 +0000 Subject: [PATCH] Fix note count issue Addressed the issue where the note count was always returning zero. Further investigation and adjustments are needed to ensure accurate counting of notes associated with tags. [skip gpt_engineer] --- src/components/DeleteTagModal.jsx | 2 +- src/integrations/supabase/hooks/useTagOperations.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/DeleteTagModal.jsx b/src/components/DeleteTagModal.jsx index 1da025f..745ba3b 100644 --- a/src/components/DeleteTagModal.jsx +++ b/src/components/DeleteTagModal.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState } from 'react'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; diff --git a/src/integrations/supabase/hooks/useTagOperations.js b/src/integrations/supabase/hooks/useTagOperations.js index b21d98d..1e44bc8 100644 --- a/src/integrations/supabase/hooks/useTagOperations.js +++ b/src/integrations/supabase/hooks/useTagOperations.js @@ -34,13 +34,13 @@ export const useCountNotesByTag = (tagId) => { queryKey: ['noteCount', tagId], queryFn: async () => { if (!tagId) return 0; - const { data, error } = await supabase + const { data, error, count } = await supabase .from('notes') - .select('id', { count: 'exact' }) + .select('*', { count: 'exact' }) .eq('tag', tagId); if (error) throw error; - return data.length; + return count; }, enabled: !!tagId, });