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({
|
const retryLink = new RetryLink({
|
||||||
delay: {
|
delay: {
|
||||||
initial: 300,
|
initial: 500,
|
||||||
max: 5,
|
max: 5,
|
||||||
jitter: true,
|
jitter: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,23 +1,35 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { useMutation } from "@apollo/react-hooks";
|
import { useMutation } from "@apollo/react-hooks";
|
||||||
import { CANCEL_APPOINTMENT_BY_ID } from "../../graphql/appointments.queries";
|
import { CANCEL_APPOINTMENT_BY_ID } from "../../graphql/appointments.queries";
|
||||||
|
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||||
import ScheduleEventComponent from "./schedule-event.component";
|
import ScheduleEventComponent from "./schedule-event.component";
|
||||||
import { notification } from "antd";
|
import { notification } from "antd";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
export default function ScheduleEventContainer({ event, refetch }) {
|
export default function ScheduleEventContainer({ event, refetch }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [cancelAppointment] = useMutation(CANCEL_APPOINTMENT_BY_ID);
|
const [cancelAppointment] = useMutation(CANCEL_APPOINTMENT_BY_ID);
|
||||||
const handleCancel = id => {
|
const [updateJob] = useMutation(UPDATE_JOB);
|
||||||
cancelAppointment({ variables: { appid: event.id } })
|
const handleCancel = async (id) => {
|
||||||
.then(r => {
|
try {
|
||||||
notification["success"]({
|
await cancelAppointment({ variables: { appid: event.id } });
|
||||||
message: t("appointments.successes.canceled")
|
notification["success"]({
|
||||||
});
|
message: t("appointments.successes.canceled"),
|
||||||
if (refetch) refetch();
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
notification["error"]({ message: t("appointments.errors.canceling") });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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} />;
|
return <ScheduleEventComponent event={event} handleCancel={handleCancel} />;
|
||||||
|
|||||||
Reference in New Issue
Block a user