101 lines
3.0 KiB
Dart
101 lines
3.0 KiB
Dart
/// Domain Entity: Project Submission
|
|
///
|
|
/// Represents a completed project submitted for loyalty points.
|
|
/// Based on API response from building_material.building_material.api.project.get_list
|
|
library;
|
|
|
|
import 'package:equatable/equatable.dart';
|
|
|
|
/// Project Submission Entity
|
|
///
|
|
/// Contains information about a completed project submission.
|
|
/// Mapped from API response:
|
|
/// - name -> submissionId
|
|
/// - designed_area -> designedArea (project name/title)
|
|
/// - design_area -> designArea (area value in m²)
|
|
/// - request_date -> requestDate
|
|
/// - status -> status (Vietnamese label)
|
|
/// - reason_for_rejection -> reasonForRejection
|
|
/// - status_color -> statusColor
|
|
class ProjectSubmission extends Equatable {
|
|
/// Unique submission identifier (API: name)
|
|
final String submissionId;
|
|
|
|
/// Project name/title (API: designed_area)
|
|
final String designedArea;
|
|
|
|
/// Design area value in square meters (API: design_area)
|
|
final double designArea;
|
|
|
|
/// Submission/request date (API: request_date)
|
|
final DateTime requestDate;
|
|
|
|
/// Status label - Vietnamese (API: status)
|
|
/// e.g., "Chờ phê duyệt", "Đã được phê duyệt", "Từ chối", "HỦY BỎ"
|
|
final String status;
|
|
|
|
/// Rejection reason if rejected (API: reason_for_rejection)
|
|
final String? reasonForRejection;
|
|
|
|
/// Status color indicator (API: status_color)
|
|
/// Values: "Warning", "Success", "Danger"
|
|
final String statusColor;
|
|
|
|
const ProjectSubmission({
|
|
required this.submissionId,
|
|
required this.designedArea,
|
|
required this.designArea,
|
|
required this.requestDate,
|
|
required this.status,
|
|
this.reasonForRejection,
|
|
required this.statusColor,
|
|
});
|
|
|
|
/// Check if submission is pending approval
|
|
bool get isPending => statusColor == 'Warning';
|
|
|
|
/// Check if submission is approved
|
|
bool get isApproved => statusColor == 'Success';
|
|
|
|
/// Check if submission is rejected or cancelled
|
|
bool get isRejected => statusColor == 'Danger';
|
|
|
|
/// Copy with method for immutability
|
|
ProjectSubmission copyWith({
|
|
String? submissionId,
|
|
String? designedArea,
|
|
double? designArea,
|
|
DateTime? requestDate,
|
|
String? status,
|
|
String? reasonForRejection,
|
|
String? statusColor,
|
|
}) {
|
|
return ProjectSubmission(
|
|
submissionId: submissionId ?? this.submissionId,
|
|
designedArea: designedArea ?? this.designedArea,
|
|
designArea: designArea ?? this.designArea,
|
|
requestDate: requestDate ?? this.requestDate,
|
|
status: status ?? this.status,
|
|
reasonForRejection: reasonForRejection ?? this.reasonForRejection,
|
|
statusColor: statusColor ?? this.statusColor,
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
submissionId,
|
|
designedArea,
|
|
designArea,
|
|
requestDate,
|
|
status,
|
|
reasonForRejection,
|
|
statusColor,
|
|
];
|
|
|
|
@override
|
|
String toString() {
|
|
return 'ProjectSubmission(submissionId: $submissionId, designedArea: $designedArea, '
|
|
'designArea: $designArea, status: $status, statusColor: $statusColor)';
|
|
}
|
|
}
|