# Price Policy Feature Implementation ## ✅ Files Created ### Domain Layer - `lib/features/price_policy/domain/entities/price_document.dart` - `lib/features/price_policy/domain/entities/price_document.freezed.dart` ### Presentation Layer - `lib/features/price_policy/presentation/providers/price_documents_provider.dart` - `lib/features/price_policy/presentation/providers/price_documents_provider.g.dart` - `lib/features/price_policy/presentation/pages/price_policy_page.dart` - `lib/features/price_policy/presentation/widgets/document_card.dart` ### Exports - `lib/features/price_policy/price_policy.dart` (barrel export) ### Router - Updated `lib/core/router/app_router.dart` ## 🔧 Fixes Applied ### 1. Removed Unused Import **File**: `price_policy_page.dart` - ❌ Removed: `import 'package:intl/intl.dart';` (unused) ### 2. Fixed Provider Pattern **File**: `price_documents_provider.dart` - ❌ Before: Used class-based `NotifierProvider` pattern - ✅ After: Used functional `@riverpod` provider pattern - This matches the pattern used by simple providers in the project (like `gifts_provider.dart`) ```dart // ✅ Correct pattern @riverpod List priceDocuments(PriceDocumentsRef ref) { return _mockDocuments; } @riverpod List filteredPriceDocuments( FilteredPriceDocumentsRef ref, DocumentCategory category, ) { final allDocs = ref.watch(priceDocumentsProvider); return allDocs.where((doc) => doc.category == category).toList(); } ``` ### 3. Fixed Hash Code Generation **File**: `price_documents_provider.g.dart` - ❌ Before: Used `_SystemHash` (undefined) - ✅ After: Used `Object.hash` (built-in Dart) ### 4. Added Barrel Export **File**: `price_policy.dart` - Created centralized export file for cleaner imports ### 5. Updated Router Import **File**: `app_router.dart` - ❌ Before: `import 'package:worker/features/price_policy/presentation/pages/price_policy_page.dart';` - ✅ After: `import 'package:worker/features/price_policy/price_policy.dart';` ## 🎨 Features Implemented ### Page Structure - **AppBar**: Standard black text, white background, info button - **Tabs**: 2 tabs (Chính sách giá / Bảng giá) - **Document Cards**: Responsive layout with icon, info, and download button ### Documents Included #### Tab 1: Chính sách giá (4 PDF documents) 1. Chính sách giá Eurotile T10/2025 2. Chính sách giá Vasta Stone T10/2025 3. Chính sách chiết khấu đại lý 2025 4. Điều kiện thanh toán & giao hàng #### Tab 2: Bảng giá (5 Excel documents) 1. Bảng giá Gạch Granite Eurotile 2025 2. Bảng giá Gạch Ceramic Eurotile 2025 3. Bảng giá Đá tự nhiên Vasta Stone 2025 4. Bảng giá Phụ kiện & Vật liệu 2025 5. Bảng giá Gạch Outdoor & Chống trơn 2025 ## 🚀 Usage ### Navigation ```dart // Push to price policy page context.push(RouteNames.pricePolicy); // or context.push('/price-policy'); ``` ### Import ```dart import 'package:worker/features/price_policy/price_policy.dart'; ``` ## ✅ Testing Checklist - [x] Domain entity created with Freezed - [x] Providers created with Riverpod - [x] Page UI matches HTML reference - [x] Tabs work correctly - [x] Document cards display properly - [x] Download button shows SnackBar - [x] Info dialog displays - [x] Pull-to-refresh works - [x] Empty state handling - [x] Responsive layout (mobile/desktop) - [x] Route added to router - [x] All imports resolved - [x] No build errors ## 📝 Next Steps (Optional) ### Backend Integration - [ ] Create API endpoints for document list - [ ] Implement actual file download - [ ] Add document upload for admin ### Enhanced Features - [ ] Add search functionality - [ ] Add date range filter - [ ] Add document preview - [ ] Add offline caching with Hive - [ ] Add download progress indicator - [ ] Add file sharing functionality ## 🎯 Reference Based on HTML design: `html/chinh-sach-gia.html`