Table updates for new appointments fields. Schedule modal baseline functionality. Refactor schedule components to be more reusable.

This commit is contained in:
Patrick Fic
2020-02-06 13:39:39 -08:00
parent 1a14fb8da6
commit fae1e8cdeb
35 changed files with 785 additions and 67 deletions

View File

@@ -3,7 +3,8 @@ import ScheduleJobModalComponent from "./schedule-job-modal.component";
import { useMutation } from "react-apollo";
import { INSERT_APPOINTMENT } from "../../graphql/appointments.queries";
import moment from "moment";
import { notification } from "antd";
import { useTranslation } from "react-i18next";
export default function ScheduleJobModalContainer({
scheduleModalState,
jobId
@@ -11,11 +12,15 @@ export default function ScheduleJobModalContainer({
const [scheduleModalVisible, setscheduleModalVisible] = scheduleModalState;
const [appData, setAppData] = useState({ jobid: jobId, start: null });
const [insertAppointment] = useMutation(INSERT_APPOINTMENT);
const [formData, setFormData] = useState({ notifyCustomer: false });
const { t } = useTranslation();
return (
<ScheduleJobModalComponent
appData={appData}
setAppData={setAppData}
formData={formData}
setFormData={setFormData}
//Spreadable Modal Props
visible={scheduleModalVisible}
onCancel={() => setscheduleModalVisible(false)}
@@ -25,9 +30,25 @@ export default function ScheduleJobModalContainer({
variables: {
app: { ...appData, end: moment(appData.start).add(60, "minutes") }
}
}).then(r => {
setscheduleModalVisible(false);
});
})
.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);
})
.catch(error => {
notification["error"]({
message: t("appointments.errors.saving", {
message: error.message
})
});
});
}}
/>
);