feat : segmentation page
This commit is contained in:
@@ -6,7 +6,7 @@ part 'segmentation_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class SegmentationModel with _$SegmentationModel {
|
||||
const factory SegmentationModel({String? key, Buyer? buyer, DateTime? date, double? weight}) =
|
||||
const factory SegmentationModel({String? key, Buyer? buyer, DateTime? date, int? weight}) =
|
||||
_SegmentationModel;
|
||||
|
||||
factory SegmentationModel.fromJson(Map<String, dynamic> json) =>
|
||||
|
||||
@@ -16,7 +16,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$SegmentationModel {
|
||||
|
||||
String? get key; Buyer? get buyer; DateTime? get date; double? get weight;
|
||||
String? get key; Buyer? get buyer; DateTime? get date; int? get weight;
|
||||
/// Create a copy of SegmentationModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -49,7 +49,7 @@ abstract mixin class $SegmentationModelCopyWith<$Res> {
|
||||
factory $SegmentationModelCopyWith(SegmentationModel value, $Res Function(SegmentationModel) _then) = _$SegmentationModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String? key, Buyer? buyer, DateTime? date, double? weight
|
||||
String? key, Buyer? buyer, DateTime? date, int? weight
|
||||
});
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable
|
||||
as String?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable
|
||||
as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable
|
||||
as double?,
|
||||
as int?,
|
||||
));
|
||||
}
|
||||
/// Create a copy of SegmentationModel
|
||||
@@ -101,7 +101,7 @@ class _SegmentationModel implements SegmentationModel {
|
||||
@override final String? key;
|
||||
@override final Buyer? buyer;
|
||||
@override final DateTime? date;
|
||||
@override final double? weight;
|
||||
@override final int? weight;
|
||||
|
||||
/// Create a copy of SegmentationModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -136,7 +136,7 @@ abstract mixin class _$SegmentationModelCopyWith<$Res> implements $SegmentationM
|
||||
factory _$SegmentationModelCopyWith(_SegmentationModel value, $Res Function(_SegmentationModel) _then) = __$SegmentationModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String? key, Buyer? buyer, DateTime? date, double? weight
|
||||
String? key, Buyer? buyer, DateTime? date, int? weight
|
||||
});
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable
|
||||
as String?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable
|
||||
as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable
|
||||
as double?,
|
||||
as int?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ _SegmentationModel _$SegmentationModelFromJson(Map<String, dynamic> json) =>
|
||||
date: json['date'] == null
|
||||
? null
|
||||
: DateTime.parse(json['date'] as String),
|
||||
weight: (json['weight'] as num?)?.toDouble(),
|
||||
weight: (json['weight'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SegmentationModelToJson(_SegmentationModel instance) =>
|
||||
|
||||
@@ -148,6 +148,8 @@ abstract class ChickenRepository {
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
|
||||
Future<void> createSegmentation({required String token, required SegmentationModel model});
|
||||
|
||||
Future<void> editSegmentation({required String token, required SegmentationModel model});
|
||||
|
||||
Future<void> deleteSegmentation({required String token, required String key});
|
||||
|
||||
@@ -450,6 +450,15 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
return res.data;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> createSegmentation({required String token, required SegmentationModel model}) async {
|
||||
await _httpClient.post(
|
||||
'/app-segmentation/',
|
||||
data: model.toJson()..removeWhere((key, value) => value == null),
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> editSegmentation({required String token, required SegmentationModel model}) async {
|
||||
await _httpClient.put(
|
||||
|
||||
Reference in New Issue
Block a user