feat: create product
This commit is contained in:
@@ -1,40 +1,49 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class ProductRequestModel {
|
||||
final String? id;
|
||||
final String name;
|
||||
final String? description;
|
||||
final String categoryId;
|
||||
final String? sku;
|
||||
final String? barcode;
|
||||
final int price;
|
||||
final int stock;
|
||||
final int categoryId;
|
||||
final int isBestSeller;
|
||||
final XFile? image;
|
||||
final int cost;
|
||||
final bool isActive;
|
||||
final bool hasVariants;
|
||||
final String imageUrl;
|
||||
final String? printerType;
|
||||
|
||||
ProductRequestModel({
|
||||
this.id,
|
||||
required this.name,
|
||||
required this.price,
|
||||
required this.stock,
|
||||
this.description,
|
||||
required this.categoryId,
|
||||
required this.isBestSeller,
|
||||
this.image,
|
||||
this.sku,
|
||||
this.barcode,
|
||||
required this.price,
|
||||
required this.cost,
|
||||
this.isActive = true,
|
||||
this.hasVariants = false,
|
||||
required this.imageUrl,
|
||||
this.printerType,
|
||||
});
|
||||
|
||||
Map<String, String> toMap() {
|
||||
log("toMap: $isBestSeller");
|
||||
final map = {
|
||||
Map<String, dynamic> toMap() {
|
||||
final map = <String, dynamic>{
|
||||
'name': name,
|
||||
'price': price.toString(),
|
||||
'stock': stock.toString(),
|
||||
'category_id': categoryId.toString(),
|
||||
'is_best_seller': isBestSeller.toString(),
|
||||
'description': description ?? '',
|
||||
'category_id': categoryId,
|
||||
'sku': sku ?? '',
|
||||
'barcode': barcode ?? '',
|
||||
'price': price,
|
||||
'cost': cost,
|
||||
'is_active': isActive,
|
||||
'has_variants': hasVariants,
|
||||
'image_url': imageUrl,
|
||||
'printer_type': printerType ?? '',
|
||||
};
|
||||
|
||||
if (id != null) {
|
||||
map['id'] = id.toString();
|
||||
map['id'] = id;
|
||||
}
|
||||
|
||||
return map;
|
||||
|
||||
Reference in New Issue
Block a user