add auth, format

This commit is contained in:
Phuoc Nguyen
2025-11-07 11:52:06 +07:00
parent 24a8508fce
commit 3803bd26e0
173 changed files with 8505 additions and 7116 deletions

View File

@@ -74,12 +74,16 @@ class ProductsLocalDataSourceImpl implements ProductsLocalDataSource {
{
'product_id': 'prod_001',
'name': 'Gạch Cát Tường 1200x1200',
'description': 'Gạch men bóng kiếng cao cấp, chống trượt, độ bền cao. Phù hợp cho phòng khách, phòng ngủ.',
'description':
'Gạch men bóng kiếng cao cấp, chống trượt, độ bền cao. Phù hợp cho phòng khách, phòng ngủ.',
'base_price': 450000.0,
'unit': '',
'images': ['https://www.eurotile.vn/pictures/catalog/product/0-gachkholon/cat-tuong/CAT-S01G-1.jpg'],
'images': [
'https://www.eurotile.vn/pictures/catalog/product/0-gachkholon/cat-tuong/CAT-S01G-1.jpg',
],
'image_captions': {},
'link_360': 'https://design.eurotile.vn/pub/tool/panorama/show?obsPlanId=3FO3H1VE59R5&locale=en_US',
'link_360':
'https://design.eurotile.vn/pub/tool/panorama/show?obsPlanId=3FO3H1VE59R5&locale=en_US',
'specifications': {},
'category': 'floor_tiles',
'brand': 'Eurotile',
@@ -92,12 +96,16 @@ class ProductsLocalDataSourceImpl implements ProductsLocalDataSource {
{
'product_id': 'prod_002',
'name': 'Gạch granite nhập khẩu',
'description': 'Gạch granite nhập khẩu Tây Ban Nha, vân đá tự nhiên, sang trọng. Kích thước 80x80cm.',
'description':
'Gạch granite nhập khẩu Tây Ban Nha, vân đá tự nhiên, sang trọng. Kích thước 80x80cm.',
'base_price': 680000.0,
'unit': '',
'images': ['https://images.unsplash.com/photo-1565193566173-7a0ee3dbe261?w=300&h=300&fit=crop'],
'images': [
'https://images.unsplash.com/photo-1565193566173-7a0ee3dbe261?w=300&h=300&fit=crop',
],
'image_captions': {},
'link_360': 'https://design.eurotile.vn/pub/tool/panorama/show?obsPlanId=3FO3H1VE59R&locale=en_US',
'link_360':
'https://design.eurotile.vn/pub/tool/panorama/show?obsPlanId=3FO3H1VE59R&locale=en_US',
'specifications': {},
'category': 'floor_tiles',
'brand': 'Vasta Stone',
@@ -110,12 +118,16 @@ class ProductsLocalDataSourceImpl implements ProductsLocalDataSource {
{
'product_id': 'prod_003',
'name': 'Gạch mosaic trang trí',
'description': 'Gạch mosaic thủy tinh màu sắc đa dạng, tạo điểm nhấn cho không gian. Kích thước 30x30cm.',
'description':
'Gạch mosaic thủy tinh màu sắc đa dạng, tạo điểm nhấn cho không gian. Kích thước 30x30cm.',
'base_price': 320000.0,
'unit': '',
'images': ['https://images.unsplash.com/photo-1615971677499-5467cbab01c0?w=300&h=300&fit=crop'],
'images': [
'https://images.unsplash.com/photo-1615971677499-5467cbab01c0?w=300&h=300&fit=crop',
],
'image_captions': {},
'link_360': 'https://design.eurotile.vn/pub/tool/panorama/show?obsPlanId=3FO3H1VE59R5&locale=en_US',
'link_360':
'https://design.eurotile.vn/pub/tool/panorama/show?obsPlanId=3FO3H1VE59R5&locale=en_US',
'specifications': {},
'category': 'decorative_tiles',
'brand': 'Eurotile',
@@ -128,12 +140,16 @@ class ProductsLocalDataSourceImpl implements ProductsLocalDataSource {
{
'product_id': 'prod_004',
'name': 'Gạch 3D họa tiết',
'description': 'Gạch 3D với họa tiết nổi độc đáo, tạo hiệu ứng thị giác ấn tượng cho tường phòng khách.',
'description':
'Gạch 3D với họa tiết nổi độc đáo, tạo hiệu ứng thị giác ấn tượng cho tường phòng khách.',
'base_price': 750000.0,
'unit': '',
'images': ['https://images.unsplash.com/photo-1600566753190-17f0baa2a6c3?w=300&h=300&fit=crop'],
'images': [
'https://images.unsplash.com/photo-1600566753190-17f0baa2a6c3?w=300&h=300&fit=crop',
],
'image_captions': {},
'link_360': 'https://design.eurotile.vn/pub/tool/panorama/show?obsPlanId=3FO3H1VE59R5&locale=en_US',
'link_360':
'https://design.eurotile.vn/pub/tool/panorama/show?obsPlanId=3FO3H1VE59R5&locale=en_US',
'specifications': {},
'category': 'wall_tiles',
'brand': 'Vasta Stone',
@@ -146,12 +162,16 @@ class ProductsLocalDataSourceImpl implements ProductsLocalDataSource {
{
'product_id': 'prod_005',
'name': 'Gạch ceramic chống trượt',
'description': 'Gạch ceramic chống trượt cấp độ R11, an toàn cho phòng tắm và ban công. Kích thước 40x40cm.',
'description':
'Gạch ceramic chống trượt cấp độ R11, an toàn cho phòng tắm và ban công. Kích thước 40x40cm.',
'base_price': 380000.0,
'unit': '',
'images': ['https://images.unsplash.com/photo-1615874694520-474822394e73?w=300&h=300&fit=crop'],
'images': [
'https://images.unsplash.com/photo-1615874694520-474822394e73?w=300&h=300&fit=crop',
],
'image_captions': {},
'link_360': 'https://design.eurotile.vn/pub/tool/panorama/show?obsPlanId=3FO3H1VE59R5&locale=en_US',
'link_360':
'https://design.eurotile.vn/pub/tool/panorama/show?obsPlanId=3FO3H1VE59R5&locale=en_US',
'specifications': {},
'category': 'outdoor_tiles',
'brand': 'Eurotile',
@@ -164,10 +184,13 @@ class ProductsLocalDataSourceImpl implements ProductsLocalDataSource {
{
'product_id': 'prod_006',
'name': 'Gạch terrazzo đá mài',
'description': 'Gạch terrazzo phong cách retro, đá mài hạt màu, độc đáo và bền đẹp theo thời gian.',
'description':
'Gạch terrazzo phong cách retro, đá mài hạt màu, độc đáo và bền đẹp theo thời gian.',
'base_price': 890000.0,
'unit': '',
'images': ['https://images.unsplash.com/photo-1564013799919-ab600027ffc6?w=300&h=300&fit=crop'],
'images': [
'https://images.unsplash.com/photo-1564013799919-ab600027ffc6?w=300&h=300&fit=crop',
],
'image_captions': {},
'link_360': null,
'specifications': {},
@@ -186,9 +209,7 @@ class ProductsLocalDataSourceImpl implements ProductsLocalDataSource {
// Simulate network delay
await Future.delayed(const Duration(milliseconds: 500));
return _productsJson
.map((json) => ProductModel.fromJson(json))
.toList();
return _productsJson.map((json) => ProductModel.fromJson(json)).toList();
}
@override
@@ -245,8 +266,6 @@ class ProductsLocalDataSourceImpl implements ProductsLocalDataSource {
// Simulate network delay
await Future.delayed(const Duration(milliseconds: 300));
return _categoriesJson
.map((json) => CategoryModel.fromJson(json))
.toList();
return _categoriesJson.map((json) => CategoryModel.fromJson(json)).toList();
}
}

View File

@@ -139,11 +139,13 @@ class ProductModel extends HiveObject {
'description': description,
'base_price': basePrice,
'images': images != null ? jsonDecode(images!) : null,
'image_captions':
imageCaptions != null ? jsonDecode(imageCaptions!) : null,
'image_captions': imageCaptions != null
? jsonDecode(imageCaptions!)
: null,
'link_360': link360,
'specifications':
specifications != null ? jsonDecode(specifications!) : null,
'specifications': specifications != null
? jsonDecode(specifications!)
: null,
'category': category,
'brand': brand,
'unit': unit,

View File

@@ -16,9 +16,7 @@ import 'package:worker/features/products/domain/repositories/products_repository
class ProductsRepositoryImpl implements ProductsRepository {
final ProductsLocalDataSource localDataSource;
const ProductsRepositoryImpl({
required this.localDataSource,
});
const ProductsRepositoryImpl({required this.localDataSource});
@override
Future<List<Product>> getAllProducts() async {
@@ -43,7 +41,9 @@ class ProductsRepositoryImpl implements ProductsRepository {
@override
Future<List<Product>> getProductsByCategory(String categoryId) async {
try {
final productModels = await localDataSource.getProductsByCategory(categoryId);
final productModels = await localDataSource.getProductsByCategory(
categoryId,
);
return productModels.map((model) => model.toEntity()).toList();
} catch (e) {
throw Exception('Failed to get products by category: $e');