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 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 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 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 }; } }