This commit is contained in:
Mohammed Al-Samarraie
2026-01-18 19:40:54 +03:00
parent 8adab4c4af
commit 79b53b6303
13 changed files with 771 additions and 94 deletions

View File

@@ -0,0 +1,25 @@
class VacationRequestDto {
final String employeeId;
final DateTime startDate;
final DateTime endDate;
final String reason;
final int type;
VacationRequestDto({
required this.employeeId,
required this.startDate,
required this.endDate,
required this.reason,
required this.type,
});
Map<String, dynamic> toJson() {
return {
'employeeId': employeeId,
'startDate': startDate.toIso8601String(),
'endDate': endDate.toIso8601String(),
'reason': reason,
'type': type,
};
}
}

View File

@@ -0,0 +1,89 @@
class VacationResponseDto {
final int statusCode;
final bool isSuccess;
final String message;
final VacationDataDto? data;
VacationResponseDto({
required this.statusCode,
required this.isSuccess,
required this.message,
this.data,
});
factory VacationResponseDto.fromJson(Map<String, dynamic> json) {
return VacationResponseDto(
statusCode: json['statusCode'] ?? 0,
isSuccess: json['isSuccess'] ?? false,
message: json['message'] ?? '',
data: json['data'] != null ? VacationDataDto.fromJson(json['data']) : null,
);
}
}
class VacationDataDto {
final String employeeId;
final String? employeeFullName;
final DateTime startDate;
final DateTime endDate;
final String reason;
final String? submittedBy;
final String? submittedByUser;
final int state;
final int type;
final String id;
final DateTime? createdAt;
final DateTime? updatedAt;
final DateTime? deletedAt;
final bool? isDeleted;
VacationDataDto({
required this.employeeId,
this.employeeFullName,
required this.startDate,
required this.endDate,
required this.reason,
this.submittedBy,
this.submittedByUser,
required this.state,
required this.type,
required this.id,
this.createdAt,
this.updatedAt,
this.deletedAt,
this.isDeleted,
});
factory VacationDataDto.fromJson(Map<String, dynamic> json) {
return VacationDataDto(
employeeId: json['employeeId']?.toString() ?? '',
employeeFullName: json['employeeFullName'],
startDate: _parseDateTime(json['startDate'])!,
endDate: _parseDateTime(json['endDate'])!,
reason: json['reason']?.toString() ?? '',
submittedBy: json['submittedBy'],
submittedByUser: json['submittedByUser'],
state: json['state'] ?? 0,
type: json['type'] ?? 0,
id: json['id']?.toString() ?? '',
createdAt: _parseDateTime(json['createdAt']),
updatedAt: _parseDateTime(json['updatedAt']),
deletedAt: _parseDateTime(json['deletedAt']),
isDeleted: json['isDeleted'],
);
}
static DateTime? _parseDateTime(dynamic value) {
if (value == null) return null;
if (value is DateTime) return value;
if (value is String) {
try {
return DateTime.parse(value);
} catch (e) {
print('Error parsing date: $value - $e');
return null;
}
}
return null;
}
}

View File

@@ -0,0 +1,43 @@
class VacationTypesResponseDto {
final int statusCode;
final bool isSuccess;
final String? message;
final List<VacationTypeDto> data;
VacationTypesResponseDto({
required this.statusCode,
required this.isSuccess,
this.message,
required this.data,
});
factory VacationTypesResponseDto.fromJson(Map<String, dynamic> json) {
return VacationTypesResponseDto(
statusCode: json['statusCode'] ?? 0,
isSuccess: json['isSuccess'] ?? false,
message: json['message'],
data: json['data'] != null
? (json['data'] as List)
.map((item) => VacationTypeDto.fromJson(item))
.toList()
: [],
);
}
}
class VacationTypeDto {
final int value;
final String name;
VacationTypeDto({
required this.value,
required this.name,
});
factory VacationTypeDto.fromJson(Map<String, dynamic> json) {
return VacationTypeDto(
value: json['value'] ?? 0,
name: json['name']?.toString() ?? '',
);
}
}