update bookable space logic

This commit is contained in:
Rafeek-Khoudare
2025-07-10 15:50:24 +03:00
parent b5d72b2a2a
commit 494a000590
4 changed files with 62 additions and 1 deletions

View File

@ -40,7 +40,24 @@ class BookableSpaceConfig {
bool get isValid => bool get isValid =>
bookableDays.isNotEmpty && bookableDays.isNotEmpty &&
cost > 0 && cost >= 0 &&
bookingStartTime != null && bookingStartTime != null &&
bookingEndTime != null; bookingEndTime != null;
BookableSpaceConfig copyWith({
List<String>? bookableDays,
TimeOfDay? bookingStartTime,
TimeOfDay? bookingEndTime,
int? cost,
bool? availability,
}) {
return BookableSpaceConfig(
configUuid: configUuid,
availability: availability ?? this.availability,
bookableDays: bookableDays ?? this.bookableDays,
cost: cost ?? this.cost,
bookingEndTime: bookingEndTime ?? this.bookingEndTime,
bookingStartTime: bookingStartTime ?? this.bookingStartTime,
);
}
} }

View File

@ -41,4 +41,18 @@ class BookableSpacemodel {
spaceVirtualAddress.isNotEmpty && spaceVirtualAddress.isNotEmpty &&
spaceConfig != null && spaceConfig != null &&
spaceConfig!.isValid; spaceConfig!.isValid;
BookableSpacemodel copyWith({
String? spaceUuid,
String? spaceName,
BookableSpaceConfig? spaceConfig,
String? spaceVirtualAddress,
}) {
return BookableSpacemodel(
spaceUuid: spaceUuid ?? this.spaceUuid,
spaceName: spaceName ?? this.spaceName,
spaceConfig: spaceConfig ?? this.spaceConfig,
spaceVirtualAddress: spaceVirtualAddress ?? this.spaceVirtualAddress,
);
}
} }

View File

@ -0,0 +1,24 @@
class UpdateBookableSpaceParam {
String spaceUuid;
List<String>? bookableDays;
String? bookingStartTime;
String? bookingEndTime;
int? cost;
bool? availability;
UpdateBookableSpaceParam({
required this.spaceUuid,
this.bookingStartTime,
this.bookingEndTime,
this.bookableDays,
this.availability,
this.cost,
});
Map<String, dynamic> toJson() => {
if (bookableDays != null) 'daysAvailable': bookableDays,
if (bookingStartTime != null) 'startTime': bookingStartTime,
if (bookingEndTime != null) 'endTime': bookingEndTime,
if (cost != null) 'points': cost,
if (availability != null) 'active': availability,
};
}

View File

@ -0,0 +1,6 @@
import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/domain/models/bookable_space_config.dart';
import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/domain/params/update_bookable_space_param.dart';
abstract class UpdateBookableSpaceService {
Future<BookableSpaceConfig> update(UpdateBookableSpaceParam updateParam);
}