import { Col, Row } from "antd";
import React from "react";
import AlertComponent from "../alert/alert.component";
import BillsListTable from "../bills-list-table/bills-list-table.component";
import JobBillsTotal from "../job-bills-total/job-bills-total.component";
import PartsOrderModal from "../parts-order-modal/parts-order-modal.container";
import PartsOrderListTableComponent from "../parts-order-list-table/parts-order-list-table.component";
const tableCol = {
  xs: {
    span: 24,
  },
  md: {
    span: 20,
  },
};

const totalsCol = {
  xs: {
    span: 24,
  },
  md: {
    span: 4,
  },
};

export default function JobsDetailPliComponent({
  job,
  billsQuery,
  handleBillOnRowClick,
  handlePartsOrderOnRowClick,
}) {
  return (
    <div>
      <PartsOrderModal />
      {billsQuery.error ? (
        <AlertComponent message={billsQuery.error.message} type="error" />
      ) : null}
      <Row>
        <Col {...tableCol}>
          <PartsOrderListTableComponent
            job={job}
            handleOnRowClick={handlePartsOrderOnRowClick}
            billsQuery={billsQuery}
          />
          <BillsListTable
            job={job}
            handleOnRowClick={handleBillOnRowClick}
            billsQuery={billsQuery}
          />
        </Col>
        <Col {...totalsCol}>
          <JobBillsTotal
            bills={billsQuery.data ? billsQuery.data.bills : []}
            loading={billsQuery.loading}
            jobTotals={job.job_totals}
          />
        </Col>
      </Row>
    </div>
  );
}
