Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bdb0614

Browse files
committed
Mock out api call on frontend
1 parent 76071b9 commit bdb0614

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

site/src/api/api.ts

+17
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,23 @@ export const getWorkspaces = async (
286286
return response.data
287287
}
288288

289+
// TODO change types
290+
export const getWorkspacesCount = async (
291+
options: TypesGen.AuditLogCountRequest = {}
292+
): Promise<TypesGen.AuditLogCountResponse> => {
293+
const searchParams = new URLSearchParams()
294+
if (options.q) {
295+
searchParams.set("q", options.q)
296+
}
297+
// TODO
298+
// const response = await axios.get(
299+
// `/api/v2/workspaces/count?${searchParams.toString()}`,
300+
// )
301+
// return response.data
302+
303+
return Promise.resolve({ count: 10 })
304+
}
305+
289306
export const getWorkspaceByOwnerAndName = async (
290307
username = "me",
291308
workspaceName: string,

site/src/xServices/workspaces/workspacesXService.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ createMachine(
387387
},
388388
assignUpdatedWorkspaceRefs: assign({
389389
workspaceRefs: (_, event) => {
390-
391390
const newWorkspaceRefs = event.data.newWorkspaces.map((workspace) =>
392391
spawn(
393392
workspaceItemMachine.withContext({ data: workspace }),
@@ -440,10 +439,9 @@ createMachine(
440439
newWorkspaces,
441440
})
442441
},
443-
getWorkspacesCount: () => {
444-
//API.getWorkspacesCount()
445-
return Promise.resolve({ count: 10 })
446-
}
442+
getWorkspacesCount: (context) => (
443+
API.getWorkspacesCount({ q: context.filter })
444+
)
447445
},
448446
},
449447
)

0 commit comments

Comments
 (0)