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:
co-authored by
Claude Opus 4.5
parent
1d68402067
commit
0d15d3dbb5
@@ -5,17 +5,25 @@ part 'quick_link_model.freezed.dart';
|
||||
part 'quick_link_model.g.dart';
|
||||
|
||||
/// Quick link data model for API serialization.
|
||||
///
|
||||
/// Maps to Core API dashboard/quick-links endpoint:
|
||||
/// - title (API) ↔ name (Flutter entity)
|
||||
/// - icon (API) ↔ iconName (Flutter entity)
|
||||
/// - position (API) ↔ sortOrder (Flutter entity)
|
||||
/// - is_visible (API) ↔ isActive (Flutter entity)
|
||||
@freezed
|
||||
sealed class QuickLinkModel with _$QuickLinkModel {
|
||||
const factory QuickLinkModel({
|
||||
required String id,
|
||||
required String name,
|
||||
required int id,
|
||||
required String title,
|
||||
required String url,
|
||||
@JsonKey(name: 'icon_name') required String iconName,
|
||||
String? icon,
|
||||
String? description,
|
||||
String? category,
|
||||
@Default('iframe') String type,
|
||||
@JsonKey(name: 'sort_order') @Default(0) int sortOrder,
|
||||
@JsonKey(name: 'is_active') @Default(true) bool isActive,
|
||||
@Default(0) int position,
|
||||
@JsonKey(name: 'is_visible') @Default(true) bool isVisible,
|
||||
String? color,
|
||||
@JsonKey(name: 'background_color') String? backgroundColor,
|
||||
}) = _QuickLinkModel;
|
||||
|
||||
const QuickLinkModel._();
|
||||
@@ -26,36 +34,42 @@ sealed class QuickLinkModel with _$QuickLinkModel {
|
||||
/// Converts to domain entity.
|
||||
QuickLink toEntity() {
|
||||
return QuickLink(
|
||||
id: id,
|
||||
name: name,
|
||||
id: id.toString(),
|
||||
name: title,
|
||||
url: url,
|
||||
iconName: iconName,
|
||||
iconName: icon ?? 'link',
|
||||
category: category,
|
||||
type: _parseType(type),
|
||||
sortOrder: sortOrder,
|
||||
isActive: isActive,
|
||||
type: QuickLinkType.iframe,
|
||||
sortOrder: position,
|
||||
isActive: isVisible,
|
||||
);
|
||||
}
|
||||
|
||||
/// Creates model from domain entity.
|
||||
factory QuickLinkModel.fromEntity(QuickLink entity) {
|
||||
return QuickLinkModel(
|
||||
id: entity.id,
|
||||
name: entity.name,
|
||||
id: int.tryParse(entity.id) ?? 0,
|
||||
title: entity.name,
|
||||
url: entity.url,
|
||||
iconName: entity.iconName,
|
||||
icon: entity.iconName,
|
||||
category: entity.category,
|
||||
type: entity.type == QuickLinkType.iframe ? 'iframe' : 'new_tab',
|
||||
sortOrder: entity.sortOrder,
|
||||
isActive: entity.isActive,
|
||||
position: entity.sortOrder,
|
||||
isVisible: entity.isActive,
|
||||
);
|
||||
}
|
||||
|
||||
QuickLinkType _parseType(String type) {
|
||||
return switch (type.toLowerCase()) {
|
||||
'iframe' => QuickLinkType.iframe,
|
||||
'new_tab' || 'newtab' => QuickLinkType.newTab,
|
||||
_ => QuickLinkType.iframe,
|
||||
/// Creates a JSON map for creating a new quick link (without id).
|
||||
Map<String, dynamic> toCreateJson() {
|
||||
return {
|
||||
'title': title,
|
||||
'url': url,
|
||||
if (icon != null) 'icon': icon,
|
||||
if (description != null) 'description': description,
|
||||
if (category != null) 'category': category,
|
||||
'position': position,
|
||||
'is_visible': isVisible,
|
||||
if (color != null) 'color': color,
|
||||
if (backgroundColor != null) 'background_color': backgroundColor,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user