From d1280e8680c4f14b4d1ad22216c6de4a57968aee Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Tue, 2 Feb 2021 12:21:06 -0800 Subject: [PATCH] Ability to delete job checklist IO-464 --- .../jobs-admin-delete-intake.component.jsx | 49 +++++++++++++++++++ .../src/pages/jobs-admin/jobs-admin.page.jsx | 8 ++- client/src/translations/en_us/common.json | 4 +- server/job/job-totals.js | 2 +- 4 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 client/src/components/jobs-admin-delete-intake/jobs-admin-delete-intake.component.jsx diff --git a/client/src/components/jobs-admin-delete-intake/jobs-admin-delete-intake.component.jsx b/client/src/components/jobs-admin-delete-intake/jobs-admin-delete-intake.component.jsx new file mode 100644 index 000000000..6b5c2787e --- /dev/null +++ b/client/src/components/jobs-admin-delete-intake/jobs-admin-delete-intake.component.jsx @@ -0,0 +1,49 @@ +import { useMutation } from "@apollo/react-hooks"; +import { Button, notification } from "antd"; +import gql from "graphql-tag"; +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +export default function JobAdminDeleteIntake({ job }) { + const { t } = useTranslation(); + const [loading, setLoading] = useState(false); + const [updateJob] = useMutation(gql` + mutation UPDATE_JOB($jobId: uuid!) { + update_jobs_by_pk( + pk_columns: { id: $jobId } + _set: { intakechecklist: null } + ) { + id + intakechecklist + } + } + `); + + const handleDelete = async (values) => { + setLoading(true); + const result = await updateJob({ + 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); + //Get the owner details, populate it all back into the job. + }; + + return ( +
+
{t("jobs.labels.deleteintake")}
+ + +
+ ); +} diff --git a/client/src/pages/jobs-admin/jobs-admin.page.jsx b/client/src/pages/jobs-admin/jobs-admin.page.jsx index 0fabeeaf3..fe3611c41 100644 --- a/client/src/pages/jobs-admin/jobs-admin.page.jsx +++ b/client/src/pages/jobs-admin/jobs-admin.page.jsx @@ -14,9 +14,10 @@ import NotFound from "../../components/not-found/not-found.component"; import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component"; import { GET_JOB_BY_PK } from "../../graphql/jobs.queries"; import { - setBreadcrumbs, - setSelectedHeader + setBreadcrumbs, + setSelectedHeader, } from "../../redux/application/application.actions"; +import JobsAdminDeleteIntake from "../../components/jobs-admin-delete-intake/jobs-admin-delete-intake.component"; const mapDispatchToProps = (dispatch) => ({ setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)), @@ -71,6 +72,9 @@ export function JobsCloseContainer({ setBreadcrumbs, setSelectedHeader }) { + + + ); diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 247501752..0e2c496f3 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -770,7 +770,7 @@ }, "fields": { "act_price": "Actual Price", - "db_price": "Database Price", + "db_price": "List Price", "lbr_types": { "LA1": "LA1", "LA2": "LA2", @@ -1363,7 +1363,7 @@ "act_price": "Price", "backordered_eta": "B.O. ETA", "backordered_on": "B.O. On", - "db_price": "DB Price", + "db_price": "List Price", "deliver_by": "Deliver By", "job_line_id": "Job Line Id", "line_desc": "Line Description", diff --git a/server/job/job-totals.js b/server/job/job-totals.js index 46f6b3f42..caccf22bf 100644 --- a/server/job/job-totals.js +++ b/server/job/job-totals.js @@ -235,7 +235,7 @@ function CalculateTaxesTotals(job, otherTotals) { if (!!!val.tax_part || !!!val.part_type || IsAdditionalCost(val)) { additionalItemsTax = additionalItemsTax.add( Dinero({ amount: Math.round((val.act_price || 0) * 100) }) - .multiply(val.value.part_qty || 0) + .multiply(val.part_qty || 0) .percentage( (job.parts_tax_rates && job.parts_tax_rates["PAN"] &&