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/hrPolicyDetails.dart';
|
||||
import 'package:nhancepolicy/models/environment.dart';
|
||||
import 'package:nhancepolicy/service/api_service.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
@ -82,10 +83,12 @@ class _excelVerifyState extends State<excelVerify> {
|
||||
bool isSuccess = false;
|
||||
String successContent = '';
|
||||
bool isLoading = false;
|
||||
late ApiService apiService;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
apiService = ApiService(context);
|
||||
_loadToken();
|
||||
}
|
||||
|
||||
@ -488,6 +491,7 @@ class _excelVerifyState extends State<excelVerify> {
|
||||
// .toList();
|
||||
// print('excelHeader : $excelHeader');
|
||||
});
|
||||
handleImportAction();
|
||||
} else {
|
||||
ToastHelper.showErrorToast(context, data['message']);
|
||||
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) {
|
||||
setState(() {
|
||||
if (query.isEmpty) {
|
||||
|
||||
@ -461,6 +461,45 @@ class ApiService {
|
||||
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(
|
||||
String? postId, String? preId, String token, String activity) async {
|
||||
print("getCashDepositDetailsToApi1");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user