BOD-35 Refactored email screen to use TinyMCE + added templates schema + base level email generation
This commit is contained in:
@@ -3,7 +3,7 @@ import ScheduleJobModalComponent from "./schedule-job-modal.component";
|
||||
import { useMutation, useQuery } from "@apollo/react-hooks";
|
||||
import {
|
||||
INSERT_APPOINTMENT,
|
||||
QUERY_APPOINTMENTS_BY_JOBID
|
||||
QUERY_APPOINTMENTS_BY_JOBID,
|
||||
} from "../../graphql/appointments.queries";
|
||||
import moment from "moment";
|
||||
import { notification, Modal } from "antd";
|
||||
@@ -18,31 +18,29 @@ import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
scheduleModal: selectSchedule
|
||||
scheduleModal: selectSchedule,
|
||||
});
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
toggleModalVisible: () => dispatch(toggleModalVisible("schedule"))
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
toggleModalVisible: () => dispatch(toggleModalVisible("schedule")),
|
||||
});
|
||||
export function ScheduleJobModalContainer({
|
||||
scheduleModal,
|
||||
bodyshop,
|
||||
toggleModalVisible
|
||||
toggleModalVisible,
|
||||
}) {
|
||||
const { visible, context, actions } = scheduleModal;
|
||||
const { jobId } = context;
|
||||
const { refetch } = actions;
|
||||
|
||||
const [appData, setAppData] = useState({
|
||||
jobid: jobId,
|
||||
start: null,
|
||||
bodyshopid: bodyshop.id
|
||||
});
|
||||
const [insertAppointment] = useMutation(INSERT_APPOINTMENT);
|
||||
const [updateJobStatus] = useMutation(UPDATE_JOB_STATUS, {
|
||||
variables: {
|
||||
jobId: jobId,
|
||||
status: bodyshop.md_ro_statuses.default_scheduled
|
||||
}
|
||||
status: bodyshop.md_ro_statuses.default_scheduled,
|
||||
},
|
||||
});
|
||||
const [formData, setFormData] = useState({ notifyCustomer: false });
|
||||
const { t } = useTranslation();
|
||||
@@ -50,20 +48,25 @@ export function ScheduleJobModalContainer({
|
||||
const existingAppointments = useQuery(QUERY_APPOINTMENTS_BY_JOBID, {
|
||||
variables: { jobid: jobId },
|
||||
fetchPolicy: "network-only",
|
||||
skip: !visible
|
||||
skip: !visible,
|
||||
});
|
||||
|
||||
//TODO Customize the amount of minutes it will add.
|
||||
const handleOk = () => {
|
||||
insertAppointment({
|
||||
variables: {
|
||||
app: { ...appData, end: moment(appData.start).add(60, "minutes") }
|
||||
}
|
||||
app: {
|
||||
...appData,
|
||||
jobid: jobId,
|
||||
bodyshopid: bodyshop.id,
|
||||
end: moment(appData.start).add(60, "minutes"),
|
||||
},
|
||||
},
|
||||
})
|
||||
.then(r => {
|
||||
updateJobStatus().then(r => {
|
||||
.then((r) => {
|
||||
updateJobStatus().then((r) => {
|
||||
notification["success"]({
|
||||
message: t("appointments.successes.created")
|
||||
message: t("appointments.successes.created"),
|
||||
});
|
||||
|
||||
if (formData.notifyCustomer) {
|
||||
@@ -74,11 +77,11 @@ export function ScheduleJobModalContainer({
|
||||
if (refetch) refetch();
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
notification["error"]({
|
||||
message: t("appointments.errors.saving", {
|
||||
message: error.message
|
||||
})
|
||||
message: error.message,
|
||||
}),
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user