@@ -783,6 +783,9 @@ export const useProjectStore = defineStore('projectModule', {
783783 Number ( item . id )
784784 )
785785 this . access = this . access . filter ( ( access ) => access . id !== item . id )
786+ this . collaborators = this . collaborators . filter (
787+ ( collaborators ) => collaborators . id !== item . id
788+ )
786789 } catch {
787790 notificationStore . error ( {
788791 text : `Failed to update project access for user ${ item . username } `
@@ -831,6 +834,42 @@ export const useProjectStore = defineStore('projectModule', {
831834 }
832835 } ,
833836
837+ async updateProjectCollaborators ( payload : {
838+ projectId : string
839+ collaborator : ProjectCollaborator
840+ data : UpdateProjectCollaboratorPayload
841+ } ) {
842+ this . accessLoading = true
843+ try {
844+ if ( ! payload . collaborator . project_role ) {
845+ await ProjectApi . addProjectCollaborator ( payload . projectId , {
846+ ...payload . data ,
847+ username : payload . collaborator . username
848+ } )
849+ } else {
850+ await ProjectApi . updateProjectCollaborator (
851+ payload . projectId ,
852+ Number ( payload . collaborator . id ) ,
853+ payload . data
854+ )
855+ }
856+ this . collaborators = this . collaborators . map ( ( collaborator ) => {
857+ if ( collaborator . id === payload . collaborator . id ) {
858+ collaborator . role = payload . data . role
859+ collaborator . project_role = payload . data . role
860+ }
861+ return collaborator
862+ } )
863+ } catch ( err ) {
864+ this . handleProjectAccessError (
865+ err ,
866+ 'Failed to update project collaborator'
867+ )
868+ } finally {
869+ this . accessLoading = false
870+ }
871+ } ,
872+
834873 handleProjectAccessError ( err : unknown , defaultMessage : string ) {
835874 const notificationStore = useNotificationStore ( )
836875 notificationStore . error ( {
0 commit comments