marco.pms.mobileapp/lib/model/employee_model.dart
Vaibhav Surve 1ea960b0ec Add employee management features including controller, models, and UI
- Implemented AddEmployeeController for handling employee creation logic.
- Created EmployeeScreen and AddEmployeeScreen for employee management UI.
- Added API endpoints for fetching and creating employees.
- Updated EmployeeModel to include additional fields: jobRole, email, and phoneNumber.
- Refactored MyRefreshWrapper to MyRefreshableContent for consistency.
- Enhanced navigation to include employee management routes.
2025-05-09 09:58:44 +05:30

61 lines
1.7 KiB
Dart

class EmployeeModel {
final String id;
final String employeeId;
final String name;
final String designation;
final String checkIn;
final String checkOut;
final int activity;
int action;
final String jobRole;
final String email;
final String phoneNumber;
EmployeeModel({
required this.id,
required this.employeeId,
required this.name,
required this.designation,
required this.checkIn,
required this.checkOut,
required this.activity,
required this.action,
required this.jobRole,
required this.email,
required this.phoneNumber,
});
factory EmployeeModel.fromJson(Map<String, dynamic> json) {
return EmployeeModel(
id: json['id']?.toString() ?? '',
employeeId: json['employeeId']?.toString() ?? '',
name: '${json['firstName'] ?? ''} ${json['lastName'] ?? ''}'.trim(),
designation: json['jobRoleName'] ?? '',
checkIn: json['checkIn']?.toString() ?? '-',
checkOut: json['checkOut']?.toString() ?? '-',
action: json['action'] ?? 0,
activity: json['activity'] ?? 0,
jobRole: json['jobRole']?.toString() ?? '-',
email: json['email']?.toString() ?? '-',
phoneNumber: json['phoneNumber']?.toString() ?? '-',
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'employeeId': employeeId,
'firstName': name.split(' ').first,
'lastName': name.split(' ').length > 1 ? name.split(' ').last : '',
'jobRoleName': designation,
'checkIn': checkIn,
'checkOut': checkOut,
'action': action,
'activity': activity,
'jobRole': jobRole.isEmpty ? '-' : jobRole,
'email': email.isEmpty ? '-' : email,
'phoneNumber': phoneNumber.isEmpty ? '-' : phoneNumber,
};
}
}