diff --git a/assets/icons/CLUNDER.svg b/assets/icons/CLUNDER.svg
new file mode 100644
index 0000000..e3671a2
--- /dev/null
+++ b/assets/icons/CLUNDER.svg
@@ -0,0 +1,12 @@
+
diff --git a/assets/icons/chart.svg b/assets/icons/chart.svg
new file mode 100644
index 0000000..76cf57c
--- /dev/null
+++ b/assets/icons/chart.svg
@@ -0,0 +1,6 @@
+
diff --git a/assets/icons/trash.svg b/assets/icons/trash.svg
new file mode 100644
index 0000000..a039c0c
--- /dev/null
+++ b/assets/icons/trash.svg
@@ -0,0 +1,7 @@
+
diff --git a/assets/icons/trash2.svg b/assets/icons/trash2.svg
new file mode 100644
index 0000000..f9c5bc9
--- /dev/null
+++ b/assets/icons/trash2.svg
@@ -0,0 +1,6 @@
+
diff --git a/lib/core/config/api_config.dart b/lib/core/config/api_config.dart
index 13b2fc7..05fe8c2 100644
--- a/lib/core/config/api_config.dart
+++ b/lib/core/config/api_config.dart
@@ -49,4 +49,5 @@ class ApiConfig {
/// Body: FormData
/// Headers: {'Authorization': 'Bearer '}
static String editDiscount(String id) => '$baseUrl/discount/edit/$id';
+ static String deleteDiscount(String id) => '$baseUrl/discount/delete/$id';
}
\ No newline at end of file
diff --git a/lib/core/config/app_colors.dart b/lib/core/config/app_colors.dart
index 30f784e..d59507c 100644
--- a/lib/core/config/app_colors.dart
+++ b/lib/core/config/app_colors.dart
@@ -18,4 +18,6 @@ class AppColors {
static const Color expiryReserve = Color.fromARGB(255, 183, 28, 28);
static const Color uploadElevated = Color.fromARGB(255, 233, 245, 254);
static const Color secTitle = Color.fromARGB(255, 95, 95, 95);
+ static const Color backDelete = Color.fromARGB(255, 254, 237,235);
+ static const Color backEdit = Color.fromARGB(255, 237, 247, 238);
}
\ No newline at end of file
diff --git a/lib/domain/entities/discount_entity.dart b/lib/domain/entities/discount_entity.dart
index 42ef9db..9427e57 100644
--- a/lib/domain/entities/discount_entity.dart
+++ b/lib/domain/entities/discount_entity.dart
@@ -9,6 +9,7 @@ class DiscountEntity {
final String description;
final double price;
final double nPrice;
+ final DateTime? startDate;
final DateTime? endDate;
DiscountEntity({
@@ -20,11 +21,11 @@ class DiscountEntity {
required this.description,
required this.price,
required this.nPrice,
+ this.startDate,
required this.endDate,
});
factory DiscountEntity.fromJson(Map json) {
- // A helper function to safely extract lists
List _parseImages(dynamic imageList) {
if (imageList is List) {
return imageList.map((img) => (img['Url'] ?? '') as String).toList();
@@ -36,7 +37,6 @@ class DiscountEntity {
// --- FIX IS HERE: Reading "ID" instead of "_id" ---
id: json['ID'] ?? '', // Changed from '_id' to 'ID'
name: json['Name'] ?? 'بدون نام',
- // Safely access nested properties
shopName:
(json['Shop'] != null ? json['Shop']['Name'] : 'فروشگاه') ?? 'فروشگاه',
images: _parseImages(json['Images']),
@@ -45,7 +45,8 @@ class DiscountEntity {
description: json['Description'] ?? '',
price: (json['Price'] as num? ?? 0).toDouble(),
nPrice: (json['NPrice'] as num? ?? 0).toDouble(),
- // Handle potential null or invalid date
+ startDate:
+ json['StartDate'] != null ? DateTime.tryParse(json['StartDate']) : null,
endDate:
json['EndDate'] != null ? DateTime.tryParse(json['EndDate']) : null,
);
diff --git a/lib/gen/assets.gen.dart b/lib/gen/assets.gen.dart
index 0c3962e..c5b69b5 100644
--- a/lib/gen/assets.gen.dart
+++ b/lib/gen/assets.gen.dart
@@ -15,6 +15,9 @@ class $AssetsIconsGen {
/// File path: assets/icons/Arrow - Right 2.svg
String get arrowRight2 => 'assets/icons/Arrow - Right 2.svg';
+ /// File path: assets/icons/CLUNDER.svg
+ String get clunder => 'assets/icons/CLUNDER.svg';
+
/// File path: assets/icons/CatBack.svg
String get catBack => 'assets/icons/CatBack.svg';
@@ -102,6 +105,9 @@ class $AssetsIconsGen {
/// File path: assets/icons/card-pos.svg
String get cardPos => 'assets/icons/card-pos.svg';
+ /// File path: assets/icons/chart.svg
+ String get chart => 'assets/icons/chart.svg';
+
/// File path: assets/icons/cinama.svg
String get cinama => 'assets/icons/cinama.svg';
@@ -225,6 +231,12 @@ class $AssetsIconsGen {
/// File path: assets/icons/timer-pause.svg
String get timerPause => 'assets/icons/timer-pause.svg';
+ /// File path: assets/icons/trash.svg
+ String get trash => 'assets/icons/trash.svg';
+
+ /// File path: assets/icons/trash2.svg
+ String get trash2 => 'assets/icons/trash2.svg';
+
/// File path: assets/icons/volume-high.svg
String get volumeHigh => 'assets/icons/volume-high.svg';
@@ -234,6 +246,7 @@ class $AssetsIconsGen {
/// List of all assets
List get values => [
arrowRight2,
+ clunder,
catBack,
cinema,
coffee,
@@ -263,6 +276,7 @@ class $AssetsIconsGen {
callCalling,
camera,
cardPos,
+ chart,
cinama,
clock,
clockProduct,
@@ -304,6 +318,8 @@ class $AssetsIconsGen {
tickPb,
ticketDiscount,
timerPause,
+ trash,
+ trash2,
volumeHigh,
warning2,
];
diff --git a/lib/presentation/discount/bloc/discount_bloc.dart b/lib/presentation/discount/bloc/discount_bloc.dart
index 045464f..3134069 100644
--- a/lib/presentation/discount/bloc/discount_bloc.dart
+++ b/lib/presentation/discount/bloc/discount_bloc.dart
@@ -45,7 +45,7 @@ class DiscountBloc extends Bloc {
images = (data['Images'] as List)
.map