IO-1284 Job Admin updates

This commit is contained in:
Patrick Fic
2021-08-03 11:45:36 -07:00
parent b0ec7867b5
commit 5b84ebbc25
7 changed files with 241 additions and 22 deletions

View File

@@ -16967,6 +16967,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>markasexported</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> <concept_node>
<name>markpstexempt</name> <name>markpstexempt</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -17177,6 +17198,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>uninvoice</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> <concept_node>
<name>unvoid</name> <name>unvoid</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -21517,6 +21559,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>adminwarning</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> <concept_node>
<name>allocations</name> <name>allocations</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -22461,6 +22524,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>deletedelivery</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> <concept_node>
<name>deleteintake</name> <name>deleteintake</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>

View File

@@ -6,8 +6,8 @@ import { useTranslation } from "react-i18next";
export default function JobAdminDeleteIntake({ job }) { export default function JobAdminDeleteIntake({ job }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [updateJob] = useMutation(gql` const [deleteIntake] = useMutation(gql`
mutation UPDATE_JOB($jobId: uuid!) { mutation DELETE_INTAKE($jobId: uuid!) {
update_jobs_by_pk( update_jobs_by_pk(
pk_columns: { id: $jobId } pk_columns: { id: $jobId }
_set: { intakechecklist: null } _set: { intakechecklist: null }
@@ -18,9 +18,39 @@ export default function JobAdminDeleteIntake({ job }) {
} }
`); `);
const [DELETE_DELIVERY] = useMutation(gql`
mutation DELETE_DELIVERY($jobId: uuid!) {
update_jobs_by_pk(
pk_columns: { id: $jobId }
_set: { deliverychecklist: null }
) {
id
deliverychecklist
}
}
`);
const handleDelete = async (values) => { const handleDelete = async (values) => {
setLoading(true); setLoading(true);
const result = await updateJob({ const result = await deleteIntake({
variables: { jobId: job.id },
});
if (!!!result.errors) {
notification["success"]({ message: t("jobs.successes.save") });
} else {
notification["error"]({
message: t("jobs.errors.saving", {
error: JSON.stringify(result.errors),
}),
});
}
setLoading(false);
};
const handleDeleteDelivery = async (values) => {
setLoading(true);
const result = await DELETE_DELIVERY({
variables: { jobId: job.id }, variables: { jobId: job.id },
}); });
@@ -34,12 +64,16 @@ export default function JobAdminDeleteIntake({ job }) {
}); });
} }
setLoading(false); setLoading(false);
//Get the owner details, populate it all back into the job.
}; };
return ( return (
<Button loading={loading} onClick={handleDelete}> <>
{t("jobs.labels.deleteintake")} <Button loading={loading} onClick={handleDelete}>
</Button> {t("jobs.labels.deleteintake")}
</Button>
<Button loading={loading} onClick={handleDeleteDelivery}>
{t("jobs.labels.deletedelivery")}
</Button>
</>
); );
} }

View File

