- the great reformat

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-02-06 18:20:58 -05:00
parent 30c530bcc4
commit e83badb454
912 changed files with 108516 additions and 107493 deletions

View File

@@ -1,125 +1,123 @@
import { Col, Row } from "antd";
import React, { useEffect } from "react";
import {Col, Row} from "antd";
import React, {useEffect} from "react";
import ScoreboardChart from "../scoreboard-chart/scoreboard-chart.component";
import ScoreboardLastDays from "../scoreboard-last-days/scoreboard-last-days.component";
import ScoreboardTargetsTable from "../scoreboard-targets-table/scoreboard-targets-table.component";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import {connect} from "react-redux";
import {createStructuredSelector} from "reselect";
import {selectBodyshop} from "../../redux/user/user.selectors";
import dayjs from "../../utils/day";
import { useApolloClient, useQuery } from "@apollo/client";
import {
GET_BLOCKED_DAYS,
QUERY_SCOREBOARD,
} from "../../graphql/scoreboard.queries";
import {useApolloClient, useQuery} from "@apollo/client";
import {GET_BLOCKED_DAYS, QUERY_SCOREBOARD,} from "../../graphql/scoreboard.queries";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
bodyshop: selectBodyshop,
//currentUser: selectCurrentUser
bodyshop: selectBodyshop,
});
const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
//setUserLanguage: language => dispatch(setUserLanguage(language))
});
export default connect(
mapStateToProps,
mapDispatchToProps
mapStateToProps,
mapDispatchToProps
)(ScoreboardDisplayComponent);
export function ScoreboardDisplayComponent({ bodyshop }) {
const scoreboardSubscription = useQuery(QUERY_SCOREBOARD, {
variables: {
start: dayjs().startOf("month"),
end: dayjs().endOf("month"),
},
pollInterval: 60000,
});
const { data } = scoreboardSubscription;
const client = useApolloClient();
const scoreBoardlist = (data && data.scoreboard) || [];
const sbEntriesByDate = {};
scoreBoardlist.forEach((i) => {
const entryDate = i.date;
if (!!!sbEntriesByDate[entryDate]) {
sbEntriesByDate[entryDate] = [];
}
sbEntriesByDate[entryDate].push(i);
});
useEffect(() => {
//Update the locals.
async function setDayJSSettings() {
let appointments;
if (!bodyshop.scoreboard_target.ignoreblockeddays) {
const { data } = await client.query({
query: GET_BLOCKED_DAYS,
variables: {
export function ScoreboardDisplayComponent({bodyshop}) {
const scoreboardSubscription = useQuery(QUERY_SCOREBOARD, {
variables: {
start: dayjs().startOf("month"),
end: dayjs().endOf("month"),
},
});
appointments = data.appointments;
}
},
pollInterval: 60000,
});
dayjs.updateLocale("ca", {
workingWeekdays: translateSettingsToWorkingDays(bodyshop.workingdays),
...(appointments
? {
holidays: appointments.map((h) =>
dayjs(h.start).format("MM-DD-YYYY")
),
const {data} = scoreboardSubscription;
const client = useApolloClient();
const scoreBoardlist = (data && data.scoreboard) || [];
const sbEntriesByDate = {};
scoreBoardlist.forEach((i) => {
const entryDate = i.date;
if (!!!sbEntriesByDate[entryDate]) {
sbEntriesByDate[entryDate] = [];
}
sbEntriesByDate[entryDate].push(i);
});
useEffect(() => {
//Update the locals.
async function setDayJSSettings() {
let appointments;
if (!bodyshop.scoreboard_target.ignoreblockeddays) {
const {data} = await client.query({
query: GET_BLOCKED_DAYS,
variables: {
start: dayjs().startOf("month"),
end: dayjs().endOf("month"),
},
});
appointments = data.appointments;
}
: {}),
holidayFormat: "MM-DD-YYYY",
});
}
setDayJSSettings();
}, [client, bodyshop]);
dayjs.updateLocale("ca", {
workingWeekdays: translateSettingsToWorkingDays(bodyshop.workingdays),
...(appointments
? {
holidays: appointments.map((h) =>
dayjs(h.start).format("MM-DD-YYYY")
),
}
: {}),
holidayFormat: "MM-DD-YYYY",
});
}
return (
<Row gutter={[16, 16]}>
<Col span={24}>
<ScoreboardTargetsTable scoreBoardlist={scoreBoardlist} />
</Col>
setDayJSSettings();
}, [client, bodyshop]);
<Col span={24}>
<ScoreboardLastDays sbEntriesByDate={sbEntriesByDate} />
</Col>
return (
<Row gutter={[16, 16]}>
<Col span={24}>
<ScoreboardTargetsTable scoreBoardlist={scoreBoardlist}/>
</Col>
<Col span={24}>
<ScoreboardChart sbEntriesByDate={sbEntriesByDate} />
</Col>
</Row>
);
<Col span={24}>
<ScoreboardLastDays sbEntriesByDate={sbEntriesByDate}/>
</Col>
<Col span={24}>
<ScoreboardChart sbEntriesByDate={sbEntriesByDate}/>
</Col>
</Row>
);
}
function translateSettingsToWorkingDays(workingdays) {
const days = [];
const days = [];
if (workingdays.monday) {
days.push(1);
}
if (workingdays.tuesday) {
days.push(2);
}
if (workingdays.wednesday) {
days.push(3);
}
if (workingdays.thursday) {
days.push(4);
}
if (workingdays.friday) {
days.push(5);
}
if (workingdays.saturday) {
days.push(6);
}
if (workingdays.sunday) {
days.push(0);
}
return days;
if (workingdays.monday) {
days.push(1);
}
if (workingdays.tuesday) {
days.push(2);
}
if (workingdays.wednesday) {
days.push(3);
}
if (workingdays.thursday) {
days.push(4);
}
if (workingdays.friday) {
days.push(5);
}
if (workingdays.saturday) {
days.push(6);
}
if (workingdays.sunday) {
days.push(0);
}
return days;
}