Refactor & clean up code.

This commit is contained in:
2025-07-17 15:20:59 -05:00
parent dabc248010
commit fefe7e8717
31 changed files with 473 additions and 295 deletions

View File

@@ -1,12 +1,10 @@
'use client';
import { createBrowserClient } from '@supabase/ssr';
import type { Database, SupabaseClient } from '@/utils/supabase';
import { useMemo } from 'react';
import type { Database, SBClientWithDatabase } from '@/utils/supabase';
let client: SupabaseClient | undefined;
let client: SBClientWithDatabase | undefined;
const getSupbaseClient = (): SupabaseClient | undefined => {
const getSupbaseClient = (): SBClientWithDatabase | undefined => {
if (client) return client;
client = createBrowserClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
@@ -15,8 +13,6 @@ const getSupbaseClient = (): SupabaseClient | undefined => {
return client;
};
const useSupabaseClient = () => {
return useMemo(getSupbaseClient, []);
};
const SupabaseClient = () => getSupbaseClient();
export { useSupabaseClient };
export { SupabaseClient };