Added est line status + expandable row for previous orders on jobs lines detail
This commit is contained in:
@@ -3,6 +3,7 @@ import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
import { Link } from "react-router-dom";
|
||||
//import EditableCell from "./job-lines-cell.component";
|
||||
import AllocationsAssignmentContainer from "../allocations-assignment/allocations-assignment.container";
|
||||
import PartsOrderModalContainer from "../parts-order-modal/parts-order-modal.container";
|
||||
@@ -111,6 +112,14 @@ export default function JobLinesComponent({
|
||||
sortOrder:
|
||||
state.sortedInfo.columnKey === "mod_lb_hrs" && state.sortedInfo.order
|
||||
},
|
||||
{
|
||||
title: t("joblines.fields.status"),
|
||||
dataIndex: "status",
|
||||
key: "status",
|
||||
sorter: (a, b) => alphaSort(a.status, b.status),
|
||||
sortOrder:
|
||||
state.sortedInfo.columnKey === "status" && state.sortedInfo.order
|
||||
},
|
||||
{
|
||||
title: t("allocations.fields.employee"),
|
||||
dataIndex: "employee",
|
||||
@@ -170,6 +179,7 @@ export default function JobLinesComponent({
|
||||
<PartsOrderModalContainer
|
||||
partsOrderModalVisible={partsOrderModalVisible}
|
||||
linesToOrder={selectedLines}
|
||||
refetch={refetch}
|
||||
jobId={jobId}
|
||||
/>
|
||||
) : null}
|
||||
@@ -200,6 +210,20 @@ export default function JobLinesComponent({
|
||||
{...formItemLayout}
|
||||
loading={loading}
|
||||
size='small'
|
||||
expandedRowRender={record => (
|
||||
<div style={{ margin: 0 }}>
|
||||
<strong>{t("parts_orders.labels.orderhistory")}</strong>
|
||||
{record.parts_order_lines.map(item => (
|
||||
<div key={item.id}>
|
||||
{`${item.parts_order.order_number || ""} from `}
|
||||
<Link to={`/manage/shop/vendors/${item.parts_order.vendor.id}`}>
|
||||
{item.parts_order.vendor.name || ""}
|
||||
</Link>
|
||||
{` on ${item.parts_order.order_date || ""}`}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
pagination={{ position: "top", defaultPageSize: 25 }}
|
||||
rowSelection={{
|
||||
// selectedRowKeys: selectedLines,
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { INSERT_NEW_PARTS_ORDERS } from "../../graphql/parts-orders.queries";
|
||||
import { UPDATE_JOB_LINE_STATUS } from "../../graphql/jobs-lines.queries";
|
||||
import { QUERY_ALL_VENDORS_FOR_ORDER } from "../../graphql/vendors.queries";
|
||||
import {
|
||||
selectBodyshop,
|
||||
@@ -26,7 +27,8 @@ export default connect(
|
||||
linesToOrder,
|
||||
jobId,
|
||||
currentUser,
|
||||
bodyshop
|
||||
bodyshop,
|
||||
refetch
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [modalVisible, setModalVisible] = partsOrderModalVisible;
|
||||
@@ -40,7 +42,7 @@ export default connect(
|
||||
db_price: value.db_price,
|
||||
act_price: value.act_price,
|
||||
line_remarks: "Alalala",
|
||||
joblineid: value.joblineid,
|
||||
job_line_id: value.id,
|
||||
status: bodyshop.md_order_statuses.default_ordered || "Ordered*"
|
||||
});
|
||||
return acc;
|
||||
@@ -61,6 +63,7 @@ export default connect(
|
||||
skip: !modalVisible
|
||||
});
|
||||
const [insertPartOrder] = useMutation(INSERT_NEW_PARTS_ORDERS);
|
||||
const [updateJobLines] = useMutation(UPDATE_JOB_LINE_STATUS);
|
||||
|
||||
const handleOk = () => {
|
||||
insertPartOrder({
|
||||
@@ -77,10 +80,25 @@ export default connect(
|
||||
}
|
||||
})
|
||||
.then(r => {
|
||||
notification["success"]({
|
||||
message: t("parts_orders.successes.created")
|
||||
});
|
||||
setModalVisible(false);
|
||||
updateJobLines({
|
||||
variables: {
|
||||
ids: linesToOrder.map(item => item.id),
|
||||
status: bodyshop.md_order_statuses.default_ordered || "Ordered*"
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
notification["success"]({
|
||||
message: t("parts_orders.successes.created")
|
||||
});
|
||||
if (refetch) refetch();
|
||||
setModalVisible(false);
|
||||
})
|
||||
.catch(error => {
|
||||
notification["error"]({
|
||||
message: t("parts_orders.errors.creating"),
|
||||
description: error.message
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
notification["error"]({
|
||||
|
||||
Reference in New Issue
Block a user