From 36351fc9203d78a21e0f1be631b276bbba3e4b58 Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Wed, 20 Nov 2024 10:43:55 +0300 Subject: [PATCH] Fixing JIRA Issues --- lib/config/provider_routes.dart | 4 + lib/main.dart | 10 +- lib/view_models/schedule_view_model.dart | 5 + .../appoinment_detail_list_page.dart | 5 +- lib/views/appoinments/appointment_page.dart | 53 ++-- .../appoinments/update_appointment_page.dart | 292 ++++++++++-------- .../schedule/add_schedules_page.dart | 182 ++++++----- .../schedule/schedules_list_page.dart | 18 +- .../services/create_item_page.dart | 16 +- .../widget/general_appointment_widget.dart | 29 +- 10 files changed, 344 insertions(+), 270 deletions(-) diff --git a/lib/config/provider_routes.dart b/lib/config/provider_routes.dart index 97d233d..453303d 100644 --- a/lib/config/provider_routes.dart +++ b/lib/config/provider_routes.dart @@ -23,6 +23,7 @@ import 'package:flutter/material.dart'; import 'package:mc_common_app/models/appointments_models/appointment_list_model.dart'; import 'package:mc_common_app/models/provider_branches_models/branch_detail_model.dart'; import 'package:mc_common_app/utils/enums.dart'; +import 'package:mc_common_app/views/setting_options/provider_accepted_requests_view.dart'; class ProviderAppRoutes { static final Map routes = { @@ -61,5 +62,8 @@ class ProviderAppRoutes { //Branch Duplication AppRoutes.matchServices: (context) => MatchedServicesPage((ModalRoute.of(context)!.settings.arguments) == null ? null : (ModalRoute.of(context)!.settings.arguments as MatchServicesArguments)), + + //Requests + AppRoutes.providerAcceptedRequestsView: (context) => const ProviderAcceptedRequestsView(), }; } diff --git a/lib/main.dart b/lib/main.dart index 13339a4..b686918 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ import 'dart:io'; import 'package:car_provider_app/config/provider_dependencies.dart'; +import 'package:flutter/services.dart'; import 'package:mc_common_app/repositories/items_repo.dart'; import 'package:mc_common_app/repositories/schedule_repo.dart'; import 'package:car_provider_app/view_models/items_view_model.dart'; @@ -159,14 +160,17 @@ Future main() async { // command to generate languages data from json class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp({super.key}); - @override + @override Widget build(BuildContext context) { + SystemChrome.setPreferredOrientations([ + DeviceOrientation.portraitUp, + DeviceOrientation.portraitDown, + ]); return Sizer( builder: (context, orientation, deviceType) { injector.get().setAppType(AppType.provider); - AppState().setPostParamsModel( PostParamsModel( languageID: EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2, diff --git a/lib/view_models/schedule_view_model.dart b/lib/view_models/schedule_view_model.dart index 2a2996e..3bb42d9 100644 --- a/lib/view_models/schedule_view_model.dart +++ b/lib/view_models/schedule_view_model.dart @@ -105,6 +105,11 @@ class ScheduleVM extends BaseVM { return response; } + Future checkServiceGroupInBranchSchedule(Map map) async { + GenericRespModel response = await scheduleRepo.checkServiceGroupInBranchSchedule(map); + return response; + } + Future addServicesInSchedule(Map map) async { GenericRespModel response = await scheduleRepo.addServicesInSchedule(map); return response; diff --git a/lib/views/appoinments/appoinment_detail_list_page.dart b/lib/views/appoinments/appoinment_detail_list_page.dart index a278f17..782ac00 100644 --- a/lib/views/appoinments/appoinment_detail_list_page.dart +++ b/lib/views/appoinments/appoinment_detail_list_page.dart @@ -13,7 +13,7 @@ import 'package:provider/provider.dart'; import 'package:easy_localization/easy_localization.dart'; class AppointmentDetailListPage extends StatelessWidget { - const AppointmentDetailListPage({Key? key}) : super(key: key); + const AppointmentDetailListPage({super.key}); @override Widget build(BuildContext context) { @@ -41,7 +41,8 @@ class AppointmentDetailListPage extends StatelessWidget { onTap: () { appointmentsVM.selectedAppointmentId = appointmentsVM.myFilteredAppointments2[appointmentsVM.selectedAppointmentIndex].customerAppointmentList![index].id ?? 0; appointmentsVM.selectedAppointmentSubIndex = index; - navigateWithName(context, AppRoutes.updateAppointmentPage, arguments: appointmentsVM.myFilteredAppointments2[appointmentsVM.selectedAppointmentIndex].customerAppointmentList![index]); + navigateWithName(context, AppRoutes.updateAppointmentPage, + arguments: appointmentsVM.myFilteredAppointments2[appointmentsVM.selectedAppointmentIndex].customerAppointmentList![index]); }, ); }, diff --git a/lib/views/appoinments/appointment_page.dart b/lib/views/appoinments/appointment_page.dart index 6173eed..6e120f9 100644 --- a/lib/views/appoinments/appointment_page.dart +++ b/lib/views/appoinments/appointment_page.dart @@ -104,32 +104,35 @@ class _AppointmentPageState extends State { EmptyWidget( spacerWidget: const SizedBox(height: 25), text: LocaleKeys.noAppointmentFound.tr(), + ) + else ...[ + ListView.separated( + itemBuilder: (context, index) { + return GeneralAppointmentWidget( + isNeedToShowItems: true, + appointmentListModel: appointmentsVM.myFilteredAppointments2[index], + isNeedTotalPayment: false, + onTap: () { + context.read().selectedAppointmentIndex = index; + navigateWithName( + context, + AppRoutes.appointmentDetailList, + // arguments: appointmentsVM + // .myFilteredAppointments2[index] + // .customerAppointmentList, + ); + }, + ); + }, + separatorBuilder: (context, snapchat) { + return 21.height; + }, + itemCount: appointmentsVM.myFilteredAppointments2.length, + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: const EdgeInsets.all(21), ), - ListView.separated( - itemBuilder: (context, index) { - return GeneralAppointmentWidget( - appointmentListModel: appointmentsVM.myFilteredAppointments2[index], - isNeedTotalPayment: false, - onTap: () { - context.read().selectedAppointmentIndex = index; - navigateWithName( - context, - AppRoutes.appointmentDetailList, - // arguments: appointmentsVM - // .myFilteredAppointments2[index] - // .customerAppointmentList, - ); - }, - ); - }, - separatorBuilder: (context, snapchat) { - return 21.height; - }, - itemCount: appointmentsVM.myFilteredAppointments2.length, - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: const EdgeInsets.all(21), - ), + ], ], ), ), diff --git a/lib/views/appoinments/update_appointment_page.dart b/lib/views/appoinments/update_appointment_page.dart index 73efa06..189861b 100644 --- a/lib/views/appoinments/update_appointment_page.dart +++ b/lib/views/appoinments/update_appointment_page.dart @@ -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 createState() => _UpdateAppointmentPageState(); +} + +class _UpdateAppointmentPageState extends State { + 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); }, diff --git a/lib/views/branch_management/schedule/add_schedules_page.dart b/lib/views/branch_management/schedule/add_schedules_page.dart index 33012e8..b323f12 100644 --- a/lib/views/branch_management/schedule/add_schedules_page.dart +++ b/lib/views/branch_management/schedule/add_schedules_page.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:developer'; import 'package:car_provider_app/view_models/schedule_view_model.dart'; import 'package:car_provider_app/views/branch_management/schedule/widgets/chips_picker_item.dart'; import 'package:car_provider_app/views/branch_management/schedule/widgets/select_days_sheet.dart'; @@ -35,6 +36,8 @@ class _AddSchedulesPageState extends State { late ScheduleData scheduleData; + int? scheduleID; + setEditData() { name = scheduleData.scheduleName ?? ""; startDate = DateHelper.formatAsYearMonthDay(scheduleData.fromDate ?? DateTime.now()); @@ -107,7 +110,9 @@ class _AddSchedulesPageState extends State { schedulevm.selectedServicesItems = []; schedulevm.selectedDaysItems = []; if (scheduleData.id != null) { + scheduleID = scheduleData.id; setEditData(); + setState(() {}); } }); } @@ -115,7 +120,7 @@ class _AddSchedulesPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: CustomAppBar(title: LocaleKeys.createGroupServices.tr()), + appBar: CustomAppBar(title: scheduleID == null ? LocaleKeys.createGroupServices.tr() : LocaleKeys.updateGroupServices.tr()), body: SizedBox( width: double.infinity, child: Consumer( @@ -298,7 +303,7 @@ class _AddSchedulesPageState extends State { ), ), ShowFillButton( - title: LocaleKeys.create.tr(), + title: scheduleID == null ? LocaleKeys.create.tr() : LocaleKeys.update.tr(), maxWidth: double.infinity, margin: const EdgeInsets.all(20), onPressed: () { @@ -353,102 +358,129 @@ class _AddSchedulesPageState extends State { } createSchedule(BuildContext context, ScheduleVM scheduleVM) async { - List days = []; - for (var element in scheduleVM.selectedDaysItems) { - days.add(element.id); - } - - //TODO: needs to verify with Zahoor about appointment type while creating Schedule - var map = { - "scheduleName": name, - "serviceProviderBranchID": scheduleData.branchId, - "fromDate": startDate, - "toDate": endDate, - "startTime": startTime, - "endTime": endTime, - "slotDurationMinute": slotsTime.replaceFirst(' Minutes', ''), - "perSlotAppointment": appointmentPerSlot, - "deliveryServiceType": 1, - "appointmentType": selectedScheduleLocationDrop.id, - "weeklyOffDays": days - }; - Utils.showLoading(context); - GenericRespModel scheduleResponse = await scheduleVM.createSchedule(map); - if (scheduleResponse.messageStatus == 1) { + try { List services = []; for (var element in scheduleVM.selectedServicesItems) { services.add(element.id); } var map1 = { - "branchAppointmentScheduleID": scheduleResponse.data, "serviceProviderServiceID": services, - "serviceGroupDescription": "string", + "appointmentType": selectedScheduleLocationDrop.id, }; - GenericRespModel servicesResponse = await scheduleVM.addServicesInSchedule(map1); + GenericRespModel respModel = await scheduleVM.checkServiceGroupInBranchSchedule(map1); Utils.hideLoading(context); - if (servicesResponse.messageStatus == 1) { - Utils.showToast("Successfully schedule created"); - context.read().getSchedules(scheduleData.branchId ?? ""); - pop(context); + + log("respModel: ${respModel.data}"); + if (respModel.messageStatus == 2) { + Utils.showToast(respModel.message ?? ""); + + return; + } + + List days = []; + for (var element in scheduleVM.selectedDaysItems) { + days.add(element.id); + } + + var map = { + "scheduleName": name, + "serviceProviderBranchID": scheduleData.branchId, + "fromDate": startDate, + "toDate": endDate, + "startTime": startTime, + "endTime": endTime, + "slotDurationMinute": slotsTime.replaceFirst(' Minutes', ''), + "perSlotAppointment": appointmentPerSlot, + "deliveryServiceType": 1, + "appointmentType": selectedScheduleLocationDrop.id, + "weeklyOffDays": days + }; + + Utils.showLoading(context); + GenericRespModel scheduleResponse = await scheduleVM.createSchedule(map); + + if (scheduleResponse.messageStatus == 1) { + var map1 = { + "branchAppointmentScheduleID": scheduleResponse.data, + "serviceProviderServiceID": services, + "serviceGroupDescription": "string", + }; + + GenericRespModel servicesResponse = await scheduleVM.addServicesInSchedule(map1); + Utils.hideLoading(context); + if (servicesResponse.messageStatus == 1) { + Utils.showToast("Successfully schedule created"); + context.read().getSchedules(scheduleData.branchId ?? ""); + pop(context); + } else { + Utils.showToast(servicesResponse.message ?? ""); + // context.read().getSchedules(scheduleData.branchId ?? ""); + // pop(context); + } } else { - Utils.showToast(servicesResponse.message ?? ""); - // context.read().getSchedules(scheduleData.branchId ?? ""); - // pop(context); + Utils.hideLoading(context); + Utils.showToast(scheduleResponse.message ?? ""); } - } else { + } catch (e) { + Utils.showToast(e.toString()); Utils.hideLoading(context); - Utils.showToast(scheduleResponse.message ?? ""); } } - updateSchedule(BuildContext context, ScheduleVM model) async { - List days = []; - for (var element in model.selectedDaysItems) { - days.add(element.id); - } - var map = { - "id": scheduleData.id, - "scheduleName": name, - "serviceProviderBranchID": scheduleData.branchId, - "fromDate": startDate, - "toDate": endDate, - "startTime": startTime, - "endTime": endTime, - "slotDurationMinute": slotsTime.replaceFirst(' Minutes', ''), - "perSlotAppointment": appointmentPerSlot, - "deliveryServiceType": 1, - "weeklyOffDays": days, - "appointmentType": selectedScheduleLocationDrop.id, - }; - - Utils.showLoading(context); - GenericRespModel scheduleResponse = await model.updateSchedule(map); - if (scheduleResponse.messageStatus == 1) { - List services = []; - for (var element in model.selectedServicesItems) { - services.add(element.id); + updateSchedule(BuildContext context, ScheduleVM scheduleVM) async { + try { + List days = []; + for (var element in scheduleVM.selectedDaysItems) { + days.add(element.id); } - var map1 = { - "branchAppointmentScheduleID": scheduleData.id, - "serviceProviderServiceID": services, - "serviceGroupDescription": "string", + var map = { + "id": scheduleData.id, + "scheduleName": name, + "serviceProviderBranchID": scheduleData.branchId, + "fromDate": startDate, + "toDate": endDate, + "startTime": startTime, + "endTime": endTime, + "slotDurationMinute": slotsTime.replaceFirst(' Minutes', ''), + "perSlotAppointment": appointmentPerSlot, + "deliveryServiceType": 1, + "weeklyOffDays": days, + "appointmentType": selectedScheduleLocationDrop.id, }; - GenericRespModel servicesResponse = await model.updateServicesInSchedule(map1); - Utils.hideLoading(context); - if (servicesResponse.messageStatus == 1) { - Utils.showToast(servicesResponse.message ?? "Schedule Successfully Updated"); - context.read().getSchedules(scheduleData.branchId ?? ""); - pop(context); + Utils.showLoading(context); + GenericRespModel scheduleResponse = await scheduleVM.updateSchedule(map); + if (scheduleResponse.messageStatus == 1) { + List services = []; + for (var element in scheduleVM.selectedServicesItems) { + services.add(element.id); + } + + var map1 = { + "branchAppointmentScheduleID": scheduleData.id, + "serviceProviderServiceID": services, + "serviceGroupDescription": "string", + }; + + GenericRespModel servicesResponse = await scheduleVM.updateServicesInSchedule(map1); + Utils.hideLoading(context); + if (servicesResponse.messageStatus == 1) { + Utils.showToast(servicesResponse.message ?? "Schedule Successfully Updated"); + context.read().getSchedules(scheduleData.branchId ?? ""); + pop(context); + } else { + Utils.showToast(servicesResponse.message ?? LocaleKeys.somethingWrong.tr()); + } } else { - Utils.showToast(servicesResponse.message ?? LocaleKeys.somethingWrong.tr()); + Utils.hideLoading(context); + Utils.showToast(scheduleResponse.message ?? LocaleKeys.somethingWrong.tr()); } - } else { + } catch (e) { + Utils.showToast(e.toString()); Utils.hideLoading(context); - Utils.showToast(scheduleResponse.message ?? LocaleKeys.somethingWrong.tr()); } } } diff --git a/lib/views/branch_management/schedule/schedules_list_page.dart b/lib/views/branch_management/schedule/schedules_list_page.dart index 503dc43..53dd43e 100644 --- a/lib/views/branch_management/schedule/schedules_list_page.dart +++ b/lib/views/branch_management/schedule/schedules_list_page.dart @@ -103,24 +103,21 @@ class _SchedulesListPageState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded(child: scheduleVM.schedule!.data![index].scheduleName.toString().toText(fontSize: 16)), - IconButton( - onPressed: () async { - return deleteScheduleConfirmationSheet(index, scheduleVM, context); - }, - icon: const Icon(Icons.delete_outline), - color: Colors.red, - ), Padding( padding: const EdgeInsets.all(4.0), child: SvgPicture.asset( MyAssets.icEdit, - width: 16, - height: 16, + width: 18, + height: 18, ), ).onPress(() { scheduleVM.schedule!.data![index].branchId = widget.branchId ?? ""; navigateWithName(context, AppRoutes.addSchedule, arguments: scheduleVM.schedule!.data![index]); }), + MyAssets.closeWithOrangeBg + .buildSvg(height: 28, width: 28) + .onPress(() => deleteScheduleConfirmationSheet(index, scheduleVM, context)) + .paddingOnly(top: 3, left: 4), ], ), 8.height, @@ -130,7 +127,8 @@ class _SchedulesListPageState extends State { showItem("${LocaleKeys.shiftEndTime.tr()}:", scheduleVM.schedule!.data![index].endTime ?? ""), showItem("${LocaleKeys.slotsTime.tr()}:", "${scheduleVM.schedule!.data![index].slotDurationMinute} Mins"), showItem("${LocaleKeys.appointmentPerSlot.tr()}:", scheduleVM.schedule!.data![index].perSlotAppointment.toString()), - showItem(LocaleKeys.serviceLocation.tr(), scheduleVM.schedule!.data![index].appointmentType == 1 ? LocaleKeys.companyLocation.tr() : LocaleKeys.customerLocation.tr()), + showItem( + LocaleKeys.serviceLocation.tr(), scheduleVM.schedule!.data![index].appointmentType == 1 ? LocaleKeys.companyLocation.tr() : LocaleKeys.customerLocation.tr()), showItem("${LocaleKeys.offDays.tr()}:", offDays(scheduleVM.schedule!.data![index])), 12.height, "${LocaleKeys.services.tr()}:".toText(fontSize: 12, color: MyColors.lightTextColor), diff --git a/lib/views/branch_management/services/create_item_page.dart b/lib/views/branch_management/services/create_item_page.dart index 00ad966..6ebed41 100644 --- a/lib/views/branch_management/services/create_item_page.dart +++ b/lib/views/branch_management/services/create_item_page.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:developer'; import 'dart:io'; import 'package:car_provider_app/view_models/items_view_model.dart'; @@ -103,7 +104,7 @@ class _CreateItemPageState extends State { ), 12.height, TxtField( - hint: LocaleKeys.manufacturedOn.tr(), + hint: LocaleKeys.manufacturedOn.tr(), value: year, keyboardType: TextInputType.number, isNeedClickAll: true, @@ -196,7 +197,12 @@ class _CreateItemPageState extends State { maxWidth: double.infinity, onPressed: () async { if (validation()) { - var attachedFile = Utils.convertFileToBase64(file!); + var attachedFile = ""; + if (file != null) { + attachedFile = Utils.convertFileToBase64(file!); + } else { + attachedFile = pickedImage.first.filePath ?? ""; + } if (!(itemData?.isUpdateOrSelected ?? false)) { Map map = { "name": name, @@ -220,6 +226,7 @@ class _CreateItemPageState extends State { } Utils.showToast(mResponse.message ?? ""); } else { + log("attachedIMag: $attachedFile"); Map map = { "id": itemData!.id, "name": name, @@ -255,7 +262,7 @@ class _CreateItemPageState extends State { bool validation() { bool valid = true; - if (file == null) { + if (pickedImage.isEmpty && file == null) { Utils.showToast("Please add al least one item image."); valid = false; } @@ -268,9 +275,6 @@ class _CreateItemPageState extends State { } else if (price == null) { Utils.showToast("Please add valid item price"); valid = false; - } else if (year == null) { - Utils.showToast("Please add valid year"); - valid = false; } return valid; } diff --git a/lib/views/dashboard/widget/general_appointment_widget.dart b/lib/views/dashboard/widget/general_appointment_widget.dart index c6daab6..331a684 100644 --- a/lib/views/dashboard/widget/general_appointment_widget.dart +++ b/lib/views/dashboard/widget/general_appointment_widget.dart @@ -29,8 +29,8 @@ class GeneralAppointmentWidget extends StatelessWidget { this.isSelectable = false, this.isNeedToShowAppointmentStatus = false, this.isNeedToShowMergeStatus = false, - Key? key, - }) : super(key: key); + super.key, + }); List buildServicesFromAppointment({required AppointmentListModel appointmentListModel}) { if (appointmentListModel.appointmentServicesList == null || appointmentListModel.appointmentServicesList!.isEmpty) { @@ -51,7 +51,7 @@ class GeneralAppointmentWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, children: [ showServices( - appointmentListModel.appointmentServicesList!.first.providerServiceDescription, + "${appointmentListModel.appointmentServicesList!.first.providerServiceDescription} - ${appointmentListModel.appointmentServicesList!.first.serviceId}", MyAssets.modificationsIcon, ), if (isNeedToShowItems) ...itemsList, @@ -67,28 +67,24 @@ class GeneralAppointmentWidget extends StatelessWidget { if (isNeedToShowItems) { itemsList = List.generate( appointmentListModel.appointmentServicesList?[index].serviceItems?.length ?? 0, - // (mIndex) => (" - ${appointmentListModel.appointmentServicesList?[index].serviceItems?[mIndex].name ?? ""}").toString().toText( - // color: MyColors.lightTextColor, - // ), - (mIndex) => showItems((appointmentListModel.appointmentServicesList?[index].serviceItems?[mIndex].name ?? "").toString(), MyAssets.modificationsIcon), ); } - return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - showServices(appointmentListModel.appointmentServicesList![index].providerServiceDescription, MyAssets.modificationsIcon), + showServices( + "${appointmentListModel.appointmentServicesList![index].providerServiceDescription} - ${appointmentListModel.appointmentServicesList![index].serviceId}", MyAssets.modificationsIcon), if (isNeedToShowItems) ...itemsList, ], ).paddingOnly(bottom: 6); }, ); - if (isNeedToShowToMoreText && appointmentListModel.appointmentServicesList!.length > 1) { + if (isNeedToShowToMoreText && appointmentListModel.appointmentServicesList!.length > 2) { servicesList.add( showServices( - "+ ${appointmentListModel.appointmentServicesList!.length - 1} More", + "+ ${appointmentListModel.appointmentServicesList!.length - 2} More", "", isMoreText: true, ), @@ -128,7 +124,7 @@ class GeneralAppointmentWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ if (isNeedToShowMergeStatus) - "${LocaleKeys.merged.tr()}".toText(color: MyColors.white).toContainer( + LocaleKeys.merged.tr().toText(color: MyColors.white).toContainer( padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3), borderRadius: 12, backgroundColor: MyColors.greenColor, @@ -183,13 +179,20 @@ class GeneralAppointmentWidget extends StatelessWidget { ), Row( children: [ - "${LocaleKeys.location.tr()}: ".toText(color: MyColors.lightTextColor), + "${LocaleKeys.serviceDeliveryType.tr()}: ".toText(color: MyColors.lightTextColor), 2.width, (appointmentListModel.appointmentTypeEnum == AppointmentTypeEnum.home ? LocaleKeys.home.tr() : LocaleKeys.workshop.tr()).toText( fontSize: 12, ), ], ), + Row( + children: [ + "${LocaleKeys.createdOn.tr()}: ".toText(color: MyColors.lightTextColor), + 2.width, + Flexible(child: appointmentListModel.appointmentDate!.toFormattedDateWithoutTime().toText(fontSize: 8)) + ], + ), ], ), ),