ecamp / ecamp/ecamp3

Implement Hitobito import UI

Open
#10,401 3 comments 1 reaction 2 assignees Claimed by @manuelmeister View on GitHub
Ready for implementation type: Frontend
Dominant language
PHP
Stars
156
Forks
72
Avg merge
12h 43m
Merged PRs (30d)
203

Description

Relevant Endpoints:
- https://github.com/ecamp/ecamp3/issues/10386
- https://github.com/ecamp/ecamp3/issues/10387
- https://github.com/ecamp/ecamp3/issues/10400

## Implementation
Add a new button "Lager importieren" to the camp list screen, which allows selecting a Hitobito provider (currently only MiData):

Image

When the user clicks a provider, initialize the OAuth flow as described here: https://github.com/ecamp/ecamp3/issues/10400 with the `callback=/camps/hitobito//import`.

The user will be redirected to a consent screen:
Image

Once they accept the requested permissions they will be redirected to the camp import page (`/camps/hitobito//import`). When the page is loaded, fetch the user's events by calling `GET /api/hitobito//events` with the provider specified in the URL.

Display a wizard with two steps:
- Event Search: Contains all returned events, the user can search by name and select one
- If an event has `isImported = true`, prevent it from being selected and show `Bereits importiert`
- If an event is selected, show the information of that event
- Camp Prototype: Similar to the camp creation wizard, allow selection of a template camp. Display the data that will be copied from the prototype camp

Image

If the user submits a step without having selected an event / camp prototype, a corresponding validation error is shown.

On successful submission:
1. Call `POST /api/camps` with the following data:
```jsonc
{
"title": "Test Lager",
// ...
"campPrototype": "/camps/25a82475e0b7",
"hitobitoProvider": "",
"hitobitoEventId": ""
}
```
See below on how to map the event data to the camp

1. If a `409 Conflict` is received, display an error `Für dieses Event existiert bereits ein Camp.`
2. Redirect to the detail page of the camp `/camps///admin/info`

Notes:
- If the user manually navigates to `/camps/hitobito//import` and the provider is invalid, redirect to the 404 page
- If any calls to the backend fail unexpectedly (forbidden, internal error), display an appropriate error message and redirect to the index page

### Event to Camp Mapping

| MiData Field | eCamp Field | **Note** |
| ---------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `event.attributes.name` | `camp.title` | truncate to 32 characters |
| `event.attributes.motto` | `camp.motto` | truncate to 128 characters |
| `event.attributes.location` | `camp.addressName` | Hitobito uses freetext address (max 65535 characters).
eCamp validation limits to 128 -> truncate to 128 characters |
| `event.dates.attributes.label` | `period.description` | truncate to 32 characters. This may not be set at Hitobito. If so, use the camp title instead. |
| `event.dates.attributes.start_at` | `period.start` | |
| `event.dates.attributes.finish_at` | `period.end` | This may not be set at Hitobito, if so use `period.start` instead. |
(for multiple `event.dates`, create multiple periods)

> Notes on mapping:
> - `camp.shortTitle` is kept empty as there doesn't seem to be an Hitobito equivalent
> - Hitobito uses a freetext address, eCamp uses a structured address. Since parsing the address may be difficult, truncating the address and setting `camp.addressname` to it seems like the best option
> - *"Einstellung für J+S"* are not mapped. Hitobito does seem to have a *J+S Rahmen* (which is not accessible using the api). All other fields (Organisator, Lagerart, J+S Coach, Kursnummer, Kursbezeichnung, Bürgerlicher Name der Betreuungsperson) don't seem to have an equivalent
> - Hitobito does have an "event kind". This seems to be different (usually course names) from eCamp's kind (Lagerart) since eCamp explicitly groups it under `J+S` whereas for Hitobito this isn't the case

> Other MiData event types (different from `Event::Camp`), such as `Event::Course` are currently also available for import. The import procedure is not restricted to camps.

## `eventId` query parameter
In case the `eventId` query parameter is set:
1. Call `GET /api/hitobito//events/` directly to retrieve the event information
2. Display the following alternative screen where the event is already pre-filled:

Image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.