This commit is contained in:
parent
cc9af51a46
commit
e4b1ab7e40
|
|
@ -190,6 +190,7 @@ export default function SetupPage() {
|
|||
|
||||
const workspaces = await getWorkspacesByUserId(profile.user_id)
|
||||
const homeWorkspace = workspaces.find(w => w.is_home)
|
||||
|
||||
|
||||
// There will always be a home workspace
|
||||
setSelectedWorkspace(homeWorkspace!)
|
||||
|
|
|
|||
|
|
@ -30,18 +30,32 @@ export const getWorkspaceById = async (workspaceId: string) => {
|
|||
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
|
||||
.from("workspaces")
|
||||
.select("*")
|
||||
.eq("user_id", userId)
|
||||
.order("created_at", { ascending: false })
|
||||
.order("created_at", { ascending: false });
|
||||
|
||||
if (!workspaces) {
|
||||
throw new Error(error.message)
|
||||
if (error) {
|
||||
throw new Error(error.message); // Make sure the error is checked
|
||||
}
|
||||
|
||||
return workspaces
|
||||
return workspaces as Workspace[]; // Explicitly cast the returned data as a Workspace array
|
||||
}
|
||||
|
||||
export const createWorkspace = async (
|
||||
|
|
|
|||
Loading…
Reference in New Issue