request detail
This commit is contained in:
118
lib/features/showrooms/domain/entities/design_request.dart
Normal file
118
lib/features/showrooms/domain/entities/design_request.dart
Normal file
@@ -0,0 +1,118 @@
|
||||
/// Domain Entity: Design Request
|
||||
///
|
||||
/// Represents a design request/ticket submitted by user.
|
||||
/// Based on API response from building_material.building_material.api.design_request
|
||||
library;
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:worker/features/showrooms/domain/entities/sample_project.dart';
|
||||
|
||||
/// Design Request Status
|
||||
///
|
||||
/// Maps from API status_color field:
|
||||
/// - "Success" -> completed
|
||||
/// - "Warning" -> pending
|
||||
/// - "Danger" -> rejected
|
||||
/// - Other -> designing
|
||||
enum DesignRequestStatus {
|
||||
pending,
|
||||
designing,
|
||||
completed,
|
||||
rejected,
|
||||
}
|
||||
|
||||
/// Design Request Entity
|
||||
///
|
||||
/// Contains information about a design request ticket.
|
||||
/// API field mapping:
|
||||
/// - name -> id
|
||||
/// - subject -> subject
|
||||
/// - description -> description (HTML content)
|
||||
/// - dateline -> dateline
|
||||
/// - status -> statusText
|
||||
/// - status_color -> statusColor (mapped to enum)
|
||||
/// - files_list -> filesList (detail only)
|
||||
class DesignRequest extends Equatable {
|
||||
/// Unique request identifier (API: name)
|
||||
final String id;
|
||||
|
||||
/// Request subject/title (API: subject)
|
||||
final String subject;
|
||||
|
||||
/// Request description - may contain HTML (API: description)
|
||||
final String? description;
|
||||
|
||||
/// Deadline date string (API: dateline)
|
||||
final String? dateline;
|
||||
|
||||
/// Status display text (API: status)
|
||||
final String statusText;
|
||||
|
||||
/// Status color code (API: status_color)
|
||||
final String statusColor;
|
||||
|
||||
/// List of attached files (API: files_list) - available in detail
|
||||
final List<ProjectFile> filesList;
|
||||
|
||||
const DesignRequest({
|
||||
required this.id,
|
||||
required this.subject,
|
||||
this.description,
|
||||
this.dateline,
|
||||
required this.statusText,
|
||||
required this.statusColor,
|
||||
this.filesList = const [],
|
||||
});
|
||||
|
||||
/// Get status enum from statusColor
|
||||
DesignRequestStatus get status {
|
||||
switch (statusColor.toLowerCase()) {
|
||||
case 'success':
|
||||
return DesignRequestStatus.completed;
|
||||
case 'warning':
|
||||
return DesignRequestStatus.pending;
|
||||
case 'danger':
|
||||
return DesignRequestStatus.rejected;
|
||||
default:
|
||||
return DesignRequestStatus.designing;
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if request is completed
|
||||
bool get isCompleted => status == DesignRequestStatus.completed;
|
||||
|
||||
/// Check if request is pending
|
||||
bool get isPending => status == DesignRequestStatus.pending;
|
||||
|
||||
/// Check if request is rejected
|
||||
bool get isRejected => status == DesignRequestStatus.rejected;
|
||||
|
||||
/// Get plain text description (strips HTML tags)
|
||||
String get plainDescription {
|
||||
if (description == null) return '';
|
||||
// Simple HTML tag removal
|
||||
return description!
|
||||
.replaceAll(RegExp(r'<[^>]*>'), '')
|
||||
.replaceAll(' ', ' ')
|
||||
.trim();
|
||||
}
|
||||
|
||||
/// Get all file URLs
|
||||
List<String> get fileUrls => filesList.map((f) => f.fileUrl).toList();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
subject,
|
||||
description,
|
||||
dateline,
|
||||
statusText,
|
||||
statusColor,
|
||||
filesList,
|
||||
];
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DesignRequest(id: $id, subject: $subject, status: $statusText, filesCount: ${filesList.length})';
|
||||
}
|
||||
}
|
||||
@@ -8,15 +8,21 @@ import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Project File Entity
|
||||
///
|
||||
/// Represents an uploaded file attached to a sample project.
|
||||
class SampleProjectFile extends Equatable {
|
||||
/// Shared entity for file attachments used by:
|
||||
/// - SampleProject (model houses)
|
||||
/// - DesignRequest (design requests)
|
||||
///
|
||||
/// API field mapping:
|
||||
/// - name -> id
|
||||
/// - file_url -> fileUrl
|
||||
class ProjectFile extends Equatable {
|
||||
/// Unique file identifier (API: name)
|
||||
final String id;
|
||||
|
||||
/// Full URL to the file (API: file_url)
|
||||
final String fileUrl;
|
||||
|
||||
const SampleProjectFile({
|
||||
const ProjectFile({
|
||||
required this.id,
|
||||
required this.fileUrl,
|
||||
});
|
||||
@@ -52,7 +58,7 @@ class SampleProject extends Equatable {
|
||||
final String? thumbnailUrl;
|
||||
|
||||
/// List of attached files/images (API: files_list) - available in detail
|
||||
final List<SampleProjectFile> filesList;
|
||||
final List<ProjectFile> filesList;
|
||||
|
||||
const SampleProject({
|
||||
required this.id,
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/// Design Request Repository Interface
|
||||
///
|
||||
/// Defines contract for design request data operations.
|
||||
library;
|
||||
|
||||
import 'package:worker/features/showrooms/domain/entities/design_request.dart';
|
||||
|
||||
/// Design Request Repository
|
||||
///
|
||||
/// Repository interface for design request operations.
|
||||
abstract class DesignRequestRepository {
|
||||
/// Get list of design requests
|
||||
///
|
||||
/// Returns list of design requests.
|
||||
/// [limitStart] - Pagination offset
|
||||
/// [limitPageLength] - Number of items per page (0 = all)
|
||||
Future<List<DesignRequest>> getDesignRequests({
|
||||
int limitStart = 0,
|
||||
int limitPageLength = 0,
|
||||
});
|
||||
|
||||
/// Get detail of a design request by name
|
||||
///
|
||||
/// Returns full design request detail with files_list.
|
||||
Future<DesignRequest> getDesignRequestDetail(String name);
|
||||
}
|
||||
Reference in New Issue
Block a user