diff --git a/client/src/App/App.container.jsx b/client/src/App/App.container.jsx index 94dfd25e6..88cb569d8 100644 --- a/client/src/App/App.container.jsx +++ b/client/src/App/App.container.jsx @@ -92,7 +92,7 @@ const authLink = setContext((_, { headers }) => { const retryLink = new RetryLink({ delay: { - initial: 300, + initial: 500, max: 5, jitter: true, }, diff --git a/client/src/components/schedule-event/schedule-event.container.jsx b/client/src/components/schedule-event/schedule-event.container.jsx index 62aa31b38..c35c03e54 100644 --- a/client/src/components/schedule-event/schedule-event.container.jsx +++ b/client/src/components/schedule-event/schedule-event.container.jsx @@ -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 ;