From 8d82d8e01e33cf23b339c8449028fc9c93fb1059 Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 20 May 2025 19:28:21 +0800 Subject: [PATCH] . --- chatdesk-ui/db/workspaces.ts | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/chatdesk-ui/db/workspaces.ts b/chatdesk-ui/db/workspaces.ts index e97fe60..bbffd51 100644 --- a/chatdesk-ui/db/workspaces.ts +++ b/chatdesk-ui/db/workspaces.ts @@ -30,34 +30,21 @@ export const getWorkspaceById = async (workspaceId: string) => { return workspace } -// export const getWorkspacesByUserId = async (userId: string) => { -// const { data: workspaces, error } = await supabase -// .from("workspaces") -// .select("*") -// .eq("user_id", userId) -// .order("created_at", { ascending: false }) - -// if (!workspaces) { -// throw new Error(error.message) -// } - -// return workspaces -// } - -export const getWorkspacesByUserId = async (userId: string): Promise => { +export const getWorkspacesByUserId = async (userId: string) => { const { data: workspaces, error } = await supabase .from("workspaces") .select("*") .eq("user_id", userId) - .order("created_at", { ascending: false }); + .order("created_at", { ascending: false }) - if (error) { - throw new Error(error.message); // Make sure the error is checked + if (!workspaces) { + throw new Error(error.message) } - return workspaces as Workspace[]; // Explicitly cast the returned data as a Workspace array + return workspaces } + export const createWorkspace = async ( workspace: TablesInsert<"workspaces"> ) => {