7/20/2
This commit is contained in:
@@ -304,25 +304,36 @@ class AI extends GetxController {
|
||||
responseIdEgyptDriverLicense['employmentType']?.toString() ??
|
||||
'Not specified',
|
||||
};
|
||||
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',
|
||||
|
||||
try {
|
||||
var res = await CRUD().post(link: AppLink.signUpCaptin, payload: payload);
|
||||
|
||||
// Check if response is valid JSON
|
||||
var status1;
|
||||
try {
|
||||
status1 = jsonDecode(res);
|
||||
} catch (e) {
|
||||
throw FormatException("Invalid JSON response: $res");
|
||||
}
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
|
||||
if (status1['status'] == 'success') {
|
||||
isDriverSaved = true;
|
||||
Get.snackbar('Success', 'Driver data saved successfully',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
} else {
|
||||
Get.snackbar('Error'.tr,
|
||||
'${'Failed to save driver data'.tr}: ${status1['message']}',
|
||||
backgroundColor: Colors.red);
|
||||
}
|
||||
} catch (e) {
|
||||
isLoading = false;
|
||||
update();
|
||||
Get.snackbar('Error'.tr, 'An error occurred while saving driver data'.tr,
|
||||
backgroundColor: Colors.red);
|
||||
}
|
||||
// } catch (e) {
|
||||
// isLoading = false;
|
||||
// update();
|
||||
// Get.snackbar('Error', 'An error occurred while saving driver data: $e',
|
||||
// backgroundColor: Colors.red);
|
||||
// }
|
||||
}
|
||||
|
||||
addCriminalDeocuments() async {
|
||||
|
||||
Reference in New Issue
Block a user