mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
49 lines
1.4 KiB
Dart
49 lines
1.4 KiB
Dart
import 'package:syncrow_web/pages/auth/model/region_model.dart';
|
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
|
|
|
class CommunityModel {
|
|
final String uuid;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
String name;
|
|
final String description;
|
|
final RegionModel? region;
|
|
List<SpaceModel> spaces;
|
|
|
|
CommunityModel({
|
|
required this.uuid,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.name,
|
|
required this.description,
|
|
required this.spaces,
|
|
this.region,
|
|
});
|
|
|
|
factory CommunityModel.fromJson(Map<String, dynamic> json) {
|
|
return CommunityModel(
|
|
uuid: json['uuid'] ?? '',
|
|
createdAt: DateTime.parse(json['createdAt'] ?? ''),
|
|
updatedAt: DateTime.parse(json['updatedAt'] ?? ''),
|
|
name: json['name'] ?? '',
|
|
description: json['description'] ?? '',
|
|
region: json['region'] != null ? RegionModel.fromJson(json['region']) : null,
|
|
spaces: json['spaces'] != null
|
|
? (json['spaces'] as List).map((space) => SpaceModel.fromJson(space)).toList()
|
|
: [],
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'uuid': uuid,
|
|
'createdAt': createdAt.toIso8601String(),
|
|
'updatedAt': updatedAt.toIso8601String(),
|
|
'name': name,
|
|
'description': description,
|
|
'region': region?.toJson(),
|
|
'spaces': spaces.map((space) => space.toMap()).toList(), // Convert spaces to Map
|
|
};
|
|
}
|
|
}
|