diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 49079f0c9..6127f5555 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -31663,6 +31663,27 @@ labels + + addtorelatedro + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + newnoteplaceholder false diff --git a/client/src/components/chat-presets/chat-presets.component.jsx b/client/src/components/chat-presets/chat-presets.component.jsx index 08ddc1b26..1e0e93cef 100644 --- a/client/src/components/chat-presets/chat-presets.component.jsx +++ b/client/src/components/chat-presets/chat-presets.component.jsx @@ -19,7 +19,7 @@ export function ChatPresetsComponent({ bodyshop, setMessage, className }) { const menu = ( {bodyshop.md_messaging_presets.map((i, idx) => ( - setMessage(i.text)} onItemHover key={idx}> + setMessage(i.text)} key={idx}> {i.label} ))} diff --git a/client/src/components/job-lines-preset-button/job-lines-preset-button.component.jsx b/client/src/components/job-lines-preset-button/job-lines-preset-button.component.jsx index 8e0aa2cb9..60272786b 100644 --- a/client/src/components/job-lines-preset-button/job-lines-preset-button.component.jsx +++ b/client/src/components/job-lines-preset-button/job-lines-preset-button.component.jsx @@ -24,7 +24,7 @@ export function JoblinePresetButton({ bodyshop, form }) { const menu = ( {bodyshop.md_jobline_presets.map((i, idx) => ( - handleSelect(i)} onItemHover key={idx}> + handleSelect(i)} key={idx}> {i.label} ))} diff --git a/client/src/components/jobs-notes/jobs-notes.container.jsx b/client/src/components/jobs-notes/jobs-notes.container.jsx index e2aa52ee2..2fbf5e965 100644 --- a/client/src/components/jobs-notes/jobs-notes.container.jsx +++ b/client/src/components/jobs-notes/jobs-notes.container.jsx @@ -61,6 +61,7 @@ export function JobNotesContainer({ jobId, insertAuditTrail }) { jobId={jobId} loading={loading} data={data ? data.jobs_by_pk.notes : null} + relatedRos={data ? data.jobs_by_pk.vehicle.jobs : null} refetch={refetch} deleteLoading={deleteLoading} handleNoteDelete={handleNoteDelete} diff --git a/client/src/components/jobs-notes/jobs.notes.component.jsx b/client/src/components/jobs-notes/jobs.notes.component.jsx index ff029149f..8f60e879d 100644 --- a/client/src/components/jobs-notes/jobs.notes.component.jsx +++ b/client/src/components/jobs-notes/jobs.notes.component.jsx @@ -37,6 +37,7 @@ export function JobNotesComponent({ setNoteUpsertContext, deleteLoading, ro_number, + relatedRos, }) { const { t } = useTranslation(); const Templates = TemplateList("job_special", { @@ -149,6 +150,7 @@ export function JobNotesComponent({ actions: { refetch: refetch }, context: { jobId: jobId, + relatedRos: relatedRos, }, }); }} diff --git a/client/src/components/note-upsert-modal/note-upsert-modal.component.jsx b/client/src/components/note-upsert-modal/note-upsert-modal.component.jsx index 6d13d0bb0..d9b8ca9bc 100644 --- a/client/src/components/note-upsert-modal/note-upsert-modal.component.jsx +++ b/client/src/components/note-upsert-modal/note-upsert-modal.component.jsx @@ -1,51 +1,92 @@ -import { Col, Form, Input, Row, Switch } from "antd"; +import { Checkbox, Col, Form, Input, Row, Space, Switch, Tag } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectNoteUpsert } from "../../redux/modals/modals.selectors"; import NotesPresetButton from "../notes-preset-button/notes-preset-button.component"; -export default function NoteUpsertModalComponent({ form }) { +const mapStateToProps = createStructuredSelector({ + noteUpsertModal: selectNoteUpsert, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); +export default connect( + mapStateToProps, + mapDispatchToProps +)(NoteUpsertModalComponent); + +export function NoteUpsertModalComponent({ form, noteUpsertModal }) { const { t } = useTranslation(); + const { jobId, existingNote, relatedRos } = noteUpsertModal.context; + + const filteredRelatedRos = relatedRos + ? relatedRos.filter((j) => j.id !== jobId) + : []; return ( - - - - - - - - - - - - - - - - - - - - + <> + + + + + + + + + + + + + + + + + + + + +
+
{!existingNote && t("notes.labels.addtorelatedro")}
+ {!existingNote && + filteredRelatedRos.map((j, idx) => ( + + + + + + {`${j.ro_number || "N/A"}${j.clm_no ? ` | ${j.clm_no}` : ""}${ + j.status ? ` | ${j.status}` : "" + }`} + + + ))} +
+ ); } diff --git a/client/src/components/note-upsert-modal/note-upsert-modal.container.jsx b/client/src/components/note-upsert-modal/note-upsert-modal.container.jsx index 38d83a302..6d29589a5 100644 --- a/client/src/components/note-upsert-modal/note-upsert-modal.container.jsx +++ b/client/src/components/note-upsert-modal/note-upsert-modal.container.jsx @@ -4,14 +4,14 @@ import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; +import { logImEXEvent } from "../../firebase/firebase.utils"; import { INSERT_NEW_NOTE, UPDATE_NOTE } from "../../graphql/notes.queries"; +import { insertAuditTrail } from "../../redux/application/application.actions"; import { toggleModalVisible } from "../../redux/modals/modals.actions"; import { selectNoteUpsert } from "../../redux/modals/modals.selectors"; import { selectCurrentUser } from "../../redux/user/user.selectors"; -import NoteUpsertModalComponent from "./note-upsert-modal.component"; -import { logImEXEvent } from "../../firebase/firebase.utils"; -import { insertAuditTrail } from "../../redux/application/application.actions"; import AuditTrailMapping from "../../utils/AuditTrailMappings"; +import NoteUpsertModalComponent from "./note-upsert-modal.component"; const mapStateToProps = createStructuredSelector({ currentUser: selectCurrentUser, @@ -48,7 +48,9 @@ export function NoteUpsertModalContainer({ } }, [existingNote, form, visible]); - const handleFinish = (values) => { + const handleFinish = async (formValues) => { + const { relatedros, ...values } = formValues; + if (existingNote) { logImEXEvent("job_note_update"); @@ -70,24 +72,48 @@ export function NoteUpsertModalContainer({ toggleModalVisible(); } else { logImEXEvent("job_note_insert"); + const AdditionalNoteInserts = Object.keys(relatedros).filter( + (key) => relatedros[key] + ); + console.log( + "🚀 ~ file: note-upsert-modal.container.jsx ~ line 78 ~ handleFinish ~ AdditionalNoteInserts", + AdditionalNoteInserts + ); - insertNote({ + await insertNote({ variables: { noteInput: [ { ...values, jobid: jobId, created_by: currentUser.email }, ], }, - }).then((r) => { - if (refetch) refetch(); - form.resetFields(); - toggleModalVisible(); - notification["success"]({ - message: t("notes.successes.create"), - }); - insertAuditTrail({ - jobid: context.jobId, - operation: AuditTrailMapping.jobnoteadded(), + }); + + if (AdditionalNoteInserts.length > 0) { + //Insert the others. + AdditionalNoteInserts.forEach(async (newJobId) => { + await insertNote({ + variables: { + noteInput: [ + { ...values, jobid: newJobId, created_by: currentUser.email }, + ], + }, + }); + insertAuditTrail({ + jobid: newJobId, + operation: AuditTrailMapping.jobnoteadded(), + }); }); + } + + if (refetch) refetch(); + form.resetFields(); + toggleModalVisible(); + notification["success"]({ + message: t("notes.successes.create"), + }); + insertAuditTrail({ + jobid: context.jobId, + operation: AuditTrailMapping.jobnoteadded(), }); } }; diff --git a/client/src/components/notes-preset-button/notes-preset-button.component.jsx b/client/src/components/notes-preset-button/notes-preset-button.component.jsx index 87412ec8c..97eaf36b6 100644 --- a/client/src/components/notes-preset-button/notes-preset-button.component.jsx +++ b/client/src/components/notes-preset-button/notes-preset-button.component.jsx @@ -24,7 +24,7 @@ export function NotesPresetButton({ bodyshop, form }) { const menu = ( {bodyshop.md_notes_presets.map((i, idx) => ( - handleSelect(i)} onItemHover key={idx}> + handleSelect(i)} key={idx}> {i.label} ))} diff --git a/client/src/graphql/notes.queries.js b/client/src/graphql/notes.queries.js index 58c9d2f19..41b605515 100644 --- a/client/src/graphql/notes.queries.js +++ b/client/src/graphql/notes.queries.js @@ -15,6 +15,14 @@ export const QUERY_NOTES_BY_JOB_PK = gql` jobs_by_pk(id: $id) { id ro_number + vehicle{ + jobs{ + id + ro_number + status + clm_no + } + } notes { created_at created_by diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 63da962fd..94e8b10ec 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1861,6 +1861,7 @@ "updatedat": "Updated At" }, "labels": { + "addtorelatedro": "Add to Related ROs", "newnoteplaceholder": "Add a note...", "notetoadd": "Note to Add" }, diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index ab3b309f8..1f67a1107 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1861,6 +1861,7 @@ "updatedat": "Actualizado en" }, "labels": { + "addtorelatedro": "", "newnoteplaceholder": "Agrega una nota...", "notetoadd": "" }, diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index bde81f6b8..8d609b5a5 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1861,6 +1861,7 @@ "updatedat": "Mis à jour à" }, "labels": { + "addtorelatedro": "", "newnoteplaceholder": "Ajouter une note...", "notetoadd": "" },