6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 3a36fd7e

AuthorEdmir Suljic<esu@dwarf.dk>
Date2025-06-04 10:09:49 +0200
Small refactor

Changed files

.../components/selectable_service.dart             |  2 +-
 .../lib/housekeeping/cubit/housekeeping_cubit.dart | 56 ++++++++++++++++++++++
 .../lib/housekeeping/cubit/housekeeping_state.dart | 20 ++++++++
 .../lib/housekeeping/housekeeping_cubit.dart       | 56 ----------------------
 .../lib/housekeeping/housekeeping_page.dart        |  4 +-
 .../lib/housekeeping/housekeeping_state.dart       | 20 --------
 .../interceptors/response_handle_interceptor.dart  |  2 +-
 7 files changed, 80 insertions(+), 80 deletions(-)

Diff

diff --git a/comwell_key_app/lib/housekeeping/components/selectable_service.dart b/comwell_key_app/lib/housekeeping/components/selectable_service.dart
index 3c4f9bb8..736cf2f5 100644
--- a/comwell_key_app/lib/housekeeping/components/selectable_service.dart
+++ b/comwell_key_app/lib/housekeeping/components/selectable_service.dart
@@ -1,4 +1,4 @@
-import 'package:comwell_key_app/housekeeping/housekeeping_cubit.dart';
+import 'package:comwell_key_app/housekeeping/cubit/housekeeping_cubit.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
diff --git a/comwell_key_app/lib/housekeeping/cubit/housekeeping_cubit.dart b/comwell_key_app/lib/housekeeping/cubit/housekeeping_cubit.dart
new file mode 100644
index 00000000..427074f9
--- /dev/null
+++ b/comwell_key_app/lib/housekeeping/cubit/housekeeping_cubit.dart
@@ -0,0 +1,56 @@
+import 'package:bloc/bloc.dart';
+import 'package:comwell_key_app/housekeeping/cubit/housekeeping_state.dart';
+import 'package:comwell_key_app/tracking/comwell_tracking.dart';
+import 'package:comwell_key_app/tracking/models/analytics_event_item.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+
+import '../components/housekeeping_service.dart';
+import '../housekeeping_repository.dart';
+
+class HouseKeepingCubit extends Cubit<HouseKeepingState> {
+ final houseKeepingRepository = HouseKeepingRepository();
+ final tracking = locator<ComwellTracking>();
+ HouseKeepingCubit() : super(HouseKeepingState.initial());
+
+ final Iterable<HouseKeepingService> servicesSupplies = [
+ HouseKeepingService.soap,
+ HouseKeepingService.towels,
+ HouseKeepingService.trash,
+ HouseKeepingService.refill
+ ];
+
+ void onAddServiceClicked(String service) {
+ final List<String> updatedServices = List.from(state.selectedServices)
+ ..add(service);
+ emit(state.servicesSelected(selectedServices: updatedServices));
+ }
+
+ void onRemoveServiceClicked(String service) {
+ final List<String> updatedServices = List.from(state.selectedServices)
+ ..remove(service);
+ emit(state.servicesSelected(selectedServices: updatedServices));
+ }
+
+ void onServiceClicked(String name) {
+ if (state.selectedServices.contains(name)) {
+ onRemoveServiceClicked(name);
+ } else {
+ onAddServiceClicked(name);
+ }
+ }
+
+ Future<void> onOrderHousekeepingClicked(String roomNumber) async {
+ await houseKeepingRepository.saveHouseKeepingOrdered(roomNumber);
+ final analyticsEventItem = AnalyticsEventItem(
+ hotelName: "Comwell",
+ currency: "DKK",
+ value: 0,
+ placement: "housekeeping_page",
+ items: state.selectedServices,
+ itemId: "housekeeping",
+ itemName: "itemName",
+ price: 0,
+ quantity: 1);
+ tracking.trackAddToCart(analyticsEventItem);
+ }
+}
\ No newline at end of file
diff --git a/comwell_key_app/lib/housekeeping/cubit/housekeeping_state.dart b/comwell_key_app/lib/housekeeping/cubit/housekeeping_state.dart
new file mode 100644
index 00000000..f48f33bf
--- /dev/null
+++ b/comwell_key_app/lib/housekeeping/cubit/housekeeping_state.dart
@@ -0,0 +1,20 @@
+class HouseKeepingState {
+ final Iterable<String> selectedServices;
+
+ HouseKeepingState({required this.selectedServices});
+
+ HouseKeepingState.initial() : selectedServices = [];
+
+ HouseKeepingState servicesSelected({
+ required Iterable<String> selectedServices,
+ }) =>
+ _copyWith(selectedServices: selectedServices);
+
+ HouseKeepingState _copyWith({
+ Iterable<String>? selectedServices,
+ }) {
+ return HouseKeepingState(
+ selectedServices: selectedServices ?? this.selectedServices,
+ );
+ }
+}
diff --git a/comwell_key_app/lib/housekeeping/housekeeping_cubit.dart b/comwell_key_app/lib/housekeeping/housekeeping_cubit.dart
deleted file mode 100644
index f568334d..00000000
--- a/comwell_key_app/lib/housekeeping/housekeeping_cubit.dart
+++ /dev/null
@@ -1,56 +0,0 @@
-import 'package:bloc/bloc.dart';
-import 'package:comwell_key_app/housekeeping/housekeeping_state.dart';
-import 'package:comwell_key_app/tracking/comwell_tracking.dart';
-import 'package:comwell_key_app/tracking/models/analytics_event_item.dart';
-import 'package:comwell_key_app/utils/locator.dart';
-
-import 'components/housekeeping_service.dart';
-import 'housekeeping_repository.dart';
-
-class HouseKeepingCubit extends Cubit<HouseKeepingState> {
- final houseKeepingRepository = HouseKeepingRepository();
- final tracking = locator<ComwellTracking>();
- HouseKeepingCubit() : super(HouseKeepingState.initial());
-
- final Iterable<HouseKeepingService> servicesSupplies = [
- HouseKeepingService.soap,
- HouseKeepingService.towels,
- HouseKeepingService.trash,
- HouseKeepingService.refill
- ];
-
- void onAddServiceClicked(String service) {
- final List<String> updatedServices = List.from(state.selectedServices)
- ..add(service);
- emit(state.servicesSelected(selectedServices: updatedServices));
- }
-
- void onRemoveServiceClicked(String service) {
- final List<String> updatedServices = List.from(state.selectedServices)
- ..remove(service);
- emit(state.servicesSelected(selectedServices: updatedServices));
- }
-
- void onServiceClicked(String name) {
- if (state.selectedServices.contains(name)) {
- onRemoveServiceClicked(name);
- } else {
- onAddServiceClicked(name);
- }
- }
-
- Future<void> onOrderHousekeepingClicked(String roomNumber) async {
- await houseKeepingRepository.saveHouseKeepingOrdered(roomNumber);
- final analyticsEventItem = AnalyticsEventItem(
- hotelName: "Comwell",
- currency: "DKK",
- value: 0,
- placement: "housekeeping_page",
- items: state.selectedServices,
- itemId: "housekeeping",
- itemName: "itemName",
- price: 0,
- quantity: 1);
- tracking.trackAddToCart(analyticsEventItem);
- }
-}
\ No newline at end of file
diff --git a/comwell_key_app/lib/housekeeping/housekeeping_page.dart b/comwell_key_app/lib/housekeeping/housekeeping_page.dart
index 55b2163f..0674cd3e 100644
--- a/comwell_key_app/lib/housekeeping/housekeeping_page.dart
+++ b/comwell_key_app/lib/housekeeping/housekeeping_page.dart
@@ -1,7 +1,7 @@
import 'package:comwell_key_app/housekeeping/components/housekeeping_service.dart';
import 'package:comwell_key_app/housekeeping/components/selectable_service.dart';
-import 'package:comwell_key_app/housekeeping/housekeeping_cubit.dart';
-import 'package:comwell_key_app/housekeeping/housekeeping_state.dart';
+import 'package:comwell_key_app/housekeeping/cubit/housekeeping_cubit.dart';
+import 'package:comwell_key_app/housekeeping/cubit/housekeeping_state.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
diff --git a/comwell_key_app/lib/housekeeping/housekeeping_state.dart b/comwell_key_app/lib/housekeeping/housekeeping_state.dart
deleted file mode 100644
index f48f33bf..00000000
--- a/comwell_key_app/lib/housekeeping/housekeeping_state.dart
+++ /dev/null
@@ -1,20 +0,0 @@
-class HouseKeepingState {
- final Iterable<String> selectedServices;
-
- HouseKeepingState({required this.selectedServices});
-
- HouseKeepingState.initial() : selectedServices = [];
-
- HouseKeepingState servicesSelected({
- required Iterable<String> selectedServices,
- }) =>
- _copyWith(selectedServices: selectedServices);
-
- HouseKeepingState _copyWith({
- Iterable<String>? selectedServices,
- }) {
- return HouseKeepingState(
- selectedServices: selectedServices ?? this.selectedServices,
- );
- }
-}
diff --git a/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart b/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart
index c2ab7a89..f2954eb7 100644
--- a/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart
+++ b/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart
@@ -53,7 +53,7 @@ class ResponseHandleInterceptor extends Interceptor {
if (response == null) {
return handler.next(DioException(
- message: "Missing response",
+ message: "Missing response ${err.response}",
requestOptions: RequestOptions(),
));
}