From bdb061404ad536b7a035d92e7d1c6f8b6deaf141 Mon Sep 17 00:00:00 2001 From: Presley Pizzo Date: Fri, 14 Oct 2022 19:21:45 +0000 Subject: [PATCH] Mock out api call on frontend --- site/src/api/api.ts | 17 +++++++++++++++++ .../xServices/workspaces/workspacesXService.ts | 8 +++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/site/src/api/api.ts b/site/src/api/api.ts index 2e60a88b84..54a31b7eaa 100644 --- a/site/src/api/api.ts +++ b/site/src/api/api.ts @@ -286,6 +286,23 @@ export const getWorkspaces = async ( return response.data } +// TODO change types +export const getWorkspacesCount = async ( + options: TypesGen.AuditLogCountRequest = {} +): Promise => { + 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, diff --git a/site/src/xServices/workspaces/workspacesXService.ts b/site/src/xServices/workspaces/workspacesXService.ts index de3a46e039..78b4232350 100644 --- a/site/src/xServices/workspaces/workspacesXService.ts +++ b/site/src/xServices/workspaces/workspacesXService.ts @@ -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 }) + ) }, }, )