Change status on scheduling.

This commit is contained in:
Patrick Fic
2020-02-06 16:33:40 -08:00
parent d422edcb0e
commit acdc17e91b
8 changed files with 103 additions and 62 deletions

View File

@@ -8,17 +8,39 @@ import {
import moment from "moment";
import { notification } from "antd";
import { useTranslation } from "react-i18next";
export default function ScheduleJobModalContainer({
import { UPDATE_JOB_STATUS } from "../../graphql/jobs.queries";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop
});
export default connect(
mapStateToProps,
null
)(function ScheduleJobModalContainer({
scheduleModalState,
jobId
jobId,
bodyshop,
refetch
}) {
const existingAppointments = useQuery(QUERY_APPOINTMENTS_BY_JOBID, {
variables: { jobid: jobId },
fetchPolicy: "network-only"
fetchPolicy: "network-only",
skip: !jobId
});
const [scheduleModalVisible, setscheduleModalVisible] = scheduleModalState;
const [appData, setAppData] = useState({ jobid: jobId, start: null });
const [insertAppointment] = useMutation(INSERT_APPOINTMENT);
const [updateJobStatus] = useMutation(UPDATE_JOB_STATUS, {
variables: {
jobId: jobId,
status: bodyshop.md_ro_statuses.default_scheduled
}
});
const [formData, setFormData] = useState({ notifyCustomer: false });
const { t } = useTranslation();
@@ -40,15 +62,18 @@ export default function ScheduleJobModalContainer({
}
})
.then(r => {
notification["success"]({
message: t("appointments.successes.created")
});
updateJobStatus().then(r => {
notification["success"]({
message: t("appointments.successes.created")
});
if (formData.notifyCustomer) {
//TODO: Implement customer reminder on scheduling.
alert("Chosed to notify the customer somehow!");
}
setscheduleModalVisible(false);
if (formData.notifyCustomer) {
//TODO: Implement customer reminder on scheduling.
alert("Chosed to notify the customer somehow!");
}
setscheduleModalVisible(false);
if (refetch) refetch();
});
})
.catch(error => {
notification["error"]({
@@ -60,4 +85,4 @@ export default function ScheduleJobModalContainer({
}}
/>
);
}
});