IO-1065 Add available jobs alert for closed jobs.

This commit is contained in:
Patrick Fic
2021-05-10 16:36:08 -07:00
parent b160b45775
commit 8bf3891535
6 changed files with 94 additions and 28 deletions

View File

@@ -20222,6 +20222,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>alreadyclosed</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>appointmentconfirmation</name>
<definition_loaded>false</definition_loaded>

View File

@@ -5,7 +5,16 @@ import {
SyncOutlined,
} from "@ant-design/icons";
import { useMutation } from "@apollo/client";
import { Button, Card, Input, notification, Space, Table } from "antd";
import {
Alert,
Button,
Card,
Input,
notification,
Space,
Table,
Tag,
} from "antd";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
@@ -16,7 +25,23 @@ import {
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import { TimeAgoFormatter } from "../../utils/DateFormatter";
import { alphaSort } from "../../utils/sorters";
export default function JobsAvailableComponent({
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
});
const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(JobsAvailableComponent);
export function JobsAvailableComponent({
bodyshop,
loading,
data,
refetch,
@@ -58,11 +83,11 @@ export default function JobsAvailableComponent({
render: (text, record) =>
record.job ? (
<Link to={`/manage/jobs/${record.job.id}`}>
{(record.job && record.job_ro_number) || t("general.labels.na")}
{(record.job && record.job.ro_number) || t("general.labels.na")}
</Link>
) : (
<div>
{(record.job && record.job_ro_number) || t("general.labels.na")}
{(record.job && record.job.ro_number) || t("general.labels.na")}
</div>
),
},
@@ -132,31 +157,47 @@ export default function JobsAvailableComponent({
{
title: t("general.labels.actions"),
key: "actions",
render: (text, record) => (
<Space wrap>
<Button
onClick={() => {
deleteJob({ variables: { id: record.id } }).then((r) => {
notification["success"]({
message: t("jobs.successes.deleted"),
render: (text, record) => {
const isClosed =
record.job &&
(record.job.status === bodyshop.md_ro_statuses.default_exported ||
record.job.status === bodyshop.md_ro_statuses.default_invoiced);
return (
<Space wrap>
<Button
onClick={() => {
deleteJob({ variables: { id: record.id } }).then((r) => {
notification["success"]({
message: t("jobs.successes.deleted"),
});
refetch();
});
refetch();
});
}}
>
<DeleteFilled />
</Button>
<Button
onClick={() => addJobAsNew(record)}
disabled={record.issupplement}
>
<PlusCircleFilled />
</Button>
<Button onClick={() => addJobAsSupp(record)}>
<DownloadOutlined />
</Button>
</Space>
),
}}
>
<DeleteFilled />
</Button>
{!isClosed && (
<>
<Button
onClick={() => addJobAsNew(record)}
disabled={record.issupplement}
>
<PlusCircleFilled />
</Button>
<Button onClick={() => addJobAsSupp(record)}>
<DownloadOutlined />
</Button>
</>
)}
{isClosed && (
<Alert
type="error"
message={t("jobs.labels.alreadyclosed")}
></Alert>
)}
</Space>
);
},
},
];

View File

@@ -19,6 +19,7 @@ export const QUERY_AVAILABLE_JOBS = gql`
job {
id
ro_number
status
}
}
}

View File

@@ -1214,6 +1214,7 @@
"adjustmentrate": "Adjustment Rate",
"adjustments": "Adjustments",
"allocations": "Allocations",
"alreadyclosed": "This job has already been closed.",
"appointmentconfirmation": "Send confirmation to customer?",
"associationwarning": "Any changes to associations will require updating the data from the new parent record to the job.",
"audit": "Audit Trail",

View File

@@ -1214,6 +1214,7 @@
"adjustmentrate": "",
"adjustments": "",
"allocations": "",
"alreadyclosed": "",
"appointmentconfirmation": "¿Enviar confirmación al cliente?",
"associationwarning": "",
"audit": "",

View File

@@ -1214,6 +1214,7 @@
"adjustmentrate": "",
"adjustments": "",
"allocations": "",
"alreadyclosed": "",
"appointmentconfirmation": "Envoyer une confirmation au client?",
"associationwarning": "",
"audit": "",