From f89660a9ff6ec5cdfa59936a5c98061c42daf146 Mon Sep 17 00:00:00 2001 From: Rafeek-Khoudare Date: Mon, 7 Jul 2025 15:38:52 +0300 Subject: [PATCH] build modeling and params --- .../domain/models/bookable_space_config.dart | 39 +++++++++++++++++ .../domain/models/bookable_space_model.dart | 42 +++++++++++++++++++ .../domain/params/bookable_spaces_params.dart | 10 +++++ .../params/non_bookable_spaces_params.dart | 12 ++++++ 4 files changed, 103 insertions(+) create mode 100644 lib/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_config.dart create mode 100644 lib/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_model.dart create mode 100644 lib/pages/access_management/manage_bookable_spaces/domain/params/bookable_spaces_params.dart create mode 100644 lib/pages/access_management/manage_bookable_spaces/domain/params/non_bookable_spaces_params.dart diff --git a/lib/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_config.dart b/lib/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_config.dart new file mode 100644 index 00000000..68e7bfd8 --- /dev/null +++ b/lib/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_config.dart @@ -0,0 +1,39 @@ +class BookableSpaceConfig { + String configUuid; + List bookableDays; + String bookingStartTime; + String bookingEndTime; + int cost; + bool availability; + BookableSpaceConfig({ + required this.configUuid, + required this.availability, + required this.bookableDays, + required this.bookingEndTime, + required this.bookingStartTime, + required this.cost, + }); + factory BookableSpaceConfig.zero() => BookableSpaceConfig( + configUuid: '', + bookableDays: [], + availability: false, + bookingEndTime: '', + bookingStartTime: '', + cost: -1, + ); + factory BookableSpaceConfig.fromJson(Map json) => + BookableSpaceConfig( + configUuid: json['uuid'] as String, + bookableDays: json['daysAvailable'] as List, + availability: (json['active'] as bool?) ?? false, + bookingEndTime: json['startTime'] as String, + bookingStartTime: json['endTime'] as String, + cost: json['points'] as int, + ); + bool get isValid => + configUuid.isNotEmpty && + bookableDays.isNotEmpty && + bookingStartTime.isNotEmpty && + bookingEndTime.isNotEmpty && + cost > 0; +} diff --git a/lib/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_model.dart b/lib/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_model.dart new file mode 100644 index 00000000..f108ab08 --- /dev/null +++ b/lib/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_model.dart @@ -0,0 +1,42 @@ +import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_config.dart'; + +class BookableSpacemodel { + String spaceUuid; + String spaceName; + BookableSpaceConfig spaceConfig; + String spaceVirtualAddress; + + BookableSpacemodel({ + required this.spaceUuid, + required this.spaceName, + required this.spaceConfig, + required this.spaceVirtualAddress, + }); + factory BookableSpacemodel.zero() => BookableSpacemodel( + spaceUuid: '', + spaceName: '', + spaceConfig: BookableSpaceConfig.zero(), + spaceVirtualAddress: '', + ); + factory BookableSpacemodel.fromJson(Map json) => + BookableSpacemodel( + spaceUuid: json['uuid'] as String, + spaceName: json['spaceName'] as String, + spaceConfig: BookableSpaceConfig.fromJson( + json['bookableConfig'] as Map), + spaceVirtualAddress: json['spaceVirtualAddress'] as String, + ); + + static List fromJsonList(List jsonList) => + jsonList + .map( + (e) => BookableSpacemodel.fromJson(e as Map), + ) + .toList(); + + bool get isValid => + spaceUuid.isNotEmpty && + spaceName.isNotEmpty && + spaceVirtualAddress.isNotEmpty && + spaceConfig.isValid; +} diff --git a/lib/pages/access_management/manage_bookable_spaces/domain/params/bookable_spaces_params.dart b/lib/pages/access_management/manage_bookable_spaces/domain/params/bookable_spaces_params.dart new file mode 100644 index 00000000..02e60733 --- /dev/null +++ b/lib/pages/access_management/manage_bookable_spaces/domain/params/bookable_spaces_params.dart @@ -0,0 +1,10 @@ +class BookableSpacesParams { + int currentPage; + BookableSpacesParams({ + required this.currentPage, + }); + + Map toJson() => { + 'page': currentPage, + }; +} diff --git a/lib/pages/access_management/manage_bookable_spaces/domain/params/non_bookable_spaces_params.dart b/lib/pages/access_management/manage_bookable_spaces/domain/params/non_bookable_spaces_params.dart new file mode 100644 index 00000000..b688e6b1 --- /dev/null +++ b/lib/pages/access_management/manage_bookable_spaces/domain/params/non_bookable_spaces_params.dart @@ -0,0 +1,12 @@ +class NonBookableSpacesParams { + int currentPage; + String? searchedWords; + NonBookableSpacesParams({ + required this.currentPage, + this.searchedWords, + }); + + Map toJson() => { + 'page': currentPage, + }; +}