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