submission
This commit is contained in:
@@ -1,22 +1,53 @@
|
||||
/// 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
|
||||
/// Based on API response from building_material.building_material.api.project.get_detail
|
||||
library;
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Project File Entity
|
||||
///
|
||||
/// Represents an uploaded file attached to a project submission.
|
||||
class ProjectFile extends Equatable {
|
||||
/// Unique file identifier (API: name)
|
||||
final String id;
|
||||
|
||||
/// Full URL to the file (API: file_url)
|
||||
final String fileUrl;
|
||||
|
||||
const ProjectFile({
|
||||
required this.id,
|
||||
required this.fileUrl,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id, fileUrl];
|
||||
}
|
||||
|
||||
/// Project Submission Entity
|
||||
///
|
||||
/// Contains information about a completed project submission.
|
||||
/// Mapped from API response:
|
||||
/// - name -> submissionId
|
||||
/// - designed_area -> designedArea (project name/title)
|
||||
/// - address_of_project -> addressOfProject
|
||||
/// - project_owner -> projectOwner
|
||||
/// - design_firm -> designFirm
|
||||
/// - contruction_contractor -> constructionContractor
|
||||
/// - design_area -> designArea (area value in m²)
|
||||
/// - products_included_in_the_design -> productsIncludedInTheDesign
|
||||
/// - project_progress -> projectProgress (ID reference)
|
||||
/// - expected_commencement_date -> expectedCommencementDate
|
||||
/// - description -> description
|
||||
/// - request_date -> requestDate
|
||||
/// - status -> status (Vietnamese label)
|
||||
/// - workflow_state -> workflowState
|
||||
/// - reason_for_rejection -> reasonForRejection
|
||||
/// - status -> status (Vietnamese label)
|
||||
/// - status_color -> statusColor
|
||||
/// - is_allow_modify -> isAllowModify
|
||||
/// - is_allow_cancel -> isAllowCancel
|
||||
/// - files_list -> filesList
|
||||
class ProjectSubmission extends Equatable {
|
||||
/// Unique submission identifier (API: name)
|
||||
final String submissionId;
|
||||
@@ -24,31 +55,80 @@ class ProjectSubmission extends Equatable {
|
||||
/// Project name/title (API: designed_area)
|
||||
final String designedArea;
|
||||
|
||||
/// Project address (API: address_of_project)
|
||||
final String? addressOfProject;
|
||||
|
||||
/// Project owner name (API: project_owner)
|
||||
final String? projectOwner;
|
||||
|
||||
/// Design firm name (API: design_firm)
|
||||
final String? designFirm;
|
||||
|
||||
/// Construction contractor name (API: contruction_contractor)
|
||||
final String? constructionContractor;
|
||||
|
||||
/// Design area value in square meters (API: design_area)
|
||||
final double designArea;
|
||||
|
||||
/// Products included in the design (API: products_included_in_the_design)
|
||||
final String? productsIncludedInTheDesign;
|
||||
|
||||
/// Project progress ID reference (API: project_progress)
|
||||
final String? projectProgress;
|
||||
|
||||
/// Expected commencement date (API: expected_commencement_date)
|
||||
final DateTime? expectedCommencementDate;
|
||||
|
||||
/// Project description (API: description)
|
||||
final String? description;
|
||||
|
||||
/// Submission/request date (API: request_date)
|
||||
final DateTime requestDate;
|
||||
|
||||
/// Workflow state (API: workflow_state)
|
||||
/// e.g., "Pending approval", "Approved", "Rejected", "Cancelled"
|
||||
final String? workflowState;
|
||||
|
||||
/// Rejection reason if rejected (API: reason_for_rejection)
|
||||
final String? reasonForRejection;
|
||||
|
||||
/// 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;
|
||||
|
||||
/// Whether the submission can be modified (API: is_allow_modify)
|
||||
final bool isAllowModify;
|
||||
|
||||
/// Whether the submission can be cancelled (API: is_allow_cancel)
|
||||
final bool isAllowCancel;
|
||||
|
||||
/// List of attached files (API: files_list)
|
||||
final List<ProjectFile> filesList;
|
||||
|
||||
const ProjectSubmission({
|
||||
required this.submissionId,
|
||||
required this.designedArea,
|
||||
this.addressOfProject,
|
||||
this.projectOwner,
|
||||
this.designFirm,
|
||||
this.constructionContractor,
|
||||
required this.designArea,
|
||||
this.productsIncludedInTheDesign,
|
||||
this.projectProgress,
|
||||
this.expectedCommencementDate,
|
||||
this.description,
|
||||
required this.requestDate,
|
||||
required this.status,
|
||||
this.workflowState,
|
||||
this.reasonForRejection,
|
||||
required this.status,
|
||||
required this.statusColor,
|
||||
this.isAllowModify = false,
|
||||
this.isAllowCancel = false,
|
||||
this.filesList = const [],
|
||||
});
|
||||
|
||||
/// Check if submission is pending approval
|
||||
@@ -64,20 +144,44 @@ class ProjectSubmission extends Equatable {
|
||||
ProjectSubmission copyWith({
|
||||
String? submissionId,
|
||||
String? designedArea,
|
||||
String? addressOfProject,
|
||||
String? projectOwner,
|
||||
String? designFirm,
|
||||
String? constructionContractor,
|
||||
double? designArea,
|
||||
String? productsIncludedInTheDesign,
|
||||
String? projectProgress,
|
||||
DateTime? expectedCommencementDate,
|
||||
String? description,
|
||||
DateTime? requestDate,
|
||||
String? status,
|
||||
String? workflowState,
|
||||
String? reasonForRejection,
|
||||
String? status,
|
||||
String? statusColor,
|
||||
bool? isAllowModify,
|
||||
bool? isAllowCancel,
|
||||
List<ProjectFile>? filesList,
|
||||
}) {
|
||||
return ProjectSubmission(
|
||||
submissionId: submissionId ?? this.submissionId,
|
||||
designedArea: designedArea ?? this.designedArea,
|
||||
addressOfProject: addressOfProject ?? this.addressOfProject,
|
||||
projectOwner: projectOwner ?? this.projectOwner,
|
||||
designFirm: designFirm ?? this.designFirm,
|
||||
constructionContractor: constructionContractor ?? this.constructionContractor,
|
||||
designArea: designArea ?? this.designArea,
|
||||
productsIncludedInTheDesign: productsIncludedInTheDesign ?? this.productsIncludedInTheDesign,
|
||||
projectProgress: projectProgress ?? this.projectProgress,
|
||||
expectedCommencementDate: expectedCommencementDate ?? this.expectedCommencementDate,
|
||||
description: description ?? this.description,
|
||||
requestDate: requestDate ?? this.requestDate,
|
||||
status: status ?? this.status,
|
||||
workflowState: workflowState ?? this.workflowState,
|
||||
reasonForRejection: reasonForRejection ?? this.reasonForRejection,
|
||||
status: status ?? this.status,
|
||||
statusColor: statusColor ?? this.statusColor,
|
||||
isAllowModify: isAllowModify ?? this.isAllowModify,
|
||||
isAllowCancel: isAllowCancel ?? this.isAllowCancel,
|
||||
filesList: filesList ?? this.filesList,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,11 +189,23 @@ class ProjectSubmission extends Equatable {
|
||||
List<Object?> get props => [
|
||||
submissionId,
|
||||
designedArea,
|
||||
addressOfProject,
|
||||
projectOwner,
|
||||
designFirm,
|
||||
constructionContractor,
|
||||
designArea,
|
||||
productsIncludedInTheDesign,
|
||||
projectProgress,
|
||||
expectedCommencementDate,
|
||||
description,
|
||||
requestDate,
|
||||
status,
|
||||
workflowState,
|
||||
reasonForRejection,
|
||||
status,
|
||||
statusColor,
|
||||
isAllowModify,
|
||||
isAllowCancel,
|
||||
filesList,
|
||||
];
|
||||
|
||||
@override
|
||||
|
||||
@@ -38,6 +38,10 @@ abstract class SubmissionsRepository {
|
||||
int limitPageLength = 0,
|
||||
});
|
||||
|
||||
/// Get project detail by name
|
||||
/// Returns the full project detail as entity for form prefilling
|
||||
Future<ProjectSubmission> getSubmissionDetail(String name);
|
||||
|
||||
/// Save (create/update) a project submission
|
||||
/// Returns the project name (ID) from the API response
|
||||
Future<String> saveSubmission(ProjectSubmissionRequest request);
|
||||
|
||||
Reference in New Issue
Block a user