Fixed canceling appointment not updating job. BOD-121
This commit is contained in:
@@ -92,7 +92,7 @@ const authLink = setContext((_, { headers }) => {
|
||||
|
||||
const retryLink = new RetryLink({
|
||||
delay: {
|
||||
initial: 300,
|
||||
initial: 500,
|
||||
max: 5,
|
||||
jitter: true,
|
||||
},
|
||||
|
||||
@@ -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} />;
|
||||
|
||||
Reference in New Issue
Block a user