Skip to content

Commit cad391d

Browse files
committed
Use '/profiles/keys/team/:id' instead of 'profiles/keys/organizations/:id/teams' to get the team profile, allowing non-org moderators access to the team profile.
1 parent 4641dd4 commit cad391d

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

lib/profiles-api.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,28 @@ export async function getOrgTeamAttributes (id) {
7070
}
7171
}
7272

73+
/**
74+
* getTeamAttributess
75+
* Get attributes for team attributes
76+
*
77+
* @returns {Array[Object]} - list of team details
78+
*/
79+
export async function getTeamAttributes (id) {
80+
let res = await fetch(join(URL, 'keys', 'teams', `${id}`), {
81+
method: 'GET',
82+
headers: {
83+
'Content-Type': 'application/json; charset=utf-8'
84+
}
85+
})
86+
if (res.status === 200) {
87+
return res.json()
88+
} else {
89+
const err = new Error('could not retrieve team member attributes')
90+
err.status = res.status
91+
throw err
92+
}
93+
}
94+
7395
/**
7496
* modifyAttribute
7597
* Modify attribute given a profile key

pages/team-edit.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import getConfig from 'next/config'
77
import EditTeamForm from '../components/edit-team-form'
88
import Button from '../components/button'
99
import theme from '../styles/theme'
10-
import { getOrgTeamAttributes, getTeamProfile } from '../lib/profiles-api'
10+
import { getTeamAttributes, getTeamProfile } from '../lib/profiles-api'
1111
const { publicRuntimeConfig } = getConfig()
1212

1313
export default class TeamEdit extends Component {
@@ -32,12 +32,9 @@ export default class TeamEdit extends Component {
3232
const { id } = this.props
3333
try {
3434
let team = await getTeam(id)
35-
let teamAttributes = []
35+
let teamAttributes = await getTeamAttributes(id)
3636
let profileValues = []
3737
profileValues = await getTeamProfile(id)
38-
if (team.org) {
39-
teamAttributes = await getOrgTeamAttributes(team.org.organization_id)
40-
}
4138
this.setState({
4239
team,
4340
profileValues,

0 commit comments

Comments
 (0)