feat(front-hall): wire quick links to Core API dashboard endpoint

Update quick links integration to use new /dashboard/quick-links API:
- Change API path from /front-hall/quick-links to /dashboard/quick-links
- Update field mappings: name→title, icon_name→icon, sort_order→position, is_active→is_visible
- Change ID type from String to int with conversion in provider
- Parse new response format {"links": [...], "total": N}
- Update reorder endpoint from PUT to POST with link_ids

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jeroen Schweitzer
2026-01-03 13:17:16 +01:00
co-authored by Claude Opus 4.5
parent 1d68402067
commit 0d15d3dbb5
3 changed files with 119 additions and 57 deletions
@@ -8,27 +8,35 @@ part 'quick_links_datasource.g.dart';
/// Data source for quick link operations.
///
/// Provides CRUD operations for Front Hall quick links via Core API.
/// Provides CRUD operations for Front Hall quick links via Core API
/// dashboard/quick-links endpoint.
class QuickLinksDatasource {
QuickLinksDatasource(this._dio);
final Dio _dio;
static const _basePath = '/front-hall/quick-links';
static const _basePath = '/dashboard/quick-links';
/// Gets all quick links.
///
/// API returns: {"links": [...], "total": N}
Future<List<QuickLink>> getQuickLinks() async {
final response = await _dio.get<List<dynamic>>(_basePath);
final data = response.data ?? [];
final response = await _dio.get<Map<String, dynamic>>(_basePath);
final data = response.data;
return data
if (data == null) {
return [];
}
final links = data['links'] as List<dynamic>? ?? [];
return links
.map((json) => QuickLinkModel.fromJson(json as Map<String, dynamic>))
.map((model) => model.toEntity())
.toList();
}
/// Gets a single quick link by ID.
Future<QuickLink> getQuickLink(String id) async {
Future<QuickLink> getQuickLink(int id) async {
final response = await _dio.get<Map<String, dynamic>>('$_basePath/$id');
final data = response.data;
@@ -44,7 +52,7 @@ class QuickLinksDatasource {
final model = QuickLinkModel.fromEntity(link);
final response = await _dio.post<Map<String, dynamic>>(
_basePath,
data: model.toJson(),
data: model.toCreateJson(),
);
final data = response.data;
@@ -58,9 +66,10 @@ class QuickLinksDatasource {
/// Updates an existing quick link.
Future<QuickLink> updateQuickLink(QuickLink link) async {
final model = QuickLinkModel.fromEntity(link);
final id = int.tryParse(link.id) ?? 0;
final response = await _dio.put<Map<String, dynamic>>(
'$_basePath/${link.id}',
data: model.toJson(),
'$_basePath/$id',
data: model.toCreateJson(),
);
final data = response.data;
@@ -72,15 +81,17 @@ class QuickLinksDatasource {
}
/// Deletes a quick link.
Future<void> deleteQuickLink(String id) async {
Future<void> deleteQuickLink(int id) async {
await _dio.delete<void>('$_basePath/$id');
}
/// Reorders quick links by updating sort orders.
Future<void> reorderQuickLinks(List<String> orderedIds) async {
await _dio.put<void>(
/// Reorders quick links by updating positions.
///
/// API expects: {"link_ids": [1, 2, 3]}
Future<void> reorderQuickLinks(List<int> orderedIds) async {
await _dio.post<void>(
'$_basePath/reorder',
data: {'ids': orderedIds},
data: {'link_ids': orderedIds},
);
}
}