
import 'package:flutter/material.dart';
import 'package:bookatanker/common/settings.dart';

class BookedTankersModel {
  String tanker_name = '';
  String date_of_order='';
  String supplierName='';
  String supplierId='';
  String date='';
  String time='';
  String time_ui='';
  String type_of_water='';
  String capacity='';
  String address='';
  String price='';
  String payment_status='';
  String order_status='';
  String booking_id='';
  Color textColor=Colors.black;
  BookedTankersModel();

  factory BookedTankersModel.fromJson(Map<String, dynamic> json){
    BookedTankersModel rtvm = new BookedTankersModel();

    rtvm.tanker_name = json['tankerName'] ?? '';
    rtvm.date_of_order = json['dateOfOrder'] ?? '';
    rtvm.time = json['dateOfOrder'] ?? '';
    rtvm.supplierName = json['supplierName'] ?? '';
    rtvm.supplierId = json['supplierId'] ?? '';
    rtvm.date = rtvm.date_of_order.replaceRange(12, rtvm.date_of_order.length, '');
    rtvm.time_ui =rtvm.time.replaceRange(0, 13, '');

    rtvm.type_of_water = json['typeofwater'] ?? '';
    rtvm.booking_id = json['bookingid'] ?? '';
    rtvm.capacity = json['capacity'] ?? '';
    rtvm.address = json['address'] ?? '';
    rtvm.price = json['price'] ?? '';
    rtvm.payment_status = json['payment_status'] ?? '';
    rtvm.order_status = json['orderStatus'] ?? '';

    if(rtvm.order_status.toString().toLowerCase()=='accepted'){
      rtvm.textColor=Colors.green;
    }
    else if(rtvm.order_status.toString().toLowerCase()=='rejected'){
      rtvm.textColor=Colors.red;
    }
    else{
      rtvm.textColor=primaryColor;
    }



    return rtvm;
  }
  Map<String, dynamic> toJson() => {
    "tankerName":this.tanker_name,
    "dateOfOrder":this.date_of_order,
    "typeofwater":this.type_of_water,
    "capacity":this.capacity,
    "address":this.address,
    "price":this.price,
    "payment_status":this.payment_status,
    "orderStatus":this.order_status,
  };
}