From 7cafe3aaa9c7b27ba4cfa17b05fd18fdd91a1653 Mon Sep 17 00:00:00 2001 From: "taha.alam" Date: Mon, 10 Feb 2025 15:27:53 +0300 Subject: [PATCH] WD: Arabic name value is handled. --- lib/models/Appointments/DoctorListResponse.dart | 16 ++++++++++++++-- .../components/SearchByClinic.dart | 4 +++- .../components/SearchByDoctor.dart | 6 ++++-- .../components/search_by_hospital_name.dart | 6 ++++-- .../doctor_response_mapper.dart | 11 ++++++----- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/lib/models/Appointments/DoctorListResponse.dart b/lib/models/Appointments/DoctorListResponse.dart index c06d8c37..cf9a5ea7 100644 --- a/lib/models/Appointments/DoctorListResponse.dart +++ b/lib/models/Appointments/DoctorListResponse.dart @@ -48,6 +48,8 @@ class DoctorList { String? projectTopName; bool? isHMC; String? region; + String? regionArabic; + String? regionEnglish; String? regionID; DoctorList( @@ -100,7 +102,9 @@ class DoctorList { this.projectTopName, this.isHMC, this.region, - this.regionID, + this.regionArabic, + this.regionEnglish, + this.regionID, }); DoctorList.fromJson( @@ -154,7 +158,15 @@ class DoctorList { projectBottomName = json['ProjectNameBottom']; projectTopName = json['ProjectNameTop']; this.isHMC = json["IsHMC"]; - this.region = json["RegionName"]; + this.regionArabic = json['RegionNameN']; + this.regionEnglish = json['RegionName']; + } + + String? getRegionName(bool isArabic) { + if (isArabic) { + return regionArabic; + } + return regionEnglish; } Map toJson() { diff --git a/lib/pages/BookAppointment/components/SearchByClinic.dart b/lib/pages/BookAppointment/components/SearchByClinic.dart index af630471..1d3373f0 100644 --- a/lib/pages/BookAppointment/components/SearchByClinic.dart +++ b/lib/pages/BookAppointment/components/SearchByClinic.dart @@ -627,6 +627,7 @@ class _SearchByClinicState extends State { } callDoctorsSearchAPI(int clinicID) { + bool isArabic = context.read().isArabic; int languageID = context.read().isArabic ? 1 : 2; GifLoaderDialogUtils.showMyDialog(context); List doctorsList = []; @@ -656,7 +657,8 @@ class _SearchByClinicState extends State { )); }); - regionHospitalList = await DoctorMapper.getMappedDoctor(doctorsList); + regionHospitalList = await DoctorMapper.getMappedDoctor(doctorsList, + isArabic: isArabic); regionHospitalList = await DoctorMapper.sortList(true, regionHospitalList); diff --git a/lib/pages/BookAppointment/components/SearchByDoctor.dart b/lib/pages/BookAppointment/components/SearchByDoctor.dart index 4ce443c4..afca5606 100644 --- a/lib/pages/BookAppointment/components/SearchByDoctor.dart +++ b/lib/pages/BookAppointment/components/SearchByDoctor.dart @@ -91,7 +91,8 @@ class _SearchByDoctorState extends State { } getDoctorsList(BuildContext context) { - int languageID = context.read().isArabic ? 1 : 2; + bool isArabic = context.read().isArabic; + int languageID = isArabic ? 1 : 2; GifLoaderDialogUtils.showMyDialog(context); List doctorsList = []; DoctorsListService service = new DoctorsListService(); @@ -119,7 +120,8 @@ class _SearchByDoctorState extends State { }); // print('the counter is ${counter}'); - regionHospitalList = await DoctorMapper.getMappedDoctor(doctorsList); + regionHospitalList = await DoctorMapper.getMappedDoctor(doctorsList, + isArabic: isArabic); regionHospitalList = await DoctorMapper.sortList(true, regionHospitalList); diff --git a/lib/pages/BookAppointment/components/search_by_hospital_name.dart b/lib/pages/BookAppointment/components/search_by_hospital_name.dart index c03e8c4d..32293a19 100644 --- a/lib/pages/BookAppointment/components/search_by_hospital_name.dart +++ b/lib/pages/BookAppointment/components/search_by_hospital_name.dart @@ -372,7 +372,8 @@ class _SearchByHospitalState extends State { } callDoctorsSearchAPI(int clinicID) { - int languageID = context.read().isArabic ? 1 : 2; + var isArabic = context.read().isArabic; + int languageID = isArabic ? 1 : 2; GifLoaderDialogUtils.showMyDialog(context); List doctorsList = []; List arr = []; @@ -403,7 +404,8 @@ class _SearchByHospitalState extends State { )); }); - regionHospitalList = await DoctorMapper.getMappedDoctor(doctorsList); + regionHospitalList = await DoctorMapper.getMappedDoctor(doctorsList, + isArabic: isArabic); regionHospitalList = await DoctorMapper.sortList(true, regionHospitalList); diff --git a/lib/services/appointment_services/doctor_response_mapper.dart b/lib/services/appointment_services/doctor_response_mapper.dart index 60ec05f6..ea6c321b 100644 --- a/lib/services/appointment_services/doctor_response_mapper.dart +++ b/lib/services/appointment_services/doctor_response_mapper.dart @@ -5,15 +5,16 @@ import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; class DoctorMapper{ - static Future getMappedDoctor(List doctorList) async { + static Future getMappedDoctor(List doctorList, + {bool isArabic = false}) async { RegionList regionList = RegionList(); AppSharedPreferences sharedPref = AppSharedPreferences(); for (var element in doctorList) { - if (element.region == null) continue; + String? region = element.getRegionName(isArabic); + if (region == null) continue; - var regionDoctorList = regionList.registeredDoctorMap?.putIfAbsent( - element.region!, () => PatientDoctorAppointmentListByRegion()); + var regionDoctorList = regionList.registeredDoctorMap?.putIfAbsent(region, () => PatientDoctorAppointmentListByRegion()); List? targetList = element.isHMC == true ? regionDoctorList?.hmcDoctorList @@ -62,7 +63,7 @@ class DoctorMapper{ regionDoctorList?.hmcSize = regionDoctorList.hmcDoctorList?.length ?? 0; regionDoctorList?.hmgSize = regionDoctorList.hmgDoctorList?.length ?? 0; - regionList.registeredDoctorMap?[element.region!] = regionDoctorList; + regionList.registeredDoctorMap?[region] = regionDoctorList; } return regionList;