import { useQuery } from "@apollo/client"; import { Col, Row, Skeleton, Space, Timeline, Typography } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { Link } from "react-router-dom"; import { createStructuredSelector } from "reselect"; import { GET_JOB_LINE_ORDERS } from "../../graphql/jobs.queries"; import { QUERY_JOBLINE_TASKS_PAGINATED } from "../../graphql/tasks.queries.js"; import { selectBodyshop } from "../../redux/user/user.selectors"; import CurrencyFormatter from "../../utils/CurrencyFormatter"; import { DateFormatter } from "../../utils/DateFormatter"; import AlertComponent from "../alert/alert.component"; import BillDetailEditcontainer from "../bill-detail-edit/bill-detail-edit.container.jsx"; import FeatureWrapper from "../feature-wrapper/feature-wrapper.component.jsx"; import TaskListContainer from "../task-list/task-list.container.jsx"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop }); const mapDispatchToProps = (dispatch) => ({}); export default connect(mapStateToProps, mapDispatchToProps)(JobLinesExpander); export function JobLinesExpander({ jobline, jobid, bodyshop }) { const { t } = useTranslation(); const { loading, error, data } = useQuery(GET_JOB_LINE_ORDERS, { fetchPolicy: "network-only", nextFetchPolicy: "network-only", variables: { joblineid: jobline.id } }); if (loading) return ; if (error) return ; return ( {t("parts_orders.labels.parts_orders")} 0 ? data.parts_order_lines.map((line) => ({ key: line.id, children: ( {line.parts_order.order_number} {line.parts_order.order_date} {line.parts_order.vendor.name} {line.backordered_eta ? ( {`${t("parts_orders.fields.backordered_eta")}: `} {line.backordered_eta} ) : null} ) })) : [ { key: "no-orders", children: t("parts_orders.labels.notyetordered") } ] } />{" "} {t("parts_dispatch.labels.parts_dispatch")} 0 ? data.parts_dispatch_lines.map((line) => ({ key: line.id, children: ( {line.parts_dispatch.number} {bodyshop.employees.find((e) => e.id === line.parts_dispatch.employeeid)?.first_name} {line.accepted_at ? ( {t("parts_dispatch_lines.fields.accepted_at")} {line.accepted_at} ) : null} ) })) : [ { key: "dispatch-lines", children: t("parts_dispatch.labels.notyetdispatched") } ] } /> null}> {t("bills.labels.bills")} 0 ? data.billlines.map((line) => ({ key: line.id, children: ( {line.bill.invoice_number} {`${t("billlines.fields.actual_price")}: `} {line.actual_price} {`${t("billlines.fields.actual_cost")}: `} {line.actual_cost} {line.bill.date} {line.bill.vendor.name} ) })) : [ { key: "no-orders", children: t("bills.labels.nobilllines") } ] } /> ); }