Mock out api call on frontend

This commit is contained in:
Presley Pizzo
2022-10-14 19:21:45 +00:00
parent 76071b9ded
commit bdb061404a
2 changed files with 20 additions and 5 deletions
+17
View File
@@ -286,6 +286,23 @@ export const getWorkspaces = async (
return response.data
}
// TODO change types
export const getWorkspacesCount = async (
options: TypesGen.AuditLogCountRequest = {}
): Promise<TypesGen.AuditLogCountResponse> => {
const searchParams = new URLSearchParams()
if (options.q) {
searchParams.set("q", options.q)
}
// TODO
// const response = await axios.get(
// `/api/v2/workspaces/count?${searchParams.toString()}`,
// )
// return response.data
return Promise.resolve({ count: 10 })
}
export const getWorkspaceByOwnerAndName = async (
username = "me",
workspaceName: string,
@@ -387,7 +387,6 @@ createMachine(
},
assignUpdatedWorkspaceRefs: assign({
workspaceRefs: (_, event) => {
const newWorkspaceRefs = event.data.newWorkspaces.map((workspace) =>
spawn(
workspaceItemMachine.withContext({ data: workspace }),
@@ -440,10 +439,9 @@ createMachine(
newWorkspaces,
})
},
getWorkspacesCount: () => {
//API.getWorkspacesCount()
return Promise.resolve({ count: 10 })
}
getWorkspacesCount: (context) => (
API.getWorkspacesCount({ q: context.filter })
)
},
},
)