|
|
|
|
@ -22,10 +22,15 @@ import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
|
|
|
|
|
class UpdateAppointmentPage extends StatelessWidget {
|
|
|
|
|
late AppointmentListModel appointmentListModel;
|
|
|
|
|
class UpdateAppointmentPage extends StatefulWidget {
|
|
|
|
|
const UpdateAppointmentPage({super.key});
|
|
|
|
|
|
|
|
|
|
UpdateAppointmentPage({Key? key}) : super(key: key);
|
|
|
|
|
@override
|
|
|
|
|
State<UpdateAppointmentPage> createState() => _UpdateAppointmentPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _UpdateAppointmentPageState extends State<UpdateAppointmentPage> {
|
|
|
|
|
late AppointmentListModel appointmentListModel;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
@ -39,144 +44,150 @@ class UpdateAppointmentPage extends StatelessWidget {
|
|
|
|
|
if (appointmentsVM.state == ViewState.busy) {
|
|
|
|
|
return const Center(child: CircularProgressIndicator());
|
|
|
|
|
} else {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: ListView(
|
|
|
|
|
padding: const EdgeInsets.all(21),
|
|
|
|
|
children: [
|
|
|
|
|
GeneralAppointmentWidget(
|
|
|
|
|
appointmentListModel: appointmentListModel,
|
|
|
|
|
isNeedTotalPayment: true,
|
|
|
|
|
isNeedToShowItems: true,
|
|
|
|
|
isNeedToShowToMoreText: false,
|
|
|
|
|
onTap: () {},
|
|
|
|
|
),
|
|
|
|
|
21.height,
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.confirmed ||
|
|
|
|
|
appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.arrived ||
|
|
|
|
|
appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.workStarted) ...[
|
|
|
|
|
ShowFillButton(
|
|
|
|
|
title: ("+ ${LocaleKeys.addNewService.tr()}"),
|
|
|
|
|
txtColor: MyColors.darkPrimaryColor,
|
|
|
|
|
isFilled: false,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
navigateWithName(
|
|
|
|
|
context,
|
|
|
|
|
AppRoutes.addServiceInAppointment,
|
|
|
|
|
arguments: appointmentListModel,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
return RefreshIndicator(
|
|
|
|
|
onRefresh: () async => _updateAppointment(context, appointmentListModel.branchId ?? 0),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: ListView(
|
|
|
|
|
padding: const EdgeInsets.all(21),
|
|
|
|
|
children: [
|
|
|
|
|
GeneralAppointmentWidget(
|
|
|
|
|
appointmentListModel: appointmentListModel,
|
|
|
|
|
isNeedTotalPayment: true,
|
|
|
|
|
isNeedToShowItems: true,
|
|
|
|
|
isNeedToShowToMoreText: false,
|
|
|
|
|
onTap: () {},
|
|
|
|
|
),
|
|
|
|
|
21.height,
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.confirmed ||
|
|
|
|
|
appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.arrived ||
|
|
|
|
|
appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.workStarted) ...[
|
|
|
|
|
ShowFillButton(
|
|
|
|
|
title: ("+ ${LocaleKeys.addNewService.tr()}"),
|
|
|
|
|
txtColor: MyColors.darkPrimaryColor,
|
|
|
|
|
isFilled: false,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
navigateWithName(
|
|
|
|
|
context,
|
|
|
|
|
AppRoutes.addServiceInAppointment,
|
|
|
|
|
arguments: appointmentListModel,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.cancelled) ...[
|
|
|
|
|
Utils.buildStatusContainer(LocaleKeys.appointmentCancelled.tr()).paddingAll(10),
|
|
|
|
|
],
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.booked)
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(child: showPayNowButton(context, appointmentsVM)),
|
|
|
|
|
12.width,
|
|
|
|
|
Expanded(child: showCancelButton(context, appointmentsVM)),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.cancelled) ...[
|
|
|
|
|
Utils.buildStatusContainer(LocaleKeys.appointmentCancelled.tr()).paddingAll(10),
|
|
|
|
|
],
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.booked)
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(child: showPayNowButton(context, appointmentsVM)),
|
|
|
|
|
12.width,
|
|
|
|
|
Expanded(child: showCancelButton(context, appointmentsVM)),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.confirmed &&
|
|
|
|
|
(appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payPartial || appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.defaultStatus))
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
showArrivedButton(context, appointmentsVM),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.confirmed &&
|
|
|
|
|
(appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payPartial ||
|
|
|
|
|
appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.defaultStatus))
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
showArrivedButton(context, appointmentsVM),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.arrived &&
|
|
|
|
|
(appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payPartial || appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.defaultStatus))
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(child: showPayNowButton(context, appointmentsVM)),
|
|
|
|
|
12.width,
|
|
|
|
|
Expanded(child: showPayLaterButton(context, appointmentsVM)),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.arrived &&
|
|
|
|
|
(appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payPartial ||
|
|
|
|
|
appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.defaultStatus))
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(child: showPayNowButton(context, appointmentsVM)),
|
|
|
|
|
12.width,
|
|
|
|
|
Expanded(child: showPayLaterButton(context, appointmentsVM)),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
|
|
|
|
|
if ((appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.arrived || appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.workStarted) &&
|
|
|
|
|
appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payNow)
|
|
|
|
|
Utils.buildStatusContainer(LocaleKeys.waitingPaymentfromtheCustomer.tr()).paddingAll(10),
|
|
|
|
|
if ((appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.arrived || appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.workStarted) &&
|
|
|
|
|
appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payNow)
|
|
|
|
|
Utils.buildStatusContainer(LocaleKeys.waitingPaymentfromtheCustomer.tr()).paddingAll(10),
|
|
|
|
|
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.arrived &&
|
|
|
|
|
(appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.paid || appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payLater))
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
showWorkStartButton(context, appointmentsVM),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.arrived &&
|
|
|
|
|
(appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.paid ||
|
|
|
|
|
appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payLater))
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
showWorkStartButton(context, appointmentsVM),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.workStarted && appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payPartial)
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(child: showPayNowButton(context, appointmentsVM)),
|
|
|
|
|
12.width,
|
|
|
|
|
Expanded(child: showPayLaterButton(context, appointmentsVM)),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
// "Show Pay Now".toText(),
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.workStarted && appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payPartial)
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(child: showPayNowButton(context, appointmentsVM)),
|
|
|
|
|
12.width,
|
|
|
|
|
Expanded(child: showPayLaterButton(context, appointmentsVM)),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
// "Show Pay Now".toText(),
|
|
|
|
|
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.workStarted && appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.paid)
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
showCompleteButton(context, appointmentsVM),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
// "Show Complete Button".toText(),
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.workStarted && appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payLater)
|
|
|
|
|
showPayNowButton(context, appointmentsVM).paddingAll(21),
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.workStarted && appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.paid)
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
showCompleteButton(context, appointmentsVM),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
// "Show Complete Button".toText(),
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.workStarted && appointmentListModel.appointmentPaymentStatusEnum == AppointmentPaymentStatusEnum.payLater)
|
|
|
|
|
showPayNowButton(context, appointmentsVM).paddingAll(21),
|
|
|
|
|
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.visitCompleted) ...[
|
|
|
|
|
Utils.buildStatusContainer(LocaleKeys.appointmentisCompleted.tr()).paddingAll(10),
|
|
|
|
|
],
|
|
|
|
|
if (appointmentListModel.appointmentStatusEnum == AppointmentStatusEnum.visitCompleted) ...[
|
|
|
|
|
Utils.buildStatusContainer(LocaleKeys.appointmentisCompleted.tr()).paddingAll(10),
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
//TODO: THIS NEEDS TO BE CHECKED. IMPORTANT
|
|
|
|
|
// Padding(
|
|
|
|
|
// padding: const EdgeInsets.all(21.0),
|
|
|
|
|
// child: Column(
|
|
|
|
|
// children: [
|
|
|
|
|
// ShowFillButton(
|
|
|
|
|
// title: "Confirm Arrive",
|
|
|
|
|
// maxWidth: double.infinity,
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// showMyBottomSheet(
|
|
|
|
|
// context,
|
|
|
|
|
// child: ShowCollectPaymentSheet(
|
|
|
|
|
// onClickYes: () {},
|
|
|
|
|
// onClickNo: () {},
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 12.height,
|
|
|
|
|
// ShowFillButton(
|
|
|
|
|
// title: "Cancel Appointment",
|
|
|
|
|
// maxWidth: double.infinity,
|
|
|
|
|
// isFilled: false,
|
|
|
|
|
// txtColor: MyColors.redColor,
|
|
|
|
|
// borderColor: MyColors.redColor,
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// showMyBottomSheet(context,
|
|
|
|
|
// child: CancelAppointmentReasonSheet(
|
|
|
|
|
// onCancelClick: (String reason) {},
|
|
|
|
|
// ));
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
],
|
|
|
|
|
//TODO: THIS NEEDS TO BE CHECKED. IMPORTANT
|
|
|
|
|
// Padding(
|
|
|
|
|
// padding: const EdgeInsets.all(21.0),
|
|
|
|
|
// child: Column(
|
|
|
|
|
// children: [
|
|
|
|
|
// ShowFillButton(
|
|
|
|
|
// title: "Confirm Arrive",
|
|
|
|
|
// maxWidth: double.infinity,
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// showMyBottomSheet(
|
|
|
|
|
// context,
|
|
|
|
|
// child: ShowCollectPaymentSheet(
|
|
|
|
|
// onClickYes: () {},
|
|
|
|
|
// onClickNo: () {},
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 12.height,
|
|
|
|
|
// ShowFillButton(
|
|
|
|
|
// title: "Cancel Appointment",
|
|
|
|
|
// maxWidth: double.infinity,
|
|
|
|
|
// isFilled: false,
|
|
|
|
|
// txtColor: MyColors.redColor,
|
|
|
|
|
// borderColor: MyColors.redColor,
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// showMyBottomSheet(context,
|
|
|
|
|
// child: CancelAppointmentReasonSheet(
|
|
|
|
|
// onCancelClick: (String reason) {},
|
|
|
|
|
// ));
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
})),
|
|
|
|
|
@ -189,9 +200,14 @@ class UpdateAppointmentPage extends StatelessWidget {
|
|
|
|
|
maxWidth: double.infinity,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
await appointmentsVM.updateAppointmentStatus(appointmentId: appointmentListModel.id!, appointmentStatusEnum: AppointmentStatusEnum.workStarted);
|
|
|
|
|
bool status = await appointmentsVM.updateAppointmentStatus(appointmentId: appointmentListModel.id!, appointmentStatusEnum: AppointmentStatusEnum.workStarted);
|
|
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
|
_updateAppointment(context, appointmentListModel.branchId ?? 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
pop(context);
|
|
|
|
|
// pop(context);
|
|
|
|
|
|
|
|
|
|
// showMyBottomSheet(
|
|
|
|
|
// context,
|
|
|
|
|
@ -210,8 +226,10 @@ class UpdateAppointmentPage extends StatelessWidget {
|
|
|
|
|
maxWidth: double.infinity,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
await appointmentsVM.updateAppointmentPaymentStatus({"appointmentID": appointmentListModel.id.toString(), "appointmentServicePaymentStatusID": 2});
|
|
|
|
|
_updateAppointment(context, appointmentListModel.branchId ?? 0);
|
|
|
|
|
bool status = await appointmentsVM.updateAppointmentPaymentStatus({"appointmentID": appointmentListModel.id.toString(), "appointmentServicePaymentStatusID": 2});
|
|
|
|
|
if (status) {
|
|
|
|
|
_updateAppointment(context, appointmentListModel.branchId ?? 0);
|
|
|
|
|
}
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
pop(context);
|
|
|
|
|
},
|
|
|
|
|
@ -224,8 +242,10 @@ class UpdateAppointmentPage extends StatelessWidget {
|
|
|
|
|
maxWidth: double.infinity,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
await appointmentsVM.updateAppointmentStatus(appointmentId: appointmentListModel.id!, appointmentStatusEnum: AppointmentStatusEnum.arrived);
|
|
|
|
|
_updateAppointment(context, appointmentListModel.branchId ?? 0);
|
|
|
|
|
bool status = await appointmentsVM.updateAppointmentStatus(appointmentId: appointmentListModel.id!, appointmentStatusEnum: AppointmentStatusEnum.arrived);
|
|
|
|
|
if (status) {
|
|
|
|
|
_updateAppointment(context, appointmentListModel.branchId ?? 0);
|
|
|
|
|
}
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
pop(context);
|
|
|
|
|
},
|
|
|
|
|
|