Files
worker/PRICE_POLICY_IMPLEMENTATION.md
2025-11-03 11:20:09 +07:00

3.8 KiB

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)
// ✅ Correct pattern
@riverpod
List<PriceDocument> priceDocuments(PriceDocumentsRef ref) {
  return _mockDocuments;
}

@riverpod
List<PriceDocument> 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

// Push to price policy page
context.push(RouteNames.pricePolicy);
// or
context.push('/price-policy');

Import

import 'package:worker/features/price_policy/price_policy.dart';

Testing Checklist

  • Domain entity created with Freezed
  • Providers created with Riverpod
  • Page UI matches HTML reference
  • Tabs work correctly
  • Document cards display properly
  • Download button shows SnackBar
  • Info dialog displays
  • Pull-to-refresh works
  • Empty state handling
  • Responsive layout (mobile/desktop)
  • Route added to router
  • All imports resolved
  • 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