CHANGE_
This commit is contained in:
parent
88cbcb4e96
commit
d60bfdeb13
711
lib/addons.dart
711
lib/addons.dart
@ -4,6 +4,7 @@ import 'package:google_fonts/google_fonts.dart';
|
|||||||
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
||||||
import 'package:nhancepolicy/models/environment.dart';
|
import 'package:nhancepolicy/models/environment.dart';
|
||||||
import 'package:nhancepolicy/responsive.dart';
|
import 'package:nhancepolicy/responsive.dart';
|
||||||
|
import 'package:nhancepolicy/service/api_service.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'customAppBar/customAppBar.dart';
|
import 'customAppBar/customAppBar.dart';
|
||||||
import 'package:jwt_decode/jwt_decode.dart';
|
import 'package:jwt_decode/jwt_decode.dart';
|
||||||
@ -22,6 +23,7 @@ class addOnsDetails extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _addOnsDetailsState extends State<addOnsDetails> {
|
class _addOnsDetailsState extends State<addOnsDetails> {
|
||||||
|
late ApiService apiService;
|
||||||
bool isChecked = false;
|
bool isChecked = false;
|
||||||
bool _addOnsDependentSwitcher =
|
bool _addOnsDependentSwitcher =
|
||||||
false; // Declare the _isSwitched variable here
|
false; // Declare the _isSwitched variable here
|
||||||
@ -116,10 +118,13 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
|
|
||||||
dynamic gmcDataIsEmpty = 1;
|
dynamic gmcDataIsEmpty = 1;
|
||||||
dynamic gpaDataIsEmpty = 1;
|
dynamic gpaDataIsEmpty = 1;
|
||||||
|
dynamic empRefId;
|
||||||
|
dynamic empClientBranchId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
apiService = ApiService(context); // Initialize ApiService here
|
||||||
_dobController = TextEditingController();
|
_dobController = TextEditingController();
|
||||||
_memberNameController = TextEditingController();
|
_memberNameController = TextEditingController();
|
||||||
_relationShipController = TextEditingController();
|
_relationShipController = TextEditingController();
|
||||||
@ -154,6 +159,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||||
print(decodedToken);
|
print(decodedToken);
|
||||||
|
empClientBranchId = prefs.getString('empClientBranchId');
|
||||||
empCodeString = prefs.getString('empCode');
|
empCodeString = prefs.getString('empCode');
|
||||||
print(empCodeString); // Check if emp_code is correct
|
print(empCodeString); // Check if emp_code is correct
|
||||||
empPrimaryId = prefs.getString('empPrimaryId');
|
empPrimaryId = prefs.getString('empPrimaryId');
|
||||||
@ -184,23 +190,18 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getClientLogoAndDetails() async {
|
Future<void> getClientLogoAndDetails() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getClientDetails?client_id=$client_id&emp_code=$empCodeString');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getClientLogoAndDetailsToApi(
|
||||||
);
|
client_id!, empCodeString!, empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
print('check 1');
|
||||||
print('response.statusCode == 200');
|
if (response['status'] == 'success') {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
if (response.containsKey('data')) {
|
||||||
print(data);
|
dynamic clientDetails = response['data'];
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
|
||||||
dynamic clientDetails = data['data'];
|
|
||||||
print(clientDetails);
|
print(clientDetails);
|
||||||
clientName = clientDetails['client']['client_name'];
|
clientName = clientDetails['client']['client_name'];
|
||||||
print(clientName);
|
print(clientName);
|
||||||
@ -210,13 +211,13 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// context, 'API request failed with status: ${data['status']}');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -225,23 +226,17 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGpaEmpPolicyDetails(empPrimaryId) async {
|
Future<void> getGpaEmpPolicyDetails(empPrimaryId) async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GPA');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGpaEmpPolicyDetailsToApi(
|
||||||
);
|
empPrimaryId, empCodeString!, client_id!, 'GPA', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
if (response.containsKey('data')) {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
gpaPolicies = response['data'];
|
||||||
print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
|
||||||
gpaPolicies = data['data'];
|
|
||||||
print(gpaPolicies);
|
print(gpaPolicies);
|
||||||
// Assuming data is a List
|
// Assuming data is a List
|
||||||
print(gpaPolicies);
|
print(gpaPolicies);
|
||||||
@ -283,7 +278,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showWarningToast(context, 'Something went wrong');
|
// ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -291,7 +286,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
});
|
});
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -300,37 +295,21 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGmcEmpPolicyDetails(empPrimaryId) async {
|
Future<void> getGmcEmpPolicyDetails(empPrimaryId) async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GMC');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGmcEmpPolicyDetailsToApi(
|
||||||
);
|
empPrimaryId, empCodeString!, client_id!, 'GMC', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('GMC response.statusCode == 200');
|
// setState(() {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
gmcPolicies = response['data'];
|
||||||
print(data);
|
print('gmcPolicies');
|
||||||
|
// });
|
||||||
if (data['status'] == 'success') {
|
// Assuming data is a List
|
||||||
// setState(() {
|
print(gmcPolicies);
|
||||||
gmcPolicies = data['data'];
|
|
||||||
print('gmcPolicies');
|
|
||||||
// });
|
|
||||||
// Assuming data is a List
|
|
||||||
print(gmcPolicies);
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
gmcDataIsEmpty = 0;
|
|
||||||
});
|
|
||||||
// Handle other status messages if needed
|
|
||||||
// ToastHelper.showErrorToast(
|
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
|
||||||
print('API request failed with status: ${data['status']}');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
gmcDataIsEmpty = 0;
|
gmcDataIsEmpty = 0;
|
||||||
@ -338,7 +317,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -347,25 +326,18 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGmcSiTopUp() async {
|
Future<void> getGmcSiTopUp() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-SI-TOPUP');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGmcSiTopUpToApi(
|
||||||
);
|
client_id!, empCodeString!, 'GMC-SI-TOPUP', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
if (response.containsKey('data')) {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
|
||||||
print('222222222');
|
|
||||||
print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
topUpSiPolicies = data['data'];
|
topUpSiPolicies = response['data'];
|
||||||
print('topUpSiPolicies');
|
print('topUpSiPolicies');
|
||||||
print(topUpSiPolicies);
|
print(topUpSiPolicies);
|
||||||
});
|
});
|
||||||
@ -430,13 +402,13 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// context, 'API request failed with status: ${data['status']}');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -445,25 +417,18 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGmcSiParentTopUp() async {
|
Future<void> getGmcSiParentTopUp() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-SI-PARENT-TOPUP');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGmcSiParentTopUpToApi(client_id!,
|
||||||
);
|
empCodeString!, 'GMC-SI-PARENT-TOPUP', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
if (response.containsKey('data')) {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
|
||||||
print('parent');
|
|
||||||
print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
topUpSiParentPolicies = data['data'];
|
topUpSiParentPolicies = response['data'];
|
||||||
print('topUpSiParentPolicies');
|
print('topUpSiParentPolicies');
|
||||||
print(topUpSiParentPolicies);
|
print(topUpSiParentPolicies);
|
||||||
});
|
});
|
||||||
@ -539,13 +504,13 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// context, 'API request failed with status: ${data['status']}');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -554,25 +519,18 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGmcDependentAddOns() async {
|
Future<void> getGmcDependentAddOns() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-DEPENDENT-ADDON');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGmcDependentAddOnsToApi(client_id!,
|
||||||
);
|
empCodeString!, 'GMC-DEPENDENT-ADDON', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
if (response.containsKey('data')) {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
|
||||||
print('222222222');
|
|
||||||
print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
addOnsDependentPolicies = data['data'];
|
addOnsDependentPolicies = response['data'];
|
||||||
print('addOnsDependentPolicies');
|
print('addOnsDependentPolicies');
|
||||||
print(addOnsDependentPolicies);
|
print(addOnsDependentPolicies);
|
||||||
});
|
});
|
||||||
@ -653,13 +611,13 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// context, 'API request failed with status: ${data['status']}');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -669,18 +627,10 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
|
|
||||||
Future<void> fetchRelationshipList() async {
|
Future<void> fetchRelationshipList() async {
|
||||||
// Replace the URL with your API endpoint
|
// Replace the URL with your API endpoint
|
||||||
final url = Uri.parse(Environment.apiUrl + 'relationshipList');
|
|
||||||
try {
|
try {
|
||||||
final response = await http.get(
|
final response = await apiService.fetchRelationshipListToApi();
|
||||||
url,
|
if (response['status'] == 'success') {
|
||||||
headers: {
|
for (var item in response['data']) {
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
final List<dynamic> data = jsonDecode(response.body)['data'];
|
|
||||||
for (var item in data) {
|
|
||||||
String relationshipName = item['relationship_name'];
|
String relationshipName = item['relationship_name'];
|
||||||
String dependent = item['dependent'];
|
String dependent = item['dependent'];
|
||||||
|
|
||||||
@ -763,22 +713,12 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
|
|
||||||
Future<void> deleteItem(Map<String, dynamic> deletedItem) async {
|
Future<void> deleteItem(Map<String, dynamic> deletedItem) async {
|
||||||
print(deletedItem);
|
print(deletedItem);
|
||||||
// Define your API endpoint
|
|
||||||
var id = deletedItem['employee_id'];
|
|
||||||
final String apiUrl = Environment.apiUrl + 'deleteDependence?id=$id';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Make the DELETE request to the API endpoint
|
var id = deletedItem['employee_id'];
|
||||||
final http.Response response = await http.get(
|
final response = await apiService.deleteItemToApi(id);
|
||||||
Uri.parse(apiUrl),
|
|
||||||
headers: {
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check if the request was successful (status code 200)
|
// Check if the request was successful (status code 200)
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
formDataList.clear();
|
formDataList.clear();
|
||||||
selectedRelationships.clear();
|
selectedRelationships.clear();
|
||||||
_relationShipController.clear();
|
_relationShipController.clear();
|
||||||
@ -796,8 +736,6 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
} else {
|
} else {
|
||||||
// Handle errors
|
// Handle errors
|
||||||
ToastHelper.showErrorToast(context, 'Failed to delete item');
|
ToastHelper.showErrorToast(context, 'Failed to delete item');
|
||||||
print('Failed to delete item. Status code: ${response.statusCode}');
|
|
||||||
print('Response body: ${response.body}');
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Handle network errors
|
// Handle network errors
|
||||||
@ -821,26 +759,18 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
'is_addon_value': 1,
|
'is_addon_value': 1,
|
||||||
'basic_cover_si': addOnsSelectedDependent,
|
'basic_cover_si': addOnsSelectedDependent,
|
||||||
'created_by': empPrimaryId,
|
'created_by': empPrimaryId,
|
||||||
|
'client_branch_id': empClientBranchId,
|
||||||
// Add the 'id' field only if action is 'Edit'
|
// Add the 'id' field only if action is 'Edit'
|
||||||
if (action == 'Edit') 'id': floatedData['employee_id'],
|
if (action == 'Edit') 'id': floatedData['employee_id'],
|
||||||
});
|
});
|
||||||
|
|
||||||
// Convert the list of objects to JSON
|
// Convert the list of objects to JSON
|
||||||
String formDataJson = jsonEncode(formDataList);
|
// String formDataJson = jsonEncode(formDataList);
|
||||||
|
|
||||||
// Prepare the API request
|
final response = await apiService.saveAddOnsDetailsToApi(formDataList);
|
||||||
var url = Uri.parse(Environment.apiUrl + 'addEmployeeAndDependence');
|
|
||||||
var response = await http.post(
|
|
||||||
url,
|
|
||||||
headers: {
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
body: formDataJson,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check the response
|
// Check the response
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
formDataList.clear();
|
formDataList.clear();
|
||||||
selectedRelationships.clear();
|
selectedRelationships.clear();
|
||||||
_relationShipController.clear();
|
_relationShipController.clear();
|
||||||
@ -859,7 +789,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
} else {
|
} else {
|
||||||
// Request failed, handle error
|
// Request failed, handle error
|
||||||
ToastHelper.showErrorToast(context, 'Failed');
|
ToastHelper.showErrorToast(context, 'Failed');
|
||||||
print('Failed to send form data. Error: ${response.reasonPhrase}');
|
print('Failed to send form data. Error: ${response}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -917,31 +847,20 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
print(selectedValues);
|
print(selectedValues);
|
||||||
}
|
}
|
||||||
// Iterate through familyMembers list and send each member's data to the API
|
// Iterate through familyMembers list and send each member's data to the API
|
||||||
final url = Uri.parse(
|
|
||||||
Environment.apiUrl + 'createOrUpdateEmployeePolicySiAmount');
|
|
||||||
final response = await http.post(
|
|
||||||
url,
|
|
||||||
body: jsonEncode(selectedValues),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
final response =
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
await apiService.sendAddonsGmcDependentToAPI(selectedValues);
|
||||||
if (data['status'] == 'success') {
|
|
||||||
// Member saved successfully
|
if (response['status'] == 'success') {
|
||||||
formDataList.clear();
|
// Member saved successfully
|
||||||
selectedRelationships.clear();
|
formDataList.clear();
|
||||||
_relationShipController.clear();
|
selectedRelationships.clear();
|
||||||
_memberNameController.clear();
|
_relationShipController.clear();
|
||||||
_dobController.clear();
|
_memberNameController.clear();
|
||||||
// Navigator.pushNamed(context, 'empReviewDetails');
|
_dobController.clear();
|
||||||
// ToastHelper.showSuccessToast(context, 'Saved successfully!');
|
// Navigator.pushNamed(context, 'empReviewDetails');
|
||||||
print('Saved successfully!');
|
// ToastHelper.showSuccessToast(context, 'Saved successfully!');
|
||||||
}
|
print('Saved successfully!');
|
||||||
} else {
|
} else {
|
||||||
// Failed to save member
|
// Failed to save member
|
||||||
// ToastHelper.showErrorToast(context, "Operation Failed!");
|
// ToastHelper.showErrorToast(context, "Operation Failed!");
|
||||||
@ -1005,32 +924,19 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
print(selectedValues);
|
print(selectedValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate through familyMembers list and send each member's data to the API
|
final response =
|
||||||
final url = Uri.parse(
|
await apiService.sendAddonsGmcSiToAPI(selectedValues);
|
||||||
Environment.apiUrl + 'createOrUpdateEmployeePolicySiAmount');
|
|
||||||
final response = await http.post(
|
|
||||||
url,
|
|
||||||
body: jsonEncode(selectedValues),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
// Member saved successfully
|
||||||
if (data['status'] == 'success') {
|
formDataList.clear();
|
||||||
// Member saved successfully
|
selectedRelationships.clear();
|
||||||
formDataList.clear();
|
_relationShipController.clear();
|
||||||
selectedRelationships.clear();
|
_memberNameController.clear();
|
||||||
_relationShipController.clear();
|
_dobController.clear();
|
||||||
_memberNameController.clear();
|
// Navigator.pushNamed(context, 'empReviewDetails');
|
||||||
_dobController.clear();
|
// ToastHelper.showSuccessToast(context, 'Saved successfully!');
|
||||||
// Navigator.pushNamed(context, 'empReviewDetails');
|
print('Saved successfully!');
|
||||||
// ToastHelper.showSuccessToast(context, 'Saved successfully!');
|
|
||||||
print('Saved successfully!');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Failed to save member
|
// Failed to save member
|
||||||
// ToastHelper.showErrorToast(context, "Operation Failed!");
|
// ToastHelper.showErrorToast(context, "Operation Failed!");
|
||||||
@ -1094,32 +1000,19 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
print(selectedValues);
|
print(selectedValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate through familyMembers list and send each member's data to the API
|
final response =
|
||||||
final url = Uri.parse(
|
await apiService.sendAddonsGmcParentSiToAPI(selectedValues);
|
||||||
Environment.apiUrl + 'createOrUpdateEmployeePolicySiAmount');
|
|
||||||
final response = await http.post(
|
|
||||||
url,
|
|
||||||
body: jsonEncode(selectedValues),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
// Member saved successfully
|
||||||
if (data['status'] == 'success') {
|
formDataList.clear();
|
||||||
// Member saved successfully
|
selectedRelationships.clear();
|
||||||
formDataList.clear();
|
_relationShipController.clear();
|
||||||
selectedRelationships.clear();
|
_memberNameController.clear();
|
||||||
_relationShipController.clear();
|
_dobController.clear();
|
||||||
_memberNameController.clear();
|
// Navigator.pushNamed(context, 'empReviewDetails');
|
||||||
_dobController.clear();
|
// ToastHelper.showSuccessToast(context, 'Saved successfully!');
|
||||||
// Navigator.pushNamed(context, 'empReviewDetails');
|
print('Saved successfully!');
|
||||||
// ToastHelper.showSuccessToast(context, 'Saved successfully!');
|
|
||||||
print('Saved successfully!');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Failed to save member
|
// Failed to save member
|
||||||
// ToastHelper.showErrorToast(context, "Operation Failed!");
|
// ToastHelper.showErrorToast(context, "Operation Failed!");
|
||||||
@ -1137,24 +1030,19 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> removeAddonsGmcDependentToAPI() async {
|
Future<void> removeAddonsGmcDependentToAPI() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$addOnsDependentClientPolicyId');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (empCodeString == null || addOnsDependentClientPolicyId == null) {
|
||||||
url,
|
return;
|
||||||
headers: {
|
}
|
||||||
'Authorization':
|
final response = await apiService.removeAddonsGmcDependentToAPI(
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
empCodeString!, addOnsDependentClientPolicyId!);
|
||||||
},
|
if (response['status'] == 'success') {
|
||||||
);
|
print(response['data']);
|
||||||
if (response.statusCode == 200) {
|
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
|
||||||
print(data);
|
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -1163,24 +1051,19 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> removeAddonsGmcSiToAPI() async {
|
Future<void> removeAddonsGmcSiToAPI() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpClientPolicyId');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (empCodeString == null || topUpClientPolicyId == null) {
|
||||||
url,
|
return;
|
||||||
headers: {
|
}
|
||||||
'Authorization':
|
final response = await apiService.removeAddonsGmcSiToAPI(
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
empCodeString!, topUpClientPolicyId!);
|
||||||
},
|
if (response['status'] == 'success') {
|
||||||
);
|
print(response['data']);
|
||||||
if (response.statusCode == 200) {
|
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
|
||||||
print(data);
|
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -1189,24 +1072,19 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> removeAddonsGmcParentSiToAPI() async {
|
Future<void> removeAddonsGmcParentSiToAPI() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpParentClientPolicyId');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (empCodeString == null || topUpParentClientPolicyId == null) {
|
||||||
url,
|
return;
|
||||||
headers: {
|
}
|
||||||
'Authorization':
|
final response = await apiService.removeAddonsGmcParentSiToAPI(
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
empCodeString!, topUpParentClientPolicyId!);
|
||||||
},
|
if (response['status'] == 'success') {
|
||||||
);
|
print(response['data']);
|
||||||
if (response.statusCode == 200) {
|
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
|
||||||
print(data);
|
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -1250,61 +1128,50 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
|
|
||||||
print(calculation);
|
print(calculation);
|
||||||
// Iterate through familyMembers list and send each member's data to the API
|
// Iterate through familyMembers list and send each member's data to the API
|
||||||
final url = Uri.parse(Environment.apiUrl + 'calculatePremium');
|
|
||||||
final response = await http.post(
|
|
||||||
url,
|
|
||||||
body: jsonEncode(calculation),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
final response = await apiService.topUpSiCalculationToAPI(calculation);
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
|
||||||
if (data['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
print(data);
|
print(response);
|
||||||
List<dynamic>? topUpEmpArray;
|
List<dynamic>? topUpEmpArray;
|
||||||
for (var item in data['data']) {
|
for (var item in response['data']) {
|
||||||
if (item.containsKey(empCodeString)) {
|
if (item.containsKey(empCodeString)) {
|
||||||
topUpEmpArray = item[empCodeString];
|
topUpEmpArray = item[empCodeString];
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (topUpEmpArray != null) {
|
||||||
|
print('Array for emp_code $empCodeString:');
|
||||||
|
print(topUpEmpArray);
|
||||||
|
double topUpRataPremimumSum = 0;
|
||||||
|
for (var item in topUpEmpArray) {
|
||||||
|
var topUpRataPremimum = item['policy_details']['rata_premimum'];
|
||||||
|
if (topUpRataPremimum != null) {
|
||||||
|
topUpRataPremimumSum += topUpRataPremimum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print('Sum of rata_premimum: $topUpRataPremimumSum');
|
||||||
|
|
||||||
if (topUpEmpArray != null) {
|
double topUpGstSum = 0;
|
||||||
print('Array for emp_code $empCodeString:');
|
for (var item in topUpEmpArray) {
|
||||||
print(topUpEmpArray);
|
var topUpGst = item['policy_details']['gst'];
|
||||||
double topUpRataPremimumSum = 0;
|
if (topUpGst != null) {
|
||||||
for (var item in topUpEmpArray) {
|
topUpGstSum += topUpGst;
|
||||||
var topUpRataPremimum = item['policy_details']['rata_premimum'];
|
|
||||||
if (topUpRataPremimum != null) {
|
|
||||||
topUpRataPremimumSum += topUpRataPremimum;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
print('Sum of rata_premimum: $topUpRataPremimumSum');
|
|
||||||
|
|
||||||
double topUpGstSum = 0;
|
|
||||||
for (var item in topUpEmpArray) {
|
|
||||||
var topUpGst = item['policy_details']['gst'];
|
|
||||||
if (topUpGst != null) {
|
|
||||||
topUpGstSum += topUpGst;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print('Sum of gst: $topUpGstSum');
|
|
||||||
setState(() {
|
|
||||||
topUpSiPremiumValue = topUpRataPremimumSum;
|
|
||||||
print(topUpSiPremiumValue);
|
|
||||||
topUpSiPremiumGst = topUpGstSum;
|
|
||||||
print(topUpSiPremiumGst);
|
|
||||||
topUpSiTotalAmt = topUpSiPremiumValue + topUpSiPremiumGst;
|
|
||||||
print(topUpSiTotalAmt);
|
|
||||||
});
|
|
||||||
sendAddonsGmcSiToAPI();
|
|
||||||
} else {
|
|
||||||
print('Array not found for emp_code $empCodeString');
|
|
||||||
}
|
}
|
||||||
|
print('Sum of gst: $topUpGstSum');
|
||||||
|
setState(() {
|
||||||
|
topUpSiPremiumValue = topUpRataPremimumSum;
|
||||||
|
print(topUpSiPremiumValue);
|
||||||
|
topUpSiPremiumGst = topUpGstSum;
|
||||||
|
print(topUpSiPremiumGst);
|
||||||
|
topUpSiTotalAmt = topUpSiPremiumValue + topUpSiPremiumGst;
|
||||||
|
print(topUpSiTotalAmt);
|
||||||
|
});
|
||||||
|
sendAddonsGmcSiToAPI();
|
||||||
|
} else {
|
||||||
|
print('Array not found for emp_code $empCodeString');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print('Operation Failed!');
|
print('Operation Failed!');
|
||||||
@ -1327,62 +1194,52 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
|
|
||||||
print(calculation);
|
print(calculation);
|
||||||
// Iterate through familyMembers list and send each member's data to the API
|
// Iterate through familyMembers list and send each member's data to the API
|
||||||
final url = Uri.parse(Environment.apiUrl + 'calculatePremium');
|
|
||||||
final response = await http.post(
|
|
||||||
url,
|
|
||||||
body: jsonEncode(calculation),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
final response =
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
await apiService.topUpParentSiCalculationToAPI(calculation);
|
||||||
if (data['status'] == 'success') {
|
|
||||||
print(data);
|
if (response['status'] == 'success') {
|
||||||
List<dynamic>? topUpEmpArray;
|
print(response['data']);
|
||||||
for (var item in data['data']) {
|
List<dynamic>? topUpEmpArray;
|
||||||
if (item.containsKey(empCodeString)) {
|
for (var item in response['data']) {
|
||||||
topUpEmpArray = item[empCodeString];
|
if (item.containsKey(empCodeString)) {
|
||||||
break;
|
topUpEmpArray = item[empCodeString];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (topUpEmpArray != null) {
|
||||||
|
print('Array for emp_code $empCodeString:');
|
||||||
|
print(topUpEmpArray);
|
||||||
|
double topUpRataPremimumSum = 0;
|
||||||
|
for (var item in topUpEmpArray) {
|
||||||
|
var topUpRataPremimum = item['policy_details']['rata_premimum'];
|
||||||
|
if (topUpRataPremimum != null) {
|
||||||
|
topUpRataPremimumSum += topUpRataPremimum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print('Sum of rata_premimum: $topUpRataPremimumSum');
|
||||||
|
|
||||||
if (topUpEmpArray != null) {
|
double topUpGstSum = 0;
|
||||||
print('Array for emp_code $empCodeString:');
|
for (var item in topUpEmpArray) {
|
||||||
print(topUpEmpArray);
|
var topUpGst = item['policy_details']['gst'];
|
||||||
double topUpRataPremimumSum = 0;
|
if (topUpGst != null) {
|
||||||
for (var item in topUpEmpArray) {
|
topUpGstSum += topUpGst;
|
||||||
var topUpRataPremimum = item['policy_details']['rata_premimum'];
|
|
||||||
if (topUpRataPremimum != null) {
|
|
||||||
topUpRataPremimumSum += topUpRataPremimum;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
print('Sum of rata_premimum: $topUpRataPremimumSum');
|
|
||||||
|
|
||||||
double topUpGstSum = 0;
|
|
||||||
for (var item in topUpEmpArray) {
|
|
||||||
var topUpGst = item['policy_details']['gst'];
|
|
||||||
if (topUpGst != null) {
|
|
||||||
topUpGstSum += topUpGst;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print('Sum of gst: $topUpGstSum');
|
|
||||||
setState(() {
|
|
||||||
topUpParentSiPremiumValue = topUpRataPremimumSum;
|
|
||||||
print(topUpParentSiPremiumValue);
|
|
||||||
topUpParentSiPremiumGst = topUpGstSum;
|
|
||||||
print(topUpSiPremiumGst);
|
|
||||||
topUpParentSiTotalAmt =
|
|
||||||
topUpParentSiPremiumValue + topUpParentSiPremiumGst;
|
|
||||||
print(topUpParentSiTotalAmt);
|
|
||||||
});
|
|
||||||
sendAddonsGmcParentSiToAPI();
|
|
||||||
} else {
|
|
||||||
print('Array not found for emp_code $empCodeString');
|
|
||||||
}
|
}
|
||||||
|
print('Sum of gst: $topUpGstSum');
|
||||||
|
setState(() {
|
||||||
|
topUpParentSiPremiumValue = topUpRataPremimumSum;
|
||||||
|
print(topUpParentSiPremiumValue);
|
||||||
|
topUpParentSiPremiumGst = topUpGstSum;
|
||||||
|
print(topUpSiPremiumGst);
|
||||||
|
topUpParentSiTotalAmt =
|
||||||
|
topUpParentSiPremiumValue + topUpParentSiPremiumGst;
|
||||||
|
print(topUpParentSiTotalAmt);
|
||||||
|
});
|
||||||
|
sendAddonsGmcParentSiToAPI();
|
||||||
|
} else {
|
||||||
|
print('Array not found for emp_code $empCodeString');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print('Operation Failed!');
|
print('Operation Failed!');
|
||||||
@ -1405,61 +1262,51 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
|
|
||||||
print(calculation);
|
print(calculation);
|
||||||
// Iterate through familyMembers list and send each member's data to the API
|
// Iterate through familyMembers list and send each member's data to the API
|
||||||
final url = Uri.parse(Environment.apiUrl + 'calculatePremium');
|
|
||||||
final response = await http.post(
|
|
||||||
url,
|
|
||||||
body: jsonEncode(calculation),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
final response =
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
await apiService.addOnsDependentCalculationToAPI(calculation);
|
||||||
if (data['status'] == 'success') {
|
|
||||||
print(data);
|
if (response['status'] == 'success') {
|
||||||
List<dynamic>? addOnsEmpArray;
|
print(response['data']);
|
||||||
for (var item in data['data']) {
|
List<dynamic>? addOnsEmpArray;
|
||||||
if (item.containsKey(empCodeString)) {
|
for (var item in response['data']) {
|
||||||
addOnsEmpArray = item[empCodeString];
|
if (item.containsKey(empCodeString)) {
|
||||||
break;
|
addOnsEmpArray = item[empCodeString];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addOnsEmpArray != null) {
|
||||||
|
print('Array for emp_code $empCodeString:');
|
||||||
|
print(addOnsEmpArray);
|
||||||
|
double addOnsRataPremimumSum = 0;
|
||||||
|
for (var item in addOnsEmpArray) {
|
||||||
|
var addOnsRataPremimum = item['policy_details']['rata_premimum'];
|
||||||
|
if (addOnsRataPremimum != null) {
|
||||||
|
addOnsRataPremimumSum += addOnsRataPremimum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print('Sum of rata_premimum: $addOnsRataPremimumSum');
|
||||||
|
|
||||||
if (addOnsEmpArray != null) {
|
double addOnsGstSum = 0;
|
||||||
print('Array for emp_code $empCodeString:');
|
for (var item in addOnsEmpArray) {
|
||||||
print(addOnsEmpArray);
|
var addOnsGst = item['policy_details']['gst'];
|
||||||
double addOnsRataPremimumSum = 0;
|
if (addOnsGst != null) {
|
||||||
for (var item in addOnsEmpArray) {
|
addOnsGstSum += addOnsGst;
|
||||||
var addOnsRataPremimum = item['policy_details']['rata_premimum'];
|
|
||||||
if (addOnsRataPremimum != null) {
|
|
||||||
addOnsRataPremimumSum += addOnsRataPremimum;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
print('Sum of rata_premimum: $addOnsRataPremimumSum');
|
|
||||||
|
|
||||||
double addOnsGstSum = 0;
|
|
||||||
for (var item in addOnsEmpArray) {
|
|
||||||
var addOnsGst = item['policy_details']['gst'];
|
|
||||||
if (addOnsGst != null) {
|
|
||||||
addOnsGstSum += addOnsGst;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print('Sum of gst: $addOnsGstSum');
|
|
||||||
setState(() {
|
|
||||||
addOnDependentPremiumValue = addOnsRataPremimumSum;
|
|
||||||
print(addOnDependentPremiumValue);
|
|
||||||
addOnsDependentPremiumGst = addOnsGstSum;
|
|
||||||
print(addOnsDependentPremiumGst);
|
|
||||||
addOnsDependentTotalAmt =
|
|
||||||
addOnDependentPremiumValue + addOnsDependentPremiumGst;
|
|
||||||
print(topUpSiTotalAmt);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
print('Array not found for emp_code $empCodeString');
|
|
||||||
}
|
}
|
||||||
|
print('Sum of gst: $addOnsGstSum');
|
||||||
|
setState(() {
|
||||||
|
addOnDependentPremiumValue = addOnsRataPremimumSum;
|
||||||
|
print(addOnDependentPremiumValue);
|
||||||
|
addOnsDependentPremiumGst = addOnsGstSum;
|
||||||
|
print(addOnsDependentPremiumGst);
|
||||||
|
addOnsDependentTotalAmt =
|
||||||
|
addOnDependentPremiumValue + addOnsDependentPremiumGst;
|
||||||
|
print(topUpSiTotalAmt);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
print('Array not found for emp_code $empCodeString');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print('Operation Failed!');
|
print('Operation Failed!');
|
||||||
@ -1496,26 +1343,18 @@ class _addOnsDetailsState extends State<addOnsDetails> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Convert the list of objects to JSON
|
// Convert the list of objects to JSON
|
||||||
String formDataJson = jsonEncode(apiParams);
|
// String formDataJson = jsonEncode(apiParams);
|
||||||
|
|
||||||
var url = Uri.parse(Environment.apiUrl + 'iAgreeForAddOn');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.post(
|
final response = await apiService.sendAddOnToAPI(apiParams);
|
||||||
url,
|
|
||||||
headers: {
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
body: formDataJson,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
print('response.statusCode == 200');
|
||||||
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
ToastHelper.showErrorToast(context, 'failed to save');
|
ToastHelper.showErrorToast(context, 'failed to save');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
|
|||||||
@ -5,9 +5,49 @@ import 'package:nhancepolicy/responsive.dart';
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:nhancepolicy/responsive.dart';
|
import 'package:nhancepolicy/responsive.dart';
|
||||||
|
|
||||||
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||||
|
@override
|
||||||
|
_CustomAppBarState createState() => _CustomAppBarState();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Size get preferredSize => Size.fromHeight(kToolbarHeight);
|
Size get preferredSize => Size.fromHeight(kToolbarHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CustomAppBarState extends State<CustomAppBar> {
|
||||||
|
bool showBackToHR = true;
|
||||||
|
bool hideInactiveStatus = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_checkTokens();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _checkTokens() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final String? hrtoken = prefs.getString('hrtoken');
|
||||||
|
final String? token = prefs.getString('token');
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
showBackToHR = (hrtoken != null && hrtoken.isNotEmpty) &&
|
||||||
|
(token != null && token.isNotEmpty);
|
||||||
|
|
||||||
|
hideInactiveStatus = token != null && token.isNotEmpty;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> hrLogout(BuildContext context) async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final String? hrtoken = prefs.getString('hrtoken');
|
||||||
|
|
||||||
|
if (hrtoken != null && hrtoken.isNotEmpty) {
|
||||||
|
prefs.remove('token');
|
||||||
|
Navigator.pushNamed(context, 'hrDashboard');
|
||||||
|
} else {
|
||||||
|
await prefs.clear();
|
||||||
|
Navigator.pushNamed(context, 'phone');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> logout(BuildContext context) async {
|
Future<void> logout(BuildContext context) async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
@ -16,8 +56,8 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
|
|
||||||
if (token != null && token.isNotEmpty) {
|
if (token != null && token.isNotEmpty) {
|
||||||
if (hrtoken != null && hrtoken.isNotEmpty) {
|
if (hrtoken != null && hrtoken.isNotEmpty) {
|
||||||
prefs.remove('token');
|
await prefs.clear();
|
||||||
Navigator.pushNamed(context, 'hrDashboard');
|
Navigator.pushNamed(context, 'hrLogin');
|
||||||
} else {
|
} else {
|
||||||
await prefs.clear();
|
await prefs.clear();
|
||||||
Navigator.pushNamed(context, 'phone');
|
Navigator.pushNamed(context, 'phone');
|
||||||
@ -26,7 +66,6 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
await prefs.clear();
|
await prefs.clear();
|
||||||
Navigator.pushNamed(context, 'hrLogin');
|
Navigator.pushNamed(context, 'hrLogin');
|
||||||
}
|
}
|
||||||
// Navigator.pushNamed(context, "phone");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -36,7 +75,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Color(0xFFFFFCE5), // Set background color for AppBar
|
backgroundColor: Color(0xFFFFFCE5), // Set background color for AppBar
|
||||||
appBar: PreferredSize(
|
appBar: PreferredSize(
|
||||||
preferredSize: preferredSize,
|
preferredSize: widget.preferredSize,
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: Responsive.isDesktop(context)
|
padding: Responsive.isDesktop(context)
|
||||||
@ -50,8 +89,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: Responsive.isDesktop(context)
|
mainAxisAlignment: Responsive.isDesktop(context)
|
||||||
? MainAxisAlignment.spaceEvenly
|
? MainAxisAlignment.spaceEvenly
|
||||||
: MainAxisAlignment
|
: MainAxisAlignment.start,
|
||||||
.start, // Adjust the alignment as needed
|
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.only(top: 10, bottom: 10),
|
margin: EdgeInsets.only(top: 10, bottom: 10),
|
||||||
@ -59,19 +97,9 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
height: 230,
|
height: 230,
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'assets/nhance_client_logo.png',
|
'assets/nhance_client_logo.png',
|
||||||
fit: BoxFit.contain, // Adjust the fit as needed
|
fit: BoxFit.contain,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// SizedBox(width: 0), // Adjust the space between the images
|
|
||||||
// Container(
|
|
||||||
// margin: EdgeInsets.only(top: 10, bottom: 10),
|
|
||||||
// width: 150,
|
|
||||||
// height: 150,
|
|
||||||
// child: Image.asset(
|
|
||||||
// 'assets/partnerLogo.png',
|
|
||||||
// fit: BoxFit.contain, // Adjust the fit as needed
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -86,35 +114,24 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
title: Text(''),
|
title: Text(''),
|
||||||
navBarItems: [
|
navBarItems: [
|
||||||
if (Responsive.isDesktop(context))
|
if (Responsive.isDesktop(context))
|
||||||
|
if (hideInactiveStatus)
|
||||||
|
NavBarItem(
|
||||||
|
text: "Inactive Policy",
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pushNamed(context, 'oldPolicy');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (showBackToHR)
|
||||||
NavBarItem(
|
NavBarItem(
|
||||||
text: "",
|
text: "Back To HR",
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pushNamed(context, "routeName");
|
hrLogout(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (Responsive.isDesktop(context))
|
|
||||||
NavBarItem(
|
|
||||||
text: "",
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pushNamed(context, "routeName");
|
|
||||||
},
|
|
||||||
),
|
|
||||||
NavBarItem(
|
|
||||||
text: "Inactive Policy",
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pushNamed(context, 'oldPolicy');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
NavBarItem(
|
NavBarItem(
|
||||||
text: "Logout",
|
text: "Logout",
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
logout(context);
|
logout(context);
|
||||||
// Clear local storage (SharedPreferences)
|
|
||||||
// final prefs = await SharedPreferences.getInstance();
|
|
||||||
// prefs.clear();
|
|
||||||
// ToastHelper.showSuccessToast(
|
|
||||||
// context, 'Logout Successfully...');
|
|
||||||
// Navigator.pushNamed(context, "phone");
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
||||||
import 'package:nhancepolicy/models/environment.dart';
|
import 'package:nhancepolicy/models/environment.dart';
|
||||||
|
import 'package:nhancepolicy/service/api_service.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'customAppBar/customAppBar.dart';
|
import 'customAppBar/customAppBar.dart';
|
||||||
import 'package:jwt_decode/jwt_decode.dart';
|
import 'package:jwt_decode/jwt_decode.dart';
|
||||||
@ -24,6 +25,7 @@ class empDetails extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _empDetailsState extends State<empDetails> {
|
class _empDetailsState extends State<empDetails> {
|
||||||
|
late ApiService apiService;
|
||||||
bool isLoading = true;
|
bool isLoading = true;
|
||||||
dynamic _token;
|
dynamic _token;
|
||||||
dynamic empCodeString;
|
dynamic empCodeString;
|
||||||
@ -85,10 +87,13 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
dynamic gmcDataIsEmpty = 1;
|
dynamic gmcDataIsEmpty = 1;
|
||||||
dynamic gpaDataIsEmpty = 1;
|
dynamic gpaDataIsEmpty = 1;
|
||||||
dynamic hrPrimaryId;
|
dynamic hrPrimaryId;
|
||||||
|
dynamic empRefId;
|
||||||
|
dynamic empClientBranchId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
apiService = ApiService(context); // Initialize ApiService here
|
||||||
_dobController = TextEditingController();
|
_dobController = TextEditingController();
|
||||||
_memberNameController = TextEditingController();
|
_memberNameController = TextEditingController();
|
||||||
_relationShipController = TextEditingController();
|
_relationShipController = TextEditingController();
|
||||||
@ -151,15 +156,19 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
Map<String, dynamic> data = json.decode(response.body);
|
Map<String, dynamic> data = json.decode(response.body);
|
||||||
print(data);
|
print(data);
|
||||||
String status = data['status'];
|
String status = data['status'];
|
||||||
print(status);
|
|
||||||
if (status == 'success') {
|
if (status == 'success') {
|
||||||
|
print(status);
|
||||||
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
prefs.setString('token', data['data']);
|
prefs.setString('token', data['data']);
|
||||||
|
|
||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||||
print(decodedToken);
|
print(decodedToken);
|
||||||
empCodeString = decodedToken['emp_code'].toString();
|
empClientBranchId = decodedToken['client_branch_id'];
|
||||||
|
prefs.setString('empClientBranchId', empClientBranchId);
|
||||||
|
print(empClientBranchId);
|
||||||
|
empCodeString = decodedToken['emp_code'];
|
||||||
prefs.setString('empCode', empCodeString);
|
prefs.setString('empCode', empCodeString);
|
||||||
empPrimaryId = decodedToken['id'];
|
empPrimaryId = decodedToken['id'];
|
||||||
prefs.setString('empPrimaryId', empPrimaryId);
|
prefs.setString('empPrimaryId', empPrimaryId);
|
||||||
@ -224,6 +233,7 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||||
print(decodedToken);
|
print(decodedToken);
|
||||||
|
empClientBranchId = prefs.getString('empClientBranchId');
|
||||||
empCodeString = prefs.getString('empCode');
|
empCodeString = prefs.getString('empCode');
|
||||||
print(empCodeString); // Check if emp_code is correct
|
print(empCodeString); // Check if emp_code is correct
|
||||||
empPrimaryId = prefs.getString('empPrimaryId');
|
empPrimaryId = prefs.getString('empPrimaryId');
|
||||||
@ -252,23 +262,19 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getClientLogoAndDetails() async {
|
Future<void> getClientLogoAndDetails() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getClientDetails?client_id=$client_id&emp_code=$empCodeString');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getClientLogoAndDetailsToApi(
|
||||||
);
|
client_id!, empCodeString!, empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
print('check 1');
|
||||||
// print('response.statusCode == 200');
|
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
|
||||||
// print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
if (response['status'] == 'success') {
|
||||||
dynamic clientDetails = data['data'];
|
if (response.containsKey('data')) {
|
||||||
|
dynamic clientDetails = response['data'];
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
prefs.setString('clientLogo', clientDetails['client']['client_logo']);
|
prefs.setString('clientLogo', clientDetails['client']['client_logo']);
|
||||||
prefs.setString('clientName', clientDetails['client']['client_name']);
|
prefs.setString('clientName', clientDetails['client']['client_name']);
|
||||||
@ -284,13 +290,13 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// context, 'API request failed with status: ${data['status']}');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -299,24 +305,19 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getSelfEmployeeProfile() async {
|
Future<void> getSelfEmployeeProfile() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getEmployeeProfile?emp_code=$empCodeString&client_id=$client_id');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getSelfEmployeeProfileToApi(
|
||||||
);
|
client_id!, empCodeString!, empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
|
||||||
// print('response.statusCode == 200');
|
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
|
||||||
// print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
if (response['status'] == 'success') {
|
||||||
|
if (response.containsKey('data')) {
|
||||||
setState(() {
|
setState(() {
|
||||||
dynamic selfDetails = data['data'];
|
dynamic selfDetails = response['data'];
|
||||||
print(selfDetails);
|
print(selfDetails);
|
||||||
mobileNumber = selfDetails['relationship'];
|
mobileNumber = selfDetails['relationship'];
|
||||||
selfRelationship = selfDetails['relationship'];
|
selfRelationship = selfDetails['relationship'];
|
||||||
@ -339,13 +340,13 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// context, 'API request failed with status: ${data['status']}');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -368,23 +369,18 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGpaEmpPolicyDetails(empPrimaryId) async {
|
Future<void> getGpaEmpPolicyDetails(empPrimaryId) async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GPA');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGpaEmpPolicyDetailsToApi(
|
||||||
);
|
empPrimaryId, empCodeString!, client_id!, 'GPA', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
|
||||||
print('response.statusCode == 200');
|
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
|
||||||
print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
if (response['status'] == 'success') {
|
||||||
gpaPolicies = data['data'];
|
if (response.containsKey('data')) {
|
||||||
|
gpaPolicies = response['data'];
|
||||||
print('gpaPolicies');
|
print('gpaPolicies');
|
||||||
// Assuming data is a List
|
// Assuming data is a List
|
||||||
print(gpaPolicies);
|
print(gpaPolicies);
|
||||||
@ -422,12 +418,12 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
// ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -436,42 +432,29 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGmcEmpPolicyDetails(empPrimaryId) async {
|
Future<void> getGmcEmpPolicyDetails(empPrimaryId) async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GMC');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGmcEmpPolicyDetailsToApi(
|
||||||
);
|
empPrimaryId, empCodeString!, client_id!, 'GMC', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('GMC response.statusCode == 200');
|
setState(() {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
gmcPolicies = response['data'];
|
||||||
print(data);
|
print('gmcPolicies');
|
||||||
|
});
|
||||||
if (data['status'] == 'success') {
|
// Assuming data is a List
|
||||||
setState(() {
|
print(gmcPolicies);
|
||||||
gmcPolicies = data['data'];
|
|
||||||
print('gmcPolicies');
|
|
||||||
});
|
|
||||||
// Assuming data is a List
|
|
||||||
print(gmcPolicies);
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
gmcDataIsEmpty = 0;
|
|
||||||
});
|
|
||||||
// Handle other status messages if needed
|
|
||||||
// ToastHelper.showErrorToast(
|
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
|
||||||
print('API request failed with status: ${data['status']}');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
setState(() {
|
||||||
|
gmcDataIsEmpty = 0;
|
||||||
|
});
|
||||||
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'API request failed with status: ${data['status']}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -481,18 +464,10 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
|
|
||||||
Future<void> fetchRelationshipList() async {
|
Future<void> fetchRelationshipList() async {
|
||||||
// Replace the URL with your API endpoint
|
// Replace the URL with your API endpoint
|
||||||
final url = Uri.parse(Environment.apiUrl + 'relationshipList');
|
|
||||||
try {
|
try {
|
||||||
final response = await http.get(
|
final response = await apiService.fetchRelationshipListToApi();
|
||||||
url,
|
if (response['status'] == 'success') {
|
||||||
headers: {
|
for (var item in response['data']) {
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
final List<dynamic> data = jsonDecode(response.body)['data'];
|
|
||||||
for (var item in data) {
|
|
||||||
String relationshipName = item['relationship_name'];
|
String relationshipName = item['relationship_name'];
|
||||||
String dependent = item['dependent'];
|
String dependent = item['dependent'];
|
||||||
|
|
||||||
@ -573,22 +548,12 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
|
|
||||||
Future<void> deleteItem(Map<String, dynamic> deletedItem) async {
|
Future<void> deleteItem(Map<String, dynamic> deletedItem) async {
|
||||||
print(deletedItem);
|
print(deletedItem);
|
||||||
// Define your API endpoint
|
|
||||||
var id = deletedItem['employee_id'];
|
|
||||||
final String apiUrl = Environment.apiUrl + 'deleteDependence?id=$id';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Make the DELETE request to the API endpoint
|
var id = deletedItem['employee_id'];
|
||||||
final http.Response response = await http.get(
|
final response = await apiService.deleteItemToApi(id);
|
||||||
Uri.parse(apiUrl),
|
|
||||||
headers: {
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check if the request was successful (status code 200)
|
// Check if the request was successful (status code 200)
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
formDataList.clear();
|
formDataList.clear();
|
||||||
selectedRelationships.clear();
|
selectedRelationships.clear();
|
||||||
_relationShipController.clear();
|
_relationShipController.clear();
|
||||||
@ -603,8 +568,8 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
} else {
|
} else {
|
||||||
// Handle errors
|
// Handle errors
|
||||||
ToastHelper.showErrorToast(context, 'Failed to delete item');
|
ToastHelper.showErrorToast(context, 'Failed to delete item');
|
||||||
print('Failed to delete item. Status code: ${response.statusCode}');
|
print('Failed to delete item. Status code: ${response['code']}');
|
||||||
print('Response body: ${response.body}');
|
print('Response body: ${response}');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Handle network errors
|
// Handle network errors
|
||||||
@ -631,6 +596,7 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
formDataList.add({
|
formDataList.add({
|
||||||
|
'client_branch_id': empClientBranchId,
|
||||||
'relationship': formData['relationship'],
|
'relationship': formData['relationship'],
|
||||||
'name': formData['memberName'],
|
'name': formData['memberName'],
|
||||||
'dob': formData['dateOfBirth'],
|
'dob': formData['dateOfBirth'],
|
||||||
@ -644,21 +610,14 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Convert the list of objects to JSON
|
// Convert the list of objects to JSON
|
||||||
String formDataJson = jsonEncode(formDataList);
|
// String formDataJson = jsonEncode(formDataList);
|
||||||
|
|
||||||
// Prepare the API request
|
// Prepare the API request
|
||||||
var url = Uri.parse(Environment.apiUrl + 'addEmployeeAndDependence');
|
final response =
|
||||||
var response = await http.post(
|
await apiService.saveFamilyMemberDetailsToApi(formDataList);
|
||||||
url,
|
|
||||||
headers: {
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
body: formDataJson,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check the response
|
// Check the response
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
formDataList.clear();
|
formDataList.clear();
|
||||||
selectedRelationships.clear();
|
selectedRelationships.clear();
|
||||||
_relationShipController.clear();
|
_relationShipController.clear();
|
||||||
@ -674,7 +633,7 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
} else {
|
} else {
|
||||||
// Request failed, handle error
|
// Request failed, handle error
|
||||||
ToastHelper.showErrorToast(context, 'Failed');
|
ToastHelper.showErrorToast(context, 'Failed');
|
||||||
print('Failed to send form data. Error: ${response.reasonPhrase}');
|
print('Failed to send form data. Error: ${response}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:intl/intl.dart';
|
|||||||
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
||||||
import 'package:nhancepolicy/models/environment.dart';
|
import 'package:nhancepolicy/models/environment.dart';
|
||||||
import 'package:nhancepolicy/responsive.dart';
|
import 'package:nhancepolicy/responsive.dart';
|
||||||
|
import 'package:nhancepolicy/service/api_service.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'customAppBar/customAppBar.dart';
|
import 'customAppBar/customAppBar.dart';
|
||||||
import 'package:jwt_decode/jwt_decode.dart';
|
import 'package:jwt_decode/jwt_decode.dart';
|
||||||
@ -22,6 +23,7 @@ class empReviewDetails extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _empReviewDetailsState extends State<empReviewDetails> {
|
class _empReviewDetailsState extends State<empReviewDetails> {
|
||||||
|
late ApiService apiService;
|
||||||
bool isChecked = false; // Declare the _isSwitched variable here
|
bool isChecked = false; // Declare the _isSwitched variable here
|
||||||
dynamic _token;
|
dynamic _token;
|
||||||
dynamic empCodeString;
|
dynamic empCodeString;
|
||||||
@ -114,10 +116,12 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
int activePremiumSummary = 0;
|
int activePremiumSummary = 0;
|
||||||
dynamic gmcDataIsEmpty = 1;
|
dynamic gmcDataIsEmpty = 1;
|
||||||
dynamic gpaDataIsEmpty = 1;
|
dynamic gpaDataIsEmpty = 1;
|
||||||
|
dynamic empClientBranchId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
apiService = ApiService(context); // Initialize ApiService here
|
||||||
_loadToken();
|
_loadToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +147,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_token = token;
|
_token = token;
|
||||||
});
|
});
|
||||||
|
empClientBranchId = prefs.getString('empClientBranchId');
|
||||||
empCodeString = prefs.getString('empCode');
|
empCodeString = prefs.getString('empCode');
|
||||||
print(empCodeString); // Check if emp_code is correct
|
print(empCodeString); // Check if emp_code is correct
|
||||||
empPrimaryId = prefs.getString('empPrimaryId');
|
empPrimaryId = prefs.getString('empPrimaryId');
|
||||||
@ -246,23 +250,17 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getClientLogoAndDetails() async {
|
Future<void> getClientLogoAndDetails() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getClientDetails?client_id=$client_id&emp_code=$empCodeString');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getClientLogoAndDetailsToApi(
|
||||||
);
|
client_id!, empCodeString!, empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
if (response.containsKey('data')) {
|
||||||
Map<String, dynamic> data = await json.decode(response.body);
|
dynamic clientDetails = response['data'];
|
||||||
print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
|
||||||
dynamic clientDetails = data['data'];
|
|
||||||
print(clientDetails);
|
print(clientDetails);
|
||||||
clientName = clientDetails['client']['client_name'];
|
clientName = clientDetails['client']['client_name'];
|
||||||
print(clientName);
|
print(clientName);
|
||||||
@ -270,11 +268,11 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
print(clientLogo);
|
print(clientLogo);
|
||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -283,23 +281,17 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGpaEmpPolicyDetails(empPrimaryId) async {
|
Future<void> getGpaEmpPolicyDetails(empPrimaryId) async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GPA');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGpaEmpPolicyDetailsToApi(
|
||||||
);
|
empPrimaryId, empCodeString!, client_id!, 'GPA', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
if (response.containsKey('data')) {
|
||||||
Map<String, dynamic> data = await json.decode(response.body);
|
gpaPolicies = response['data'];
|
||||||
print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
|
||||||
gpaPolicies = data['data'];
|
|
||||||
print(gpaPolicies);
|
print(gpaPolicies);
|
||||||
// Assuming data is a List
|
// Assuming data is a List
|
||||||
print(gpaPolicies);
|
print(gpaPolicies);
|
||||||
@ -346,7 +338,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
} else {
|
} else {
|
||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
ToastHelper.showWarningToast(context, 'Something went wrong');
|
ToastHelper.showWarningToast(context, 'Something went wrong');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -354,7 +346,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
});
|
});
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
ToastHelper.showErrorToast(context, 'Something went wrong');
|
ToastHelper.showErrorToast(context, 'Something went wrong');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -363,37 +355,21 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGmcEmpPolicyDetails(empPrimaryId) async {
|
Future<void> getGmcEmpPolicyDetails(empPrimaryId) async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GMC');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGmcEmpPolicyDetailsToApi(
|
||||||
);
|
empPrimaryId, empCodeString!, client_id!, 'GMC', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
setState(() {
|
||||||
Map<String, dynamic> data = await json.decode(response.body);
|
gmcPolicies = response['data'];
|
||||||
print(data);
|
print('gmcPolicies');
|
||||||
|
});
|
||||||
if (data['status'] == 'success') {
|
// Assuming data is a List
|
||||||
setState(() {
|
print(gmcPolicies);
|
||||||
gmcPolicies = data['data'];
|
|
||||||
print('gmcPolicies');
|
|
||||||
});
|
|
||||||
// Assuming data is a List
|
|
||||||
print(gmcPolicies);
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
gmcDataIsEmpty = 0;
|
|
||||||
});
|
|
||||||
// Handle other status messages if needed
|
|
||||||
// ToastHelper.showErrorToast(
|
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
|
||||||
print('API request failed with status: ${data['status']}');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
gmcDataIsEmpty = 0;
|
gmcDataIsEmpty = 0;
|
||||||
@ -401,7 +377,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -410,23 +386,17 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGmcSiTopUp() async {
|
Future<void> getGmcSiTopUp() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-SI-TOPUP');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGmcSiTopUpToApi(
|
||||||
);
|
client_id!, empCodeString!, 'GMC-SI-TOPUP', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
if (response.containsKey('data')) {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
dynamic topUpSiPolicies = response['data'];
|
||||||
print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
|
||||||
dynamic topUpSiPolicies = data['data'];
|
|
||||||
print(topUpSiPolicies);
|
print(topUpSiPolicies);
|
||||||
if (topUpSiPolicies.isNotEmpty) {
|
if (topUpSiPolicies.isNotEmpty) {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
@ -468,13 +438,13 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// context, 'API request failed with status: ${data['status']}');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -483,25 +453,18 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGmcSiParentTopUp() async {
|
Future<void> getGmcSiParentTopUp() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-SI-PARENT-TOPUP');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGmcSiParentTopUpToApi(client_id!,
|
||||||
);
|
empCodeString!, 'GMC-SI-PARENT-TOPUP', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
if (response.containsKey('data')) {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
|
||||||
print('parent');
|
|
||||||
print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
topUpSiParentPolicies = data['data'];
|
topUpSiParentPolicies = response['data'];
|
||||||
print('topUpSiParentPolicies');
|
print('topUpSiParentPolicies');
|
||||||
print(topUpSiParentPolicies);
|
print(topUpSiParentPolicies);
|
||||||
});
|
});
|
||||||
@ -568,13 +531,13 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// context, 'API request failed with status: ${data['status']}');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -583,24 +546,17 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getGmcDependentAddOns() async {
|
Future<void> getGmcDependentAddOns() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-DEPENDENT-ADDON');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (client_id == null ||
|
||||||
url,
|
empCodeString == null ||
|
||||||
headers: {
|
empClientBranchId == null) {
|
||||||
'Authorization':
|
return;
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
}
|
||||||
},
|
final response = await apiService.getGmcDependentAddOnsToApi(client_id!,
|
||||||
);
|
empCodeString!, 'GMC-DEPENDENT-ADDON', empClientBranchId!);
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
if (response.containsKey('data')) {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
dynamic addOnsDependentPolicies = response['data'];
|
||||||
print('222222222');
|
|
||||||
print(data);
|
|
||||||
|
|
||||||
if (data.containsKey('data')) {
|
|
||||||
dynamic addOnsDependentPolicies = data['data'];
|
|
||||||
print('addOnsDependentPolicies');
|
print('addOnsDependentPolicies');
|
||||||
print(addOnsDependentPolicies);
|
print(addOnsDependentPolicies);
|
||||||
if (addOnsDependentPolicies.isNotEmpty) {
|
if (addOnsDependentPolicies.isNotEmpty) {
|
||||||
@ -646,13 +602,13 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
// Handle other status messages if needed
|
// Handle other status messages if needed
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
// context, 'API request failed with status: ${data['status']}');
|
||||||
print('API request failed with status: ${data['status']}');
|
print('API request failed with status: ${response['status']}');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
// ToastHelper.showErrorToast(
|
// ToastHelper.showErrorToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
@ -728,24 +684,16 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
// Convert the list of objects to JSON
|
// Convert the list of objects to JSON
|
||||||
String formDataJson = jsonEncode(apiParams);
|
String formDataJson = jsonEncode(apiParams);
|
||||||
|
|
||||||
var url = Uri.parse(Environment.apiUrl + 'iAgreeForAddOn');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.post(
|
final response = await apiService.sendAddOnToAPI(apiParams);
|
||||||
url,
|
|
||||||
headers: {
|
|
||||||
'Authorization':
|
|
||||||
'Bearer $_token', // Add token to the Authorization header
|
|
||||||
},
|
|
||||||
body: formDataJson,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response['status'] == 'success') {
|
||||||
print('response.statusCode == 200');
|
print('response.statusCode == 200');
|
||||||
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
||||||
} else {
|
} else {
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
ToastHelper.showErrorToast(context, 'Failed to Save');
|
ToastHelper.showErrorToast(context, 'Failed to Save');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle exceptions
|
// Handle exceptions
|
||||||
|
|||||||
@ -51,6 +51,8 @@ class _excelVerifyState extends State<excelVerify> {
|
|||||||
List<Map<String, dynamic>> nonExcelFilteredData = [];
|
List<Map<String, dynamic>> nonExcelFilteredData = [];
|
||||||
dynamic invalidRelationships = 0;
|
dynamic invalidRelationships = 0;
|
||||||
dynamic dobAgeCheckCount = 0;
|
dynamic dobAgeCheckCount = 0;
|
||||||
|
dynamic empRefId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -72,6 +74,7 @@ class _excelVerifyState extends State<excelVerify> {
|
|||||||
});
|
});
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||||
clintID = decodedToken['client_id'].toString();
|
clintID = decodedToken['client_id'].toString();
|
||||||
|
empRefId = prefs.getString('empRefId');
|
||||||
await getPolicyDetails();
|
await getPolicyDetails();
|
||||||
} else {
|
} else {
|
||||||
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
|
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
|
||||||
@ -418,6 +421,7 @@ class _excelVerifyState extends State<excelVerify> {
|
|||||||
print('clientPolicyId: $clientPolicyId');
|
print('clientPolicyId: $clientPolicyId');
|
||||||
// if (policyFirstPart == 'GPA') {
|
// if (policyFirstPart == 'GPA') {
|
||||||
request.fields['policy_id'] = clientPolicyId;
|
request.fields['policy_id'] = clientPolicyId;
|
||||||
|
request.fields['client_branch_id'] = empRefId;
|
||||||
// } else {
|
// } else {
|
||||||
// request.fields['policy_id'] = '3';
|
// request.fields['policy_id'] = '3';
|
||||||
// }
|
// }
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import 'package:google_fonts/google_fonts.dart';
|
|||||||
import 'package:jwt_decode/jwt_decode.dart';
|
import 'package:jwt_decode/jwt_decode.dart';
|
||||||
import 'package:nhancepolicy/models/environment.dart';
|
import 'package:nhancepolicy/models/environment.dart';
|
||||||
import 'package:nhancepolicy/responsive.dart';
|
import 'package:nhancepolicy/responsive.dart';
|
||||||
|
import 'package:nhancepolicy/service/api_service.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'customAppBar/customAppBar.dart';
|
import 'customAppBar/customAppBar.dart';
|
||||||
@ -21,6 +22,7 @@ class hrDashboard extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _hrDashboardState extends State<hrDashboard> {
|
class _hrDashboardState extends State<hrDashboard> {
|
||||||
|
late ApiService apiService;
|
||||||
bool isLoading = true;
|
bool isLoading = true;
|
||||||
late String _token;
|
late String _token;
|
||||||
dynamic getPolicyNo;
|
dynamic getPolicyNo;
|
||||||
@ -31,6 +33,7 @@ class _hrDashboardState extends State<hrDashboard> {
|
|||||||
dynamic getCardArrays = [];
|
dynamic getCardArrays = [];
|
||||||
dynamic clientName;
|
dynamic clientName;
|
||||||
dynamic clientLogo;
|
dynamic clientLogo;
|
||||||
|
dynamic empRefId;
|
||||||
final List<Color> cardColors = [
|
final List<Color> cardColors = [
|
||||||
Color(0xFFFFE3D9),
|
Color(0xFFFFE3D9),
|
||||||
Color(0xFFFFD9EE),
|
Color(0xFFFFD9EE),
|
||||||
@ -41,6 +44,7 @@ class _hrDashboardState extends State<hrDashboard> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
apiService = ApiService(context); // Initialize ApiService here
|
||||||
_loadToken();
|
_loadToken();
|
||||||
Future.delayed(Duration(seconds: 3), () {
|
Future.delayed(Duration(seconds: 3), () {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -63,6 +67,8 @@ class _hrDashboardState extends State<hrDashboard> {
|
|||||||
});
|
});
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||||
clintID = decodedToken['client_id'].toString();
|
clintID = decodedToken['client_id'].toString();
|
||||||
|
empRefId = prefs.getString('empRefId');
|
||||||
|
print(empRefId);
|
||||||
print(clintID);
|
print(clintID);
|
||||||
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
||||||
clientLogo = prefs.getString('clientLogo');
|
clientLogo = prefs.getString('clientLogo');
|
||||||
@ -70,7 +76,7 @@ class _hrDashboardState extends State<hrDashboard> {
|
|||||||
} else {
|
} else {
|
||||||
getClientLogoAndDetails();
|
getClientLogoAndDetails();
|
||||||
}
|
}
|
||||||
await getCashDepositDetails(clintID);
|
getCashDepositDetails(clintID);
|
||||||
} else {
|
} else {
|
||||||
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
|
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
|
||||||
// For now, let's navigate to the login screen
|
// For now, let's navigate to the login screen
|
||||||
@ -80,8 +86,8 @@ class _hrDashboardState extends State<hrDashboard> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getClientLogoAndDetails() async {
|
Future<void> getClientLogoAndDetails() async {
|
||||||
var url =
|
var url = Uri.parse(Environment.apiUrl +
|
||||||
Uri.parse(Environment.apiUrl + 'getClientDetails?client_id=$clintID');
|
'getClientDetails?client_id=$clintID&client_branch_id=$empRefId');
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
@ -130,26 +136,17 @@ class _hrDashboardState extends State<hrDashboard> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
var url = Uri.parse(
|
|
||||||
Environment.apiUrl + 'getCashDepositData?client_id=' + clintID);
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
if (clintID == null || empRefId == null) {
|
||||||
url,
|
return;
|
||||||
headers: {
|
}
|
||||||
'Authorization': 'Bearer $_token',
|
final response =
|
||||||
},
|
await apiService.getCashDepositDetailsToApi(clintID!, empRefId!);
|
||||||
);
|
if (response['status'] == 'success') {
|
||||||
if (response.statusCode == 200) {
|
setState(() {
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
getCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
||||||
if (data['status'] == 'success') {
|
print(getCardArrays);
|
||||||
setState(() {
|
});
|
||||||
getCardArrays = List<Map<String, dynamic>>.from(data['data']);
|
|
||||||
print(getCardArrays);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// No matching policy found
|
|
||||||
print('No matching policy found for');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
print('API request failed with status');
|
print('API request failed with status');
|
||||||
}
|
}
|
||||||
@ -158,12 +155,12 @@ class _hrDashboardState extends State<hrDashboard> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> downloadExcel(clintId, clintIdclintId, insurerName) async {
|
Future<void> downloadExcel(clintId, insurerId, insurerName) async {
|
||||||
// API endpoint to download the Excel file
|
// API endpoint to download the Excel file
|
||||||
|
|
||||||
// Send GET request to the API
|
// Send GET request to the API
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
var url = Uri.parse(Environment.apiUrl +
|
||||||
'exportCashDepositData?client_id=$clintId&insurer_id=$clintIdclintId');
|
'exportCashDepositData?client_id=$clintId&insurer_id=$insurerId');
|
||||||
|
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
@ -300,329 +297,328 @@ class _hrDashboardState extends State<hrDashboard> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
Card(
|
if (getCardArrays.length != 0)
|
||||||
elevation: 0,
|
Card(
|
||||||
child: Container(
|
elevation: 0,
|
||||||
width: double.infinity,
|
child: Container(
|
||||||
padding: Responsive.isDesktop(context)
|
width: double.infinity,
|
||||||
? EdgeInsets.all(20)
|
padding: Responsive.isDesktop(context)
|
||||||
: EdgeInsets.all(
|
? EdgeInsets.all(20)
|
||||||
10), // Add padding to the container
|
: EdgeInsets.all(
|
||||||
child: Column(children: [
|
10), // Add padding to the container
|
||||||
Row(children: [
|
child: Column(children: [
|
||||||
Text(
|
Row(children: [
|
||||||
'Cash Transaction',
|
Text(
|
||||||
style: GoogleFonts.poppins(
|
'Cash Transaction',
|
||||||
fontSize: 18,
|
style: GoogleFonts.poppins(
|
||||||
fontWeight: FontWeight.w600,
|
fontSize: 18,
|
||||||
color: Colors.black,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
color: Colors.black,
|
||||||
)
|
),
|
||||||
]),
|
)
|
||||||
SizedBox(height: 8),
|
]),
|
||||||
Row(
|
SizedBox(height: 8),
|
||||||
children: [
|
Row(
|
||||||
// Create an Expanded widget with flex of 4 for each card
|
children: [
|
||||||
for (var cardData in getCardArrays)
|
// Create an Expanded widget with flex of 4 for each card
|
||||||
Container(
|
for (var cardData in getCardArrays)
|
||||||
width:
|
Container(
|
||||||
300, // Set a fixed width for the card
|
width:
|
||||||
height: cardHeight,
|
300, // Set a fixed width for the card
|
||||||
child: Card(
|
height: cardHeight,
|
||||||
elevation: 3,
|
child: Card(
|
||||||
color: cardColors[
|
elevation: 3,
|
||||||
getCardArrays.indexOf(cardData) %
|
color: cardColors[
|
||||||
cardColors.length],
|
getCardArrays.indexOf(cardData) %
|
||||||
child: Column(
|
cardColors.length],
|
||||||
crossAxisAlignment:
|
child: Column(
|
||||||
CrossAxisAlignment.start,
|
crossAxisAlignment:
|
||||||
children: [
|
CrossAxisAlignment.start,
|
||||||
ListTile(
|
children: [
|
||||||
title: SizedBox(
|
ListTile(
|
||||||
height: 50,
|
title: SizedBox(
|
||||||
child: Text(
|
height: 50,
|
||||||
cardData['insurerName'],
|
child: Text(
|
||||||
|
cardData['insurerName'],
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
height: 1.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
'Balance: ₹ ${cardData['balance']}',
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 18,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w400,
|
||||||
color: Color(0xFF000000),
|
color: Color(0xFF000000),
|
||||||
height: 1.5,
|
height: 1.5,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
SizedBox(height: 10),
|
||||||
'Balance: ₹ ${cardData['balance']}',
|
Padding(
|
||||||
style: GoogleFonts.poppins(
|
padding: EdgeInsets.symmetric(
|
||||||
fontSize: 16,
|
horizontal: 15),
|
||||||
fontWeight: FontWeight.w400,
|
child: GestureDetector(
|
||||||
color: Color(0xFF000000),
|
onTap: () {
|
||||||
height: 1.5,
|
openForm(
|
||||||
),
|
cardData['depositData'],
|
||||||
),
|
cardData['insurerName'],
|
||||||
),
|
cardData['clientId'],
|
||||||
SizedBox(height: 10),
|
cardData['insurerId'],
|
||||||
Padding(
|
cardColors[getCardArrays
|
||||||
padding: EdgeInsets.symmetric(
|
.indexOf(cardData) %
|
||||||
horizontal: 15),
|
cardColors.length],
|
||||||
child: GestureDetector(
|
);
|
||||||
onTap: () {
|
},
|
||||||
openForm(
|
child: MouseRegion(
|
||||||
cardData['depositData'],
|
cursor:
|
||||||
cardData['insurerName'],
|
SystemMouseCursors.click,
|
||||||
cardData['clientId'],
|
child: Align(
|
||||||
cardData['insurerId'],
|
alignment:
|
||||||
cardColors[getCardArrays
|
Alignment.centerRight,
|
||||||
.indexOf(cardData) %
|
child: Text(
|
||||||
cardColors.length],
|
'View Details',
|
||||||
);
|
style:
|
||||||
},
|
GoogleFonts.poppins(
|
||||||
child: MouseRegion(
|
color:
|
||||||
cursor:
|
Color(0xFF000000),
|
||||||
SystemMouseCursors.click,
|
fontSize: 14,
|
||||||
child: Align(
|
fontWeight:
|
||||||
alignment:
|
FontWeight.w300,
|
||||||
Alignment.centerRight,
|
height: 1.5,
|
||||||
child: Text(
|
),
|
||||||
'View Details',
|
|
||||||
style: GoogleFonts.poppins(
|
|
||||||
color: Color(0xFF000000),
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.w300,
|
|
||||||
height: 1.5,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
])),
|
||||||
])),
|
),
|
||||||
),
|
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
Card(
|
if (getCardArrays.length != 0)
|
||||||
elevation: 0,
|
Card(
|
||||||
child: Padding(
|
elevation: 0,
|
||||||
padding: Responsive.isDesktop(context)
|
child: Padding(
|
||||||
? EdgeInsets.all(20)
|
padding: Responsive.isDesktop(context)
|
||||||
: EdgeInsets.all(10),
|
? EdgeInsets.all(20)
|
||||||
child: Column(
|
: EdgeInsets.all(10),
|
||||||
children: [
|
child: Column(
|
||||||
Row(
|
children: [
|
||||||
children: [
|
Row(
|
||||||
Expanded(
|
children: [
|
||||||
child: Column(
|
Expanded(
|
||||||
crossAxisAlignment:
|
child: Column(
|
||||||
CrossAxisAlignment.start,
|
crossAxisAlignment:
|
||||||
children: List.generate(
|
CrossAxisAlignment.start,
|
||||||
numExpanded,
|
children: List.generate(
|
||||||
(index) {
|
numExpanded,
|
||||||
var insurerName = getCardArrays[index]
|
(index) {
|
||||||
['insurerName'];
|
var insurerName =
|
||||||
var policyDetails =
|
getCardArrays[index]
|
||||||
getCardArrays[index]
|
['insurerName'];
|
||||||
['policyDetails'];
|
var policyDetails =
|
||||||
|
getCardArrays[index]
|
||||||
|
['policyDetails'];
|
||||||
|
|
||||||
// Determine the color for the policyDetails based on the index of the card in getCardArrays
|
// Determine the color for the policyDetails based on the index of the card in getCardArrays
|
||||||
var cardColorIndex =
|
var cardColorIndex =
|
||||||
getCardArrays.indexOf(
|
getCardArrays.indexOf(
|
||||||
getCardArrays[index]) %
|
getCardArrays[index]) %
|
||||||
cardColors.length;
|
cardColors.length;
|
||||||
var cardColor =
|
var cardColor =
|
||||||
cardColors[cardColorIndex];
|
cardColors[cardColorIndex];
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
CrossAxisAlignment.start,
|
CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
insurerName,
|
insurerName,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
SizedBox(height: 8),
|
||||||
SizedBox(height: 8),
|
Row(
|
||||||
Row(
|
children: List.generate(
|
||||||
children: List.generate(
|
policyDetails.length,
|
||||||
policyDetails.length,
|
(index) => Container(
|
||||||
(index) => Container(
|
width: 300,
|
||||||
width: 300,
|
height: policyHeight,
|
||||||
height: policyHeight,
|
child: GestureDetector(
|
||||||
child: GestureDetector(
|
onTap: () {
|
||||||
onTap: () {
|
Navigator.pushNamed(
|
||||||
Navigator.pushNamed(
|
context,
|
||||||
context,
|
'hrPolicyDetails',
|
||||||
'hrPolicyDetails',
|
arguments:
|
||||||
arguments:
|
policyDetails[
|
||||||
policyDetails[
|
index]);
|
||||||
index]);
|
},
|
||||||
},
|
child: MouseRegion(
|
||||||
child: MouseRegion(
|
cursor:
|
||||||
cursor:
|
SystemMouseCursors
|
||||||
SystemMouseCursors
|
.click,
|
||||||
.click,
|
child: Card(
|
||||||
child: Card(
|
elevation: 3,
|
||||||
elevation: 3,
|
color:
|
||||||
color:
|
cardColor, // Use the determined color
|
||||||
cardColor, // Use the determined color
|
child: Column(
|
||||||
child: Column(
|
crossAxisAlignment:
|
||||||
crossAxisAlignment:
|
CrossAxisAlignment
|
||||||
CrossAxisAlignment
|
.start,
|
||||||
.start,
|
children: [
|
||||||
children: [
|
ListTile(
|
||||||
ListTile(
|
title:
|
||||||
title: SizedBox(
|
SizedBox(
|
||||||
height: 50,
|
height: 50,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${policyDetails[index]['policy_name']} - (${policyDetails[index]['type']})',
|
'${policyDetails[index]['policy_name']} - (${policyDetails[index]['type']})',
|
||||||
style: GoogleFonts
|
style: GoogleFonts
|
||||||
.poppins(
|
.poppins(
|
||||||
fontSize:
|
fontSize:
|
||||||
16,
|
16,
|
||||||
fontWeight:
|
fontWeight:
|
||||||
FontWeight
|
FontWeight.w500,
|
||||||
.w500,
|
color: Color(
|
||||||
color: Color(
|
0xFF000000),
|
||||||
0xFF000000),
|
height:
|
||||||
height:
|
1.5,
|
||||||
1.5,
|
),
|
||||||
|
softWrap:
|
||||||
|
true, // Allow text to wrap to the next line if needed
|
||||||
),
|
),
|
||||||
softWrap:
|
|
||||||
true, // Allow text to wrap to the next line if needed
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
SizedBox(
|
height: 8),
|
||||||
height: 8),
|
Padding(
|
||||||
Padding(
|
padding: EdgeInsets
|
||||||
padding: EdgeInsets
|
.only(
|
||||||
.only(
|
left:
|
||||||
left:
|
15,
|
||||||
15,
|
right:
|
||||||
right:
|
15),
|
||||||
15),
|
child: Row(
|
||||||
child: Row(
|
children: [
|
||||||
children: [
|
Expanded(
|
||||||
Expanded(
|
flex: 4,
|
||||||
flex: 4,
|
child:
|
||||||
child:
|
Column(
|
||||||
Column(
|
crossAxisAlignment:
|
||||||
crossAxisAlignment:
|
CrossAxisAlignment.center,
|
||||||
CrossAxisAlignment.center,
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
'Draft',
|
||||||
'Draft',
|
style: GoogleFonts.poppins(
|
||||||
style:
|
fontSize: 16,
|
||||||
GoogleFonts.poppins(
|
fontWeight: FontWeight.w500,
|
||||||
fontSize: 16,
|
color: Color(0xFF000000),
|
||||||
fontWeight: FontWeight.w500,
|
height: 1.5,
|
||||||
color: Color(0xFF000000),
|
),
|
||||||
height: 1.5,
|
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
Text(
|
policyDetails[index]['membersCountOfDraft'].toString(),
|
||||||
policyDetails[index]['membersCountOfDraft'].toString(),
|
style: GoogleFonts.poppins(
|
||||||
style:
|
fontSize: 16,
|
||||||
GoogleFonts.poppins(
|
fontWeight: FontWeight.w400,
|
||||||
fontSize: 16,
|
color: Color(0xFF000000),
|
||||||
fontWeight: FontWeight.w400,
|
height: 1.5,
|
||||||
color: Color(0xFF000000),
|
),
|
||||||
height: 1.5,
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
Expanded(
|
flex: 4,
|
||||||
flex: 4,
|
child:
|
||||||
child:
|
Column(
|
||||||
Column(
|
crossAxisAlignment:
|
||||||
crossAxisAlignment:
|
CrossAxisAlignment.center,
|
||||||
CrossAxisAlignment.center,
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
'Enrolled',
|
||||||
'Enrolled',
|
style: GoogleFonts.poppins(
|
||||||
style:
|
fontSize: 16,
|
||||||
GoogleFonts.poppins(
|
fontWeight: FontWeight.w500,
|
||||||
fontSize: 16,
|
color: Color(0xFF000000),
|
||||||
fontWeight: FontWeight.w500,
|
height: 1.5,
|
||||||
color: Color(0xFF000000),
|
),
|
||||||
height: 1.5,
|
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
Text(
|
policyDetails[index]['membersCountOfEnrolled'].toString(),
|
||||||
policyDetails[index]['membersCountOfEnrolled'].toString(),
|
style: GoogleFonts.poppins(
|
||||||
style:
|
fontSize: 16,
|
||||||
GoogleFonts.poppins(
|
fontWeight: FontWeight.w400,
|
||||||
fontSize: 16,
|
color: Color(0xFF000000),
|
||||||
fontWeight: FontWeight.w400,
|
height: 1.5,
|
||||||
color: Color(0xFF000000),
|
),
|
||||||
height: 1.5,
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
Expanded(
|
flex: 4,
|
||||||
flex: 4,
|
child:
|
||||||
child:
|
Column(
|
||||||
Column(
|
crossAxisAlignment:
|
||||||
crossAxisAlignment:
|
CrossAxisAlignment.center,
|
||||||
CrossAxisAlignment.center,
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
'Total',
|
||||||
'Total',
|
style: GoogleFonts.poppins(
|
||||||
style:
|
fontSize: 16,
|
||||||
GoogleFonts.poppins(
|
fontWeight: FontWeight.w500,
|
||||||
fontSize: 16,
|
color: Color(0xFF000000),
|
||||||
fontWeight: FontWeight.w500,
|
height: 1.5,
|
||||||
color: Color(0xFF000000),
|
),
|
||||||
height: 1.5,
|
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
Text(
|
policyDetails[index]['totalMembersCount'].toString(),
|
||||||
policyDetails[index]['totalMembersCount'].toString(),
|
style: GoogleFonts.poppins(
|
||||||
style:
|
fontSize: 16,
|
||||||
GoogleFonts.poppins(
|
fontWeight: FontWeight.w400,
|
||||||
fontSize: 16,
|
color: Color(0xFF000000),
|
||||||
fontWeight: FontWeight.w400,
|
height: 1.5,
|
||||||
color: Color(0xFF000000),
|
),
|
||||||
height: 1.5,
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
), // Adjust the horizontal padding as needed
|
||||||
), // Adjust the horizontal padding as needed
|
)
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
SizedBox(height: 20),
|
||||||
SizedBox(height: 20),
|
],
|
||||||
],
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
)
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
),
|
))
|
||||||
))
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'package:google_fonts/google_fonts.dart';
|
|||||||
import 'package:nhancepolicy/customAppBar/customAppBar.dart';
|
import 'package:nhancepolicy/customAppBar/customAppBar.dart';
|
||||||
import 'package:nhancepolicy/excel_verification.dart';
|
import 'package:nhancepolicy/excel_verification.dart';
|
||||||
import 'package:nhancepolicy/models/environment.dart';
|
import 'package:nhancepolicy/models/environment.dart';
|
||||||
|
import 'package:nhancepolicy/service/api_service.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:jwt_decode/jwt_decode.dart';
|
import 'package:jwt_decode/jwt_decode.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
@ -42,12 +43,15 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
dynamic policyName;
|
dynamic policyName;
|
||||||
dynamic clientPolicyId;
|
dynamic clientPolicyId;
|
||||||
dynamic clientId;
|
dynamic clientId;
|
||||||
|
dynamic empRefId;
|
||||||
int inceptionType = 0;
|
int inceptionType = 0;
|
||||||
TextEditingController searchController = TextEditingController();
|
TextEditingController searchController = TextEditingController();
|
||||||
|
late ApiService apiService;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
apiService = ApiService(context); // Initialize ApiService here
|
||||||
_tabController = TabController(length: 4, vsync: this);
|
_tabController = TabController(length: 4, vsync: this);
|
||||||
_loadToken();
|
_loadToken();
|
||||||
}
|
}
|
||||||
@ -66,6 +70,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
_token = token;
|
_token = token;
|
||||||
});
|
});
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||||
|
empRefId = prefs.getString('empRefId');
|
||||||
// clintID = decodedToken['client_id'];
|
// clintID = decodedToken['client_id'];
|
||||||
getPolicyDetails();
|
getPolicyDetails();
|
||||||
} else {
|
} else {
|
||||||
@ -131,35 +136,22 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
|
||||||
'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
final response = await apiService.getEmployeeAndDependenceToApi(
|
||||||
url,
|
clintID!, getPolicyNo!, empRefId!);
|
||||||
headers: {
|
if (response['status'] == 'success') {
|
||||||
'Authorization': 'Bearer $_token',
|
setState(() {
|
||||||
},
|
getEmpDependenceByClintId =
|
||||||
);
|
List<Map<String, dynamic>>.from(response['data']);
|
||||||
if (response.statusCode == 200) {
|
originalData = getEmpDependenceByClintId;
|
||||||
Map<String, dynamic> data = json.decode(response.body);
|
filteredData = List.from(originalData);
|
||||||
if (data['status'] == 'success') {
|
print('filteredData');
|
||||||
setState(() {
|
print(filteredData);
|
||||||
getEmpDependenceByClintId =
|
});
|
||||||
List<Map<String, dynamic>>.from(data['data']);
|
|
||||||
originalData = getEmpDependenceByClintId;
|
|
||||||
filteredData = List.from(originalData);
|
|
||||||
print('filteredData');
|
|
||||||
print(filteredData);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// ToastHelper.showWarningToast(
|
|
||||||
// context, 'API request failed with status: ${data['status']}');
|
|
||||||
print('API request failed with status: ${data['status']}');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response.statusCode}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Exception occurred: $e');
|
print('Exception occurred: $e');
|
||||||
@ -258,7 +250,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
|
|
||||||
// Send GET request to the API
|
// Send GET request to the API
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
var url = Uri.parse(Environment.apiUrl +
|
||||||
'exportDataByClientPolicyId?client_id=$clientId&client_policy_id=$clientPolicyId');
|
'exportDataByClientPolicyId?client_id=$clientId&client_policy_id=$clientPolicyId&client_branch_id=$empRefId');
|
||||||
|
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class _MyVerifyState extends State<MyHrVerify> {
|
|||||||
dynamic client_id;
|
dynamic client_id;
|
||||||
dynamic clientName;
|
dynamic clientName;
|
||||||
dynamic clientLogo;
|
dynamic clientLogo;
|
||||||
|
dynamic empRefId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -137,7 +138,12 @@ class _MyVerifyState extends State<MyHrVerify> {
|
|||||||
|
|
||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||||
|
print('decodedToken');
|
||||||
print(decodedToken);
|
print(decodedToken);
|
||||||
|
empRefId = decodedToken['ref_id'];
|
||||||
|
print('empRefId');
|
||||||
|
print(empRefId);
|
||||||
|
prefs.setString('empRefId', empRefId);
|
||||||
empCodeString = decodedToken['emp_code'].toString();
|
empCodeString = decodedToken['emp_code'].toString();
|
||||||
prefs.setString('empCode', empCodeString);
|
prefs.setString('empCode', empCodeString);
|
||||||
empPrimaryId = decodedToken['id'];
|
empPrimaryId = decodedToken['id'];
|
||||||
@ -188,7 +194,7 @@ class _MyVerifyState extends State<MyHrVerify> {
|
|||||||
|
|
||||||
Future<void> getClientLogoAndDetails() async {
|
Future<void> getClientLogoAndDetails() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
var url = Uri.parse(Environment.apiUrl +
|
||||||
'getClientDetails?client_id=$client_id&emp_code=$empCodeString');
|
'getClientDetails?client_id=$client_id&client_branch_id=$empRefId');
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
|
|||||||
@ -39,6 +39,7 @@ class _oldPolicyState extends State<oldPolicy> {
|
|||||||
dynamic oldPolicyFloaterTextHeading;
|
dynamic oldPolicyFloaterTextHeading;
|
||||||
dynamic oldPolicyStartDate;
|
dynamic oldPolicyStartDate;
|
||||||
dynamic oldPolicyEndDate;
|
dynamic oldPolicyEndDate;
|
||||||
|
dynamic empClientBranchId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -62,6 +63,7 @@ class _oldPolicyState extends State<oldPolicy> {
|
|||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
||||||
print(decodedToken);
|
print(decodedToken);
|
||||||
|
empClientBranchId = prefs.getString('empClientBranchId');
|
||||||
empCodeString = prefs.getString('empCode');
|
empCodeString = prefs.getString('empCode');
|
||||||
print(empCodeString); // Check if emp_code is correct
|
print(empCodeString); // Check if emp_code is correct
|
||||||
empPrimaryId = prefs.getString('empPrimaryId');
|
empPrimaryId = prefs.getString('empPrimaryId');
|
||||||
@ -79,7 +81,7 @@ class _oldPolicyState extends State<oldPolicy> {
|
|||||||
|
|
||||||
Future<void> getOldPolicyDetails() async {
|
Future<void> getOldPolicyDetails() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
var url = Uri.parse(Environment.apiUrl +
|
||||||
'getEmployeeActiveOrInactivePolicy?client_id=$client_id&emp_code=$empCodeString&type=Inactive');
|
'getEmployeeActiveOrInactivePolicy?client_id=$client_id&emp_code=$empCodeString&type=Inactive&client_branch_id=$empClientBranchId');
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
|
|||||||
502
lib/service/api_service.dart
Normal file
502
lib/service/api_service.dart
Normal file
@ -0,0 +1,502 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import '../customAppBar/toastHelper.dart';
|
||||||
|
import '../models/environment.dart';
|
||||||
|
|
||||||
|
class ApiService {
|
||||||
|
final BuildContext context;
|
||||||
|
String? _token;
|
||||||
|
String? _hrtoken;
|
||||||
|
bool _isSessionOutToastShown = false; // Flag to track toast message
|
||||||
|
|
||||||
|
ApiService(this.context) {
|
||||||
|
_initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _initializeToken() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
_token = prefs.getString('token') ?? '';
|
||||||
|
final hrprefs = await SharedPreferences.getInstance();
|
||||||
|
_hrtoken = hrprefs.getString('hrtoken') ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getClientLogoAndDetailsToApi(
|
||||||
|
String clientId, String empCode, String branchID) async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}getClientDetails?client_id=$clientId&emp_code=$empCode&client_branch_id=$branchID');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getSelfEmployeeProfileToApi(
|
||||||
|
String clientId, String empCode, String branchID) async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}getEmployeeProfile?emp_code=$empCode&client_id=$clientId&client_branch_id=$branchID');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> fetchRelationshipListToApi() async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse('${Environment.apiUrl}relationshipList');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getGpaEmpPolicyDetailsToApi(String empPrimaryId,
|
||||||
|
String empCode, String clientId, String policy, String branchID) async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}getEmployeePolicy?id=$empPrimaryId&emp_code=$empCode&client_id=$clientId&policy=$policy&client_branch_id=$branchID');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getGmcEmpPolicyDetailsToApi(String empPrimaryId,
|
||||||
|
String empCode, String clientId, String policy, String branchID) async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}getEmployeePolicy?id=$empPrimaryId&emp_code=$empCode&client_id=$clientId&policy=$policy&client_branch_id=$branchID');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getGmcSiTopUpToApi(
|
||||||
|
String client_id, String emp_code, String policy, String branchID) async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getGmcSiParentTopUpToApi(
|
||||||
|
String client_id, String emp_code, String policy, String branchID) async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getGmcDependentAddOnsToApi(
|
||||||
|
String client_id, String emp_code, String policy, String branchID) async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}getAddOnPolicy?client_id=$client_id&emp_code=$emp_code&policy=$policy&client_branch_id=$branchID');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> removeAddonsGmcDependentToAPI(
|
||||||
|
String empCodeString, String addOnsDependentClientPolicyId) async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$addOnsDependentClientPolicyId');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> removeAddonsGmcSiToAPI(
|
||||||
|
String empCodeString, String topUpClientPolicyId) async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpClientPolicyId');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> removeAddonsGmcParentSiToAPI(
|
||||||
|
String empCodeString, String topUpParentClientPolicyId) async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpParentClientPolicyId');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> deleteItemToApi(id) async {
|
||||||
|
print(_token);
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse('${Environment.apiUrl}deleteDependence?id=$id');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> saveFamilyMemberDetailsToApi(
|
||||||
|
List<Map<String, dynamic>> formDataList) async {
|
||||||
|
print('saveFamilyMemberDetailsToApi API SERVICE');
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url = Uri.parse('${Environment.apiUrl}addEmployeeAndDependence');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
'Content-Type': 'application/json', // Ensure content type is JSON
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert formDataList to JSON string
|
||||||
|
final formDataJson = jsonEncode(formDataList);
|
||||||
|
|
||||||
|
// Send formDataJson as the body
|
||||||
|
final response = await _makePostRequest(url, formDataJson, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> saveAddOnsDetailsToApi(
|
||||||
|
List<Map<String, dynamic>> formDataList) async {
|
||||||
|
print('saveAddOnsDetailsToApi API SERVICE');
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url = Uri.parse('${Environment.apiUrl}addEmployeeAndDependence');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
'Content-Type': 'application/json', // Ensure content type is JSON
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert formDataList to JSON string
|
||||||
|
final formDataJson = jsonEncode(formDataList);
|
||||||
|
|
||||||
|
// Send formDataJson as the body
|
||||||
|
final response = await _makePostRequest(url, formDataJson, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> sendAddonsGmcDependentToAPI(
|
||||||
|
List<Map<String, dynamic>> formDataList) async {
|
||||||
|
print('saveAddOnsDetailsToApi API SERVICE');
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url =
|
||||||
|
Uri.parse('${Environment.apiUrl}createOrUpdateEmployeePolicySiAmount');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
'Content-Type': 'application/json', // Ensure content type is JSON
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert formDataList to JSON string
|
||||||
|
final formDataJson = jsonEncode(formDataList);
|
||||||
|
|
||||||
|
// Send formDataJson as the body
|
||||||
|
final response = await _makePostRequest(url, formDataJson, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> sendAddonsGmcSiToAPI(
|
||||||
|
List<Map<String, dynamic>> formDataList) async {
|
||||||
|
print('saveAddOnsDetailsToApi API SERVICE');
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url =
|
||||||
|
Uri.parse('${Environment.apiUrl}createOrUpdateEmployeePolicySiAmount');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
'Content-Type': 'application/json', // Ensure content type is JSON
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert formDataList to JSON string
|
||||||
|
final formDataJson = jsonEncode(formDataList);
|
||||||
|
|
||||||
|
// Send formDataJson as the body
|
||||||
|
final response = await _makePostRequest(url, formDataJson, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> sendAddonsGmcParentSiToAPI(
|
||||||
|
List<Map<String, dynamic>> formDataList) async {
|
||||||
|
print('saveAddOnsDetailsToApi API SERVICE');
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url =
|
||||||
|
Uri.parse('${Environment.apiUrl}createOrUpdateEmployeePolicySiAmount');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
'Content-Type': 'application/json', // Ensure content type is JSON
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert formDataList to JSON string
|
||||||
|
final formDataJson = jsonEncode(formDataList);
|
||||||
|
|
||||||
|
// Send formDataJson as the body
|
||||||
|
final response = await _makePostRequest(url, formDataJson, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> sendAddOnToAPI(
|
||||||
|
Map<String, dynamic> formData) async {
|
||||||
|
print('sendAddOnToAPI API SERVICE');
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url = Uri.parse('${Environment.apiUrl}iAgreeForAddOn');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
'Content-Type': 'application/json', // Ensure content type is JSON
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert formDataList to JSON string
|
||||||
|
final formDataJson = jsonEncode(formData);
|
||||||
|
|
||||||
|
// Send formDataJson as the body
|
||||||
|
final response = await _makePostRequest(url, formDataJson, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> topUpSiCalculationToAPI(formDataList) async {
|
||||||
|
print('saveAddOnsDetailsToApi API SERVICE');
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url = Uri.parse('${Environment.apiUrl}calculatePremium');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
'Content-Type': 'application/json', // Ensure content type is JSON
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert formDataList to JSON string
|
||||||
|
final formDataJson = jsonEncode(formDataList);
|
||||||
|
|
||||||
|
// Send formDataJson as the body
|
||||||
|
final response = await _makePostRequest(url, formDataJson, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> topUpParentSiCalculationToAPI(
|
||||||
|
formDataList) async {
|
||||||
|
print('saveAddOnsDetailsToApi API SERVICE');
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url = Uri.parse('${Environment.apiUrl}calculatePremium');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
'Content-Type': 'application/json', // Ensure content type is JSON
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert formDataList to JSON string
|
||||||
|
final formDataJson = jsonEncode(formDataList);
|
||||||
|
|
||||||
|
// Send formDataJson as the body
|
||||||
|
final response = await _makePostRequest(url, formDataJson, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> addOnsDependentCalculationToAPI(
|
||||||
|
formDataList) async {
|
||||||
|
print('saveAddOnsDetailsToApi API SERVICE');
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final url = Uri.parse('${Environment.apiUrl}calculatePremium');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _token ?? '',
|
||||||
|
'Content-Type': 'application/json', // Ensure content type is JSON
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert formDataList to JSON string
|
||||||
|
final formDataJson = jsonEncode(formDataList);
|
||||||
|
|
||||||
|
// Send formDataJson as the body
|
||||||
|
final response = await _makePostRequest(url, formDataJson, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
//HR API STARTS
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getCashDepositDetailsToApi(
|
||||||
|
String clintID, String empRefId) async {
|
||||||
|
print(_hrtoken);
|
||||||
|
if (_hrtoken == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}getCashDepositData?client_id=$clintID&client_branch_id=$empRefId');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _hrtoken ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getEmployeeAndDependenceToApi(
|
||||||
|
String clintID, String getPolicyNo, String empRefId) async {
|
||||||
|
print(_hrtoken);
|
||||||
|
if (_hrtoken == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Environment.apiUrl}getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo&client_branch_id=$empRefId');
|
||||||
|
final headers = {
|
||||||
|
'Authorization': _hrtoken ?? '',
|
||||||
|
};
|
||||||
|
final response = await _makeGetRequest(url, headers);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Future<Map<String, dynamic>> getTrackClaimsList(
|
||||||
|
// String empMobileNo, String empCode) async {
|
||||||
|
// final url = Uri.parse(
|
||||||
|
// '${Environment.apiUrlTicket}/ticket/get_ticket_data?emp_code=$empCode&mobile_number=$empMobileNo');
|
||||||
|
// final response = await _makeGetRequest(url, {
|
||||||
|
// 'Token': Environment.ticketToken,
|
||||||
|
// });
|
||||||
|
// return response;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Future<Map<String, dynamic>> fetchDepartmentList() async {
|
||||||
|
// final url = Uri.parse('${Environment.apiUrlTicket}/departments');
|
||||||
|
// final response = await _makeGetRequest(url, {
|
||||||
|
// 'Token': Environment.ticketToken,
|
||||||
|
// });
|
||||||
|
// return response;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Future<Map<String, dynamic>> sendFormDataToApi(
|
||||||
|
// Map<String, dynamic> formData) async {
|
||||||
|
// final url = Uri.parse('${Environment.apiUrlTicket}/tickets/create');
|
||||||
|
// // Convert formData to Map<String, String>
|
||||||
|
// Map<String, String> stringFormData =
|
||||||
|
// formData.map((key, value) => MapEntry(key, value.toString()));
|
||||||
|
// final response = await _makePostRequest(url, stringFormData, {
|
||||||
|
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
// 'Token': Environment.ticketToken,
|
||||||
|
// });
|
||||||
|
// return response;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Future<Map<String, dynamic>> sendClaimsMessageToApi(
|
||||||
|
// Map<String, dynamic> formData) async {
|
||||||
|
// final url = Uri.parse('${Environment.apiUrlTicket}/messages/create');
|
||||||
|
// // Convert formData to Map<String, String>
|
||||||
|
// Map<String, String> stringFormData =
|
||||||
|
// formData.map((key, value) => MapEntry(key, value.toString()));
|
||||||
|
// final response = await _makePostRequest(url, stringFormData, {
|
||||||
|
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
// 'Token': Environment.ticketToken,
|
||||||
|
// });
|
||||||
|
// return response;
|
||||||
|
// }
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> _makeGetRequest(
|
||||||
|
Uri url, Map<String, String> headers) async {
|
||||||
|
final response = await http.get(url, headers: headers);
|
||||||
|
return _handleResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> _makePostRequest(
|
||||||
|
Uri url, String body, Map<String, String> headers) async {
|
||||||
|
final response = await http.post(url, headers: headers, body: body);
|
||||||
|
return _handleResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> _handleResponse(http.Response response) async {
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return jsonDecode(response.body);
|
||||||
|
} else if (response.statusCode == 401) {
|
||||||
|
if (!_isSessionOutToastShown) {
|
||||||
|
_isSessionOutToastShown = true;
|
||||||
|
await _clearLocalStorageAndRedirect();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
} else {
|
||||||
|
throw Exception('Failed to load data');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _clearLocalStorageAndRedirect() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.clear();
|
||||||
|
// Assuming you have access to the context
|
||||||
|
ToastHelper.showErrorToast(context, 'Session Out');
|
||||||
|
Navigator.pushNamed(context, 'phone');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -32,6 +32,7 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
dynamic _token;
|
dynamic _token;
|
||||||
dynamic clientName;
|
dynamic clientName;
|
||||||
dynamic clientLogo;
|
dynamic clientLogo;
|
||||||
|
dynamic empClientBranchId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -131,6 +132,8 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
// Decode the JWT token received from the API response
|
// Decode the JWT token received from the API response
|
||||||
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
||||||
print(decodedToken);
|
print(decodedToken);
|
||||||
|
empClientBranchId = decodedToken['client_branch_id'];
|
||||||
|
prefs.setString('empClientBranchId', empClientBranchId);
|
||||||
empCodeString = decodedToken['emp_code'].toString();
|
empCodeString = decodedToken['emp_code'].toString();
|
||||||
prefs.setString('empCode', empCodeString);
|
prefs.setString('empCode', empCodeString);
|
||||||
empPrimaryId = decodedToken['id'];
|
empPrimaryId = decodedToken['id'];
|
||||||
@ -139,6 +142,7 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
prefs.setString('gpaEmpName', gpaEmpName);
|
prefs.setString('gpaEmpName', gpaEmpName);
|
||||||
client_id = decodedToken['client_id'];
|
client_id = decodedToken['client_id'];
|
||||||
prefs.setString('client_id', client_id);
|
prefs.setString('client_id', client_id);
|
||||||
|
|
||||||
getClientLogoAndDetails();
|
getClientLogoAndDetails();
|
||||||
|
|
||||||
print('Successfully Login');
|
print('Successfully Login');
|
||||||
@ -177,7 +181,7 @@ class _MyVerifyState extends State<MyVerify> {
|
|||||||
|
|
||||||
Future<void> getClientLogoAndDetails() async {
|
Future<void> getClientLogoAndDetails() async {
|
||||||
var url = Uri.parse(Environment.apiUrl +
|
var url = Uri.parse(Environment.apiUrl +
|
||||||
'getClientDetails?client_id=$client_id&emp_code=$empCodeString');
|
'getClientDetails?client_id=$client_id&emp_code=$empCodeString&client_branch_id=$empClientBranchId');
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
url,
|
url,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user