This commit is contained in:
hailin 2025-05-20 19:28:21 +08:00
parent 0f4730c226
commit 8d82d8e01e
1 changed files with 6 additions and 19 deletions

View File

@ -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<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 });
.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">
) => {