7/5/1
This commit is contained in:
@@ -201,7 +201,7 @@ class AI extends GetxController {
|
||||
|
||||
if (isCarSaved && isDriverSaved) {
|
||||
DeviceController().getDeviceSerialNumber();
|
||||
box.write(BoxName.phoneVerified, 1);
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
Get.offAll(() => HomeCaptain());
|
||||
// Get.offAll(() => HomeCaptain());
|
||||
}
|
||||
@@ -209,89 +209,164 @@ class AI extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> addDriverEgypt() async {
|
||||
try {
|
||||
// Extract values from box or set defaults
|
||||
var firstName = responseIdEgyptDriverLicense['firstName'] ?? '';
|
||||
var lastName = responseIdEgyptDriverLicense['lastName'] ?? '';
|
||||
var email = box.read(BoxName.emailDriver) ?? '';
|
||||
var phone = box.read(BoxName.phoneDriver)?.toString() ?? '';
|
||||
var driverId = box.read(BoxName.driverID)?.toString() ?? '';
|
||||
var password = '123456';
|
||||
var gender = responseIdEgyptBack['gender'] == 'ذكر' ? 'Male' : 'Female';
|
||||
var licenseType = responseIdEgyptDriverLicense['license_type'] ?? '';
|
||||
var nationalNumber = responseIdEgyptBack['nationalID'] ?? '';
|
||||
var nameArabic = responseIdEgyptDriverLicense['name_arabic'] ?? '';
|
||||
var nameEnglish = responseIdEgyptDriverLicense['name_english'] ?? '';
|
||||
var issueDate = responseIdEgyptDriverLicense['issue_date'] ?? '';
|
||||
var expiryDate = responseIdEgyptDriverLicense['expiry_date'] ?? '';
|
||||
var licenseCategories =
|
||||
responseIdEgyptDriverLicense['license_categories'] ?? '';
|
||||
var address = responseIdEgyptFront['address'] ?? '';
|
||||
var cardId = responseIdEgyptFront['card_id'] ?? '';
|
||||
var occupation = responseIdEgyptBack['occupation'] ?? '';
|
||||
var education = responseIdEgyptBack['occupation'] ?? '';
|
||||
var licenseIssueDate =
|
||||
responseIdEgyptDriverLicense['issue_date'].toString() ?? '';
|
||||
var religion = responseIdEgyptBack['religion'] ?? '';
|
||||
var status = responseIdEgyptBack['fullName'] ?? '';
|
||||
var birthdate = responseIdEgyptFront['dob'] != null
|
||||
? DateTime.parse(responseIdEgyptFront['dob'] + '-01-01').toString()
|
||||
: '1960-01-01';
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
var maritalStatus = responseIdEgyptBack['maritalStatus'] ?? '';
|
||||
var site = responseIdEgyptDriverLicense['address'] ?? '';
|
||||
var employmentType = responseIdEgyptDriverLicense['employmentType'] ?? '';
|
||||
|
||||
// Create payload
|
||||
var payload = {
|
||||
'first_name': firstName,
|
||||
'last_name': lastName,
|
||||
'email': email,
|
||||
'phone': phone,
|
||||
'id': driverId,
|
||||
'password': password,
|
||||
'gender': gender,
|
||||
'license_type': licenseType,
|
||||
'national_number': nationalNumber,
|
||||
'name_arabic': nameArabic,
|
||||
'name_english': nameEnglish,
|
||||
'issue_date': issueDate,
|
||||
'expiry_date': expiryDate,
|
||||
'license_categories': licenseCategories,
|
||||
'address': address,
|
||||
'card_id': cardId,
|
||||
'occupation': occupation,
|
||||
'education': education,
|
||||
'licenseIssueDate': licenseIssueDate,
|
||||
'religion': religion,
|
||||
'status': status,
|
||||
'birthdate': birthdate,
|
||||
'maritalStatus': maritalStatus,
|
||||
'site': site,
|
||||
'employmentType': employmentType,
|
||||
};
|
||||
isLoading = true;
|
||||
update();
|
||||
// Make POST request
|
||||
var res = await CRUD().post(link: AppLink.signUpCaptin, payload: payload);
|
||||
var status1 = jsonDecode(res);
|
||||
isLoading = false;
|
||||
update();
|
||||
// Handle response
|
||||
|
||||
if (status1['status'] == 'success') {
|
||||
isDriverSaved = true;
|
||||
Get.snackbar('Success', 'Driver data saved successfully',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
} else {
|
||||
Get.snackbar('Error', 'Failed to save driver data',
|
||||
backgroundColor: Colors.red);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.snackbar('Error', 'An error occurred while saving driver data',
|
||||
var payload = {
|
||||
'first_name': responseIdEgyptDriverLicense['firstName']?.toString() ??
|
||||
'Not specified',
|
||||
'last_name': responseIdEgyptDriverLicense['lastName']?.toString() ??
|
||||
'Not specified',
|
||||
'email': box.read(BoxName.emailDriver)?.toString() ?? 'Not specified',
|
||||
'phone': box.read(BoxName.phoneDriver)?.toString() ?? 'Not specified',
|
||||
'id': box.read(BoxName.driverID)?.toString() ?? 'Not specified',
|
||||
'password': '123456',
|
||||
'gender': responseIdEgyptBack['gender']?.toString() ?? 'Not specified',
|
||||
'license_type':
|
||||
responseIdEgyptDriverLicense['license_type']?.toString() ??
|
||||
'Not specified',
|
||||
'national_number':
|
||||
responseIdEgyptBack['nationalID']?.toString() ?? 'Not specified',
|
||||
'name_arabic': responseIdEgyptDriverLicense['name_arabic']?.toString() ??
|
||||
'Not specified',
|
||||
'name_english':
|
||||
responseIdEgyptDriverLicense['name_english']?.toString() ??
|
||||
'Not specified',
|
||||
'issue_date': responseIdEgyptDriverLicense['issue_date']?.toString() ??
|
||||
'Not specified',
|
||||
'expiry_date': responseIdEgyptDriverLicense['expiry_date']?.toString() ??
|
||||
'Not specified',
|
||||
'license_categories': responseIdEgyptDriverLicense['license_categories']
|
||||
is List
|
||||
? responseIdEgyptDriverLicense['license_categories'].join(', ')
|
||||
: responseIdEgyptDriverLicense['license_categories']?.toString() ??
|
||||
'Not specified',
|
||||
'address': responseIdEgyptFront['address']?.toString() ?? 'Not specified',
|
||||
'card_id': responseIdEgyptFront['card_id']?.toString() ?? 'Not specified',
|
||||
'occupation':
|
||||
responseIdEgyptBack['occupation']?.toString() ?? 'Not specified',
|
||||
'education':
|
||||
responseIdEgyptBack['occupation']?.toString() ?? 'Not specified',
|
||||
'licenseIssueDate':
|
||||
responseIdEgyptDriverLicense['issue_date']?.toString() ??
|
||||
'Not specified',
|
||||
'religion':
|
||||
responseIdEgyptBack['religion']?.toString() ?? 'Not specified',
|
||||
'status': 'yet',
|
||||
'birthdate': responseIdEgyptFront['dob']?.toString() ?? 'Not specified',
|
||||
'maritalStatus':
|
||||
responseIdEgyptBack['maritalStatus']?.toString() ?? 'Not specified',
|
||||
'site': responseIdEgyptDriverLicense['address']?.toString() ??
|
||||
'Not specified',
|
||||
'employmentType':
|
||||
responseIdEgyptDriverLicense['employmentType']?.toString() ??
|
||||
'Not specified',
|
||||
};
|
||||
var res = await CRUD().post(link: AppLink.signUpCaptin, payload: payload);
|
||||
var status1 = jsonDecode(res);
|
||||
isLoading = false;
|
||||
update();
|
||||
print(res);
|
||||
// Handle response
|
||||
if (status1['status'] == 'success') {
|
||||
isDriverSaved = true;
|
||||
Get.snackbar('Success', 'Driver data saved successfully',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
} else {
|
||||
Get.snackbar('Error', 'Failed to save driver data',
|
||||
backgroundColor: Colors.red);
|
||||
}
|
||||
// } catch (e) {
|
||||
// isLoading = false;
|
||||
// update();
|
||||
// Get.snackbar('Error', 'An error occurred while saving driver data: $e',
|
||||
// backgroundColor: Colors.red);
|
||||
// }
|
||||
}
|
||||
// Future<void> addDriverEgypt() async {
|
||||
// // try {
|
||||
// // Extract values from box or set defaults
|
||||
// var firstName = responseIdEgyptDriverLicense['firstName'] ?? '';
|
||||
// var lastName = responseIdEgyptDriverLicense['lastName'] ?? '';
|
||||
// var email = box.read(BoxName.emailDriver) ?? '';
|
||||
// var phone = box.read(BoxName.phoneDriver)?.toString() ?? '';
|
||||
// var driverId = box.read(BoxName.driverID)?.toString() ?? '';
|
||||
// var password = '123456';
|
||||
// var gender = responseIdEgyptBack['gender'] == 'ذكر' ? 'Male' : 'Female';
|
||||
// var licenseType = responseIdEgyptDriverLicense['license_type'] ?? '';
|
||||
// var nationalNumber = responseIdEgyptBack['nationalID'] ?? '';
|
||||
// var nameArabic = responseIdEgyptDriverLicense['name_arabic'] ?? '';
|
||||
// var nameEnglish = responseIdEgyptDriverLicense['name_english'] ?? '';
|
||||
// var issueDate = responseIdEgyptDriverLicense['issue_date'] ?? '';
|
||||
// var expiryDate = responseIdEgyptDriverLicense['expiry_date'] ?? '';
|
||||
// var licenseCategories =
|
||||
// responseIdEgyptDriverLicense['license_categories'] ?? '';
|
||||
// var address = responseIdEgyptFront['address'] ?? '';
|
||||
// var cardId = responseIdEgyptFront['card_id'] ?? '';
|
||||
// var occupation = responseIdEgyptBack['occupation'] ?? '';
|
||||
// var education = responseIdEgyptBack['occupation'] ?? '';
|
||||
// var licenseIssueDate =
|
||||
// responseIdEgyptDriverLicense['issue_date'].toString() ?? '';
|
||||
// var religion = responseIdEgyptBack['religion'] ?? '';
|
||||
// var status = responseIdEgyptBack['fullName'] ?? '';
|
||||
// var birthdate = responseIdEgyptFront['dob'] != null
|
||||
// ? DateTime.parse(responseIdEgyptFront['dob'] + '-01-01').toString()
|
||||
// : '1960-01-01';
|
||||
//
|
||||
// var maritalStatus = responseIdEgyptBack['maritalStatus'] ?? '';
|
||||
// var site = responseIdEgyptDriverLicense['address'] ?? '';
|
||||
// var employmentType = responseIdEgyptDriverLicense['employmentType'] ?? '';
|
||||
//
|
||||
// // Create payload
|
||||
// var payload = {
|
||||
// 'first_name': firstName,
|
||||
// 'last_name': lastName,
|
||||
// 'email': email,
|
||||
// 'phone': phone,
|
||||
// 'id': driverId,
|
||||
// 'password': password,
|
||||
// 'gender': gender,
|
||||
// 'license_type': licenseType,
|
||||
// 'national_number': nationalNumber,
|
||||
// 'name_arabic': nameArabic,
|
||||
// 'name_english': nameEnglish,
|
||||
// 'issue_date': issueDate,
|
||||
// 'expiry_date': expiryDate,
|
||||
// 'license_categories': licenseCategories,
|
||||
// 'address': address,
|
||||
// 'card_id': cardId,
|
||||
// 'occupation': occupation,
|
||||
// 'education': education,
|
||||
// 'licenseIssueDate': licenseIssueDate,
|
||||
// 'religion': religion,
|
||||
// 'status': status,
|
||||
// 'birthdate': birthdate,
|
||||
// 'maritalStatus': maritalStatus,
|
||||
// 'site': site,
|
||||
// 'employmentType': employmentType,
|
||||
// };
|
||||
// isLoading = true;
|
||||
// update();
|
||||
// // Make POST request
|
||||
// var res = await CRUD().post(link: AppLink.signUpCaptin, payload: payload);
|
||||
// var status1 = jsonDecode(res);
|
||||
// isLoading = false;
|
||||
// update();
|
||||
// // Handle response
|
||||
//
|
||||
// if (status1['status'] == 'success') {
|
||||
// isDriverSaved = true;
|
||||
// Get.snackbar('Success', 'Driver data saved successfully',
|
||||
// backgroundColor: AppColor.greenColor);
|
||||
// } else {
|
||||
// Get.snackbar('Error', 'Failed to save driver data',
|
||||
// backgroundColor: Colors.red);
|
||||
// }
|
||||
// // } catch (e) {
|
||||
// // Get.snackbar('Error', 'An error occurred while saving driver data',
|
||||
// // backgroundColor: Colors.red);
|
||||
// // }
|
||||
// }
|
||||
|
||||
Future addRegistrationCarEgypt() async {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user