diff --git a/.gitignore b/.gitignore index 43b28bba..00aba771 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,6 @@ node_modules/ /playwright-report/ /blob-report/ /playwright/.cache/ + +# Snaplet +/.snaplet/ \ No newline at end of file diff --git a/src/app/casos-activos/layout.tsx b/src/app/casos-activos/layout.tsx index 4944cf4f..85086a99 100644 --- a/src/app/casos-activos/layout.tsx +++ b/src/app/casos-activos/layout.tsx @@ -1,18 +1,18 @@ -import { supabase } from '@/lib/supabase/client'; +import { createClient } from '@/lib/supabase/server'; import TabNavigation from '@/components/TabNavigation'; import { PropsWithChildren } from 'react'; -const getCount = async () => { - const { - data: solicitaData, - count: solicitaCount, - error: solicitaError, - } = await supabase.from('help_requests').select('id', { count: 'exact' }).eq('type', 'necesita'); +import { SupabaseClient } from '@supabase/supabase-js'; +import { Database } from '@/types/database'; +const getCount = async (supabase: SupabaseClient) => { + const { count: solicitaCount, error: solicitaError } = await supabase + .from('help_requests') + .select('id', { count: 'exact' }) + .eq('type', 'necesita'); - const { - data: ofreceData, - count: ofreceCount, - error: ofreceError, - } = await supabase.from('help_requests').select('id', { count: 'exact' }).eq('type', 'ofrece'); + const { count: ofreceCount, error: ofreceError } = await supabase + .from('help_requests') + .select('id', { count: 'exact' }) + .eq('type', 'ofrece'); if (solicitaError) { throw new Error('Error fetching solicita:', solicitaError); @@ -28,7 +28,8 @@ const getCount = async () => { }; export default async function CasosActivosLayout({ children }: PropsWithChildren) { - const count = await getCount(); + const supabase = await createClient(); + const count = await getCount(supabase); return ( <>
diff --git a/src/app/page.tsx b/src/app/page.tsx index 6d4c2685..a2516ed5 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -5,7 +5,7 @@ import PhoneNumberDialog from '@/components/auth/PhoneNumberDialog'; import Image from 'next/image'; import { CallCenterLink } from '@/components/CallCenterLink'; -export default function Home() { +export default async function Home() { const emergencyNumbers = [ { name: 'Emergencias', number: '112', description: 'Para situaciones de peligro inmediato' }, { name: 'PolicĂ­a Local', number: '092', description: 'Asistencia y seguridad local' }, diff --git a/src/lib/service.ts b/src/lib/service.ts index 13b58609..a0b2bb42 100644 --- a/src/lib/service.ts +++ b/src/lib/service.ts @@ -2,6 +2,7 @@ import { supabase } from './supabase/client'; import { Database } from '@/types/database'; import { HelpRequestAssignmentInsert, HelpRequestUpdate } from '@/types/Requests'; import { createClient } from '@/lib/supabase/server'; +import { SupabaseClient } from '@supabase/supabase-js'; export const helpRequestService = { async createRequest(requestData: Database['public']['Tables']['help_requests']['Insert']) { @@ -114,6 +115,7 @@ export const helpRequestService = { }; }, async getTodaysCountByTown() { + const supabase = await getSupabaseClient(); const today = new Date().toISOString().split('T')[0]; const { data: towns, error: townError } = await supabase.from('towns').select('id, name');