CHANGE_IMPORT_API_INTEGRATION
This commit is contained in:
parent
bc0eaf3027
commit
749d72d0a7
@ -10,6 +10,7 @@ import 'package:http/http.dart' as http;
|
|||||||
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
||||||
import 'package:nhancepolicy/hrPolicyDetails.dart';
|
import 'package:nhancepolicy/hrPolicyDetails.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:universal_html/html.dart' as html;
|
import 'package:universal_html/html.dart' as html;
|
||||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||||
@ -82,10 +83,12 @@ class _excelVerifyState extends State<excelVerify> {
|
|||||||
bool isSuccess = false;
|
bool isSuccess = false;
|
||||||
String successContent = '';
|
String successContent = '';
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
|
late ApiService apiService;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
apiService = ApiService(context);
|
||||||
_loadToken();
|
_loadToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,6 +491,7 @@ class _excelVerifyState extends State<excelVerify> {
|
|||||||
// .toList();
|
// .toList();
|
||||||
// print('excelHeader : $excelHeader');
|
// print('excelHeader : $excelHeader');
|
||||||
});
|
});
|
||||||
|
handleImportAction();
|
||||||
} else {
|
} else {
|
||||||
ToastHelper.showErrorToast(context, data['message']);
|
ToastHelper.showErrorToast(context, data['message']);
|
||||||
print('Table');
|
print('Table');
|
||||||
@ -519,6 +523,38 @@ class _excelVerifyState extends State<excelVerify> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> handleImportAction() async {
|
||||||
|
print('handleImportAction');
|
||||||
|
|
||||||
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
final postId = prefs.getString('empHrId');
|
||||||
|
final preId = prefs.getString('enrollmentEmpPrimaryId');
|
||||||
|
var activity = "import_enrollempdata";
|
||||||
|
|
||||||
|
dynamic response;
|
||||||
|
|
||||||
|
print('postId - $postId');
|
||||||
|
print('preId - $preId');
|
||||||
|
print('activity - $activity');
|
||||||
|
|
||||||
|
try {
|
||||||
|
print('10');
|
||||||
|
|
||||||
|
response = await apiService.getImportLogHrActivity(
|
||||||
|
postId!, preId!, widget.Token, activity);
|
||||||
|
|
||||||
|
if (response['status'] == 'success') {
|
||||||
|
print('Request success');
|
||||||
|
} else {
|
||||||
|
// ToastHelper.showWarningToast(
|
||||||
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
|
print('Request failed with status: ${response['code']}');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Exception occurred: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void search(String query) {
|
void search(String query) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (query.isEmpty) {
|
if (query.isEmpty) {
|
||||||
|
|||||||
@ -461,6 +461,45 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getImportLogHrActivity(
|
||||||
|
String? postId, String? preId, String token, String activity) async {
|
||||||
|
print("getCashDepositDetailsToApi1");
|
||||||
|
|
||||||
|
print('postId1 - $postId');
|
||||||
|
print('preId1 - $preId');
|
||||||
|
print('activity1 - $activity');
|
||||||
|
|
||||||
|
// final url = Uri.parse(
|
||||||
|
// '${Environment.apiUrlPost}logHrActivity?user_id=$postId&pre_hr_id=$preId&user_type=hr&activity=$activity');
|
||||||
|
|
||||||
|
final url = Uri.parse('${Environment.apiUrlPost}logHrActivity');
|
||||||
|
|
||||||
|
final headers = {
|
||||||
|
'Authorization': 'Bearer $token' ?? '',
|
||||||
|
};
|
||||||
|
|
||||||
|
final body = {
|
||||||
|
'user_id': postId,
|
||||||
|
'pre_hr_id': preId,
|
||||||
|
'user_type': 'hr',
|
||||||
|
'activity': activity,
|
||||||
|
};
|
||||||
|
|
||||||
|
final response = await http.post(
|
||||||
|
url,
|
||||||
|
headers: headers,
|
||||||
|
body: jsonEncode(body),
|
||||||
|
);
|
||||||
|
|
||||||
|
// final response = await _makeGetRequest(url, headers);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return jsonDecode(response.body);
|
||||||
|
} else {
|
||||||
|
throw Exception(
|
||||||
|
'Failed to log HR activity: ${response.statusCode} ${response.body}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getPostLogHrActivity(
|
Future<Map<String, dynamic>> getPostLogHrActivity(
|
||||||
String? postId, String? preId, String token, String activity) async {
|
String? postId, String? preId, String token, String activity) async {
|
||||||
print("getCashDepositDetailsToApi1");
|
print("getCashDepositDetailsToApi1");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user