CLEANUP Schedule modal now using redux. Deleted manual schedule modal. To be incorporated into generic.
This commit is contained in:
@@ -24,24 +24,25 @@ import BarcodePopup from "../barcode-popup/barcode-popup.component";
|
|||||||
import OwnerTagPopoverComponent from "../owner-tag-popover/owner-tag-popover.component";
|
import OwnerTagPopoverComponent from "../owner-tag-popover/owner-tag-popover.component";
|
||||||
import VehicleTagPopoverComponent from "../vehicle-tag-popover/vehicle-tag-popover.component";
|
import VehicleTagPopoverComponent from "../vehicle-tag-popover/vehicle-tag-popover.component";
|
||||||
import JobsDetailHeaderActions from "../jobs-detail-header-actions/jobs-detail-header-actions.component";
|
import JobsDetailHeaderActions from "../jobs-detail-header-actions/jobs-detail-header-actions.component";
|
||||||
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop
|
bodyshop: selectBodyshop
|
||||||
});
|
});
|
||||||
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
setScheduleContext: context =>
|
||||||
|
dispatch(setModalContext({ context: context, modal: "schedule" }))
|
||||||
|
});
|
||||||
|
|
||||||
export default connect(
|
export function JobsDetailHeader({
|
||||||
mapStateToProps,
|
|
||||||
null
|
|
||||||
)(function JobsDetailHeader({
|
|
||||||
job,
|
job,
|
||||||
mutationConvertJob,
|
mutationConvertJob,
|
||||||
refetch,
|
refetch,
|
||||||
scheduleModalState,
|
|
||||||
bodyshop,
|
bodyshop,
|
||||||
updateJobStatus
|
updateJobStatus,
|
||||||
|
setScheduleContext
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const setscheduleModalVisible = scheduleModalState[1];
|
|
||||||
|
|
||||||
const tombstoneTitle = (
|
const tombstoneTitle = (
|
||||||
<div>
|
<div>
|
||||||
@@ -74,7 +75,12 @@ export default connect(
|
|||||||
<Button
|
<Button
|
||||||
//TODO Enabled logic based on status.
|
//TODO Enabled logic based on status.
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setscheduleModalVisible(true);
|
setScheduleContext({
|
||||||
|
actions: { refetch: refetch },
|
||||||
|
context: {
|
||||||
|
jobId: job.id
|
||||||
|
}
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t("jobs.actions.schedule")}
|
{t("jobs.actions.schedule")}
|
||||||
@@ -163,4 +169,6 @@ export default connect(
|
|||||||
</Descriptions>
|
</Descriptions>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(JobsDetailHeader);
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
import { Checkbox, Col, DatePicker, Modal, Row, TimePicker, Input } from "antd";
|
|
||||||
import React from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import ScheduleDayViewContainer from "../schedule-day-view/schedule-day-view.container";
|
|
||||||
|
|
||||||
export default function ScheduleJobModalComponent({
|
|
||||||
appData,
|
|
||||||
setAppData,
|
|
||||||
formData,
|
|
||||||
setFormData,
|
|
||||||
...props
|
|
||||||
}) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
//TODO Existing appointments list only refreshes sometimes after modal close. May have to do with the container class.
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
{...props}
|
|
||||||
width={"80%"}
|
|
||||||
maskClosable={false}
|
|
||||||
destroyOnClose={true}
|
|
||||||
okButtonProps={{ disabled: appData.start ? false : true }}
|
|
||||||
>
|
|
||||||
<Row>
|
|
||||||
<Col span={14}>
|
|
||||||
<Row>
|
|
||||||
Manual Job Selection Scheduled Time
|
|
||||||
<Input
|
|
||||||
placeholder={t("appointments.fields.title")}
|
|
||||||
onChange={e => {
|
|
||||||
setAppData({ ...appData, title: e.target.value });
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<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>
|
|
||||||
|
|
||||||
{
|
|
||||||
//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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
import { notification } from "antd";
|
|
||||||
import moment from "moment";
|
|
||||||
import React, { useState } from "react";
|
|
||||||
import { useMutation } from "@apollo/react-hooks";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { connect } from "react-redux";
|
|
||||||
import { createStructuredSelector } from "reselect";
|
|
||||||
import { INSERT_APPOINTMENT } from "../../graphql/appointments.queries";
|
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
|
||||||
import ScheduleAppointmentModalComponent from "./schedule-appointment-modal.component";
|
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
|
||||||
bodyshop: selectBodyshop
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(
|
|
||||||
mapStateToProps,
|
|
||||||
null
|
|
||||||
)(function ScheduleAppointmentModalContainer({
|
|
||||||
scheduleModalState,
|
|
||||||
jobId,
|
|
||||||
bodyshop,
|
|
||||||
refetch
|
|
||||||
}) {
|
|
||||||
const [scheduleModalVisible, setscheduleModalVisible] = scheduleModalState;
|
|
||||||
const [appData, setAppData] = useState({
|
|
||||||
jobid: jobId,
|
|
||||||
bodyshopid: bodyshop.id,
|
|
||||||
isintake: false,
|
|
||||||
start: null
|
|
||||||
});
|
|
||||||
const [insertAppointment] = useMutation(INSERT_APPOINTMENT);
|
|
||||||
const [formData, setFormData] = useState({ notifyCustomer: false });
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ScheduleAppointmentModalComponent
|
|
||||||
appData={appData}
|
|
||||||
setAppData={setAppData}
|
|
||||||
formData={formData}
|
|
||||||
setFormData={setFormData}
|
|
||||||
//Spreadable Modal Props
|
|
||||||
visible={scheduleModalVisible}
|
|
||||||
onCancel={() => setscheduleModalVisible(false)}
|
|
||||||
onOk={() => {
|
|
||||||
//TODO Customize the amount of minutes it will add.
|
|
||||||
insertAppointment({
|
|
||||||
variables: {
|
|
||||||
app: { ...appData, end: moment(appData.start).add(60, "minutes") }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.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 (refetch) refetch();
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
notification["error"]({
|
|
||||||
message: t("appointments.errors.saving", {
|
|
||||||
message: error.message
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
@@ -1,15 +1,23 @@
|
|||||||
|
import { SyncOutlined } from "@ant-design/icons";
|
||||||
|
import { Button } from "antd";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
//import "react-big-calendar/lib/css/react-big-calendar.css";
|
//import "react-big-calendar/lib/css/react-big-calendar.css";
|
||||||
import ScheduleCalendarWrapperComponent from "../schedule-calendar-wrapper/scheduler-calendar-wrapper.component";
|
import ScheduleCalendarWrapperComponent from "../schedule-calendar-wrapper/scheduler-calendar-wrapper.component";
|
||||||
import { Button } from "antd";
|
import ScheduleModal from "../schedule-job-modal/schedule-job-modal.container";
|
||||||
import { SyncOutlined } from "@ant-design/icons";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import ScheduleAppointmentModalContainer from "../schedule-appointment-modal/schedule-appointment-modal.container";
|
|
||||||
|
|
||||||
export default function ScheduleCalendarComponent({
|
|
||||||
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
setScheduleContext: context =>
|
||||||
|
dispatch(setModalContext({ context: context, modal: "schedule" }))
|
||||||
|
});
|
||||||
|
|
||||||
|
export function ScheduleCalendarComponent({
|
||||||
data,
|
data,
|
||||||
refetch,
|
refetch,
|
||||||
scheduleModalState
|
setScheduleContext
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -25,17 +33,18 @@ export default function ScheduleCalendarComponent({
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
scheduleModalState[1](true);
|
setScheduleContext({
|
||||||
|
actions: { refetch: refetch },
|
||||||
|
context: {
|
||||||
|
jobId: null
|
||||||
|
}
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t("appointments.actions.new")}
|
{t("appointments.actions.new")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<ScheduleAppointmentModalContainer
|
<ScheduleModal />
|
||||||
scheduleModalState={scheduleModalState}
|
|
||||||
jobId={null}
|
|
||||||
refetch={refetch}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ScheduleCalendarWrapperComponent
|
<ScheduleCalendarWrapperComponent
|
||||||
data={data}
|
data={data}
|
||||||
@@ -45,3 +54,4 @@ export default function ScheduleCalendarComponent({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
export default connect(null, mapDispatchToProps)(ScheduleCalendarComponent);
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
import React, { useState } from "react";
|
|
||||||
import { useQuery } from "@apollo/react-hooks";
|
import { useQuery } from "@apollo/react-hooks";
|
||||||
import ScheduleCalendarComponent from "./schedule-calendar.component";
|
import React from "react";
|
||||||
import { QUERY_ALL_ACTIVE_APPOINTMENTS } from "../../graphql/appointments.queries";
|
import { QUERY_ALL_ACTIVE_APPOINTMENTS } from "../../graphql/appointments.queries";
|
||||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
|
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||||
|
import ScheduleCalendarComponent from "./schedule-calendar.component";
|
||||||
|
|
||||||
export default function ScheduleCalendarContainer() {
|
export default function ScheduleCalendarContainer() {
|
||||||
const { loading, error, data, refetch } = useQuery(
|
const { loading, error, data, refetch } = useQuery(
|
||||||
QUERY_ALL_ACTIVE_APPOINTMENTS,
|
QUERY_ALL_ACTIVE_APPOINTMENTS
|
||||||
{
|
|
||||||
fetchPolicy: "network-only"
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
const scheduleModalState = useState(false);
|
|
||||||
|
|
||||||
if (loading) return <LoadingSpinner />;
|
if (loading) return <LoadingSpinner />;
|
||||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||||
@@ -28,7 +24,6 @@ export default function ScheduleCalendarContainer() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ScheduleCalendarComponent
|
<ScheduleCalendarComponent
|
||||||
scheduleModalState={scheduleModalState}
|
|
||||||
refetch={refetch}
|
refetch={refetch}
|
||||||
data={data ? normalizedData : null}
|
data={data ? normalizedData : null}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,74 +1,63 @@
|
|||||||
import { Checkbox, Col, DatePicker, Modal, Row, Tabs, TimePicker } from "antd";
|
import { Checkbox, Col, DatePicker, Row, Tabs, TimePicker } from "antd";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import ScheduleDayViewContainer from "../schedule-day-view/schedule-day-view.container";
|
import ScheduleDayViewContainer from "../schedule-day-view/schedule-day-view.container";
|
||||||
import ScheduleExistingAppointmentsList from "../schedule-existing-appointments-list/schedule-existing-appointments-list.component";
|
import ScheduleExistingAppointmentsList from "../schedule-existing-appointments-list/schedule-existing-appointments-list.component";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default function ScheduleJobModalComponent({
|
export default function ScheduleJobModalComponent({
|
||||||
existingAppointments,
|
existingAppointments,
|
||||||
appData,
|
appData,
|
||||||
setAppData,
|
setAppData,
|
||||||
formData,
|
formData,
|
||||||
setFormData,
|
setFormData
|
||||||
...props
|
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
//TODO Existing appointments list only refreshes sometimes after modal close. May have to do with the container class.
|
//TODO Existing appointments list only refreshes sometimes after modal close. May have to do with the container class.
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Row>
|
||||||
{...props}
|
<Col span={14}>
|
||||||
width={"80%"}
|
<Tabs defaultActiveKey="1">
|
||||||
maskClosable={false}
|
<Tabs.TabPane tab="SMART Scheduling" key="auto">
|
||||||
destroyOnClose={true}
|
Automatic Job Selection.
|
||||||
okButtonProps={{ disabled: appData.start ? false : true }}
|
</Tabs.TabPane>
|
||||||
>
|
<Tabs.TabPane tab="Manual Scheduling" key="manual">
|
||||||
<Row>
|
<Row>
|
||||||
<Col span={14}>
|
Manual Job Selection Scheduled Time
|
||||||
<Tabs defaultActiveKey="1">
|
<DatePicker
|
||||||
<Tabs.TabPane tab="SMART Scheduling" key="auto">
|
value={appData.start}
|
||||||
Automatic Job Selection.
|
onChange={e => {
|
||||||
</Tabs.TabPane>
|
setAppData({ ...appData, start: e });
|
||||||
<Tabs.TabPane tab="Manual Scheduling" key="manual">
|
}}
|
||||||
<Row>
|
/>
|
||||||
Manual Job Selection Scheduled Time
|
<TimePicker
|
||||||
<DatePicker
|
value={appData.start}
|
||||||
value={appData.start}
|
format={"HH:mm"}
|
||||||
onChange={e => {
|
minuteStep={15}
|
||||||
setAppData({ ...appData, start: e });
|
onChange={e => {
|
||||||
}}
|
setAppData({ ...appData, start: e });
|
||||||
/>
|
}}
|
||||||
<TimePicker
|
/>
|
||||||
value={appData.start}
|
</Row>
|
||||||
format={"HH:mm"}
|
</Tabs.TabPane>
|
||||||
minuteStep={15}
|
</Tabs>
|
||||||
onChange={e => {
|
<ScheduleExistingAppointmentsList
|
||||||
setAppData({ ...appData, start: e });
|
existingAppointments={existingAppointments}
|
||||||
}}
|
/>
|
||||||
/>
|
{
|
||||||
</Row>
|
//TODO Build out notifications.
|
||||||
</Tabs.TabPane>
|
}
|
||||||
</Tabs>
|
<Checkbox
|
||||||
<ScheduleExistingAppointmentsList
|
defaultChecked={formData.notifyCustomer}
|
||||||
existingAppointments={existingAppointments}
|
onChange={e =>
|
||||||
/>
|
setFormData({ ...formData, notifyCustomer: e.target.checked })
|
||||||
{
|
|
||||||
//TODO Build out notifications.
|
|
||||||
}
|
}
|
||||||
<Checkbox
|
>
|
||||||
defaultChecked={formData.notifyCustomer}
|
{t("jobs.labels.appointmentconfirmation")}
|
||||||
onChange={e =>
|
</Checkbox>
|
||||||
setFormData({ ...formData, notifyCustomer: e.target.checked })
|
</Col>
|
||||||
}
|
<Col span={10}>
|
||||||
>
|
<ScheduleDayViewContainer day={appData.start} />
|
||||||
{t("jobs.labels.appointmentconfirmation")}
|
</Col>
|
||||||
</Checkbox>
|
</Row>
|
||||||
</Col>
|
|
||||||
<Col span={10}>
|
|
||||||
<ScheduleDayViewContainer day={appData.start} />
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</Modal>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,28 +6,32 @@ import {
|
|||||||
QUERY_APPOINTMENTS_BY_JOBID
|
QUERY_APPOINTMENTS_BY_JOBID
|
||||||
} from "../../graphql/appointments.queries";
|
} from "../../graphql/appointments.queries";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { notification } from "antd";
|
import { notification, Modal } from "antd";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { UPDATE_JOB_STATUS } from "../../graphql/jobs.queries";
|
import { UPDATE_JOB_STATUS } from "../../graphql/jobs.queries";
|
||||||
|
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
|
import { selectSchedule } from "../../redux/modals/modals.selectors";
|
||||||
|
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop
|
bodyshop: selectBodyshop,
|
||||||
|
scheduleModal: selectSchedule
|
||||||
});
|
});
|
||||||
|
const mapDispatchToProps = dispatch => ({
|
||||||
export default connect(
|
toggleModalVisible: () => dispatch(toggleModalVisible("schedule"))
|
||||||
mapStateToProps,
|
});
|
||||||
null
|
export function ScheduleJobModalContainer({
|
||||||
)(function ScheduleJobModalContainer({
|
scheduleModal,
|
||||||
scheduleModalState,
|
|
||||||
jobId,
|
|
||||||
bodyshop,
|
bodyshop,
|
||||||
refetch
|
toggleModalVisible
|
||||||
}) {
|
}) {
|
||||||
const [scheduleModalVisible, setscheduleModalVisible] = scheduleModalState;
|
const { visible, context, actions } = scheduleModal;
|
||||||
|
const { jobId } = context;
|
||||||
|
const { refetch } = actions;
|
||||||
|
|
||||||
const [appData, setAppData] = useState({
|
const [appData, setAppData] = useState({
|
||||||
jobid: jobId,
|
jobid: jobId,
|
||||||
start: null,
|
start: null,
|
||||||
@@ -46,48 +50,61 @@ export default connect(
|
|||||||
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: !scheduleModalVisible
|
skip: !visible
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
//TODO Customize the amount of minutes it will add.
|
||||||
<ScheduleJobModalComponent
|
const handleOk = () => {
|
||||||
existingAppointments={existingAppointments}
|
insertAppointment({
|
||||||
appData={appData}
|
variables: {
|
||||||
setAppData={setAppData}
|
app: { ...appData, end: moment(appData.start).add(60, "minutes") }
|
||||||
formData={formData}
|
}
|
||||||
setFormData={setFormData}
|
})
|
||||||
//Spreadable Modal Props
|
.then(r => {
|
||||||
visible={scheduleModalVisible}
|
updateJobStatus().then(r => {
|
||||||
onCancel={() => setscheduleModalVisible(false)}
|
notification["success"]({
|
||||||
onOk={() => {
|
message: t("appointments.successes.created")
|
||||||
//TODO Customize the amount of minutes it will add.
|
|
||||||
insertAppointment({
|
|
||||||
variables: {
|
|
||||||
app: { ...appData, end: moment(appData.start).add(60, "minutes") }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(r => {
|
|
||||||
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 (refetch) refetch();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
notification["error"]({
|
|
||||||
message: t("appointments.errors.saving", {
|
|
||||||
message: error.message
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}}
|
|
||||||
/>
|
if (formData.notifyCustomer) {
|
||||||
|
//TODO Implement customer reminder on scheduling.
|
||||||
|
alert("Chosed to notify the customer somehow!");
|
||||||
|
}
|
||||||
|
toggleModalVisible();
|
||||||
|
if (refetch) refetch();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
notification["error"]({
|
||||||
|
message: t("appointments.errors.saving", {
|
||||||
|
message: error.message
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
visible={visible}
|
||||||
|
onCancel={() => toggleModalVisible()}
|
||||||
|
onOk={handleOk}
|
||||||
|
width={"90%"}
|
||||||
|
maskClosable={false}
|
||||||
|
destroyOnClose
|
||||||
|
okButtonProps={{ disabled: appData.start ? false : true }}
|
||||||
|
>
|
||||||
|
<ScheduleJobModalComponent
|
||||||
|
existingAppointments={existingAppointments}
|
||||||
|
appData={appData}
|
||||||
|
setAppData={setAppData}
|
||||||
|
formData={formData}
|
||||||
|
setFormData={setFormData}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(ScheduleJobModalContainer);
|
||||||
|
|||||||
@@ -11,12 +11,7 @@ export default function JobsAvailablePageContainer() {
|
|||||||
const [deleteJob] = useMutation(DELETE_AVAILABLE_JOB);
|
const [deleteJob] = useMutation(DELETE_AVAILABLE_JOB);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const estDataLazyLoad = useLazyQuery(
|
const estDataLazyLoad = useLazyQuery(QUERY_AVAILABLE_NEW_JOBS_EST_DATA_BY_PK);
|
||||||
QUERY_AVAILABLE_NEW_JOBS_EST_DATA_BY_PK,
|
|
||||||
{
|
|
||||||
fetchPolicy: "network-only"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.title = t("titles.jobsavailable");
|
document.title = t("titles.jobsavailable");
|
||||||
|
|||||||
@@ -16,20 +16,9 @@ import {
|
|||||||
FaRegStickyNote,
|
FaRegStickyNote,
|
||||||
FaShieldAlt
|
FaShieldAlt
|
||||||
} from "react-icons/fa";
|
} from "react-icons/fa";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory, useLocation } from "react-router-dom";
|
||||||
//import JobsLinesContainer from "../../components/job-detail-lines/job-lines.container";
|
|
||||||
//import JobsDetailClaims from "../../components/jobs-detail-claims/jobs-detail-claims.component";
|
|
||||||
//import JobsDetailDatesComponent from "../../components/jobs-detail-dates/jobs-detail-dates.component";
|
|
||||||
//import JobsDetailFinancials from "../../components/jobs-detail-financial/jobs-detail-financial.component";
|
|
||||||
//import JobsDetailHeader from "../../components/jobs-detail-header/jobs-detail-header.component";
|
|
||||||
//import JobsDetailInsurance from "../../components/jobs-detail-insurance/jobs-detail-insurance.component";
|
|
||||||
//import JobsDocumentsContainer from "../../components/jobs-documents/jobs-documents.container";
|
|
||||||
//import JobNotesContainer from "../../components/jobs-notes/jobs-notes.container";
|
|
||||||
//import ScheduleJobModalContainer from "../../components/schedule-job-modal/schedule-job-modal.container";
|
|
||||||
//import JobLineUpsertModalContainer from "../../components/job-lines-upsert-modal/job-lines-upsert-modal.container";
|
|
||||||
//import EnterInvoiceModalContainer from "../../components/invoice-enter-modal/invoice-enter-modal.container";
|
|
||||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||||
|
import queryString from "query-string";
|
||||||
const JobsLinesContainer = lazy(() =>
|
const JobsLinesContainer = lazy(() =>
|
||||||
import("../../components/job-detail-lines/job-lines.container")
|
import("../../components/job-detail-lines/job-lines.container")
|
||||||
);
|
);
|
||||||
@@ -84,14 +73,13 @@ export default function JobsDetailPage({
|
|||||||
mutationConvertJob,
|
mutationConvertJob,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
refetch,
|
refetch,
|
||||||
scheduleModalState,
|
updateJobStatus
|
||||||
updateJobStatus,
|
|
||||||
tab
|
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
|
const search = queryString.parse(useLocation().search);
|
||||||
const formItemLayout = {
|
const formItemLayout = {
|
||||||
labelCol: {
|
labelCol: {
|
||||||
xs: { span: 12 },
|
xs: { span: 12 },
|
||||||
@@ -118,12 +106,7 @@ export default function JobsDetailPage({
|
|||||||
<Suspense
|
<Suspense
|
||||||
fallback={<LoadingSpinner message={t("general.labels.loadingapp")} />}
|
fallback={<LoadingSpinner message={t("general.labels.loadingapp")} />}
|
||||||
>
|
>
|
||||||
<ScheduleJobModalContainer
|
<ScheduleJobModalContainer />
|
||||||
scheduleModalState={scheduleModalState}
|
|
||||||
jobId={job.id}
|
|
||||||
refetch={refetch}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<JobLineUpsertModalContainer />
|
<JobLineUpsertModalContainer />
|
||||||
<EnterInvoiceModalContainer />
|
<EnterInvoiceModalContainer />
|
||||||
|
|
||||||
@@ -168,14 +151,11 @@ export default function JobsDetailPage({
|
|||||||
mutationConvertJob={mutationConvertJob}
|
mutationConvertJob={mutationConvertJob}
|
||||||
refetch={refetch}
|
refetch={refetch}
|
||||||
handleSubmit={handleSubmit}
|
handleSubmit={handleSubmit}
|
||||||
scheduleModalState={scheduleModalState}
|
|
||||||
updateJobStatus={updateJobStatus}
|
updateJobStatus={updateJobStatus}
|
||||||
/>
|
/>
|
||||||
<Tabs
|
<Tabs
|
||||||
defaultActiveKey={history.location.search.substring(1) || null}
|
defaultActiveKey={search.tab}
|
||||||
onChange={key =>
|
onChange={key => history.push({ search: `?tab=${key}` })}
|
||||||
history.replace({ ...history.location, search: `?${key}` })
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Tabs.TabPane
|
<Tabs.TabPane
|
||||||
tab={
|
tab={
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { notification } from "antd";
|
|
||||||
import React, { useEffect, useState } from "react";
|
|
||||||
import { useMutation, useQuery } from "@apollo/react-hooks";
|
import { useMutation, useQuery } from "@apollo/react-hooks";
|
||||||
|
import { notification } from "antd";
|
||||||
|
import React, { useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import AlertComponent from "../../components/alert/alert.component";
|
import AlertComponent from "../../components/alert/alert.component";
|
||||||
import SpinComponent from "../../components/loading-spinner/loading-spinner.component";
|
import SpinComponent from "../../components/loading-spinner/loading-spinner.component";
|
||||||
@@ -8,11 +8,9 @@ import { CONVERT_JOB_TO_RO, GET_JOB_BY_PK, UPDATE_JOB, UPDATE_JOB_STATUS } from
|
|||||||
import JobsDetailPage from "./jobs-detail.page.component";
|
import JobsDetailPage from "./jobs-detail.page.component";
|
||||||
|
|
||||||
function JobsDetailPageContainer({ match }) {
|
function JobsDetailPageContainer({ match }) {
|
||||||
const { jobId, tab } = match.params;
|
const { jobId } = match.params;
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const scheduleModalState = useState(false);
|
|
||||||
|
|
||||||
const { loading, error, data, refetch } = useQuery(GET_JOB_BY_PK, {
|
const { loading, error, data, refetch } = useQuery(GET_JOB_BY_PK, {
|
||||||
variables: { id: jobId },
|
variables: { id: jobId },
|
||||||
fetchPolicy: "network-only"
|
fetchPolicy: "network-only"
|
||||||
@@ -55,9 +53,7 @@ function JobsDetailPageContainer({ match }) {
|
|||||||
mutationConvertJob={mutationConvertJob}
|
mutationConvertJob={mutationConvertJob}
|
||||||
mutationUpdateJob={mutationUpdateJob}
|
mutationUpdateJob={mutationUpdateJob}
|
||||||
refetch={refetch}
|
refetch={refetch}
|
||||||
scheduleModalState={scheduleModalState}
|
|
||||||
updateJobStatus={updateJobStatus}
|
updateJobStatus={updateJobStatus}
|
||||||
tab={tab}
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<AlertComponent message={t("jobs.errors.noaccess")} type="error" />
|
<AlertComponent message={t("jobs.errors.noaccess")} type="error" />
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ const INITIAL_STATE = {
|
|||||||
jobLineEdit: { ...baseModal },
|
jobLineEdit: { ...baseModal },
|
||||||
invoiceEnter: { ...baseModal },
|
invoiceEnter: { ...baseModal },
|
||||||
courtesyCarReturn: { ...baseModal },
|
courtesyCarReturn: { ...baseModal },
|
||||||
noteUpsert: { ...baseModal }
|
noteUpsert: { ...baseModal },
|
||||||
|
schedule: { ...baseModal }
|
||||||
};
|
};
|
||||||
|
|
||||||
const modalsReducer = (state = INITIAL_STATE, action) => {
|
const modalsReducer = (state = INITIAL_STATE, action) => {
|
||||||
|
|||||||
@@ -21,3 +21,8 @@ export const selectNoteUpsert = createSelector(
|
|||||||
[selectModals],
|
[selectModals],
|
||||||
modals => modals.noteUpsert
|
modals => modals.noteUpsert
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectSchedule = createSelector(
|
||||||
|
[selectModals],
|
||||||
|
modals => modals.schedule
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user