Change status on scheduling.
This commit is contained in:
@@ -78,9 +78,7 @@ export default connect(
|
||||
const statusmenu = (
|
||||
<Menu
|
||||
onClick={e => {
|
||||
updateJobStatus({
|
||||
variables: { jobId: job.id, status: e.key }
|
||||
}).then(r => refetch());
|
||||
updateJobStatus(e.key);
|
||||
}}
|
||||
>
|
||||
{bodyshop.md_ro_statuses.statuses.map(item => (
|
||||
|
||||
@@ -22,49 +22,51 @@ export default function ScheduleJobModalComponent({
|
||||
destroyOnClose={true}
|
||||
okButtonProps={{ disabled: appData.start ? false : true }}
|
||||
>
|
||||
<ScheduleExistingAppointmentsList
|
||||
existingAppointments={existingAppointments}
|
||||
/>
|
||||
<Tabs defaultActiveKey="1">
|
||||
<Tabs.TabPane tab="SMART Scheduling" key="auto">
|
||||
Automatic Job Selection.
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="Manual Scheduling" key="manual">
|
||||
<Row>
|
||||
<Col span={14}>
|
||||
Manual Job Selection Scheduled Time
|
||||
<DatePicker
|
||||
value={appData.start}
|
||||
onChange={e => {
|
||||
setAppData({ ...appData, start: e });
|
||||
}}
|
||||
/>
|
||||
<TimePicker
|
||||
value={appData.start}
|
||||
format={"HH:mm"}
|
||||
minuteStep={15}
|
||||
onChange={e => {
|
||||
setAppData({ ...appData, start: e });
|
||||
}}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={10}>
|
||||
<ScheduleDayViewContainer day={appData.start} />
|
||||
</Col>
|
||||
</Row>
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
{
|
||||
//TODO: Build out notifications.
|
||||
}
|
||||
<Checkbox
|
||||
defaultChecked={formData.notifyCustomer}
|
||||
onChange={e =>
|
||||
setFormData({ ...formData, notifyCustomer: e.target.checked })
|
||||
}
|
||||
>
|
||||
{t("jobs.labels.appointmentconfirmation")}
|
||||
</Checkbox>
|
||||
<Row>
|
||||
<Col span={14}>
|
||||
<Tabs defaultActiveKey="1">
|
||||
<Tabs.TabPane tab="SMART Scheduling" key="auto">
|
||||
Automatic Job Selection.
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="Manual Scheduling" key="manual">
|
||||
<Row>
|
||||
Manual Job Selection Scheduled Time
|
||||
<DatePicker
|
||||
value={appData.start}
|
||||
onChange={e => {
|
||||
setAppData({ ...appData, start: e });
|
||||
}}
|
||||
/>
|
||||
<TimePicker
|
||||
value={appData.start}
|
||||
format={"HH:mm"}
|
||||
minuteStep={15}
|
||||
onChange={e => {
|
||||
setAppData({ ...appData, start: e });
|
||||
}}
|
||||
/>
|
||||
</Row>
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
<ScheduleExistingAppointmentsList
|
||||
existingAppointments={existingAppointments}
|
||||
/>
|
||||
{
|
||||
//TODO: Build out notifications.
|
||||
}
|
||||
<Checkbox
|
||||
defaultChecked={formData.notifyCustomer}
|
||||
onChange={e =>
|
||||
setFormData({ ...formData, notifyCustomer: e.target.checked })
|
||||
}
|
||||
>
|
||||
{t("jobs.labels.appointmentconfirmation")}
|
||||
</Checkbox>
|
||||
</Col>
|
||||
<Col span={10}>
|
||||
<ScheduleDayViewContainer day={appData.start} />
|
||||
</Col>
|
||||
</Row>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,17 +8,39 @@ import {
|
||||
import moment from "moment";
|
||||
import { notification } from "antd";
|
||||
import { useTranslation } from "react-i18next";
|
||||
export default function ScheduleJobModalContainer({
|
||||
import { UPDATE_JOB_STATUS } from "../../graphql/jobs.queries";
|
||||
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
null
|
||||
)(function ScheduleJobModalContainer({
|
||||
scheduleModalState,
|
||||
jobId
|
||||
jobId,
|
||||
bodyshop,
|
||||
refetch
|
||||
}) {
|
||||
const existingAppointments = useQuery(QUERY_APPOINTMENTS_BY_JOBID, {
|
||||
variables: { jobid: jobId },
|
||||
fetchPolicy: "network-only"
|
||||
fetchPolicy: "network-only",
|
||||
skip: !jobId
|
||||
});
|
||||
const [scheduleModalVisible, setscheduleModalVisible] = scheduleModalState;
|
||||
const [appData, setAppData] = useState({ jobid: jobId, start: null });
|
||||
const [insertAppointment] = useMutation(INSERT_APPOINTMENT);
|
||||
const [updateJobStatus] = useMutation(UPDATE_JOB_STATUS, {
|
||||
variables: {
|
||||
jobId: jobId,
|
||||
status: bodyshop.md_ro_statuses.default_scheduled
|
||||
}
|
||||
});
|
||||
const [formData, setFormData] = useState({ notifyCustomer: false });
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -40,15 +62,18 @@ export default function ScheduleJobModalContainer({
|
||||
}
|
||||
})
|
||||
.then(r => {
|
||||
notification["success"]({
|
||||
message: t("appointments.successes.created")
|
||||
});
|
||||
updateJobStatus().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);
|
||||
if (formData.notifyCustomer) {
|
||||
//TODO: Implement customer reminder on scheduling.
|
||||
alert("Chosed to notify the customer somehow!");
|
||||
}
|
||||
setscheduleModalVisible(false);
|
||||
if (refetch) refetch();
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
notification["error"]({
|
||||
@@ -60,4 +85,4 @@ export default function ScheduleJobModalContainer({
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -47,6 +47,7 @@ export default function JobsDetailPage({
|
||||
<ScheduleJobModalContainer
|
||||
scheduleModalState={scheduleModalState}
|
||||
jobId={job.id}
|
||||
refetch={refetch}
|
||||
/>
|
||||
|
||||
<Form onSubmit={handleSubmit} {...formItemLayout} autoComplete={"off"}>
|
||||
|
||||
@@ -25,7 +25,22 @@ function JobsDetailPageContainer({ match, form }) {
|
||||
});
|
||||
const [mutationUpdateJob] = useMutation(UPDATE_JOB);
|
||||
const [mutationConvertJob] = useMutation(CONVERT_JOB_TO_RO);
|
||||
const [updateJobStatus] = useMutation(UPDATE_JOB_STATUS);
|
||||
const [mutationUpdateJobstatus] = useMutation(UPDATE_JOB_STATUS);
|
||||
|
||||
const updateJobStatus = status => {
|
||||
mutationUpdateJobstatus({
|
||||
variables: { jobId: jobId, status: status }
|
||||
})
|
||||
.then(r => {
|
||||
notification["success"]({ message: t("jobs.successes.save") });
|
||||
refetch();
|
||||
})
|
||||
.catch(error => {
|
||||
//TODO Error handling.
|
||||
console.log("error", error);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
document.title = loading
|
||||
? t("titles.app")
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
"converted": "Job converted successfully.",
|
||||
"created": "Job created successfully. Click to view.",
|
||||
"deleted": "Job deleted successfully.",
|
||||
"save": "Record Saved",
|
||||
"save": "Job saved successfully.",
|
||||
"savetitle": "Record saved successfully."
|
||||
}
|
||||
},
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
"converted": "Trabajo convertido con éxito.",
|
||||
"created": "Trabajo creado con éxito. Click para ver.",
|
||||
"deleted": "Trabajo eliminado con éxito.",
|
||||
"save": "Registro guardado",
|
||||
"save": "Trabajo guardado con éxito.",
|
||||
"savetitle": "Registro guardado con éxito."
|
||||
}
|
||||
},
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
"converted": "Travail converti avec succès.",
|
||||
"created": "Le travail a été créé avec succès. Clique pour voir.",
|
||||
"deleted": "Le travail a bien été supprimé.",
|
||||
"save": "Enregistrement enregistré",
|
||||
"save": "Le travail a été enregistré avec succès.",
|
||||
"savetitle": "Enregistrement enregistré avec succès."
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user