mirror of https://github.com/kortix-ai/suna.git
20 lines
594 B
TypeScript
20 lines
594 B
TypeScript
import useSWR, {SWRConfiguration} from "swr";
|
|
import { createClient } from "@/lib/supabase/client";
|
|
import { GetAccountsResponse } from "@usebasejump/shared";
|
|
|
|
export const useAccounts = (options?: SWRConfiguration) => {
|
|
const supabaseClient = createClient();
|
|
return useSWR<GetAccountsResponse>(
|
|
!!supabaseClient && ["accounts"],
|
|
async () => {
|
|
const {data, error} = await supabaseClient.rpc("get_accounts");
|
|
|
|
if (error) {
|
|
throw new Error(error.message);
|
|
}
|
|
|
|
return data;
|
|
},
|
|
options
|
|
);
|
|
}; |