@@ -7,6 +7,7 @@ import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors";
import moment from "moment";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop, bodyshop: selectBodyshop,
}); });
@@ -21,8 +22,8 @@ export default connect(
export function JobAdminMarkReexport({ bodyshop, job }) { export function JobAdminMarkReexport({ bodyshop, job }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [updateJob] = useMutation(gql` const [markJobForReexport] = useMutation(gql`
mutation UPDATE_JOB($jobId: uuid!) { mutation MARK_JOB_FOR_REEXPORT($jobId: uuid!) {
update_jobs_by_pk( update_jobs_by_pk(
pk_columns: { id: $jobId } pk_columns: { id: $jobId }
_set: { date_exported: null _set: { date_exported: null
@@ -30,14 +31,84 @@ export function JobAdminMarkReexport({ bodyshop, job }) {
} }
) { ) {
id id
intakechecklist date_exported
status
date_invoiced
} }
} }
`); `);
const handleUpdate = async (values) => { const [markJobExported] = useMutation(gql`
mutation MARK_JOB_AS_EXPORTED($jobId: uuid!, $date_exported: timestamptz!) {
update_jobs_by_pk(
pk_columns: { id: $jobId }
_set: { date_exported: $date_exported
status: "${bodyshop.md_ro_statuses.default_exported}"
}
) {
id
date_exported
date_invoiced
status
}
}
`);
const [markJobUninvoiced] = useMutation(gql`
mutation MARK_JOB_AS_UNINVOICED($jobId: uuid!, ) {
update_jobs_by_pk(
pk_columns: { id: $jobId }
_set: { date_exported: null
date_invoiced: null
status: "${bodyshop.md_ro_statuses.default_delivered}"
}
) {
id
date_exported
date_invoiced
status
}
}
`);
const handleMarkForExport = async () => {
setLoading(true); setLoading(true);
const result = await updateJob({ const result = await markJobForReexport({
variables: { jobId: job.id },
});
if (!result.errors) {
notification["success"]({ message: t("jobs.successes.save") });
} else {
notification["error"]({
message: t("jobs.errors.saving", {
error: JSON.stringify(result.errors),
}),
});
}
setLoading(false);
};
const handleMarkExported = async () => {
setLoading(true);
const result = await markJobExported({
variables: { jobId: job.id, date_exported: moment() },
});
if (!result.errors) {
notification["success"]({ message: t("jobs.successes.save") });
} else {
notification["error"]({
message: t("jobs.errors.saving", {
error: JSON.stringify(result.errors),
}),
});
}
setLoading(false);
};
const handleUninvoice = async () => {
setLoading(true);
const result = await markJobUninvoiced({
variables: { jobId: job.id }, variables: { jobId: job.id },
}); });
@@ -51,16 +122,31 @@ export function JobAdminMarkReexport({ bodyshop, job }) {
}); });
} }
setLoading(false); setLoading(false);
//Get the owner details, populate it all back into the job.
}; };
return ( return (
<Button <>
loading={loading} <Button
disabled={!job.date_exported} loading={loading}
onClick={handleUpdate} disabled={!job.date_exported}
> onClick={handleMarkForExport}
{t("jobs.labels.markforreexport")} >
</Button> {t("jobs.labels.markforreexport")}
</Button>
<Button
loading={loading}
disabled={job.date_exported}
onClick={handleMarkExported}
>
{t("jobs.actions.markasexported")}
</Button>
<Button
loading={loading}
disabled={!job.date_invoiced || job.date_exported}
onClick={handleUninvoice}
>
{t("jobs.actions.uninvoice")}
</Button>
</>
); );
} }

View File

