diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 3cd5f523b..3404bf856 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -19821,6 +19821,32 @@ scoreboard + + actions + + + edit + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + errors @@ -19866,6 +19892,27 @@ + + updating + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + @@ -20091,6 +20138,27 @@ + + updated + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + diff --git a/client/src/components/jobs-close-allocation-tags/jobs-close-allocation-tags.component.jsx b/client/src/components/jobs-close-allocation-tags/jobs-close-allocation-tags.component.jsx index e34fe66eb..96ca22716 100644 --- a/client/src/components/jobs-close-allocation-tags/jobs-close-allocation-tags.component.jsx +++ b/client/src/components/jobs-close-allocation-tags/jobs-close-allocation-tags.component.jsx @@ -1,5 +1,6 @@ import React from "react"; import { Tag } from "antd"; +import Dinero from "dinero.js"; export default function JobsCloseLabMatAllocationTags({ allocationKey, allocation, @@ -27,7 +28,7 @@ export default function JobsCloseLabMatAllocationTags({ }); }} key={idx} - >{`${a.center} - ${a.amount.toFormat()}`} + >{`${a.center} - ${Dinero(a.amount).toFormat()}`} ))} ); diff --git a/client/src/components/jobs-close-auto-allocate/jobs-close-auto-allocate.component.jsx b/client/src/components/jobs-close-auto-allocate/jobs-close-auto-allocate.component.jsx index 3a5430939..90aba73c1 100644 --- a/client/src/components/jobs-close-auto-allocate/jobs-close-auto-allocate.component.jsx +++ b/client/src/components/jobs-close-auto-allocate/jobs-close-auto-allocate.component.jsx @@ -5,7 +5,7 @@ import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { useTranslation } from "react-i18next"; import { logImEXEvent } from "../../firebase/firebase.utils"; - +import Dinero from "dinero.js"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, }); @@ -28,7 +28,10 @@ export function JobsCloseAutoAllocate({ Object.keys(labmatAllocations).forEach((i) => { const defaultProfitCenter = defaults.profits[i.toUpperCase()]; - if (!!defaultProfitCenter && labmatAllocations[i].total.getAmount() > 0) { + if ( + !!defaultProfitCenter && + Dinero(labmatAllocations[i].total).getAmount() > 0 + ) { setLabmatAllocations((st) => { return { ...st, @@ -49,7 +52,10 @@ export function JobsCloseAutoAllocate({ Object.keys(partsAllocations).forEach((i) => { const defaultProfitCenter = defaults.profits[i.toUpperCase()]; - if (!!defaultProfitCenter && partsAllocations[i].total.getAmount() > 0) { + if ( + !!defaultProfitCenter && + Dinero(partsAllocations[i].total).getAmount() > 0 + ) { setPartsAllocations((st) => { return { ...st, diff --git a/client/src/components/jobs-close-labmat-allocation/jobs-close-labmat-allocation.component.jsx b/client/src/components/jobs-close-labmat-allocation/jobs-close-labmat-allocation.component.jsx index a0a645140..b551cc8c9 100644 --- a/client/src/components/jobs-close-labmat-allocation/jobs-close-labmat-allocation.component.jsx +++ b/client/src/components/jobs-close-labmat-allocation/jobs-close-labmat-allocation.component.jsx @@ -40,8 +40,7 @@ export default function JobCloseLabMatAllocation({ Dinero({ amount: labmatAllocations[alloc].allocations.reduce( (acc, val) => { - console.log("val :>> ", val); - return acc + val.amount.getAmount(); + return acc + Dinero(val.amount).getAmount(); }, 0 ), @@ -58,7 +57,7 @@ export default function JobCloseLabMatAllocation({ Dinero({ amount: labmatAllocations[alloc].allocations.reduce( (acc, val) => { - return acc + val.amount.getAmount(); + return acc + Dinero(val.amount).getAmount(); }, 0 ), diff --git a/client/src/components/jobs-close-parts-allocation/jobs-close-parts-allocation.component.jsx b/client/src/components/jobs-close-parts-allocation/jobs-close-parts-allocation.component.jsx index f34dd8ecf..148e03afc 100644 --- a/client/src/components/jobs-close-parts-allocation/jobs-close-parts-allocation.component.jsx +++ b/client/src/components/jobs-close-parts-allocation/jobs-close-parts-allocation.component.jsx @@ -40,7 +40,7 @@ export default function JobsClosePartsAllocation({ Dinero({ amount: partsAllocations[alloc].allocations.reduce( (acc, val) => { - return acc + val.amount.getAmount(); + return acc + Dinero(val.amount).getAmount(); }, 0 ), @@ -57,7 +57,7 @@ export default function JobsClosePartsAllocation({ Dinero({ amount: partsAllocations[alloc].allocations.reduce( (acc, val) => { - return acc + val.amount.getAmount(); + return acc + Dinero(val.amount).getAmount(); }, 0 ), diff --git a/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js b/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js index 48fcb77d1..2d62ba78e 100644 --- a/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js +++ b/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js @@ -100,7 +100,6 @@ export function ScheduleCalendarHeaderComponent({ ) : null; - console.log("loadData", loadData); return (
diff --git a/client/src/components/scoreboard-entry-edit/scoreboard-entry-edit.component.jsx b/client/src/components/scoreboard-entry-edit/scoreboard-entry-edit.component.jsx new file mode 100644 index 000000000..cc9822b74 --- /dev/null +++ b/client/src/components/scoreboard-entry-edit/scoreboard-entry-edit.component.jsx @@ -0,0 +1,104 @@ +import { Button, Card, Dropdown, Form, InputNumber, notification } from "antd"; +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import FormDatePicker from "../form-date-picker/form-date-picker.component"; +import { useMutation } from "react-apollo"; +import { UPDATE_SCOREBOARD_ENTRY } from "../../graphql/scoreboard.queries"; +export default function ScoreboardEntryEdit({ entry }) { + const [visible, setVisible] = useState(false); + const [loading, setLoading] = useState(false); + const { t } = useTranslation(); + const [updateScoreboardentry] = useMutation(UPDATE_SCOREBOARD_ENTRY); + + const handleFinish = async (values) => { + setLoading(true); + const result = await updateScoreboardentry({ + variables: { sbId: entry.id, sbInput: values }, + }); + + if (!!result.errors) { + notification["error"]({ + message: t("scoreboard.errors.updating", { + message: JSON.stringify(result.errors), + }), + }); + return; + } else { + notification["success"]({ + message: t("scoredboard.successes.updated"), + }); + setVisible(false); + } + setLoading(false); + }; + + const popContent = ( + +
e.stopPropagation()} + > + + + + + + + + + + + + +
+
+ ); + + return ( +
+ + + +
+ ); +} diff --git a/client/src/components/scoreboard-jobs-list/scoreboard-jobs-list.component.jsx b/client/src/components/scoreboard-jobs-list/scoreboard-jobs-list.component.jsx index 496227219..684d9b61b 100644 --- a/client/src/components/scoreboard-jobs-list/scoreboard-jobs-list.component.jsx +++ b/client/src/components/scoreboard-jobs-list/scoreboard-jobs-list.component.jsx @@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; import ScoreboardRemoveButton from "../scoreboard-remove-button/scorebard-remove-button.component"; import { DateFormatter } from "../../utils/DateFormatter"; +import ScoreboardEntryEdit from "../scoreboard-entry-edit/scoreboard-entry-edit.component"; export default function ScoreboardJobsList({ scoreBoardlist }) { const { t } = useTranslation(); @@ -49,6 +50,7 @@ export default function ScoreboardJobsList({ scoreBoardlist }) { key: "actions", render: (text, record) => (
+
), @@ -56,14 +58,16 @@ export default function ScoreboardJobsList({ scoreBoardlist }) { ]; const overlay = ( -
+
e.stopPropagation()} /> ); diff --git a/client/src/graphql/scoreboard.queries.js b/client/src/graphql/scoreboard.queries.js index e0cba5ad9..a327ed863 100644 --- a/client/src/graphql/scoreboard.queries.js +++ b/client/src/graphql/scoreboard.queries.js @@ -35,3 +35,17 @@ export const INSERT_SCOREBOARD_ENTRY = gql` } } `; + +export const UPDATE_SCOREBOARD_ENTRY = gql` + mutation UPDATE_SCOREBOARD_ENTRY( + $sbId: uuid! + $sbInput: scoreboard_set_input! + ) { + update_scoreboard_by_pk(_set: $sbInput, pk_columns: { id: $sbId }) { + id + date + bodyhrs + painthrs + } + } +`; diff --git a/client/src/pages/jobs-close/jobs-close.component.jsx b/client/src/pages/jobs-close/jobs-close.component.jsx index 7f42797cb..9a47b6531 100644 --- a/client/src/pages/jobs-close/jobs-close.component.jsx +++ b/client/src/pages/jobs-close/jobs-close.component.jsx @@ -87,7 +87,7 @@ export function JobsCloseComponent({ job, bodyshop, jobTotals }) { const labmatAllocatedTotal = Dinero({ amount: labmatAllocatedTotalsArray.reduce((acc, val) => { - return (acc = acc + val.amount.getAmount()); + return (acc = acc + Dinero(val.amount).getAmount()); }, 0), }); @@ -97,7 +97,7 @@ export function JobsCloseComponent({ job, bodyshop, jobTotals }) { const partsAllocatedTotal = Dinero({ amount: partsAllocatedTotalsArray.reduce((acc, val) => { - return (acc = acc + val.amount.getAmount()); + return (acc = acc + Dinero(val.amount).getAmount()); }, 0), }); diff --git a/client/src/pages/jobs-close/jobs-close.container.jsx b/client/src/pages/jobs-close/jobs-close.container.jsx index cd77d9cbe..feaffd339 100644 --- a/client/src/pages/jobs-close/jobs-close.container.jsx +++ b/client/src/pages/jobs-close/jobs-close.container.jsx @@ -10,6 +10,8 @@ import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component"; import { QUERY_JOB_CLOSE_DETAILS } from "../../graphql/jobs.queries"; import { setBreadcrumbs } from "../../redux/application/application.actions"; import JobsCloseComponent from "./jobs-close.component"; +import { Result } from "antd"; +import JobCalculateTotals from "../../components/job-calculate-totals/job-calculate-totals.component"; const mapDispatchToProps = (dispatch) => ({ setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)), @@ -47,13 +49,19 @@ export function JobsCloseContainer({ setBreadcrumbs }) { if (loading) return ; if (error) return ; if (!!!data.jobs_by_pk) return ; - + if (!data.jobs_by_pk.job_totals) + return ( + } + /> + ); return (
diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 9c05730a8..85299342c 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1224,9 +1224,13 @@ } }, "scoreboard": { + "actions": { + "edit": "Edit" + }, "errors": { "adding": "Error adding job to scoreboard. {{message}}", - "removing": "Error removing job from scoreboard. {{message}}" + "removing": "Error removing job from scoreboard. {{message}}", + "updating": "Error updating scoreboard. {{message}}" }, "fields": { "bodyhrs": "Body Hours", @@ -1242,7 +1246,8 @@ }, "successes": { "added": "Job added to scoreboard.", - "removed": "Job removed from scoreboard." + "removed": "Job removed from scoreboard.", + "updated": "Scoreboard updated." } }, "tech": { diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 8c94f79c8..d25d42057 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1224,9 +1224,13 @@ } }, "scoreboard": { + "actions": { + "edit": "" + }, "errors": { "adding": "", - "removing": "" + "removing": "", + "updating": "" }, "fields": { "bodyhrs": "", @@ -1242,7 +1246,8 @@ }, "successes": { "added": "", - "removed": "" + "removed": "", + "updated": "" } }, "tech": { diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index ca6ef3b4e..33258fb5a 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1224,9 +1224,13 @@ } }, "scoreboard": { + "actions": { + "edit": "" + }, "errors": { "adding": "", - "removing": "" + "removing": "", + "updating": "" }, "fields": { "bodyhrs": "", @@ -1242,7 +1246,8 @@ }, "successes": { "added": "", - "removed": "" + "removed": "", + "updated": "" } }, "tech": {