#26 - Loading animation + success message fix

This commit was merged in pull request #31.
This commit is contained in:
Martin Slachta
2026-06-22 11:20:28 +02:00
parent c754e18a82
commit 97ee8fc991
32 changed files with 597 additions and 175 deletions
@@ -28,6 +28,18 @@ class RsvTimetableReservationController {
// refuse() validates against the database before changing state.
'permission_callback' => [RsvRestPolicy::class, 'open'],
]);
register_rest_route($this->namespace, '/timetable-reservation/(?P<id>\d+)/accept', [
'methods' => 'POST',
'callback' => [$this, 'accept_by_id'],
'permission_callback' => [RsvRestPolicy::class, 'admin'],
]);
register_rest_route($this->namespace, '/timetable-reservation/(?P<id>\d+)/refuse', [
'methods' => 'POST',
'callback' => [$this, 'refuse_by_id'],
'permission_callback' => [RsvRestPolicy::class, 'admin'],
]);
}
public function by_timetable(WP_REST_Request $request): WP_REST_Response {
@@ -59,4 +71,26 @@ class RsvTimetableReservationController {
return new WP_REST_Response(['error' => 'Invalid or expired confirmation code.'], 404);
}
}
function accept_by_id(WP_REST_Request $request) {
try {
$service = new RsvTimetableReservationService();
$service->accept_by_id(intval($request->get_param('id')));
return new WP_REST_Response(['status' => 'accepted'], 200);
} catch (InvalidArgumentException $e) {
return new WP_REST_Response(['error' => 'Invalid or expired confirmation code.'], 404);
}
}
function refuse_by_id(WP_REST_Request $request) {
try {
$service = new RsvTimetableReservationService();
$service->refuse_by_id(intval($request->get_param('id')));
return new WP_REST_Response(['status' => 'refused'], 200);
} catch (InvalidArgumentException $e) {
return new WP_REST_Response(['error' => 'Invalid or expired confirmation code.'], 404);
}
}
}