@@ -1,5 +1,5 @@
import { useQuery } from "@apollo/client"; import { useQuery } from "@apollo/client";
import { Card, Col, Result, Row, Space } from "antd"; import { Card, Col, Result, Row, Space, Typography } from "antd";
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
@@ -84,6 +84,9 @@ export function JobsCloseContainer({ setBreadcrumbs, setSelectedHeader }) {
return ( return (
<RbacWrapper action="jobs:admin"> <RbacWrapper action="jobs:admin">
<Typography.Title level={4} style={{ color: "tomato" }}>
{t("jobs.labels.adminwarning")}
</Typography.Title>
<Row gutter={[16, 16]}> <Row gutter={[16, 16]}>
<Col {...colSpan}> <Col {...colSpan}>
<Card style={cardStyle}> <Card style={cardStyle}>

View File

@@ -1059,6 +1059,7 @@
"intake": "Intake", "intake": "Intake",
"manualnew": "Create New Job Manually", "manualnew": "Create New Job Manually",
"mark": "Mark", "mark": "Mark",
"markasexported": "Mark as Exported",
"markpstexempt": "Mark Job PST Exempt", "markpstexempt": "Mark Job PST Exempt",
"markpstexemptconfirm": "Are you sure you want to do this? To undo this, you must manually update all PST rates.", "markpstexemptconfirm": "Are you sure you want to do this? To undo this, you must manually update all PST rates.",
"postbills": "Post Bills", "postbills": "Post Bills",
@@ -1069,6 +1070,7 @@
"schedule": "Schedule", "schedule": "Schedule",
"sendcsi": "Send CSI", "sendcsi": "Send CSI",
"sync": "Sync", "sync": "Sync",
"uninvoice": "Uninvoice",
"unvoid": "Unvoid Job", "unvoid": "Unvoid Job",
"viewchecklist": "View Checklists", "viewchecklist": "View Checklists",
"viewdetail": "View Details" "viewdetail": "View Details"
@@ -1288,6 +1290,7 @@
"additionaltotal": "Additional Total", "additionaltotal": "Additional Total",
"adjustmentrate": "Adjustment Rate", "adjustmentrate": "Adjustment Rate",
"adjustments": "Adjustments", "adjustments": "Adjustments",
"adminwarning": "Use the functionality on this page at your own risk. You are responsible for any and all changes to your data.",
"allocations": "Allocations", "allocations": "Allocations",
"alreadyclosed": "This job has already been closed.", "alreadyclosed": "This job has already been closed.",
"appointmentconfirmation": "Send confirmation to customer?", "appointmentconfirmation": "Send confirmation to customer?",
@@ -1340,7 +1343,8 @@
"waived": "Waived" "waived": "Waived"
}, },
"deleteconfirm": "Are you sure you want to delete this job? This cannot be undone. ", "deleteconfirm": "Are you sure you want to delete this job? This cannot be undone. ",
"deleteintake": "Delete Intake", "deletedelivery": "Delete Delivery Checklist",
"deleteintake": "Delete Intake Checklist",
"deliverchecklist": "Deliver Checklist", "deliverchecklist": "Deliver Checklist",
"difference": "Difference", "difference": "Difference",
"diskscan": "Scan Disk for Estimates", "diskscan": "Scan Disk for Estimates",

View File

@@ -1059,6 +1059,7 @@
"intake": "", "intake": "",
"manualnew": "", "manualnew": "",
"mark": "", "mark": "",
"markasexported": "",
"markpstexempt": "", "markpstexempt": "",
"markpstexemptconfirm": "", "markpstexemptconfirm": "",
"postbills": "Contabilizar facturas", "postbills": "Contabilizar facturas",
@@ -1069,6 +1070,7 @@
"schedule": "Programar", "schedule": "Programar",
"sendcsi": "", "sendcsi": "",
"sync": "", "sync": "",
"uninvoice": "",
"unvoid": "", "unvoid": "",
"viewchecklist": "", "viewchecklist": "",
"viewdetail": "" "viewdetail": ""
@@ -1288,6 +1290,7 @@
"additionaltotal": "", "additionaltotal": "",
"adjustmentrate": "", "adjustmentrate": "",
"adjustments": "", "adjustments": "",
"adminwarning": "",
"allocations": "", "allocations": "",
"alreadyclosed": "", "alreadyclosed": "",
"appointmentconfirmation": "¿Enviar confirmación al cliente?", "appointmentconfirmation": "¿Enviar confirmación al cliente?",
@@ -1340,6 +1343,7 @@
"waived": "" "waived": ""
}, },
"deleteconfirm": "", "deleteconfirm": "",
"deletedelivery": "",
"deleteintake": "", "deleteintake": "",
"deliverchecklist": "", "deliverchecklist": "",
"difference": "", "difference": "",

View File

@@ -1059,6 +1059,7 @@
"intake": "", "intake": "",
"manualnew": "", "manualnew": "",
"mark": "", "mark": "",
"markasexported": "",
"markpstexempt": "", "markpstexempt": "",
"markpstexemptconfirm": "", "markpstexemptconfirm": "",
"postbills": "Poster des factures", "postbills": "Poster des factures",
@@ -1069,6 +1070,7 @@
"schedule": "Programme", "schedule": "Programme",
"sendcsi": "", "sendcsi": "",
"sync": "", "sync": "",
"uninvoice": "",
"unvoid": "", "unvoid": "",
"viewchecklist": "", "viewchecklist": "",
"viewdetail": "" "viewdetail": ""
@@ -1288,6 +1290,7 @@
"additionaltotal": "", "additionaltotal": "",
"adjustmentrate": "", "adjustmentrate": "",
"adjustments": "", "adjustments": "",
"adminwarning": "",
"allocations": "", "allocations": "",
"alreadyclosed": "", "alreadyclosed": "",
"appointmentconfirmation": "Envoyer une confirmation au client?", "appointmentconfirmation": "Envoyer une confirmation au client?",
@@ -1340,6 +1343,7 @@
"waived": "" "waived": ""
}, },
"deleteconfirm": "", "deleteconfirm": "",
"deletedelivery": "",
"deleteintake": "", "deleteintake": "",
"deliverchecklist": "", "deliverchecklist": "",
"difference": "", "difference": "",