mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-28 00:24:55 +00:00
matched community and space models with API.
This commit is contained in:
@ -34,8 +34,8 @@ class CommunitiesPaginationModel extends Equatable {
|
||||
page: json['page'] as int? ?? 1,
|
||||
size: json['size'] as int? ?? 25,
|
||||
hasNext: json['hasNext'] as bool? ?? false,
|
||||
totalItems: json['totalItems'] as int? ?? 0,
|
||||
totalPages: json['totalPages'] as int? ?? 0,
|
||||
totalItems: json['totalItem'] as int? ?? 0,
|
||||
totalPages: json['totalPage'] as int? ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -4,11 +4,19 @@ import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain
|
||||
class CommunityModel extends Equatable {
|
||||
final String uuid;
|
||||
final String name;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final String description;
|
||||
final String externalId;
|
||||
final List<SpaceModel> spaces;
|
||||
|
||||
const CommunityModel({
|
||||
required this.uuid,
|
||||
required this.name,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.description,
|
||||
required this.externalId,
|
||||
required this.spaces,
|
||||
});
|
||||
|
||||
@ -16,6 +24,10 @@ class CommunityModel extends Equatable {
|
||||
return CommunityModel(
|
||||
uuid: json['uuid'] as String,
|
||||
name: json['name'] as String,
|
||||
createdAt: DateTime.parse(json['createdAt'] as String),
|
||||
updatedAt: DateTime.parse(json['updatedAt'] as String),
|
||||
description: json['description'] as String,
|
||||
externalId: json['externalId'] as String,
|
||||
spaces: (json['spaces'] as List<dynamic>)
|
||||
.map((e) => SpaceModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
|
||||
@ -1,43 +1,38 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
enum SpaceStatus {
|
||||
active,
|
||||
deleted,
|
||||
parentDeleted;
|
||||
|
||||
static SpaceStatus getValueFromString(String value) => switch (value) {
|
||||
'active' => active,
|
||||
'deleted' => deleted,
|
||||
'parentDeleted' => parentDeleted,
|
||||
_ => active,
|
||||
};
|
||||
}
|
||||
|
||||
class SpaceModel extends Equatable {
|
||||
final String uuid;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final String spaceName;
|
||||
final String icon;
|
||||
final List<SpaceModel> children;
|
||||
final SpaceStatus status;
|
||||
final SpaceModel? parent;
|
||||
|
||||
const SpaceModel({
|
||||
required this.uuid,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.spaceName,
|
||||
required this.icon,
|
||||
required this.children,
|
||||
required this.status,
|
||||
required this.parent,
|
||||
});
|
||||
|
||||
factory SpaceModel.fromJson(Map<String, dynamic> json) {
|
||||
return SpaceModel(
|
||||
uuid: json['uuid'] as String,
|
||||
createdAt: DateTime.parse(json['createdAt'] as String),
|
||||
updatedAt: DateTime.parse(json['updatedAt'] as String),
|
||||
spaceName: json['spaceName'] as String,
|
||||
icon: json['icon'] as String,
|
||||
children: (json['children'] as List<dynamic>?)
|
||||
?.map((e) => SpaceModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
status: SpaceStatus.getValueFromString(json['status'] as String),
|
||||
parent: json['parent'] != null
|
||||
? SpaceModel.fromJson(json['parent'] as Map<String, dynamic>)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user