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
@@ -33,7 +33,11 @@ Future<QuickLink> quickLink(Ref ref, String id) async {
// If not in defaults, try API
try {
final datasource = ref.watch(quickLinksDatasourceProvider);
return await datasource.getQuickLink(id);
final intId = int.tryParse(id);
if (intId == null) {
throw Exception('Invalid link ID: $id');
}
return await datasource.getQuickLink(intId);
} catch (_) {
throw Exception('Link not found: $id');
}
@@ -45,49 +49,82 @@ class QuickLinkActions extends _$QuickLinkActions {
@override
AsyncValue<void> build() => const AsyncValue.data(null);
/// Safely sets state, ignoring disposal errors.
void _safeSetState(AsyncValue<void> newState) {
try {
state = newState;
} catch (_) {
// Provider was disposed - ignore
}
}
/// Safely invalidates providers after async operations.
void _safeInvalidate(List<ProviderOrFamily> providers) {
try {
for (final provider in providers) {
ref.invalidate(provider);
}
} catch (_) {
// Provider was disposed - ignore
}
}
/// Creates a new quick link.
Future<QuickLink?> create(QuickLink link) async {
state = const AsyncValue.loading();
QuickLink? result;
state = await AsyncValue.guard(() async {
try {
_safeSetState(const AsyncValue.loading());
final datasource = ref.read(quickLinksDatasourceProvider);
result = await datasource.createQuickLink(link);
ref.invalidate(quickLinksProvider);
});
_safeInvalidate([quickLinksProvider]);
_safeSetState(const AsyncValue.data(null));
} catch (e, st) {
_safeSetState(AsyncValue.error(e, st));
}
return result;
}
/// Updates an existing quick link.
Future<QuickLink?> update(QuickLink link) async {
state = const AsyncValue.loading();
QuickLink? result;
state = await AsyncValue.guard(() async {
try {
_safeSetState(const AsyncValue.loading());
final datasource = ref.read(quickLinksDatasourceProvider);
result = await datasource.updateQuickLink(link);
ref.invalidate(quickLinksProvider);
ref.invalidate(quickLinkProvider(link.id));
});
_safeInvalidate([quickLinksProvider, quickLinkProvider(link.id)]);
_safeSetState(const AsyncValue.data(null));
} catch (e, st) {
_safeSetState(AsyncValue.error(e, st));
}
return result;
}
/// Deletes a quick link.
Future<void> delete(String id) async {
state = const AsyncValue.loading();
state = await AsyncValue.guard(() async {
try {
_safeSetState(const AsyncValue.loading());
final datasource = ref.read(quickLinksDatasourceProvider);
await datasource.deleteQuickLink(id);
ref.invalidate(quickLinksProvider);
});
final intId = int.tryParse(id) ?? 0;
await datasource.deleteQuickLink(intId);
_safeInvalidate([quickLinksProvider]);
_safeSetState(const AsyncValue.data(null));
} catch (e, st) {
_safeSetState(AsyncValue.error(e, st));
}
}
/// Reorders quick links.
Future<void> reorder(List<String> orderedIds) async {
state = const AsyncValue.loading();
state = await AsyncValue.guard(() async {
try {
_safeSetState(const AsyncValue.loading());
final datasource = ref.read(quickLinksDatasourceProvider);
await datasource.reorderQuickLinks(orderedIds);
ref.invalidate(quickLinksProvider);
});
final intIds = orderedIds.map((id) => int.tryParse(id) ?? 0).toList();
await datasource.reorderQuickLinks(intIds);
_safeInvalidate([quickLinksProvider]);
_safeSetState(const AsyncValue.data(null));
} catch (e, st) {
_safeSetState(AsyncValue.error(e, st));
}
}
}