This commit is contained in:
Phuoc Nguyen
2025-11-27 14:59:48 +07:00
parent dc8e60f589
commit ba04576750
25 changed files with 931 additions and 721 deletions

View File

@@ -272,31 +272,45 @@ class ApiConstants {
static const String getPaymentDetails = '/payments';
// ============================================================================
// Project Endpoints
// Project Endpoints (Frappe ERPNext)
// ============================================================================
/// Create new project
/// Get project status list (requires sid and csrf_token)
/// POST /api/method/building_material.building_material.api.project.get_project_status_list
/// Body: { "limit_start": 0, "limit_page_length": 0 }
/// Returns: { "message": [{ "status": "...", "label": "...", "color": "...", "index": 0 }] }
static const String getProjectStatusList =
'/building_material.building_material.api.project.get_project_status_list';
/// Get list of project submissions (requires sid and csrf_token)
/// POST /api/method/building_material.building_material.api.project.get_list
/// Body: { "limit_start": 0, "limit_page_length": 0 }
/// Returns: { "message": [{ "name": "...", "designed_area": "...", "design_area": 0, ... }] }
static const String getProjectList =
'/building_material.building_material.api.project.get_list';
/// Create new project (legacy endpoint - may be deprecated)
/// POST /projects
static const String createProject = '/projects';
/// Get user's projects
/// Get user's projects (legacy endpoint - may be deprecated)
/// GET /projects?status={status}&page={page}&limit={limit}
static const String getProjects = '/projects';
/// Get project details by ID
/// Get project details by ID (legacy endpoint - may be deprecated)
/// GET /projects/{projectId}
static const String getProjectDetails = '/projects';
/// Update project
/// Update project (legacy endpoint - may be deprecated)
/// PUT /projects/{projectId}
static const String updateProject = '/projects';
/// Update project progress
/// Update project progress (legacy endpoint - may be deprecated)
/// PATCH /projects/{projectId}/progress
/// Body: { "progress": 75 }
static const String updateProjectProgress = '/projects';
/// Delete project
/// Delete project (legacy endpoint - may be deprecated)
/// DELETE /projects/{projectId}
static const String deleteProject = '/projects';

View File

@@ -64,6 +64,9 @@ class HiveBoxNames {
/// Order status list cache
static const String orderStatusBox = 'order_status_box';
/// Project status list cache
static const String projectStatusBox = 'project_status_box';
/// Get all box names for initialization
static List<String> get allBoxes => [
userBox,
@@ -77,6 +80,7 @@ class HiveBoxNames {
cityBox,
wardBox,
orderStatusBox,
projectStatusBox,
settingsBox,
cacheBox,
syncStateBox,
@@ -139,6 +143,7 @@ class HiveTypeIds {
static const int cityModel = 31;
static const int wardModel = 32;
static const int orderStatusModel = 62;
static const int projectStatusModel = 63;
// Enums (33-61)
static const int userRole = 33;
@@ -239,6 +244,37 @@ class OrderStatusIndex {
static const int cancelled = 6;
}
/// Project Status Indices
///
/// Index values for project statuses stored in Hive.
/// These correspond to the index field in ProjectStatusModel.
///
/// API Response Structure:
/// - status: "Pending approval" (English status name)
/// - label: "Chờ phê duyệt" (Vietnamese display label)
/// - color: "Warning" (Status color indicator)
/// - index: 1 (Unique identifier)
class ProjectStatusIndex {
// Private constructor to prevent instantiation
ProjectStatusIndex._();
/// Pending approval - "Chờ phê duyệt"
/// Color: Warning
static const int pendingApproval = 1;
/// Approved - "Đã được phê duyệt"
/// Color: Success
static const int approved = 2;
/// Rejected - "Từ chối"
/// Color: Danger
static const int rejected = 3;
/// Cancelled - "HỦY BỎ"
/// Color: Danger
static const int cancelled = 4;
}
/// Hive Keys (continued)
extension HiveKeysContinued on HiveKeys {
// Cache Box Keys

View File

@@ -102,9 +102,15 @@ class HiveService {
debugPrint(
'HiveService: ${Hive.isAdapterRegistered(HiveTypeIds.orderStatus) ? "" : ""} OrderStatus adapter',
);
debugPrint(
'HiveService: ${Hive.isAdapterRegistered(HiveTypeIds.orderStatusModel) ? "" : ""} OrderStatusModel adapter',
);
debugPrint(
'HiveService: ${Hive.isAdapterRegistered(HiveTypeIds.projectType) ? "" : ""} ProjectType adapter',
);
debugPrint(
'HiveService: ${Hive.isAdapterRegistered(HiveTypeIds.projectStatusModel) ? "" : ""} ProjectStatusModel adapter',
);
debugPrint(
'HiveService: ${Hive.isAdapterRegistered(HiveTypeIds.entryType) ? "" : ""} EntryType adapter',
);
@@ -171,6 +177,9 @@ class HiveService {
// Order status box (non-sensitive) - caches order status list from API
Hive.openBox<dynamic>(HiveBoxNames.orderStatusBox),
// Project status box (non-sensitive) - caches project status list from API
Hive.openBox<dynamic>(HiveBoxNames.projectStatusBox),
]);
// Open potentially encrypted boxes (sensitive data)

View File

@@ -189,7 +189,7 @@ final class LoggingInterceptorProvider
}
String _$loggingInterceptorHash() =>
r'6afa480caa6fcd723dab769bb01601b8a37e20fd';
r'4d3147e9084d261e14653386ecd74ee471993af4';
/// Provider for ErrorTransformerInterceptor