Added working days to scheduling IO-153

This commit is contained in:
Patrick Fic
2021-01-29 17:26:48 -08:00
parent e71a7bd17b
commit 10e70230ba
20 changed files with 638 additions and 20 deletions

View File

@@ -8,13 +8,14 @@ import { Link } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import {
selectScheduleLoad,
selectScheduleLoadCalculating
selectScheduleLoadCalculating,
} from "../../redux/application/application.selectors";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { DateTimeFormatter } from "../../utils/DateFormatter";
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
import ScheduleBlockDay from "../schedule-block-day/schedule-block-day.component";
import ScheduleCalendarHeaderGraph from "./schedule-calendar-header-graph.component";
import moment from "moment";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -124,10 +125,42 @@ export function ScheduleCalendarHeaderComponent({
</div>
) : null;
const isShopOpen = (date) => {
let day;
switch (moment(date).day()) {
case 0:
day = "sunday";
break;
case 1:
day = "monday";
break;
case 2:
day = "tuesday";
break;
case 3:
day = "wednesday";
break;
case 4:
day = "thursday";
break;
case 5:
day = "friday";
break;
case 6:
day = "saturday";
break;
default:
day = "sunday";
break;
}
return bodyshop.workingdays[day];
};
return (
<div className="imex-calendar-load">
<ScheduleBlockDay date={date} refetch={refetch}>
<div>
<div style={{ color: isShopOpen(date) ? "" : "tomato" }}>
{label}
{calculating ? <LoadingSkeleton /> : LoadComponent}
</div>