This commit is contained in:
parent
0f4730c226
commit
8d82d8e01e
|
|
@ -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">
|
||||
) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue