This commit is contained in:
parent
0f4730c226
commit
8d82d8e01e
|
|
@ -30,34 +30,21 @@ export const getWorkspaceById = async (workspaceId: string) => {
|
||||||
return workspace
|
return workspace
|
||||||
}
|
}
|
||||||
|
|
||||||
// export const getWorkspacesByUserId = async (userId: string) => {
|
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[]> => {
|
|
||||||
const { data: workspaces, error } = await supabase
|
const { data: workspaces, error } = await supabase
|
||||||
.from("workspaces")
|
.from("workspaces")
|
||||||
.select("*")
|
.select("*")
|
||||||
.eq("user_id", userId)
|
.eq("user_id", userId)
|
||||||
.order("created_at", { ascending: false });
|
.order("created_at", { ascending: false })
|
||||||
|
|
||||||
if (error) {
|
if (!workspaces) {
|
||||||
throw new Error(error.message); // Make sure the error is checked
|
throw new Error(error.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
return workspaces as Workspace[]; // Explicitly cast the returned data as a Workspace array
|
return workspaces
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const createWorkspace = async (
|
export const createWorkspace = async (
|
||||||
workspace: TablesInsert<"workspaces">
|
workspace: TablesInsert<"workspaces">
|
||||||
) => {
|
) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue