mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
build modeling and params
This commit is contained in:
@ -0,0 +1,39 @@
|
|||||||
|
class BookableSpaceConfig {
|
||||||
|
String configUuid;
|
||||||
|
List<String> 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<String, dynamic> json) =>
|
||||||
|
BookableSpaceConfig(
|
||||||
|
configUuid: json['uuid'] as String,
|
||||||
|
bookableDays: json['daysAvailable'] as List<String>,
|
||||||
|
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;
|
||||||
|
}
|
@ -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<String, dynamic> json) =>
|
||||||
|
BookableSpacemodel(
|
||||||
|
spaceUuid: json['uuid'] as String,
|
||||||
|
spaceName: json['spaceName'] as String,
|
||||||
|
spaceConfig: BookableSpaceConfig.fromJson(
|
||||||
|
json['bookableConfig'] as Map<String, dynamic>),
|
||||||
|
spaceVirtualAddress: json['spaceVirtualAddress'] as String,
|
||||||
|
);
|
||||||
|
|
||||||
|
static List<BookableSpacemodel> fromJsonList(List<dynamic> jsonList) =>
|
||||||
|
jsonList
|
||||||
|
.map(
|
||||||
|
(e) => BookableSpacemodel.fromJson(e as Map<String, dynamic>),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
bool get isValid =>
|
||||||
|
spaceUuid.isNotEmpty &&
|
||||||
|
spaceName.isNotEmpty &&
|
||||||
|
spaceVirtualAddress.isNotEmpty &&
|
||||||
|
spaceConfig.isValid;
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
class BookableSpacesParams {
|
||||||
|
int currentPage;
|
||||||
|
BookableSpacesParams({
|
||||||
|
required this.currentPage,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'page': currentPage,
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
class NonBookableSpacesParams {
|
||||||
|
int currentPage;
|
||||||
|
String? searchedWords;
|
||||||
|
NonBookableSpacesParams({
|
||||||
|
required this.currentPage,
|
||||||
|
this.searchedWords,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'page': currentPage,
|
||||||
|
};
|
||||||
|
}
|
Reference in New Issue
Block a user