IO-1055 Blocked Day improvements.
This commit is contained in:
@@ -24,6 +24,15 @@ export function ScheduleEventComponent({
|
|||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
|
|
||||||
|
const blockContent = (
|
||||||
|
<div>
|
||||||
|
<Button onClick={() => handleCancel(event.id)} disabled={event.arrived}>
|
||||||
|
{t("appointments.actions.cancel")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
const popoverContent = (
|
const popoverContent = (
|
||||||
<div>
|
<div>
|
||||||
{!event.isintake ? (
|
{!event.isintake ? (
|
||||||
@@ -167,7 +176,7 @@ export function ScheduleEventComponent({
|
|||||||
visible={visible}
|
visible={visible}
|
||||||
onVisibleChange={(vis) => setVisible(vis)}
|
onVisibleChange={(vis) => setVisible(vis)}
|
||||||
trigger="click"
|
trigger="click"
|
||||||
content={popoverContent}
|
content={event.block ? blockContent : popoverContent}
|
||||||
style={{ height: "100%", width: "100%" }}
|
style={{ height: "100%", width: "100%" }}
|
||||||
>
|
>
|
||||||
{RegularEvent}
|
{RegularEvent}
|
||||||
|
|||||||
@@ -30,26 +30,27 @@ export default function ScheduleEventContainer({ bodyshop, event, refetch }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const jobUpdate = await updateJob({
|
if (event.job) {
|
||||||
variables: {
|
const jobUpdate = await updateJob({
|
||||||
jobId: event.job.id,
|
variables: {
|
||||||
|
jobId: event.job.id,
|
||||||
|
|
||||||
job: {
|
job: {
|
||||||
date_scheduled: null,
|
date_scheduled: null,
|
||||||
scheduled_in: null,
|
scheduled_in: null,
|
||||||
status: bodyshop.md_ro_statuses.default_imported,
|
status: bodyshop.md_ro_statuses.default_imported,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
});
|
|
||||||
if (!!jobUpdate.errors) {
|
|
||||||
notification["error"]({
|
|
||||||
message: t("jobs.errors.updating", {
|
|
||||||
message: JSON.stringify(jobUpdate.errors),
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
return;
|
if (!!jobUpdate.errors) {
|
||||||
|
notification["error"]({
|
||||||
|
message: t("jobs.errors.updating", {
|
||||||
|
message: JSON.stringify(jobUpdate.errors),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refetch) refetch();
|
if (refetch) refetch();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,13 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({});
|
const mapDispatchToProps = (dispatch) => ({});
|
||||||
|
|
||||||
export function ScheduleBlockDay({ date, children, refetch, bodyshop }) {
|
export function ScheduleBlockDay({
|
||||||
|
date,
|
||||||
|
children,
|
||||||
|
refetch,
|
||||||
|
bodyshop,
|
||||||
|
alreadyBlocked,
|
||||||
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [insertBlock] = useMutation(INSERT_APPOINTMENT_BLOCK);
|
const [insertBlock] = useMutation(INSERT_APPOINTMENT_BLOCK);
|
||||||
|
|
||||||
@@ -56,7 +62,11 @@ export function ScheduleBlockDay({ date, children, refetch, bodyshop }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropdown overlay={menu} trigger={["contextMenu"]}>
|
<Dropdown
|
||||||
|
overlay={menu}
|
||||||
|
disabled={alreadyBlocked}
|
||||||
|
trigger={["contextMenu"]}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ export function ScheduleCalendarHeaderComponent({
|
|||||||
);
|
);
|
||||||
}, [events, date]);
|
}, [events, date]);
|
||||||
|
|
||||||
|
const isDayBlocked = useMemo(() => {
|
||||||
|
return events.filter(
|
||||||
|
(e) => moment(date).isSame(moment(e.start), "day") && e.block
|
||||||
|
);
|
||||||
|
}, [events, date]);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const loadData = load[date.toISOString().substr(0, 10)];
|
const loadData = load[date.toISOString().substr(0, 10)];
|
||||||
|
|
||||||
@@ -136,9 +142,9 @@ export function ScheduleCalendarHeaderComponent({
|
|||||||
<div>
|
<div>
|
||||||
<ul style={{ listStyleType: "none", columns: "2 auto", padding: 0 }}>
|
<ul style={{ listStyleType: "none", columns: "2 auto", padding: 0 }}>
|
||||||
{Object.keys(ATSToday).map((key, idx) => (
|
{Object.keys(ATSToday).map((key, idx) => (
|
||||||
<li key={idx}>{`${key === "null" ? "N/A" : key}: ${
|
<li key={idx}>{`${
|
||||||
ATSToday[key].length
|
key === "null" || key === "undefined" ? "N/A" : key
|
||||||
}`}</li>
|
}: ${ATSToday[key].length}`}</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -179,7 +185,11 @@ export function ScheduleCalendarHeaderComponent({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="imex-calendar-load">
|
<div className="imex-calendar-load">
|
||||||
<ScheduleBlockDay date={date} refetch={refetch}>
|
<ScheduleBlockDay
|
||||||
|
alreadyBlocked={isDayBlocked.length > 0}
|
||||||
|
date={date}
|
||||||
|
refetch={refetch}
|
||||||
|
>
|
||||||
<div style={{ color: isShopOpen(date) ? "" : "tomato" }}>
|
<div style={{ color: isShopOpen(date) ? "" : "tomato" }}>
|
||||||
{label}
|
{label}
|
||||||
{calculating ? <LoadingSkeleton /> : LoadComponent}
|
{calculating ? <LoadingSkeleton /> : LoadComponent}
|
||||||
|
|||||||
@@ -78,7 +78,9 @@ export function ScheduleCalendarWrapperComponent({
|
|||||||
components={{
|
components={{
|
||||||
event: (e) =>
|
event: (e) =>
|
||||||
Event({ bodyshop: bodyshop, event: e.event, refetch: refetch }),
|
Event({ bodyshop: bodyshop, event: e.event, refetch: refetch }),
|
||||||
header: (p) => <HeaderComponent {...p} events={data} />,
|
header: (p) => (
|
||||||
|
<HeaderComponent {...p} events={data} refetch={refetch} />
|
||||||
|
),
|
||||||
}}
|
}}
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user