diff --git a/client/src/components/job-audit-trail/job-audit-trail.component.jsx b/client/src/components/job-audit-trail/job-audit-trail.component.jsx index e6015c381..e58c285d1 100644 --- a/client/src/components/job-audit-trail/job-audit-trail.component.jsx +++ b/client/src/components/job-audit-trail/job-audit-trail.component.jsx @@ -40,7 +40,7 @@ export default function JobAuditTrail({ jobId }) { title: t("audit.fields.created"), dataIndex: " created_at", key: " created_at", - width: "10%", + render: (text, record) => ( {record.created_at} ), @@ -50,14 +50,13 @@ export default function JobAuditTrail({ jobId }) { title: t("audit.fields.useremail"), dataIndex: "useremail", key: "useremail", - width: "10%", }, { title: t("audit.fields.to"), dataIndex: "to", key: "to", - width: "10%", + render: (text, record) => record.to && record.to.map((email, idx) => {email}), @@ -66,7 +65,7 @@ export default function JobAuditTrail({ jobId }) { title: t("audit.fields.cc"), dataIndex: "cc", key: "cc", - width: "10%", + render: (text, record) => record.cc && record.cc.map((email, idx) => {email}), @@ -75,7 +74,6 @@ export default function JobAuditTrail({ jobId }) { title: t("audit.fields.subject"), dataIndex: "subject", key: "subject", - width: "10%", }, // { // title: t("audit.fields.contents"), diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addevent.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addevent.jsx new file mode 100644 index 000000000..164769063 --- /dev/null +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addevent.jsx @@ -0,0 +1,149 @@ +import { useMutation } from "@apollo/client"; +import { Button, Card, Form, Input, Menu, Popover, Select, Space } from "antd"; +import moment from "moment"; +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { logImEXEvent } from "../../firebase/firebase.utils"; +import { INSERT_MANUAL_APPT } from "../../graphql/appointments.queries"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +import FormDateTimePickerComponent from "../form-date-time-picker/form-date-time-picker.component"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); +export default connect( + mapStateToProps, + mapDispatchToProps +)(JobsDetailHeaderAddEvent); + +export function JobsDetailHeaderAddEvent({ bodyshop, jobid, ...props }) { + const { t } = useTranslation(); + const [insertAppointment] = useMutation(INSERT_MANUAL_APPT); + + const [loading, setLoading] = useState(false); + const [form] = Form.useForm(); + const [visibility, setVisibility] = useState(false); + + const handleFinish = async (values) => { + logImEXEvent("schedule_manual_event"); + + setLoading(true); + try { + insertAppointment({ + variables: { + apt: { ...values, isintake: false, jobid, bodyshopid: bodyshop.id }, + }, + refetchQueries: ["QUERY_ALL_ACTIVE_APPOINTMENTS"], + }); + } catch (error) { + console.log(error); + } finally { + setLoading(false); + setVisibility(false); + } + }; + + const overlay = ( + +
+
+ + + + + + + + { + const start = form.getFieldValue("start"); + form.setFieldsValue({ end: start.add(30, "minutes") }); + }} + /> + + ({ + async validator(rule, value) { + if (value) { + const { start } = form.getFieldsValue(); + if (moment(start).isAfter(moment(value))) { + return Promise.reject( + t("employees.labels.endmustbeafterstart") + ); + } else { + return Promise.resolve(); + } + } else { + return Promise.resolve(); + } + }, + }), + ]} + > + + + + + + + + + + +
+
+
+ ); + + const handleClick = (e) => { + setVisibility(true); + }; + + return ( + + + {t("appointments.labels.manualevent")} + + + ); +} diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx index 7cac639e9..5002a0e5d 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx @@ -15,6 +15,7 @@ import { selectBodyshop, selectCurrentUser, } from "../../redux/user/user.selectors"; +import JobsDetailHeaderActionsAddevent from "./jobs-detail-header-actions.addevent"; import AddToProduction from "./jobs-detail-header-actions.addtoproduction.util"; import JobsDetaiLheaderCsi from "./jobs-detail-header-actions.csi.component"; import DuplicateJob from "./jobs-detail-header-actions.duplicate.util"; @@ -421,6 +422,7 @@ export function JobsDetailHeaderActions({ )} + {!jobRO && job.converted && (