From 8a518aff31a0271e3dce3bad2156ea24015954af Mon Sep 17 00:00:00 2001 From: Herman Snevajs Date: Fri, 13 Dec 2024 16:47:42 +0100 Subject: [PATCH] Adjust projectApi --- .../lib/src/modules/project/projectApi.ts | 28 ++++++++++++++++--- .../packages/lib/src/modules/project/types.ts | 6 ++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/web-app/packages/lib/src/modules/project/projectApi.ts b/web-app/packages/lib/src/modules/project/projectApi.ts index ec9b4789..01b63cd8 100644 --- a/web-app/packages/lib/src/modules/project/projectApi.ts +++ b/web-app/packages/lib/src/modules/project/projectApi.ts @@ -25,7 +25,7 @@ import { ProjectVersion, ProjectAccessDetail, ProjectAccess, - ProjectVersionFileChange + ProjectVersionFileChange, CreateProjectAccessParams } from '@/modules/project/types' export const ProjectApi = { @@ -175,12 +175,32 @@ export const ProjectApi = { async updateProjectAccess( id: string, + userId: number, data: UpdateProjectAccessParams, withRetry?: boolean ): Promise> { - return ProjectModule.httpService.patch(`/app/project/${id}/access`, data, { - ...(withRetry ? getDefaultRetryOptions() : {}) - }) + return ProjectModule.httpService.patch( + `/v2/projects/${id}/collaborators/${userId}`, + data, + { + ...(withRetry ? getDefaultRetryOptions() : {}) + } + ) + }, + + async createProjectAccess( + id: string, + userId: number, + data: CreateProjectAccessParams, + withRetry?: boolean + ): Promise> { + return ProjectModule.httpService.post( + `/v2/projects/${id}/collaborators/${userId}`, + data, + { + ...(withRetry ? getDefaultRetryOptions() : {}) + } + ) }, async pushProjectChanges( diff --git a/web-app/packages/lib/src/modules/project/types.ts b/web-app/packages/lib/src/modules/project/types.ts index 8260991f..3f471334 100644 --- a/web-app/packages/lib/src/modules/project/types.ts +++ b/web-app/packages/lib/src/modules/project/types.ts @@ -298,6 +298,12 @@ export interface UpdateProjectAccessParams { public?: boolean } +export interface CreateProjectAccessParams { + user_id?: number + role?: ProjectRoleName + public?: boolean +} + export interface DownloadPayload { url: string }