diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 3686dcf30..7b07e622e 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -29415,6 +29415,32 @@ + + errors + + + inserting + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + fields @@ -29549,6 +29575,27 @@ + + notetoadd + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + diff --git a/client/src/components/production-list-columns/production-list-columns.data.js b/client/src/components/production-list-columns/production-list-columns.data.js index 031c49e32..027cfcc32 100644 --- a/client/src/components/production-list-columns/production-list-columns.data.js +++ b/client/src/components/production-list-columns/production-list-columns.data.js @@ -15,6 +15,7 @@ import ProductionListColumnPaintPriority from "./production-list-columns.paintpr import ProductionListColumnNote from "./production-list-columns.productionnote.component"; import ProductionListColumnStatus from "./production-list-columns.status.component"; import ProductionlistColumnTouchTime from "./prodution-list-columns.touchtime.component"; +import ProductionListLastContacted from "./production-list-columns.lastcontacted.component"; const r = ({ technician, state }) => { return [ @@ -106,9 +107,7 @@ const r = ({ technician, state }) => { sortOrder: state.sortedInfo.columnKey === "date_last_contacted" && state.sortedInfo.order, - render: (text, record) => ( - - ), + render: (text, record) => , }, { title: i18n.t("jobs.fields.scheduled_delivery"), diff --git a/client/src/components/production-list-columns/production-list-columns.lastcontacted.component.jsx b/client/src/components/production-list-columns/production-list-columns.lastcontacted.component.jsx new file mode 100644 index 000000000..94c68674b --- /dev/null +++ b/client/src/components/production-list-columns/production-list-columns.lastcontacted.component.jsx @@ -0,0 +1,132 @@ +import { useMutation } from "@apollo/client"; +import { Button, Card, Dropdown, Form, Input, notification, Space } from "antd"; +import moment from "moment"; +import React, { useState, useEffect } from "react"; +import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { logImEXEvent } from "../../firebase/firebase.utils"; +import { UPDATE_JOB } from "../../graphql/jobs.queries"; +import { INSERT_NEW_NOTE } from "../../graphql/notes.queries"; +import { selectCurrentUser } from "../../redux/user/user.selectors"; +import { DateFormatter } from "../../utils/DateFormatter"; +import FormDateTimePickerComponent from "../form-date-time-picker/form-date-time-picker.component"; + +const mapStateToProps = createStructuredSelector({ + currentUser: selectCurrentUser, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); +export default connect( + mapStateToProps, + mapDispatchToProps +)(ProductionLastContacted); + +export function ProductionLastContacted({ currentUser, record }) { + const [updateAlert] = useMutation(UPDATE_JOB); + const [insertNote] = useMutation(INSERT_NEW_NOTE); + const [visible, setVisible] = useState(false); + const { t } = useTranslation(); + const [form] = Form.useForm(); + const handleFinish = async ({ date_last_contacted, note }) => { + logImEXEvent("production_last_contacted"); + + //e.stopPropagation(); + const res = await updateAlert({ + variables: { + jobId: record.id, + job: { + date_last_contacted, + }, + }, + }); + if (res.errors) { + notification.open({ + type: "error", + message: t("jobs.errors.saving", { + error: JSON.stringify(res.errors), + }), + }); + } + if (note && note.trim() !== "") { + //Insert a note. + const res2 = await insertNote({ + variables: { + noteInput: { + jobid: record.id, + text: note, + created_by: currentUser.email, + }, + }, + }); + if (res2.errors) { + notification.open({ + type: "error", + message: t("notes.errors.inserting", { + error: JSON.stringify(res.errors), + }), + }); + } + } + if (record.refetch) record.refetch(); + + setVisible(false); + }; + + useEffect(() => { + if (visible) { + form.setFieldsValue({ + note: null, + date_last_contacted: + record.date_last_contacted && moment(record.date_last_contacted), + }); + } + }, [visible, form, record.date_last_contacted]); + + return ( +
+ e.stopPropagation()} + > +
+ + + + + + + + + + +
+ + } + > +
setVisible(true)} + style={{ + height: "19px", + }} + > + + {record.date_last_contacted} + +
+
+
+ ); +} diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 7a1590ba5..ba295c6bc 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1739,6 +1739,9 @@ "edit": "Edit Note", "new": "New Note" }, + "errors": { + "inserting": "Error inserting note. {{error}}" + }, "fields": { "createdby": "Created By", "critical": "Critical", @@ -1747,7 +1750,8 @@ "updatedat": "Updated At" }, "labels": { - "newnoteplaceholder": "Add a note..." + "newnoteplaceholder": "Add a note...", + "notetoadd": "Note to Add" }, "successes": { "create": "Note created successfully.", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 6ce6c9bc8..679ce223d 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1739,6 +1739,9 @@ "edit": "Editar nota", "new": "Nueva nota" }, + "errors": { + "inserting": "" + }, "fields": { "createdby": "Creado por", "critical": "Crítico", @@ -1747,7 +1750,8 @@ "updatedat": "Actualizado en" }, "labels": { - "newnoteplaceholder": "Agrega una nota..." + "newnoteplaceholder": "Agrega una nota...", + "notetoadd": "" }, "successes": { "create": "Nota creada con éxito.", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 7198486db..aab0aa3b3 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1739,6 +1739,9 @@ "edit": "Note éditée", "new": "Nouvelle note" }, + "errors": { + "inserting": "" + }, "fields": { "createdby": "Créé par", "critical": "Critique", @@ -1747,7 +1750,8 @@ "updatedat": "Mis à jour à" }, "labels": { - "newnoteplaceholder": "Ajouter une note..." + "newnoteplaceholder": "Ajouter une note...", + "notetoadd": "" }, "successes": { "create": "Remarque créée avec succès.",