From 14b91ad622a5da88a515f142f9e37720ab65b326 Mon Sep 17 00:00:00 2001 From: meylis98 Date: Fri, 17 Mar 2023 19:06:47 +0500 Subject: [PATCH] bugs fixed in details --- lib/features/screens/details/details.dart | 41 +- .../screens/drawer/sapaly_drawer.dart | 118 +-- lib/features/services/details_service.dart | 8 +- lib/main.dart | 7 +- lib/models/cart/cart_model.dart | 794 ++++++++++++++++++ 5 files changed, 890 insertions(+), 78 deletions(-) create mode 100644 lib/models/cart/cart_model.dart diff --git a/lib/features/screens/details/details.dart b/lib/features/screens/details/details.dart index c65a777..e2c029b 100644 --- a/lib/features/screens/details/details.dart +++ b/lib/features/screens/details/details.dart @@ -233,9 +233,9 @@ class _DetailsState extends State
{ ), SizedBox(height: 20.adaptedPx()), InkWell( - splashColor: AppTheme.lightPrimaryColor.withOpacity(0.2), + splashColor: AppTheme.lightTextColor.withOpacity(0.2), highlightColor: - AppTheme.lightPrimaryColor.withOpacity(0.1), + AppTheme.lightBackgroundColor.withOpacity(0.1), borderRadius: BorderRadius.circular(15.adaptedPx()), onTap: () { ScaffoldMessenger.of(context).showSnackBar( @@ -257,27 +257,34 @@ class _DetailsState extends State
{ }, child: Container( decoration: BoxDecoration( - border: Border.all( - width: 1.adaptedPx(), - color: AppTheme.lightPrimaryColor, - ), + color: AppTheme.lightPrimaryColor, borderRadius: BorderRadius.circular(15.adaptedPx()), ), padding: EdgeInsets.symmetric( vertical: 15.adaptedPx(), horizontal: 15.adaptedPx(), ), - child: Text( - 'add_to_cart'.translation, - textAlign: TextAlign.center, - style: Theme.of(context) - .primaryTextTheme - .bodyMedium - ?.copyWith( - fontSize: 15.adaptedPx(), - fontWeight: FontWeight.w600, - color: AppTheme.lightPrimaryColor, - ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset( + 'assets/icons/drawerIcons/shops.svg', + color: AppTheme.whiteColor, + ), + SizedBox(width: 10.adaptedPx()), + Text( + 'add_to_cart'.translation, + textAlign: TextAlign.center, + style: Theme.of(context) + .primaryTextTheme + .bodyMedium + ?.copyWith( + fontSize: 17.adaptedPx(), + fontWeight: FontWeight.w600, + color: AppTheme.whiteColor, + ), + ), + ], ), ), ), diff --git a/lib/features/screens/drawer/sapaly_drawer.dart b/lib/features/screens/drawer/sapaly_drawer.dart index d8a367e..acfbeda 100644 --- a/lib/features/screens/drawer/sapaly_drawer.dart +++ b/lib/features/screens/drawer/sapaly_drawer.dart @@ -124,37 +124,39 @@ class _SapalyDrawerState extends State { ], ), ), - GestureDetector( - onTap: () { - PageNavigator(ctx: context) - .nextPage(page: const SettingsScreen()); - }, - child: Row( - children: [ - Icon( - Icons.account_circle, - size: 45.adaptedPx(), - color: AppTheme.lightPrimaryColor, - ), - SizedBox(width: 5.adaptedPx()), - Expanded( - child: Text( - user.email, - softWrap: true, - maxLines: 4, - style: Theme.of(context) - .primaryTextTheme - .bodyMedium - ?.copyWith( - fontWeight: FontWeight.w600, - color: AppTheme.blackColor, - fontSize: 13.adaptedPx(), + user.email == '' + ? Container() + : GestureDetector( + onTap: () { + PageNavigator(ctx: context) + .nextPage(page: const SettingsScreen()); + }, + child: Row( + children: [ + Icon( + Icons.account_circle, + size: 45.adaptedPx(), + color: AppTheme.lightPrimaryColor, + ), + SizedBox(width: 5.adaptedPx()), + Expanded( + child: Text( + user.email, + softWrap: true, + maxLines: 4, + style: Theme.of(context) + .primaryTextTheme + .bodyMedium + ?.copyWith( + fontWeight: FontWeight.w600, + color: AppTheme.blackColor, + fontSize: 13.adaptedPx(), + ), ), + ) + ], ), - ) - ], - ), - ), + ), Padding( padding: EdgeInsets.symmetric(vertical: 10.adaptedPx()), child: GestureDetector( @@ -167,38 +169,42 @@ class _SapalyDrawerState extends State { .pushNamedAndRemoveUntil('/home', (route) => false); } }, - child: Row( - children: [ - IconButton( - onPressed: () async { - var lang = await languagePicker( - context, settings.currentLanguage); + child: TextButton( + onPressed: () async { + var lang = await languagePicker( + context, settings.currentLanguage); - if (lang != null) { - await settings.setLanguage(lang); - Navigator.of(context, rootNavigator: true) - .pushNamedAndRemoveUntil( - '/home', (route) => false); - } - }, - icon: SvgPicture.asset( + if (lang != null) { + await settings.setLanguage(lang); + Navigator.of(context, rootNavigator: true) + .pushNamedAndRemoveUntil('/home', (route) => false); + } + }, + child: Row( + children: [ + SvgPicture.asset( 'assets/icons/lang.svg', width: 25.adaptedPx(), height: 25.adaptedPx(), ), - ), - Text( - 'currentLang'.translation, - style: Theme.of(context) - .primaryTextTheme - .bodyMedium - ?.copyWith( - color: AppTheme.blackColor, - fontWeight: FontWeight.w600, - fontSize: 15.adaptedPx(), - ), - ), - ], + SizedBox(width: 10.adaptedPx()), + Text( + // 'currentLang'.translation, + settings.currentLanguage == 'tk' + ? 'TM' + : settings.currentLanguage.toUpperCase(), + textAlign: TextAlign.right, + style: Theme.of(context) + .primaryTextTheme + .bodyMedium + ?.copyWith( + color: AppTheme.blackColor, + fontWeight: FontWeight.w600, + fontSize: 15.adaptedPx(), + ), + ), + ], + ), ), ), ), diff --git a/lib/features/services/details_service.dart b/lib/features/services/details_service.dart index af14513..1328d20 100644 --- a/lib/features/services/details_service.dart +++ b/lib/features/services/details_service.dart @@ -20,15 +20,17 @@ class DetailsService { try { http.Response response = await http.post( - Uri.parse('${GlobalVariables.kBaseUrl}/api/v1/cart'), + Uri.parse('${GlobalVariables.kBaseUrl}/api/v1/add/cart'), headers: { 'Content-Type': 'application/json', - 'jwt': userProvider.token, + 'Authorization': 'Bearer ${userProvider.token}', }, body: jsonEncode({ - 'id': product.id, + 'offer_id': product.id, + 'quantity': product.offer.first.id, }), ); + debugPrint(response.body); httpErrorHandle( response: response, context: context, diff --git a/lib/main.dart b/lib/main.dart index 60a2495..73e3741 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -23,7 +23,7 @@ Future main() async { WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); SharedPreferences prefs = await SharedPreferences.getInstance(); FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding); - Future.delayed(const Duration(seconds: 4)); + Future.delayed(const Duration(seconds: 3)); await SettingsModel.initLocalization( prefs.getString('language') ?? kDefaultLanguage); @@ -54,7 +54,10 @@ class _MyAppState extends State { String token = prefs.getString('token') ?? ''; String email = prefs.getString('email') ?? ''; String phone = prefs.getString('phone') ?? ''; - userProvider.setUser(email: email, phone: phone, token: token); + // userProvider.setUser(email: email, phone: phone, token: token); + context + .read() + .setUser(email: email, token: token, phone: phone); } @override diff --git a/lib/models/cart/cart_model.dart b/lib/models/cart/cart_model.dart new file mode 100644 index 0000000..9a78cdd --- /dev/null +++ b/lib/models/cart/cart_model.dart @@ -0,0 +1,794 @@ +// To parse this JSON data, do +// +// final cartModel = cartModelFromJson(jsonString); + +import 'package:meta/meta.dart'; +import 'dart:convert'; + +CartModel cartModelFromJson(String str) => CartModel.fromJson(json.decode(str)); + +String cartModelToJson(CartModel data) => json.encode(data.toJson()); + +class CartModel { + CartModel({ + required this.id, + required this.position, + required this.shippingPrice, + required this.positionTotalPrice, + required this.totalPrice, + required this.quantity, + required this.totalQuantity, + required this.weight, + required this.paymentMethodId, + required this.shippingTypeId, + required this.userData, + required this.shippingAddress, + required this.billingAddress, + required this.property, + }); + + final int id; + final Position position; + final ShippingPrice shippingPrice; + final TotalPrice positionTotalPrice; + final TotalPrice totalPrice; + final int quantity; + final int totalQuantity; + final int weight; + final dynamic paymentMethodId; + final dynamic shippingTypeId; + final dynamic userData; + final dynamic shippingAddress; + final dynamic billingAddress; + final dynamic property; + + factory CartModel.fromJson(Map json) => CartModel( + id: json["id"], + position: Position.fromJson(json["position"]), + shippingPrice: ShippingPrice.fromJson(json["shipping_price"]), + positionTotalPrice: TotalPrice.fromJson(json["position_total_price"]), + totalPrice: TotalPrice.fromJson(json["total_price"]), + quantity: json["quantity"], + totalQuantity: json["total_quantity"], + weight: json["weight"], + paymentMethodId: json["payment_method_id"], + shippingTypeId: json["shipping_type_id"], + userData: json["user_data"], + shippingAddress: json["shipping_address"], + billingAddress: json["billing_address"], + property: json["property"], + ); + + Map toJson() => { + "id": id, + "position": position.toJson(), + "shipping_price": shippingPrice.toJson(), + "position_total_price": positionTotalPrice.toJson(), + "total_price": totalPrice.toJson(), + "quantity": quantity, + "total_quantity": totalQuantity, + "weight": weight, + "payment_method_id": paymentMethodId, + "shipping_type_id": shippingTypeId, + "user_data": userData, + "shipping_address": shippingAddress, + "billing_address": billingAddress, + "property": property, + }; +} + +class Position { + Position({ + required this.the84, + }); + + final ShippingPrice the84; + + factory Position.fromJson(Map json) => Position( + the84: ShippingPrice.fromJson(json["84"]), + ); + + Map toJson() => { + "84": the84.toJson(), + }; +} + +class ShippingPrice { + ShippingPrice({ + required this.price, + required this.priceValue, + required this.taxPrice, + required this.taxPriceValue, + required this.priceWithoutTax, + required this.priceWithoutTaxValue, + required this.priceWithTax, + required this.priceWithTaxValue, + required this.oldPrice, + required this.oldPriceValue, + required this.taxOldPrice, + required this.taxOldPriceValue, + required this.oldPriceWithoutTax, + required this.oldPriceWithoutTaxValue, + required this.oldPriceWithTax, + required this.oldPriceWithTaxValue, + required this.discountPrice, + required this.discountPriceValue, + required this.taxDiscountPrice, + required this.taxDiscountPriceValue, + required this.discountPriceWithoutTax, + required this.discountPriceWithoutTaxValue, + required this.discountPriceWithTax, + required this.discountPriceWithTaxValue, + required this.increasePrice, + required this.increasePriceValue, + required this.taxIncreasePrice, + required this.taxIncreasePriceValue, + required this.increasePriceWithoutTax, + required this.increasePriceWithoutTaxValue, + required this.increasePriceWithTax, + required this.increasePriceWithTaxValue, + required this.pricePerUnit, + required this.pricePerUnitValue, + required this.taxPricePerUnit, + required this.taxPricePerUnitValue, + required this.pricePerUnitWithoutTax, + required this.pricePerUnitWithoutTaxValue, + required this.pricePerUnitWithTax, + required this.pricePerUnitWithTaxValue, + required this.oldPricePerUnit, + required this.oldPricePerUnitValue, + required this.taxOldPricePerUnit, + required this.taxOldPricePerUnitValue, + required this.oldPricePerUnitWithoutTax, + required this.oldPricePerUnitWithoutTaxValue, + required this.oldPricePerUnitWithTax, + required this.oldPricePerUnitWithTaxValue, + required this.discountPricePerUnit, + required this.discountPricePerUnitValue, + required this.taxDiscountPricePerUnit, + required this.taxDiscountPricePerUnitValue, + required this.discountPricePerUnitWithoutTax, + required this.discountPricePerUnitWithoutTaxValue, + required this.discountPricePerUnitWithTax, + required this.discountPricePerUnitWithTaxValue, + required this.increasePricePerUnit, + required this.increasePricePerUnitValue, + required this.taxIncreasePricePerUnit, + required this.taxIncreasePricePerUnitValue, + required this.increasePricePerUnitWithoutTax, + required this.increasePricePerUnitWithoutTaxValue, + required this.increasePricePerUnitWithTax, + required this.increasePricePerUnitWithTaxValue, + required this.log, + required this.id, + required this.itemId, + required this.product, + required this.itemType, + required this.quantity, + required this.maxQuantity, + required this.weight, + required this.property, + }); + + final String price; + final int priceValue; + final String taxPrice; + final int taxPriceValue; + final String priceWithoutTax; + final int priceWithoutTaxValue; + final String priceWithTax; + final int priceWithTaxValue; + final String oldPrice; + final int oldPriceValue; + final String taxOldPrice; + final int taxOldPriceValue; + final String oldPriceWithoutTax; + final int oldPriceWithoutTaxValue; + final String oldPriceWithTax; + final int oldPriceWithTaxValue; + final String discountPrice; + final int discountPriceValue; + final String taxDiscountPrice; + final int taxDiscountPriceValue; + final String discountPriceWithoutTax; + final int discountPriceWithoutTaxValue; + final String discountPriceWithTax; + final int discountPriceWithTaxValue; + final String increasePrice; + final int increasePriceValue; + final String taxIncreasePrice; + final int taxIncreasePriceValue; + final String increasePriceWithoutTax; + final int increasePriceWithoutTaxValue; + final String increasePriceWithTax; + final int increasePriceWithTaxValue; + final String pricePerUnit; + final int pricePerUnitValue; + final String taxPricePerUnit; + final int taxPricePerUnitValue; + final String pricePerUnitWithoutTax; + final int pricePerUnitWithoutTaxValue; + final String pricePerUnitWithTax; + final int pricePerUnitWithTaxValue; + final String oldPricePerUnit; + final int oldPricePerUnitValue; + final String taxOldPricePerUnit; + final int taxOldPricePerUnitValue; + final String oldPricePerUnitWithoutTax; + final int oldPricePerUnitWithoutTaxValue; + final String oldPricePerUnitWithTax; + final int oldPricePerUnitWithTaxValue; + final String discountPricePerUnit; + final int discountPricePerUnitValue; + final String taxDiscountPricePerUnit; + final int taxDiscountPricePerUnitValue; + final String discountPricePerUnitWithoutTax; + final int discountPricePerUnitWithoutTaxValue; + final String discountPricePerUnitWithTax; + final int discountPricePerUnitWithTaxValue; + final String increasePricePerUnit; + final int increasePricePerUnitValue; + final String taxIncreasePricePerUnit; + final int taxIncreasePricePerUnitValue; + final String increasePricePerUnitWithoutTax; + final int increasePricePerUnitWithoutTaxValue; + final String increasePricePerUnitWithTax; + final int increasePricePerUnitWithTaxValue; + final List log; + final int id; + final int itemId; + final ShippingPriceProduct product; + final String itemType; + final int quantity; + final int maxQuantity; + final int weight; + final String property; + + factory ShippingPrice.fromJson(Map json) => ShippingPrice( + price: json["price"], + priceValue: json["price_value"], + taxPrice: json["tax_price"], + taxPriceValue: json["tax_price_value"], + priceWithoutTax: json["price_without_tax"], + priceWithoutTaxValue: json["price_without_tax_value"], + priceWithTax: json["price_with_tax"], + priceWithTaxValue: json["price_with_tax_value"], + oldPrice: json["old_price"], + oldPriceValue: json["old_price_value"], + taxOldPrice: json["tax_old_price"], + taxOldPriceValue: json["tax_old_price_value"], + oldPriceWithoutTax: json["old_price_without_tax"], + oldPriceWithoutTaxValue: json["old_price_without_tax_value"], + oldPriceWithTax: json["old_price_with_tax"], + oldPriceWithTaxValue: json["old_price_with_tax_value"], + discountPrice: json["discount_price"], + discountPriceValue: json["discount_price_value"], + taxDiscountPrice: json["tax_discount_price"], + taxDiscountPriceValue: json["tax_discount_price_value"], + discountPriceWithoutTax: json["discount_price_without_tax"], + discountPriceWithoutTaxValue: json["discount_price_without_tax_value"], + discountPriceWithTax: json["discount_price_with_tax"], + discountPriceWithTaxValue: json["discount_price_with_tax_value"], + increasePrice: json["increase_price"], + increasePriceValue: json["increase_price_value"], + taxIncreasePrice: json["tax_increase_price"], + taxIncreasePriceValue: json["tax_increase_price_value"], + increasePriceWithoutTax: json["increase_price_without_tax"], + increasePriceWithoutTaxValue: json["increase_price_without_tax_value"], + increasePriceWithTax: json["increase_price_with_tax"], + increasePriceWithTaxValue: json["increase_price_with_tax_value"], + pricePerUnit: json["price_per_unit"], + pricePerUnitValue: json["price_per_unit_value"], + taxPricePerUnit: json["tax_price_per_unit"], + taxPricePerUnitValue: json["tax_price_per_unit_value"], + pricePerUnitWithoutTax: json["price_per_unit_without_tax"], + pricePerUnitWithoutTaxValue: json["price_per_unit_without_tax_value"], + pricePerUnitWithTax: json["price_per_unit_with_tax"], + pricePerUnitWithTaxValue: json["price_per_unit_with_tax_value"], + oldPricePerUnit: json["old_price_per_unit"], + oldPricePerUnitValue: json["old_price_per_unit_value"], + taxOldPricePerUnit: json["tax_old_price_per_unit"], + taxOldPricePerUnitValue: json["tax_old_price_per_unit_value"], + oldPricePerUnitWithoutTax: json["old_price_per_unit_without_tax"], + oldPricePerUnitWithoutTaxValue: + json["old_price_per_unit_without_tax_value"], + oldPricePerUnitWithTax: json["old_price_per_unit_with_tax"], + oldPricePerUnitWithTaxValue: json["old_price_per_unit_with_tax_value"], + discountPricePerUnit: json["discount_price_per_unit"], + discountPricePerUnitValue: json["discount_price_per_unit_value"], + taxDiscountPricePerUnit: json["tax_discount_price_per_unit"], + taxDiscountPricePerUnitValue: json["tax_discount_price_per_unit_value"], + discountPricePerUnitWithoutTax: + json["discount_price_per_unit_without_tax"], + discountPricePerUnitWithoutTaxValue: + json["discount_price_per_unit_without_tax_value"], + discountPricePerUnitWithTax: json["discount_price_per_unit_with_tax"], + discountPricePerUnitWithTaxValue: + json["discount_price_per_unit_with_tax_value"], + increasePricePerUnit: json["increase_price_per_unit"], + increasePricePerUnitValue: json["increase_price_per_unit_value"], + taxIncreasePricePerUnit: json["tax_increase_price_per_unit"], + taxIncreasePricePerUnitValue: json["tax_increase_price_per_unit_value"], + increasePricePerUnitWithoutTax: + json["increase_price_per_unit_without_tax"], + increasePricePerUnitWithoutTaxValue: + json["increase_price_per_unit_without_tax_value"], + increasePricePerUnitWithTax: json["increase_price_per_unit_with_tax"], + increasePricePerUnitWithTaxValue: + json["increase_price_per_unit_with_tax_value"], + log: List.from(json["log"].map((x) => x)), + id: json["id"], + itemId: json["item_id"], + product: ShippingPriceProduct.fromJson(json["product"]), + itemType: json["item_type"], + quantity: json["quantity"], + maxQuantity: json["max_quantity"], + weight: json["weight"], + property: json["property"], + ); + + Map toJson() => { + "price": price, + "price_value": priceValue, + "tax_price": taxPrice, + "tax_price_value": taxPriceValue, + "price_without_tax": priceWithoutTax, + "price_without_tax_value": priceWithoutTaxValue, + "price_with_tax": priceWithTax, + "price_with_tax_value": priceWithTaxValue, + "old_price": oldPrice, + "old_price_value": oldPriceValue, + "tax_old_price": taxOldPrice, + "tax_old_price_value": taxOldPriceValue, + "old_price_without_tax": oldPriceWithoutTax, + "old_price_without_tax_value": oldPriceWithoutTaxValue, + "old_price_with_tax": oldPriceWithTax, + "old_price_with_tax_value": oldPriceWithTaxValue, + "discount_price": discountPrice, + "discount_price_value": discountPriceValue, + "tax_discount_price": taxDiscountPrice, + "tax_discount_price_value": taxDiscountPriceValue, + "discount_price_without_tax": discountPriceWithoutTax, + "discount_price_without_tax_value": discountPriceWithoutTaxValue, + "discount_price_with_tax": discountPriceWithTax, + "discount_price_with_tax_value": discountPriceWithTaxValue, + "increase_price": increasePrice, + "increase_price_value": increasePriceValue, + "tax_increase_price": taxIncreasePrice, + "tax_increase_price_value": taxIncreasePriceValue, + "increase_price_without_tax": increasePriceWithoutTax, + "increase_price_without_tax_value": increasePriceWithoutTaxValue, + "increase_price_with_tax": increasePriceWithTax, + "increase_price_with_tax_value": increasePriceWithTaxValue, + "price_per_unit": pricePerUnit, + "price_per_unit_value": pricePerUnitValue, + "tax_price_per_unit": taxPricePerUnit, + "tax_price_per_unit_value": taxPricePerUnitValue, + "price_per_unit_without_tax": pricePerUnitWithoutTax, + "price_per_unit_without_tax_value": pricePerUnitWithoutTaxValue, + "price_per_unit_with_tax": pricePerUnitWithTax, + "price_per_unit_with_tax_value": pricePerUnitWithTaxValue, + "old_price_per_unit": oldPricePerUnit, + "old_price_per_unit_value": oldPricePerUnitValue, + "tax_old_price_per_unit": taxOldPricePerUnit, + "tax_old_price_per_unit_value": taxOldPricePerUnitValue, + "old_price_per_unit_without_tax": oldPricePerUnitWithoutTax, + "old_price_per_unit_without_tax_value": oldPricePerUnitWithoutTaxValue, + "old_price_per_unit_with_tax": oldPricePerUnitWithTax, + "old_price_per_unit_with_tax_value": oldPricePerUnitWithTaxValue, + "discount_price_per_unit": discountPricePerUnit, + "discount_price_per_unit_value": discountPricePerUnitValue, + "tax_discount_price_per_unit": taxDiscountPricePerUnit, + "tax_discount_price_per_unit_value": taxDiscountPricePerUnitValue, + "discount_price_per_unit_without_tax": discountPricePerUnitWithoutTax, + "discount_price_per_unit_without_tax_value": + discountPricePerUnitWithoutTaxValue, + "discount_price_per_unit_with_tax": discountPricePerUnitWithTax, + "discount_price_per_unit_with_tax_value": + discountPricePerUnitWithTaxValue, + "increase_price_per_unit": increasePricePerUnit, + "increase_price_per_unit_value": increasePricePerUnitValue, + "tax_increase_price_per_unit": taxIncreasePricePerUnit, + "tax_increase_price_per_unit_value": taxIncreasePricePerUnitValue, + "increase_price_per_unit_without_tax": increasePricePerUnitWithoutTax, + "increase_price_per_unit_without_tax_value": + increasePricePerUnitWithoutTaxValue, + "increase_price_per_unit_with_tax": increasePricePerUnitWithTax, + "increase_price_per_unit_with_tax_value": + increasePricePerUnitWithTaxValue, + "log": List.from(log.map((x) => x)), + "id": id, + "item_id": itemId, + "product": product.toJson(), + "item_type": itemType, + "quantity": quantity, + "max_quantity": maxQuantity, + "weight": weight, + "property": property, + }; +} + +class ShippingPriceProduct { + ShippingPriceProduct({ + required this.id, + required this.active, + required this.productId, + required this.name, + required this.code, + required this.externalId, + required this.quantity, + required this.measureId, + required this.weight, + required this.height, + required this.length, + required this.width, + required this.measureOfUnitId, + required this.quantityInUnit, + required this.previewText, + required this.description, + required this.deletedAt, + required this.createdAt, + required this.updatedAt, + required this.price, + required this.priceValue, + required this.oldPrice, + required this.oldPriceValue, + required this.discountPrice, + required this.discountPriceValue, + required this.priceList, + required this.product, + required this.mainPrice, + required this.priceLink, + }); + + final int id; + final int active; + final int productId; + final String name; + final String code; + final String externalId; + final int quantity; + final dynamic measureId; + final dynamic weight; + final dynamic height; + final dynamic length; + final dynamic width; + final dynamic measureOfUnitId; + final int quantityInUnit; + final String previewText; + final String description; + final dynamic deletedAt; + final DateTime createdAt; + final DateTime updatedAt; + final String price; + final String priceValue; + final String oldPrice; + final String oldPriceValue; + final String discountPrice; + final int discountPriceValue; + final List priceList; + final ProductProduct product; + final MainPrice mainPrice; + final List priceLink; + + factory ShippingPriceProduct.fromJson(Map json) => + ShippingPriceProduct( + id: json["id"], + active: json["active"], + productId: json["product_id"], + name: json["name"], + code: json["code"], + externalId: json["external_id"], + quantity: json["quantity"], + measureId: json["measure_id"], + weight: json["weight"], + height: json["height"], + length: json["length"], + width: json["width"], + measureOfUnitId: json["measure_of_unit_id"], + quantityInUnit: json["quantity_in_unit"], + previewText: json["preview_text"], + description: json["description"], + deletedAt: json["deleted_at"], + createdAt: DateTime.parse(json["created_at"]), + updatedAt: DateTime.parse(json["updated_at"]), + price: json["price"], + priceValue: json["price_value"], + oldPrice: json["old_price"], + oldPriceValue: json["old_price_value"], + discountPrice: json["discount_price"], + discountPriceValue: json["discount_price_value"], + priceList: List.from(json["price_list"].map((x) => x)), + product: ProductProduct.fromJson(json["product"]), + mainPrice: MainPrice.fromJson(json["main_price"]), + priceLink: List.from(json["price_link"].map((x) => x)), + ); + + Map toJson() => { + "id": id, + "active": active, + "product_id": productId, + "name": name, + "code": code, + "external_id": externalId, + "quantity": quantity, + "measure_id": measureId, + "weight": weight, + "height": height, + "length": length, + "width": width, + "measure_of_unit_id": measureOfUnitId, + "quantity_in_unit": quantityInUnit, + "preview_text": previewText, + "description": description, + "deleted_at": deletedAt, + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt.toIso8601String(), + "price": price, + "price_value": priceValue, + "old_price": oldPrice, + "old_price_value": oldPriceValue, + "discount_price": discountPrice, + "discount_price_value": discountPriceValue, + "price_list": List.from(priceList.map((x) => x)), + "product": product.toJson(), + "main_price": mainPrice.toJson(), + "price_link": List.from(priceLink.map((x) => x)), + }; +} + +class MainPrice { + MainPrice({ + required this.id, + required this.itemId, + required this.itemType, + required this.price, + required this.oldPrice, + required this.priceTypeId, + required this.createdAt, + required this.updatedAt, + }); + + final int id; + final int itemId; + final String itemType; + final String price; + final String oldPrice; + final dynamic priceTypeId; + final DateTime createdAt; + final DateTime updatedAt; + + factory MainPrice.fromJson(Map json) => MainPrice( + id: json["id"], + itemId: json["item_id"], + itemType: json["item_type"], + price: json["price"], + oldPrice: json["old_price"], + priceTypeId: json["price_type_id"], + createdAt: DateTime.parse(json["created_at"]), + updatedAt: DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "item_id": itemId, + "item_type": itemType, + "price": price, + "old_price": oldPrice, + "price_type_id": priceTypeId, + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt.toIso8601String(), + }; +} + +class ProductProduct { + ProductProduct({ + required this.id, + required this.active, + required this.name, + required this.slug, + required this.brandId, + required this.categoryId, + required this.externalId, + required this.code, + required this.previewText, + required this.description, + required this.deletedAt, + required this.createdAt, + required this.updatedAt, + required this.featured, + }); + + final int id; + final int active; + final String name; + final String slug; + final dynamic brandId; + final int categoryId; + final String externalId; + final String code; + final dynamic previewText; + final dynamic description; + final dynamic deletedAt; + final DateTime createdAt; + final DateTime updatedAt; + final String featured; + + factory ProductProduct.fromJson(Map json) => ProductProduct( + id: json["id"], + active: json["active"], + name: json["name"], + slug: json["slug"], + brandId: json["brand_id"], + categoryId: json["category_id"], + externalId: json["external_id"], + code: json["code"], + previewText: json["preview_text"], + description: json["description"], + deletedAt: json["deleted_at"], + createdAt: DateTime.parse(json["created_at"]), + updatedAt: DateTime.parse(json["updated_at"]), + featured: json["featured"], + ); + + Map toJson() => { + "id": id, + "active": active, + "name": name, + "slug": slug, + "brand_id": brandId, + "category_id": categoryId, + "external_id": externalId, + "code": code, + "preview_text": previewText, + "description": description, + "deleted_at": deletedAt, + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt.toIso8601String(), + "featured": featured, + }; +} + +class TotalPrice { + TotalPrice({ + required this.price, + required this.priceValue, + required this.taxPrice, + required this.taxPriceValue, + required this.priceWithoutTax, + required this.priceWithoutTaxValue, + required this.priceWithTax, + required this.priceWithTaxValue, + required this.oldPrice, + required this.oldPriceValue, + required this.taxOldPrice, + required this.taxOldPriceValue, + required this.oldPriceWithoutTax, + required this.oldPriceWithoutTaxValue, + required this.oldPriceWithTax, + required this.oldPriceWithTaxValue, + required this.discountPrice, + required this.discountPriceValue, + required this.taxDiscountPrice, + required this.taxDiscountPriceValue, + required this.discountPriceWithoutTax, + required this.discountPriceWithoutTaxValue, + required this.discountPriceWithTax, + required this.discountPriceWithTaxValue, + required this.increasePrice, + required this.increasePriceValue, + required this.taxIncreasePrice, + required this.taxIncreasePriceValue, + required this.increasePriceWithoutTax, + required this.increasePriceWithoutTaxValue, + required this.increasePriceWithTax, + required this.increasePriceWithTaxValue, + required this.log, + }); + + final String price; + final int priceValue; + final String taxPrice; + final int taxPriceValue; + final String priceWithoutTax; + final int priceWithoutTaxValue; + final String priceWithTax; + final int priceWithTaxValue; + final String oldPrice; + final int oldPriceValue; + final String taxOldPrice; + final int taxOldPriceValue; + final String oldPriceWithoutTax; + final int oldPriceWithoutTaxValue; + final String oldPriceWithTax; + final int oldPriceWithTaxValue; + final String discountPrice; + final int discountPriceValue; + final String taxDiscountPrice; + final int taxDiscountPriceValue; + final String discountPriceWithoutTax; + final int discountPriceWithoutTaxValue; + final String discountPriceWithTax; + final int discountPriceWithTaxValue; + final String increasePrice; + final int increasePriceValue; + final String taxIncreasePrice; + final int taxIncreasePriceValue; + final String increasePriceWithoutTax; + final int increasePriceWithoutTaxValue; + final String increasePriceWithTax; + final int increasePriceWithTaxValue; + final List log; + + factory TotalPrice.fromJson(Map json) => TotalPrice( + price: json["price"], + priceValue: json["price_value"], + taxPrice: json["tax_price"], + taxPriceValue: json["tax_price_value"], + priceWithoutTax: json["price_without_tax"], + priceWithoutTaxValue: json["price_without_tax_value"], + priceWithTax: json["price_with_tax"], + priceWithTaxValue: json["price_with_tax_value"], + oldPrice: json["old_price"], + oldPriceValue: json["old_price_value"], + taxOldPrice: json["tax_old_price"], + taxOldPriceValue: json["tax_old_price_value"], + oldPriceWithoutTax: json["old_price_without_tax"], + oldPriceWithoutTaxValue: json["old_price_without_tax_value"], + oldPriceWithTax: json["old_price_with_tax"], + oldPriceWithTaxValue: json["old_price_with_tax_value"], + discountPrice: json["discount_price"], + discountPriceValue: json["discount_price_value"], + taxDiscountPrice: json["tax_discount_price"], + taxDiscountPriceValue: json["tax_discount_price_value"], + discountPriceWithoutTax: json["discount_price_without_tax"], + discountPriceWithoutTaxValue: json["discount_price_without_tax_value"], + discountPriceWithTax: json["discount_price_with_tax"], + discountPriceWithTaxValue: json["discount_price_with_tax_value"], + increasePrice: json["increase_price"], + increasePriceValue: json["increase_price_value"], + taxIncreasePrice: json["tax_increase_price"], + taxIncreasePriceValue: json["tax_increase_price_value"], + increasePriceWithoutTax: json["increase_price_without_tax"], + increasePriceWithoutTaxValue: json["increase_price_without_tax_value"], + increasePriceWithTax: json["increase_price_with_tax"], + increasePriceWithTaxValue: json["increase_price_with_tax_value"], + log: List.from(json["log"].map((x) => x)), + ); + + Map toJson() => { + "price": price, + "price_value": priceValue, + "tax_price": taxPrice, + "tax_price_value": taxPriceValue, + "price_without_tax": priceWithoutTax, + "price_without_tax_value": priceWithoutTaxValue, + "price_with_tax": priceWithTax, + "price_with_tax_value": priceWithTaxValue, + "old_price": oldPrice, + "old_price_value": oldPriceValue, + "tax_old_price": taxOldPrice, + "tax_old_price_value": taxOldPriceValue, + "old_price_without_tax": oldPriceWithoutTax, + "old_price_without_tax_value": oldPriceWithoutTaxValue, + "old_price_with_tax": oldPriceWithTax, + "old_price_with_tax_value": oldPriceWithTaxValue, + "discount_price": discountPrice, + "discount_price_value": discountPriceValue, + "tax_discount_price": taxDiscountPrice, + "tax_discount_price_value": taxDiscountPriceValue, + "discount_price_without_tax": discountPriceWithoutTax, + "discount_price_without_tax_value": discountPriceWithoutTaxValue, + "discount_price_with_tax": discountPriceWithTax, + "discount_price_with_tax_value": discountPriceWithTaxValue, + "increase_price": increasePrice, + "increase_price_value": increasePriceValue, + "tax_increase_price": taxIncreasePrice, + "tax_increase_price_value": taxIncreasePriceValue, + "increase_price_without_tax": increasePriceWithoutTax, + "increase_price_without_tax_value": increasePriceWithoutTaxValue, + "increase_price_with_tax": increasePriceWithTax, + "increase_price_with_tax_value": increasePriceWithTaxValue, + "log": List.from(log.map((x) => x)), + }; +}