import dayjs from 'dayjs'

const BookingTableColumns: any = [
  {
    field: 'booking_no',
    title: 'Booking No.',
    slots: {
      default: 'bookingNo'
    },
    type: 'link'
  },
  {
    field: 'm_bol',
    title: 'MBOL No.'
  },
  {
    field: 'h_bol',
    title: 'HBOL No.'
  },
  {
    field: 'po_no',
    title: 'PO No.'
  },
  {
    field: 'quote_no',
    title: 'Quote No.'
  },
  {
    field: 'carrier_booking',
    title: 'Carrier Booking No.'
  },
  {
    field: 'contract',
    title: 'Contract No.'
  },
  {
    field: 'mode',
    title: 'Transportation Mode',
    type: 'mode',
    slots: {
      default: 'mode'
    }
  },
  {
    field: 'status',
    title: 'Status',
    type: 'status',
    slots: {
      default: 'status'
    }
  },
  {
    field: 'shipper',
    title: 'Shipper'
  },
  {
    field: 'consignee',
    title: 'Consignee'
  },
  {
    field: 'origin',
    title: 'Origin Agent'
  },
  {
    field: 'agent',
    title: 'Destination Agent'
  },
  {
    field: 'sales_rep',
    title: 'Sales'
  },
  {
    field: 'created_time',
    title: 'Creation Time',
    formatter: ({ cellValue }: any) => {
      return cellValue ? dayjs(cellValue).format('MMM-DD-YYYY HH:mm:ss') : '--'
    }
  },
  {
    field: 'confirmation_time',
    title: 'Confirmation Time',
    formatter: ({ cellValue }: any) => {
      return cellValue ? dayjs(cellValue).format('MMM-DD-YYYY HH:mm:ss') : '--'
    }
  },
  {
    field: 'f_etd',
    title: 'ETD',
    formatter: ({ cellValue }: any) => {
      return cellValue ? dayjs(cellValue).format('MMM-DD-YYYY') : '--'
    }
  },
  {
    field: 'f_eta',
    title: 'ETA',
    formatter: ({ cellValue }: any) => {
      return cellValue ? dayjs(cellValue).format('MMM-DD-YYYY') : '--'
    }
  },
  {
    field: 'place_of_receipt_exp',
    title: 'Place of Receipt'
  },
  {
    field: 'fport_of_loading_exp',
    title: 'Port of Loading'
  },
  {
    field: 'place_of_delivery_exp',
    title: 'Place of Delivery'
  },
  {
    field: 'final_desination_exp',
    title: 'Destination'
  },
  {
    field: 'from_station',
    title: 'Origin'
  },
  {
    field: 'f_carrier',
    title: 'Carrier'
  },
  {
    field: 'f_voyage',
    title: 'Voyage'
  },
  {
    field: 'f_vessel',
    title: 'Vessel'
  },
  {
    field: 'week',
    title: 'Week'
  },
  {
    field: 'd20',
    title: 'D20'
  },
  {
    field: 'sd40',
    title: 'D40'
  },
  {
    field: 'd45',
    title: 'D45'
  },
  {
    field: 'rd40',
    title: 'RD'
  },
  {
    field: 'hq40',
    title: 'HQ'
  },
  {
    field: 'created_by',
    title: 'Created by'
  },
  {
    field: 'terms',
    title: 'Other info'
  }
]

const addOtherConfig = () => {
  BookingTableColumns.forEach((item: any) => {
    item.sortable = true
  })
}
addOtherConfig()

const defaultColumns = [
  'Transportation Mode',
  'Status',
  'Booking No.',
  'MBOL No.',
  'HBOL No.',
  'PO No.',
  'Shipper',
  'Consignee',
  'Origin',
  'Destination',
  'Creation Time',
  'ETD',
  'ETA',
  'Week',
  'Vessel',
  'Voyage',
  'Created by',
  'Other info'
]

