diff --git a/dashboard/src/scenes/team/list.js b/dashboard/src/scenes/team/list.js index 130c4ee79..d70e31196 100644 --- a/dashboard/src/scenes/team/list.js +++ b/dashboard/src/scenes/team/list.js @@ -125,7 +125,12 @@ const Create = () => { body: { name: values.name, organisation: organisation._id, nightSession: values.nightSession === 'true' }, }); if (!newTeamRes.ok) return actions.setSubmitting(false); - const userPutRes = await API.put({ path: `/user/${user._id}`, body: { team: [...(user.team || []), newTeamRes.data._id] } }); + const userPutRes = await API.put({ + path: `/user/${user._id}`, + body: { + team: [...(user.teams || []).map((team) => team._id), newTeamRes.data._id], + }, + }); if (!userPutRes.ok) return actions.setSubmitting(false); const meResponse = await API.get({ path: '/user/me' }); setUser(meResponse.user); diff --git a/dashboard/src/types/user.ts b/dashboard/src/types/user.ts index a7435d0ed..8014df9a3 100644 --- a/dashboard/src/types/user.ts +++ b/dashboard/src/types/user.ts @@ -10,5 +10,6 @@ export type UserInstance = { termsAccepted: Date | null; healthcareProfessional: boolean | null; role: 'normal' | 'admin'; // Add other roles if available. - team: UUIDV4[]; + team?: UUIDV4[]; + teams?: UUIDV4[]; };