|
|
|
|
@ -1,10 +1,11 @@
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/loading_utils.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
|
|
|
|
@ -17,8 +18,8 @@ import 'package:hmg_patient_app_new/features/symptoms_checker/symptoms_checker_v
|
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/book_appointment/waiting_appointment/waiting_appointment_payment_page.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
|
|
|
|
@ -77,7 +78,8 @@ class _ReviewAppointmentPageState extends State<ReviewAppointmentPage> {
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Image.network(
|
|
|
|
|
bookAppointmentsViewModel.selectedDoctor.doctorImageURL ?? "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png",
|
|
|
|
|
bookAppointmentsViewModel.selectedDoctor.doctorImageURL ??
|
|
|
|
|
"https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png",
|
|
|
|
|
width: 50.h,
|
|
|
|
|
height: 50.h,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
@ -93,9 +95,11 @@ class _ReviewAppointmentPageState extends State<ReviewAppointmentPage> {
|
|
|
|
|
.toString()
|
|
|
|
|
.toText16(isBold: true, maxlines: 1),
|
|
|
|
|
SizedBox(width: 12.w),
|
|
|
|
|
(bookAppointmentsViewModel.selectedDoctor.nationalityFlagURL != null && bookAppointmentsViewModel.selectedDoctor.nationalityFlagURL!.isNotEmpty)
|
|
|
|
|
(bookAppointmentsViewModel.selectedDoctor.nationalityFlagURL != null &&
|
|
|
|
|
bookAppointmentsViewModel.selectedDoctor.nationalityFlagURL!.isNotEmpty)
|
|
|
|
|
? Image.network(
|
|
|
|
|
bookAppointmentsViewModel.selectedDoctor.nationalityFlagURL ?? "https://hmgwebservices.com/Images/flag/SAU.png",
|
|
|
|
|
bookAppointmentsViewModel.selectedDoctor.nationalityFlagURL ??
|
|
|
|
|
"https://hmgwebservices.com/Images/flag/SAU.png",
|
|
|
|
|
width: 20.h,
|
|
|
|
|
height: 15.h,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
@ -104,7 +108,9 @@ class _ReviewAppointmentPageState extends State<ReviewAppointmentPage> {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 2.h),
|
|
|
|
|
(bookAppointmentsViewModel.selectedDoctor.speciality!.isNotEmpty ? bookAppointmentsViewModel.selectedDoctor.speciality!.first : "")
|
|
|
|
|
(bookAppointmentsViewModel.selectedDoctor.speciality!.isNotEmpty
|
|
|
|
|
? bookAppointmentsViewModel.selectedDoctor.speciality!.first
|
|
|
|
|
: "")
|
|
|
|
|
.toString()
|
|
|
|
|
.toText12(isBold: true, color: AppColors.greyTextColor, maxLine: 1),
|
|
|
|
|
],
|
|
|
|
|
@ -166,7 +172,8 @@ class _ReviewAppointmentPageState extends State<ReviewAppointmentPage> {
|
|
|
|
|
spacing: 4.h,
|
|
|
|
|
runSpacing: 4.h,
|
|
|
|
|
children: [
|
|
|
|
|
AppCustomChipWidget(labelText: "${appState.getAuthenticatedUser()!.age} ${LocaleKeys.yearsOld.tr(context: context)}"),
|
|
|
|
|
AppCustomChipWidget(
|
|
|
|
|
labelText: "${appState.getAuthenticatedUser()!.age} ${LocaleKeys.yearsOld.tr(context: context)}"),
|
|
|
|
|
AppCustomChipWidget(
|
|
|
|
|
labelText:
|
|
|
|
|
"${LocaleKeys.gender.tr(context: context)}: ${appState.getAuthenticatedUser()?.gender == 1 ? LocaleKeys.malE.tr(context: context) : LocaleKeys.femaleGender.tr(context: context)}"),
|
|
|
|
|
@ -303,7 +310,9 @@ class _ReviewAppointmentPageState extends State<ReviewAppointmentPage> {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
showCommonBottomSheetWithoutHeight(context, title: LocaleKeys.success.tr(context: context), child: Utils.getSuccessWidget(loadingText: apiResponse.data["SuccessMsg"]), callBackFunc: () {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(context,
|
|
|
|
|
title: LocaleKeys.success.tr(context: context),
|
|
|
|
|
child: Utils.getSuccessWidget(loadingText: apiResponse.data["SuccessMsg"]), callBackFunc: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
@ -315,7 +324,8 @@ class _ReviewAppointmentPageState extends State<ReviewAppointmentPage> {
|
|
|
|
|
},
|
|
|
|
|
onError: (error) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(context, title: LocaleKeys.error.tr(context: context), child: Utils.getErrorWidget(loadingText: error), callBackFunc: () {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(context, title: LocaleKeys.error.tr(context: context), child: Utils.getErrorWidget(loadingText: error),
|
|
|
|
|
callBackFunc: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
}, isFullScreen: false);
|
|
|
|
|
},
|
|
|
|
|
@ -325,7 +335,9 @@ class _ReviewAppointmentPageState extends State<ReviewAppointmentPage> {
|
|
|
|
|
void initiateBookAppointment() async {
|
|
|
|
|
// LoadingUtils.showFullScreenLoader(barrierDismissible: true, isSuccessDialog: false, loadingText: bookAppointmentsViewModel.isPatientRescheduleAppointment ? LocaleKeys.reschedulingAppo.tr(context: context) : LocaleKeys.bookingYourAppointment.tr(context: context));
|
|
|
|
|
LoaderBottomSheet.showLoader(
|
|
|
|
|
loadingText: bookAppointmentsViewModel.isPatientRescheduleAppointment ? LocaleKeys.reschedulingAppo.tr(context: context) : LocaleKeys.bookingYourAppointment.tr(context: context));
|
|
|
|
|
loadingText: bookAppointmentsViewModel.isPatientRescheduleAppointment
|
|
|
|
|
? LocaleKeys.reschedulingAppo.tr(context: context)
|
|
|
|
|
: LocaleKeys.bookingYourAppointment.tr(context: context));
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
|
|
|
|
|
if (bookAppointmentsViewModel.isLiveCareSchedule) {
|
|
|
|
|
@ -336,7 +348,8 @@ class _ReviewAppointmentPageState extends State<ReviewAppointmentPage> {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
await Future.delayed(Duration(milliseconds: 50)).then((value) async {
|
|
|
|
|
// LoaderBottomSheet.showLoader(loadingText: LocaleKeys.appointmentSuccess.tr());
|
|
|
|
|
showCommonBottomSheetWithoutHeight(context, child: Utils.getSuccessWidget(loadingText: LocaleKeys.appointmentSuccess.tr()), callBackFunc: () {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(context, child: Utils.getSuccessWidget(loadingText: LocaleKeys.appointmentSuccess.tr()),
|
|
|
|
|
callBackFunc: () {
|
|
|
|
|
bookAppointmentsViewModel.setIsPatientRescheduleAppointment(false);
|
|
|
|
|
bookAppointmentsViewModel.setIsLiveCareSchedule(false);
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
@ -366,12 +379,24 @@ class _ReviewAppointmentPageState extends State<ReviewAppointmentPage> {
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
}, onSuccess: (apiResp) async {
|
|
|
|
|
log("AppointmentNo: ${symptomsCheckerViewModel.isBookingFromSymptomsChecker}");
|
|
|
|
|
// Check if booking is from symptoms checker and call the API
|
|
|
|
|
if (symptomsCheckerViewModel.isBookingFromSymptomsChecker) {
|
|
|
|
|
final appointmentNo = apiResp.data['AppointmentNo']?.toString() ?? '';
|
|
|
|
|
final doctorId = bookAppointmentsViewModel.selectedDoctor.doctorID?.toString() ?? '';
|
|
|
|
|
// Combine date and time for ISO string format
|
|
|
|
|
final appointmentDate = '${bookAppointmentsViewModel.selectedAppointmentDate} ${bookAppointmentsViewModel.selectedAppointmentTime}';
|
|
|
|
|
|
|
|
|
|
// Convert date and time to ISO 8601 format with timezone
|
|
|
|
|
DateTime? appointmentDateTime;
|
|
|
|
|
try {
|
|
|
|
|
// Combine date (YYYY-MM-DD) and time (HH:MM) into ISO format string
|
|
|
|
|
final dateTimeString = '${bookAppointmentsViewModel.selectedAppointmentDate}T${bookAppointmentsViewModel.selectedAppointmentTime}:00';
|
|
|
|
|
appointmentDateTime = DateTime.parse(dateTimeString);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log("Error parsing appointment date/time: $e");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Convert to ISO 8601 format with UTC timezone (e.g., "2026-02-11T13:15:37.652Z")
|
|
|
|
|
final appointmentDate = appointmentDateTime != null ? DateUtil.getISODateFormat(appointmentDateTime.toUtc()) : '';
|
|
|
|
|
final mobileNumber = appState.getAuthenticatedUser()?.mobileNumber ?? '';
|
|
|
|
|
final fileNo = appState.getAuthenticatedUser()?.patientId?.toString() ?? '';
|
|
|
|
|
final projectId = bookAppointmentsViewModel.selectedDoctor.projectID ?? 0;
|
|
|
|
|
@ -388,7 +413,6 @@ class _ReviewAppointmentPageState extends State<ReviewAppointmentPage> {
|
|
|
|
|
onSuccess: (response) {
|
|
|
|
|
// Success - continue with normal flow
|
|
|
|
|
debugPrint("onSuccess called for saveAppointmentDetailsForSymptomsChecker: ${response.data}");
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onError: (error) {
|
|
|
|
|
// Log error but don't block the user flow
|
|
|
|
|
@ -399,7 +423,8 @@ class _ReviewAppointmentPageState extends State<ReviewAppointmentPage> {
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
await Future.delayed(Duration(milliseconds: 50)).then((value) async {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(context, child: Utils.getSuccessWidget(loadingText: LocaleKeys.appointmentSuccess.tr()).paddingSymmetrical(0.h, 24.h), callBackFunc: () {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(context,
|
|
|
|
|
child: Utils.getSuccessWidget(loadingText: LocaleKeys.appointmentSuccess.tr()).paddingSymmetrical(0.h, 24.h), callBackFunc: () {
|
|
|
|
|
bookAppointmentsViewModel.setIsLiveCareSchedule(false);
|
|
|
|
|
bookAppointmentsViewModel.setIsPatientRescheduleAppointment(false);
|
|
|
|
|
Navigator.pushAndRemoveUntil(context, CustomPageRoute(page: LandingNavigation()), (r) => false);
|
|
|
|
|
|