add refresh token
This commit is contained in:
@@ -31,10 +31,10 @@ class ProductModel extends HiveObject {
|
||||
final bool isAvailable;
|
||||
|
||||
@HiveField(8)
|
||||
final DateTime createdAt;
|
||||
final DateTime? createdAt;
|
||||
|
||||
@HiveField(9)
|
||||
final DateTime updatedAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
ProductModel({
|
||||
required this.id,
|
||||
@@ -45,8 +45,8 @@ class ProductModel extends HiveObject {
|
||||
required this.categoryId,
|
||||
required this.stockQuantity,
|
||||
required this.isAvailable,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
/// Convert to domain entity
|
||||
@@ -92,8 +92,12 @@ class ProductModel extends HiveObject {
|
||||
categoryId: json['categoryId'] as String,
|
||||
stockQuantity: json['stockQuantity'] as int? ?? 0,
|
||||
isAvailable: json['isAvailable'] as bool? ?? true,
|
||||
createdAt: DateTime.parse(json['createdAt'] as String),
|
||||
updatedAt: DateTime.parse(json['updatedAt'] as String),
|
||||
createdAt: json['createdAt'] != null
|
||||
? DateTime.parse(json['createdAt'] as String)
|
||||
: null,
|
||||
updatedAt: json['updatedAt'] != null
|
||||
? DateTime.parse(json['updatedAt'] as String)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -108,8 +112,8 @@ class ProductModel extends HiveObject {
|
||||
'categoryId': categoryId,
|
||||
'stockQuantity': stockQuantity,
|
||||
'isAvailable': isAvailable,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'updatedAt': updatedAt.toIso8601String(),
|
||||
'createdAt': createdAt?.toIso8601String(),
|
||||
'updatedAt': updatedAt?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ class ProductModelAdapter extends TypeAdapter<ProductModel> {
|
||||
categoryId: fields[5] as String,
|
||||
stockQuantity: (fields[6] as num).toInt(),
|
||||
isAvailable: fields[7] as bool,
|
||||
createdAt: fields[8] as DateTime,
|
||||
updatedAt: fields[9] as DateTime,
|
||||
createdAt: fields[8] as DateTime?,
|
||||
updatedAt: fields[9] as DateTime?,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ class Product extends Equatable {
|
||||
final String categoryId;
|
||||
final int stockQuantity;
|
||||
final bool isAvailable;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
const Product({
|
||||
required this.id,
|
||||
@@ -22,8 +22,8 @@ class Product extends Equatable {
|
||||
required this.categoryId,
|
||||
required this.stockQuantity,
|
||||
required this.isAvailable,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
@override
|
||||
|
||||
@@ -296,14 +296,18 @@ class ProductDetailPage extends ConsumerWidget {
|
||||
context,
|
||||
icon: Icons.calendar_today,
|
||||
label: 'Created',
|
||||
value: dateFormat.format(product.createdAt),
|
||||
value: product.createdAt != null
|
||||
? dateFormat.format(product.createdAt!)
|
||||
: 'N/A',
|
||||
),
|
||||
const Divider(height: 24),
|
||||
_buildInfoRow(
|
||||
context,
|
||||
icon: Icons.update,
|
||||
label: 'Last Updated',
|
||||
value: dateFormat.format(product.updatedAt),
|
||||
value: product.updatedAt != null
|
||||
? dateFormat.format(product.updatedAt!)
|
||||
: 'N/A',
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -493,10 +493,18 @@ class _ProductsPageState extends ConsumerState<ProductsPage> {
|
||||
sorted.sort((a, b) => b.price.compareTo(a.price));
|
||||
break;
|
||||
case ProductSortOption.newest:
|
||||
sorted.sort((a, b) => b.createdAt.compareTo(a.createdAt));
|
||||
sorted.sort((a, b) {
|
||||
final aDate = a.createdAt ?? DateTime(2000);
|
||||
final bDate = b.createdAt ?? DateTime(2000);
|
||||
return bDate.compareTo(aDate);
|
||||
});
|
||||
break;
|
||||
case ProductSortOption.oldest:
|
||||
sorted.sort((a, b) => a.createdAt.compareTo(b.createdAt));
|
||||
sorted.sort((a, b) {
|
||||
final aDate = a.createdAt ?? DateTime(2000);
|
||||
final bDate = b.createdAt ?? DateTime(2000);
|
||||
return aDate.compareTo(bDate);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,10 +91,18 @@ class SortedProducts extends _$SortedProducts {
|
||||
sorted.sort((a, b) => b.price.compareTo(a.price));
|
||||
break;
|
||||
case ProductSortOption.newest:
|
||||
sorted.sort((a, b) => b.createdAt.compareTo(a.createdAt));
|
||||
sorted.sort((a, b) {
|
||||
final aDate = a.createdAt ?? DateTime(2000);
|
||||
final bDate = b.createdAt ?? DateTime(2000);
|
||||
return bDate.compareTo(aDate);
|
||||
});
|
||||
break;
|
||||
case ProductSortOption.oldest:
|
||||
sorted.sort((a, b) => a.createdAt.compareTo(b.createdAt));
|
||||
sorted.sort((a, b) {
|
||||
final aDate = a.createdAt ?? DateTime(2000);
|
||||
final bDate = b.createdAt ?? DateTime(2000);
|
||||
return aDate.compareTo(bDate);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ final class SortedProductsProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$sortedProductsHash() => r'653f1e9af8c188631dadbfe9ed7d944c6876d2d3';
|
||||
String _$sortedProductsHash() => r'8a526ae12a15ca7decc8880ebbd083df455875a8';
|
||||
|
||||
/// Provider for sorted products
|
||||
/// Adds sorting capability on top of filtered products
|
||||
|
||||
Reference in New Issue
Block a user