6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 9a69e6ca
Changed files
comwell_key_app/lib/contact/contact_page.dart | 5 +++-- comwell_key_app/lib/contact/cubit/contact_cubit.dart | 20 +++++++++++++++++--- comwell_key_app/lib/contact/cubit/contact_state.dart | 4 ++++ .../lib/contact/repository/contact_repository.dart | 4 ++-- comwell_key_app/lib/routing/app_router.dart | 2 +- comwell_key_app/lib/services/api.dart | 2 +- 6 files changed, 28 insertions(+), 9 deletions(-)
Diff
diff --git a/comwell_key_app/lib/contact/contact_page.dart b/comwell_key_app/lib/contact/contact_page.dart
index 1e95b731..f638e0bf 100644
--- a/comwell_key_app/lib/contact/contact_page.dart
+++ b/comwell_key_app/lib/contact/contact_page.dart
@@ -6,6 +6,8 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
class ContactPage extends StatelessWidget {
+ final String hotelCode;
+ const ContactPage({required this.hotelCode, super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -27,9 +29,8 @@ class ContactPage extends StatelessWidget {
const Divider(color: colorDivider),
const SizedBox(height: 20),
GetAPhoneCallSection(
-
onPressed: () {
- // Handle button 2 press
+
},
),
],
diff --git a/comwell_key_app/lib/contact/cubit/contact_cubit.dart b/comwell_key_app/lib/contact/cubit/contact_cubit.dart
index e404f8ec..307823f0 100644
--- a/comwell_key_app/lib/contact/cubit/contact_cubit.dart
+++ b/comwell_key_app/lib/contact/cubit/contact_cubit.dart
@@ -1,13 +1,27 @@
import 'package:bloc/bloc.dart';
+import 'package:comwell_key_app/contact/repository/contact_repository.dart';
+import 'package:comwell_key_app/overview/cubit/overview_cubit.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/overview/models/bookings.dart';
+import 'package:comwell_key_app/overview/repository/overview_repository.dart';
import 'package:equatable/equatable.dart';
part 'contact_state.dart';
class ContactCubit extends Cubit<ContactState> {
- ContactCubit() : super(ContactInitial());
+ final ContactRepository contactRepository;
+ final OverviewRepository overviewRepository;
+ ContactCubit({required this.contactRepository, required this.overviewRepository}) : super(ContactInitial());
- void sendContact() {
+ void sendContact(String hotelCode) async {
emit(ContactSend());
-
+ try {
+ Bookings bookings = await overviewRepository.fetchAllBookingsForUser('1');
+ // Send contact
+ contactRepository.sendContact(bookings.current[0].hotelCode);
+ emit(ContactSent());
+ } catch (e) {
+ emit(ContactError());
+ }
}
}
diff --git a/comwell_key_app/lib/contact/cubit/contact_state.dart b/comwell_key_app/lib/contact/cubit/contact_state.dart
index 54fa6b46..7bb5982a 100644
--- a/comwell_key_app/lib/contact/cubit/contact_state.dart
+++ b/comwell_key_app/lib/contact/cubit/contact_state.dart
@@ -10,3 +10,7 @@ sealed class ContactState extends Equatable {
final class ContactInitial extends ContactState {}
final class ContactSend extends ContactState {}
+
+final class ContactSent extends ContactState {}
+
+final class ContactError extends ContactState {}
diff --git a/comwell_key_app/lib/contact/repository/contact_repository.dart b/comwell_key_app/lib/contact/repository/contact_repository.dart
index 78903cab..25b02e6c 100644
--- a/comwell_key_app/lib/contact/repository/contact_repository.dart
+++ b/comwell_key_app/lib/contact/repository/contact_repository.dart
@@ -6,8 +6,8 @@ class ContactRepository {
ContactRepository();
Future<void> sendContact(
- String telefonnummer,
+ String hotelCode
) async {
- return api.sendContact(telefonnummer);
+ return api.sendContact(hotelCode);
}
}
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index ca0d5c16..a5a5df9e 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -60,7 +60,7 @@ GoRouter goRouter(AuthenticationBloc authBloc) {
path: '/contact',
name: AppRoutes.contact.name,
builder: (context, state) {
- return ContactPage();
+ return const ContactPage(hotelCode: 'CBO',);//TODO: Get hotel code from somewhere
}),
GoRoute(
path: '/loading_page',
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
index f6e8e522..94c48578 100644
--- a/comwell_key_app/lib/services/api.dart
+++ b/comwell_key_app/lib/services/api.dart
@@ -72,5 +72,5 @@ class Api {
);
}
- Future<void> sendContact(String telefonnummer) async {}
+ Future<void> sendContact(String hotelCode) async {}
}