Implement Hitobito camp invite UI
- Dominant language
- PHP
- Stars
- 156
- Forks
- 72
- Avg merge
- 12h 43m
- Merged PRs (30d)
- 203
Description
Once a camp is linked with Hitobito, the user can invite co-leaders of the Hitobito event to eCamp. Users are added to the corresponding camp.
Relevant Endpoints:
- https://github.com/ecamp/ecamp3/issues/10424
- https://github.com/ecamp/ecamp3/issues/10400
## Implementation
Add a new button on the collaborators page in the camp detail view:
- The button is only shown if `camp.hitobitoId` and `camp.hitobitoProvider` are set
- The button adapts it's design based on the provider of the camp
When the user clicks the button, initialize the OAuth flow as described here: https://github.com/ecamp/ecamp3/issues/10400 with the `callback=/camps///hitobito/invite`.
The user will be redirected to the consent screen and then to the invite page (`/camps///hitobito/invite`)
Once the page is loaded, fetch all participants of the event by calling `GET /api/hitobito//events/`
Gather all emails of collaborators part of this eCamp camp:
- For invited collaborators, use the `collaborators` embedded in the camp model. Gather all emails where `inviteEmail` is not null
```jsonc
// GET /api/camps/
{
"_links": {
// ...
},
"_embedded": {
"periods": [
// ...
],
"campCollaborations": [
{
"inviteEmail": null,
"status": "established",
"role": "manager",
// ...
},
{
"inviteEmail": "x@z.com",
"status": "invited",
"role": "member",
// ...
}
]
},
// ...
}
```
- For established collaborators, use the `GET /profiles` endpoint:
```jsonc
// GET /api/profiles?user.collaborations.camp=/camps/
{
"_links": {
// ...
},
"totalItems": 2,
"_embedded": {
"items": [
{
"email": "test@example.com",
// ...
},
{
"email": "castor@example.com",
// ...
}
]
}
}
```
Match the retrieved event participants against the gathered eCamp collaborator emails.
Display the users that will be invited (users without an existing collaboration), and the event participants that are already part of the camp.
If there are no more users to be added from MiData, display the following screen:
Once the user confirms the invitation, go through each new email (of event participants that aren't part of the camp yet) and call
```jsonc
// POST /api/camp_collaborations
{
"camp": "/camps/",
"inviteEmail": "",
"role": "member"
}
```
When all calls complete, redirect back to the collaborators page.
Notes:
- If any calls to the backend fail unexpectedly (forbidden, internal error), display an appropriate error message
Contributor guide
Assessment
This issue has not been assessed yet.