From b06fbd25a0853e2d1c0f203234c4e271c0abe1d6 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 17 May 2023 07:49:25 -0700 Subject: [PATCH] Add shop config section. --- bodyshop_translations.babel | 215 ++++++++++++++++++ .../shop-info/shop-info.component.jsx | 7 + .../shop-info.task-presets.component.jsx | 144 ++++++++++++ .../time-ticket-task-modal.container.jsx | 7 +- .../time-ticket-tasks-presets.component.jsx | 59 +++-- client/src/graphql/bodyshop.queries.js | 2 + client/src/graphql/jobs-lines.queries.js | 2 +- client/src/graphql/timetickets.queries.js | 2 +- client/src/translations/en_us/common.json | 16 +- client/src/translations/es/common.json | 16 +- client/src/translations/fr/common.json | 16 +- 11 files changed, 457 insertions(+), 29 deletions(-) create mode 100644 client/src/components/shop-info/shop-info.task-presets.component.jsx diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 3b4fff18d..028b9e90c 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -3602,6 +3602,27 @@ actions + + add_task_preset + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + addapptcolor false @@ -5584,6 +5605,95 @@ + + md_tasks_presets + + + hourstype + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + memo + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + name + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + percent + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + messaginglabel false @@ -9750,6 +9860,27 @@ + + md_tasks_presets + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + md_to_emails false @@ -10259,6 +10390,27 @@ + + task-presets + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + workingdays false @@ -14788,6 +14940,27 @@ + + newmember + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + @@ -14814,6 +14987,27 @@ + + employeeid + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + name false @@ -14835,6 +15029,27 @@ + + percentage + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + diff --git a/client/src/components/shop-info/shop-info.component.jsx b/client/src/components/shop-info/shop-info.component.jsx index 9baeb2c58..aad29074e 100644 --- a/client/src/components/shop-info/shop-info.component.jsx +++ b/client/src/components/shop-info/shop-info.component.jsx @@ -15,6 +15,7 @@ import ShopInfoResponsibilityCenterComponent from "./shop-info.responsibilitycen import ShopInfoROStatusComponent from "./shop-info.rostatus.component"; import ShopInfoSchedulingComponent from "./shop-info.scheduling.component"; import ShopInfoSpeedPrint from "./shop-info.speedprint.component"; +import ShopInfoTaskPresets from "./shop-info.task-presets.component"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -83,6 +84,12 @@ export function ShopInfoComponent({ bodyshop, form, saveLoading }) { )} + + + ); diff --git a/client/src/components/shop-info/shop-info.task-presets.component.jsx b/client/src/components/shop-info/shop-info.task-presets.component.jsx new file mode 100644 index 000000000..7218f8056 --- /dev/null +++ b/client/src/components/shop-info/shop-info.task-presets.component.jsx @@ -0,0 +1,144 @@ +import { DeleteFilled } from "@ant-design/icons"; +import { + Button, + Checkbox, + Col, + Form, + Input, + InputNumber, + Row, + Space, +} from "antd"; +import React from "react"; +import { useTranslation } from "react-i18next"; +import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component"; +import LayoutFormRow from "../layout-form-row/layout-form-row.component"; + +export default function ShopInfoTaskPresets({ form }) { + const { t } = useTranslation(); + + return ( + + + {(fields, { add, remove, move }) => { + return ( +
+ {fields.map((field, index) => ( + + + + + + + + + + + {t("joblines.fields.lbr_types.LAB")} + + + + + {t("joblines.fields.lbr_types.LAR")} + + + + + {t("joblines.fields.lbr_types.LAM")} + + + + + {t("joblines.fields.lbr_types.LAF")} + + + + + {t("joblines.fields.lbr_types.LAG")} + + + + + + + + + + + + + { + remove(field.name); + }} + /> + + + + + ))} + + + +
+ ); + }} +
+
+ ); +} diff --git a/client/src/components/time-ticket-task-modal/time-ticket-task-modal.container.jsx b/client/src/components/time-ticket-task-modal/time-ticket-task-modal.container.jsx index cc8ae83a6..09fffd9b2 100644 --- a/client/src/components/time-ticket-task-modal/time-ticket-task-modal.container.jsx +++ b/client/src/components/time-ticket-task-modal/time-ticket-task-modal.container.jsx @@ -52,6 +52,10 @@ export function TimeTickeTaskModalContainer({ }); async function handleFinish(values) { + console.log( + "🚀 ~ file: time-ticket-task-modal.container.jsx:55 ~ handleFinish ~ values:", + values + ); try { if (true) { const result = await insertTimeTicketApproval({ @@ -112,7 +116,6 @@ export function TimeTickeTaskModalContainer({ }, [context.jobid, queryJobInfo, visible]); const calculateTimeTickets = (presetMemo) => { - console.log("🚀 ~ file: time-ticket-task-modal.container.jsx:115 ~ calculateTimeTickets ~ presetMemo:", presetMemo) const formData = form.getFieldsValue(); if ( !formData.jobid || @@ -147,7 +150,7 @@ export function TimeTickeTaskModalContainer({ jobid: formData.jobid, rate: e.labor_rates[hourstype], actualhrs: 0, - memo: presetMemo, + memo: typeof presetMemo === "string" ? presetMemo : "", flat_rate: true, ciecacode: hourstype, cost_center: diff --git a/client/src/components/time-ticket-tasks-presets/time-ticket-tasks-presets.component.jsx b/client/src/components/time-ticket-tasks-presets/time-ticket-tasks-presets.component.jsx index 05a845926..b940ca972 100644 --- a/client/src/components/time-ticket-tasks-presets/time-ticket-tasks-presets.component.jsx +++ b/client/src/components/time-ticket-tasks-presets/time-ticket-tasks-presets.component.jsx @@ -1,12 +1,28 @@ import { Button, Dropdown } from "antd"; import React from "react"; -export default function TimeTicketsTasksPresets({ +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +const mapStateToProps = createStructuredSelector({ + //currentUser: selectCurrentUser + bodyshop: selectBodyshop, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); +export default connect( + mapStateToProps, + mapDispatchToProps +)(TimeTicketsTasksPresets); + +export function TimeTicketsTasksPresets({ + bodyshop, form, calculateTimeTickets, }) { const handleClick = (props) => { - const preset = samplePresets.find((p) => { + const preset = bodyshop.md_tasks_presets?.presets?.find((p) => { return p.name === props.key; }); @@ -24,7 +40,12 @@ export default function TimeTicketsTasksPresets({ ({ label: p.name, key: p.name })), + items: bodyshop.md_tasks_presets?.presets + ? bodyshop.md_tasks_presets?.presets?.map((p) => ({ + label: p.name, + key: p.name, + })) + : [], onClick: handleClick, }} > @@ -33,19 +54,19 @@ export default function TimeTicketsTasksPresets({ ); } -const samplePresets = [ - { - name: "Teardown", - hourstype: ["LAB", "LAM"], - percent: 10, - memo: "Teardown Preset Task", - }, - { - name: "Disassembly", - hourstype: ["LAB", "LAD"], - percent: 20, - memo: "Disassy Preset Claim", - }, - { name: "Body", hourstype: ["LAB", "LAD"], percent: 20 }, - { name: "Prep", hourstype: ["LAR"], percent: 20 }, -]; +// const samplePresets = [ +// { +// name: "Teardown", +// hourstype: ["LAB", "LAM"], +// percent: 10, +// memo: "Teardown Preset Task", +// }, +// { +// name: "Disassembly", +// hourstype: ["LAB", "LAD"], +// percent: 20, +// memo: "Disassy Preset Claim", +// }, +// { name: "Body", hourstype: ["LAB", "LAD"], percent: 20 }, +// { name: "Prep", hourstype: ["LAR"], percent: 20 }, +// ]; diff --git a/client/src/graphql/bodyshop.queries.js b/client/src/graphql/bodyshop.queries.js index c934c9514..301ed6628 100644 --- a/client/src/graphql/bodyshop.queries.js +++ b/client/src/graphql/bodyshop.queries.js @@ -117,6 +117,7 @@ export const QUERY_BODYSHOP = gql` md_parts_scan enforce_conversion_category tt_enforce_hours_for_tech_console + md_tasks_presets employees { user_email id @@ -232,6 +233,7 @@ export const UPDATE_SHOP = gql` md_parts_scan enforce_conversion_category tt_enforce_hours_for_tech_console + md_tasks_presets employees { id first_name diff --git a/client/src/graphql/jobs-lines.queries.js b/client/src/graphql/jobs-lines.queries.js index 03b3a3075..9318f3d88 100644 --- a/client/src/graphql/jobs-lines.queries.js +++ b/client/src/graphql/jobs-lines.queries.js @@ -67,7 +67,7 @@ export const GET_LINE_TICKET_BY_PK = gql` clockoff rate committed_at - committed_by + commited_by employee { id first_name diff --git a/client/src/graphql/timetickets.queries.js b/client/src/graphql/timetickets.queries.js index 88c710a2b..0dec7c9e4 100644 --- a/client/src/graphql/timetickets.queries.js +++ b/client/src/graphql/timetickets.queries.js @@ -84,7 +84,7 @@ export const QUERY_TIME_TICKETS_IN_RANGE_SB = gql` memo jobid committed_at - committed_by + commited_by flat_rate job { id diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index b158ec418..0639c7b09 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -227,6 +227,7 @@ }, "bodyshop": { "actions": { + "add_task_preset": "Add Task Preset", "addapptcolor": "Add Appointment Color", "addbucket": "Add Definition", "addpartslocation": "Add Parts Location", @@ -339,6 +340,12 @@ }, "md_payment_types": "Payment Types", "md_referral_sources": "Referral Sources", + "md_tasks_presets": { + "hourstype": "Hour Types", + "memo": "Time Ticket Memo", + "name": "Preset Name", + "percent": "Percent" + }, "messaginglabel": "Messaging Preset Label", "messagingtext": "Messaging Preset Text", "noteslabel": "Note Label", @@ -592,6 +599,7 @@ "jobstatuses": "Job Statuses", "laborrates": "Labor Rates", "licensing": "Licensing", + "md_tasks_presets": "Tasks Presets", "md_to_emails": "Preset To Emails", "md_to_emails_emails": "Emails", "messagingpresets": "Messaging Presets", @@ -618,6 +626,7 @@ "speedprint": "Speed Print Configuration", "ssbuckets": "Job Size Definitions", "systemsettings": "System Settings", + "task-presets": "Task Presets", "workingdays": "Working Days" }, "successes": { @@ -919,11 +928,14 @@ }, "employee_teams": { "actions": { - "new": "New Team" + "new": "New Team", + "newmember": "New Team Member" }, "fields": { "active": "Active", - "name": "Team Name" + "employeeid": "Employee", + "name": "Team Name", + "percentage": "Percent" } }, "employees": { diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 5d7a7bf2e..1d2f81e58 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -227,6 +227,7 @@ }, "bodyshop": { "actions": { + "add_task_preset": "", "addapptcolor": "", "addbucket": "", "addpartslocation": "", @@ -339,6 +340,12 @@ }, "md_payment_types": "", "md_referral_sources": "", + "md_tasks_presets": { + "hourstype": "", + "memo": "", + "name": "", + "percent": "" + }, "messaginglabel": "", "messagingtext": "", "noteslabel": "", @@ -592,6 +599,7 @@ "jobstatuses": "", "laborrates": "", "licensing": "", + "md_tasks_presets": "", "md_to_emails": "", "md_to_emails_emails": "", "messagingpresets": "", @@ -618,6 +626,7 @@ "speedprint": "", "ssbuckets": "", "systemsettings": "", + "task-presets": "", "workingdays": "" }, "successes": { @@ -919,11 +928,14 @@ }, "employee_teams": { "actions": { - "new": "" + "new": "", + "newmember": "" }, "fields": { "active": "", - "name": "" + "employeeid": "", + "name": "", + "percentage": "" } }, "employees": { diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index f6a56ac38..57a2e32a8 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -227,6 +227,7 @@ }, "bodyshop": { "actions": { + "add_task_preset": "", "addapptcolor": "", "addbucket": "", "addpartslocation": "", @@ -339,6 +340,12 @@ }, "md_payment_types": "", "md_referral_sources": "", + "md_tasks_presets": { + "hourstype": "", + "memo": "", + "name": "", + "percent": "" + }, "messaginglabel": "", "messagingtext": "", "noteslabel": "", @@ -592,6 +599,7 @@ "jobstatuses": "", "laborrates": "", "licensing": "", + "md_tasks_presets": "", "md_to_emails": "", "md_to_emails_emails": "", "messagingpresets": "", @@ -618,6 +626,7 @@ "speedprint": "", "ssbuckets": "", "systemsettings": "", + "task-presets": "", "workingdays": "" }, "successes": { @@ -919,11 +928,14 @@ }, "employee_teams": { "actions": { - "new": "" + "new": "", + "newmember": "" }, "fields": { "active": "", - "name": "" + "employeeid": "", + "name": "", + "percentage": "" } }, "employees": {