// 分组
const groupColumns = [
  {
    name: 'All',
    children: [
      {
        label: 'Booking No.',
        field: 'booking_no'
      },
      {
        label: 'MBOL No.',
        field: 'm_bol'
      },
      {
        label: 'HBOL No.',
        field: 'h_bol'
      },
      {
        label: 'PO No.',
        field: 'po_no'
      },
      {
        label: 'Quote No.',
        field: 'quote_no'
      },
      {
        label: 'Carrier Booking No.',
        field: 'carrier_booking'
      },
      {
        label: 'Contract No.',
        field: 'contract'
      },
      {
        label: 'Transportation Mode',
        field: 'mode'
      },
      {
        label: 'Status',
        field: 'status'
      },
      {
        label: 'Shipper',
        field: 'shipper'
      },
      {
        label: 'Consignee',
        field: 'consignee'
      },
      {
        label: 'Origin Agent',
        field: 'origin'
      },
      {
        label: 'Destination Agent',
        field: 'agent'
      },
      {
        label: 'Sales',
        field: 'sales_rep'
      },
      {
        label: 'Creation Time',
        field: 'created_time'
      },
      {
        label: 'Confirmation Time',
        field: 'confirmation_time'
      },
      {
        label: 'ETD',
        field: 'f_etd'
      },
      {
        label: 'ETA',
        field: 'f_eta'
      },
      {
        label: 'Place of Receipt',
        field: 'place_of_receipt_exp'
      },
      {
        label: 'Port of Loading',
        field: 'fport_of_loading_exp'
      },
      {
        label: 'Place of Delivery',
        field: 'place_of_delivery_exp'
      },
      {
        label: 'Destination',
        field: 'final_desination_exp'
      },
      {
        label: 'Origin',
        field: 'from_station'
      },
      {
        label: 'Carrier',
        field: 'f_carrier'
      },
      {
        label: 'Voyage',
        field: 'f_voyage'
      },
      {
        label: 'Vessel',
        field: 'f_vessel'
      },
      {
        label: 'Week',
        field: 'week'
      },
      {
        label: 'D20',
        field: 'd20'
      },
      {
        label: 'D40',
        field: 'sd40'
      },
      {
        label: 'D45',
        field: 'd45'
      },
      {
        label: 'RD',
        field: 'rd40'
      },
      {
        label: 'HQ',
        field: 'hq40'
      },
      {
        label: 'Created by',
        field: 'created_by'
      },
      {
        label: 'Other info',
        field: 'terms'
      }
    ]
  },
  {
    name: 'Reference No.',
    children: [
      {
        label: 'Booking No.',
        field: 'booking_no'
      },
      {
        label: 'MBOL No.',
        field: 'm_bol'
      },
      {
        label: 'HBOL No.',
        field: 'h_bol'
      },
      {
        label: 'PO No.',
        field: 'po_no'
      },
      {
        label: 'Quote No.',
        field: 'quote_no'
      },
      {
        label: 'Carrier Booking No.',
        field: 'carrier_booking'
      },
      {
        label: 'Contract No.',
        field: 'contract'
      }
    ]
  },
  {
    name: 'General',
    children: [
      {
        label: 'Transportation Mode',
        field: 'mode'
      },
      {
        label: 'Status',
        field: 'status'
      }
    ]
  },
  {
    name: 'Parties',
    children: [
      {
        label: 'Shipper',
        field: 'shipper'
      },
      {
        label: 'Consignee',
        field: 'consignee'
      },
      {
        label: 'Origin Agent',
        field: 'origin'
      },
      {
        label: 'Destination Agent',
        field: 'agent'
      },
      {
        label: 'Sales',
        field: 'sales_rep'
      }
    ]
  },
  {
    name: 'Time',
    children: [
      {
        label: 'Creation Time',
        field: 'created_time'
      },
      {
        label: 'Confirmation Time',
        field: 'confirmation_time'
      },
      {
        label: 'ETD',
        field: 'f_etd'
      },
      {
        label: 'ETA',
        field: 'f_eta'
      }
    ]
  },
  {
    name: 'Places',
    children: [
      {
        label: 'Place of Receipt',
        field: 'place_of_receipt_exp'
      },
      {
        label: 'Port of Loading',
        field: 'fport_of_loading_exp'
      },
      {
        label: 'Place of Delivery',
        field: 'place_of_delivery_exp'
      },
      {
        label: 'Destination',
        field: 'final_desination_exp'
      },
      {
        label: 'Origin',
        field: 'from_station'
      }
    ]
  },
  {
    name: 'Transportation',
    children: [
      {
        label: 'Carrier',
        field: 'f_carrier'
      },
      {
        label: 'Voyage',
        field: 'voyage_m_voyage'
      },
      {
        label: 'Vessel',
        field: 'vessel_m_vessel'
      },
      {
        label: 'Week',
        field: 'week'
      },
      {
        label: 'D20',
        field: 'd20'
      },
      {
        label: 'D40',
        field: 'sd40'
      },
      {
        label: 'D45',
        field: 'd45'
      },
      {
        label: 'RD',
        field: 'rd40'
      },
      {
        label: 'HQ',
        field: 'hq40'
      }
    ]
  },
  {
    name: 'Others',
    children: [
      {
        label: 'Created by',
        field: 'created_by'
      },
      {
        label: 'Other info',
        field: 'terms'
      }
    ]
  }
]

export { BookingTableColumns, defaultColumns, groupColumns }
