Added basic bucketed smart scheduling BOD-4
This commit is contained in:
@@ -4,3 +4,7 @@
|
||||
box-sizing: unset !important;
|
||||
min-height: unset !important;
|
||||
}
|
||||
|
||||
.imex-event-arrived {
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,20 @@ import moment from "moment";
|
||||
import queryString from "query-string";
|
||||
import React from "react";
|
||||
import { Calendar, momentLocalizer } from "react-big-calendar";
|
||||
import { connect } from "react-redux";
|
||||
import { useHistory, useLocation } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import Event from "../schedule-event/schedule-event.container";
|
||||
import HeaderComponent from "./schedule-calendar-header.component";
|
||||
import "./schedule-calendar.styles.scss";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const localizer = momentLocalizer(moment);
|
||||
|
||||
export default function ScheduleCalendarWrapperComponent({
|
||||
export function ScheduleCalendarWrapperComponent({
|
||||
bodyshop,
|
||||
data,
|
||||
refetch,
|
||||
defaultView,
|
||||
@@ -19,6 +25,21 @@ export default function ScheduleCalendarWrapperComponent({
|
||||
}) {
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const history = useHistory();
|
||||
|
||||
const handleEventPropStyles = (event, start, end, isSelected) => {
|
||||
// if (!!!bodyshop.ssbuckets) {
|
||||
// return {};
|
||||
// }
|
||||
// const defaultEventColor = "#3174ad";
|
||||
// const jobHrs = result.jobs_by_pk.jobhrs.aggregate.sum.mod_lb_hrs;
|
||||
// const JobBucket = bodyshop.ssbuckets.filter(
|
||||
// (bucket) =>
|
||||
// bucket.gte <= jobHrs && (!!bucket.lt ? bucket.lt > jobHrs : true)
|
||||
// )[0];
|
||||
|
||||
return { className: event.arrived ? "imex-event-arrived" : "" };
|
||||
};
|
||||
|
||||
return (
|
||||
<Calendar
|
||||
events={data}
|
||||
@@ -41,6 +62,7 @@ export default function ScheduleCalendarWrapperComponent({
|
||||
localizer={localizer}
|
||||
min={new Date("2020-01-01T06:00:00")} //TODO Read from business settings.
|
||||
max={new Date("2020-01-01T20:00:00")}
|
||||
eventPropGetter={handleEventPropStyles}
|
||||
components={{
|
||||
event: (e) => Event({ event: e.event, refetch: refetch }),
|
||||
header: HeaderComponent,
|
||||
@@ -49,3 +71,5 @@ export default function ScheduleCalendarWrapperComponent({
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, null)(ScheduleCalendarWrapperComponent);
|
||||
|
||||
Reference in New Issue
Block a user