CLEANUP Refactored parts order to use redux modals.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { Button, Input, Table } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { Link } from "react-router-dom";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
import AllocationsAssignmentContainer from "../allocations-assignment/allocations-assignment.container";
|
||||
@@ -9,14 +11,19 @@ import AllocationsBulkAssignmentContainer from "../allocations-bulk-assignment/a
|
||||
import AllocationsEmployeeLabelContainer from "../allocations-employee-label/allocations-employee-label.container";
|
||||
import PartsOrderModalContainer from "../parts-order-modal/parts-order-modal.container";
|
||||
|
||||
export default function JobLinesComponent({
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
setPartsOrderContext: context =>
|
||||
dispatch(setModalContext({ context: context, modal: "partsOrder" }))
|
||||
});
|
||||
|
||||
export function JobLinesComponent({
|
||||
setPartsOrderContext,
|
||||
loading,
|
||||
refetch,
|
||||
jobLines,
|
||||
setSearchText,
|
||||
selectedLines,
|
||||
setSelectedLines,
|
||||
partsOrderModalVisible,
|
||||
jobId,
|
||||
setJobLineEditContext
|
||||
}) {
|
||||
@@ -24,7 +31,7 @@ export default function JobLinesComponent({
|
||||
sortedInfo: {}
|
||||
});
|
||||
const { t } = useTranslation();
|
||||
const setPartsModalVisible = partsOrderModalVisible[1];
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t("joblines.fields.unq_seq"),
|
||||
@@ -205,13 +212,7 @@ export default function JobLinesComponent({
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PartsOrderModalContainer
|
||||
partsOrderModalVisible={partsOrderModalVisible}
|
||||
linesToOrder={selectedLines}
|
||||
refetch={refetch}
|
||||
jobId={jobId}
|
||||
/>
|
||||
|
||||
<PartsOrderModalContainer />
|
||||
<Table
|
||||
title={() => {
|
||||
return (
|
||||
@@ -225,7 +226,15 @@ export default function JobLinesComponent({
|
||||
/>
|
||||
<Button
|
||||
disabled={selectedLines.length > 0 ? false : true}
|
||||
onClick={() => setPartsModalVisible(true)}
|
||||
onClick={() => {
|
||||
setPartsOrderContext({
|
||||
actions: { refetch: refetch },
|
||||
context: {
|
||||
jobId: jobId,
|
||||
linesToOrder: selectedLines
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("parts.actions.order")}
|
||||
</Button>
|
||||
@@ -280,3 +289,4 @@ export default function JobLinesComponent({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default connect(null, mapDispatchToProps)(JobLinesComponent);
|
||||
|
||||
Reference in New Issue
Block a user