Fixed canceling appointment not updating job. BOD-121

This commit is contained in:
Patrick Fic
2020-06-03 21:49:27 -07:00
parent 7d4e73320d
commit 4af463d39c
2 changed files with 23 additions and 11 deletions

View File

@@ -92,7 +92,7 @@ const authLink = setContext((_, { headers }) => {
const retryLink = new RetryLink({
delay: {
initial: 300,
initial: 500,
max: 5,
jitter: true,
},

View File

@@ -1,23 +1,35 @@
import React from "react";
import { useMutation } from "@apollo/react-hooks";
import { CANCEL_APPOINTMENT_BY_ID } from "../../graphql/appointments.queries";
import { UPDATE_JOB } from "../../graphql/jobs.queries";
import ScheduleEventComponent from "./schedule-event.component";
import { notification } from "antd";
import { useTranslation } from "react-i18next";
export default function ScheduleEventContainer({ event, refetch }) {
const { t } = useTranslation();
const [cancelAppointment] = useMutation(CANCEL_APPOINTMENT_BY_ID);
const handleCancel = id => {
cancelAppointment({ variables: { appid: event.id } })
.then(r => {
notification["success"]({
message: t("appointments.successes.canceled")
});
if (refetch) refetch();
})
.catch(error => {
notification["error"]({ message: t("appointments.errors.canceling") });
const [updateJob] = useMutation(UPDATE_JOB);
const handleCancel = async (id) => {
try {
await cancelAppointment({ variables: { appid: event.id } });
notification["success"]({
message: t("appointments.successes.canceled"),
});
await updateJob({
variables: {
jobId: event.job.id,
job: {
date_scheduled: null,
scheduled_in: null,
},
},
});
if (refetch) refetch();
} catch (error) {
notification["error"]({ message: t("appointments.errors.canceling") });
}
};
return <ScheduleEventComponent event={event} handleCancel={handleCancel} />;