Update: 2026-06-26 17:29:23
This commit is contained in:
@@ -3,9 +3,9 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_admin/constant/colors.dart';
|
||||
import 'package:siro_admin/constant/links.dart';
|
||||
import 'package:siro_admin/controller/functions/crud.dart';
|
||||
import 'package:siro_admin/views/widgets/snackbar.dart';
|
||||
|
||||
class EmployeeController extends GetxController {
|
||||
List employee = [];
|
||||
@@ -19,7 +19,7 @@ class EmployeeController extends GetxController {
|
||||
fetchEmployee() async {
|
||||
var res = await CRUD().get(link: AppLink.getEmployee, payload: {});
|
||||
if (res is String && (res == 'failure' || res == 'token_expired')) {
|
||||
Get.snackbar('error', 'Failed to load employees', backgroundColor: AppColor.redColor);
|
||||
mySnackbarError('Failed to load employees');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class EmployeeController extends GetxController {
|
||||
employee = jsonData['message'];
|
||||
update();
|
||||
} catch (e) {
|
||||
Get.snackbar('error', 'Invalid server response', backgroundColor: AppColor.redColor);
|
||||
mySnackbarError('Invalid server response');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,7 @@ class EmployeeController extends GetxController {
|
||||
// You can handle the success case here, such as showing a success message
|
||||
|
||||
Get.back();
|
||||
Get.snackbar('Success', 'Employee added successfully',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
mySnackbarSuccess('Employee added successfully');
|
||||
name.clear();
|
||||
education.clear();
|
||||
site.clear();
|
||||
@@ -69,8 +68,7 @@ class EmployeeController extends GetxController {
|
||||
fetchEmployee();
|
||||
} else {
|
||||
// Handle the error case by showing a snackbar with an error message
|
||||
Get.snackbar('Error', 'Failed to add employee',
|
||||
backgroundColor: AppColor.redColor);
|
||||
mySnackbarError('Failed to add employee');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user