BOD-84 Added base calculations for schedule load
This commit is contained in:
@@ -8,16 +8,15 @@ import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import ScheduleCalendarWrapperComponent from "../schedule-calendar-wrapper/scheduler-calendar-wrapper.component";
|
||||
import ScheduleModal from "../schedule-job-modal/schedule-job-modal.container";
|
||||
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
setScheduleContext: context =>
|
||||
dispatch(setModalContext({ context: context, modal: "schedule" }))
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setScheduleContext: (context) =>
|
||||
dispatch(setModalContext({ context: context, modal: "schedule" })),
|
||||
});
|
||||
|
||||
export function ScheduleCalendarComponent({
|
||||
data,
|
||||
refetch,
|
||||
setScheduleContext
|
||||
setScheduleContext,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -36,8 +35,8 @@ export function ScheduleCalendarComponent({
|
||||
setScheduleContext({
|
||||
actions: { refetch: refetch },
|
||||
context: {
|
||||
jobId: null
|
||||
}
|
||||
jobId: null,
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
@@ -46,11 +45,7 @@ export function ScheduleCalendarComponent({
|
||||
|
||||
<ScheduleModal />
|
||||
|
||||
<ScheduleCalendarWrapperComponent
|
||||
data={data}
|
||||
defaultView="week"
|
||||
refetch={refetch}
|
||||
/>
|
||||
<ScheduleCalendarWrapperComponent data={data} refetch={refetch} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,33 @@
|
||||
import { useQuery } from "@apollo/react-hooks";
|
||||
import queryString from "query-string";
|
||||
import React from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { QUERY_ALL_ACTIVE_APPOINTMENTS } from "../../graphql/appointments.queries";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import { getRange } from "../schedule-calendar-wrapper/schedule-calendar-util";
|
||||
import ScheduleCalendarComponent from "./schedule-calendar.component";
|
||||
import { calculateScheduleLoad } from "../../redux/application/application.actions";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
calculateScheduleLoad: (endDate) => dispatch(calculateScheduleLoad(endDate)),
|
||||
});
|
||||
|
||||
export default function ScheduleCalendarContainer() {
|
||||
export function ScheduleCalendarContainer({ calculateScheduleLoad }) {
|
||||
const search = queryString.parse(useLocation().search);
|
||||
|
||||
const { date, view } = search;
|
||||
const range = getRange(date, view);
|
||||
const { loading, error, data, refetch } = useQuery(
|
||||
QUERY_ALL_ACTIVE_APPOINTMENTS
|
||||
QUERY_ALL_ACTIVE_APPOINTMENTS,
|
||||
{
|
||||
variables: { start: range.start.toDate(), end: range.end.toDate() },
|
||||
skip: !!!range.start || !!!range.end,
|
||||
}
|
||||
);
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
@@ -22,10 +42,32 @@ export default function ScheduleCalendarContainer() {
|
||||
);
|
||||
});
|
||||
|
||||
console.log("ScheduleCalendarContainer -> normalizedData", normalizedData);
|
||||
normalizedData.push({
|
||||
id: 1,
|
||||
title: "All day event",
|
||||
allDay: true,
|
||||
isintake: false,
|
||||
start: new Date(),
|
||||
end: new Date(),
|
||||
});
|
||||
return (
|
||||
<ScheduleCalendarComponent
|
||||
refetch={refetch}
|
||||
data={data ? normalizedData : null}
|
||||
/>
|
||||
<span>
|
||||
<button
|
||||
onClick={() => {
|
||||
calculateScheduleLoad(range.end);
|
||||
}}
|
||||
>
|
||||
Calc Load
|
||||
</button>
|
||||
<ScheduleCalendarComponent
|
||||
refetch={refetch}
|
||||
data={data ? normalizedData : null}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(ScheduleCalendarContainer);
|
||||
|
||||
Reference in New Issue
Block a user