Reformat all project files to use the prettier config file.
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
import {CalendarOutlined} from "@ant-design/icons";
|
||||
import {Card, Col, Divider, Row, Statistic} from "antd";
|
||||
import { CalendarOutlined } from "@ant-design/icons";
|
||||
import { Card, Col, Divider, Row, Statistic } from "antd";
|
||||
import _ from "lodash";
|
||||
import dayjs from "../../utils/day";
|
||||
import React, {useMemo} from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {connect} from "react-redux";
|
||||
import {createStructuredSelector} from "reselect";
|
||||
import {selectBodyshop} from "../../redux/user/user.selectors";
|
||||
import React, { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import ScoreboardJobsList from "../scoreboard-jobs-list/scoreboard-jobs-list.component";
|
||||
import * as Util from "./scoreboard-targets-table.util";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
const rowGutter = [16, 16];
|
||||
const statSpans = {xs: 24, sm: 3};
|
||||
const statSpans = { xs: 24, sm: 3 };
|
||||
|
||||
export function ScoreboardTargetsTable({bodyshop, scoreBoardlist}) {
|
||||
const {t} = useTranslation();
|
||||
export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const values = useMemo(() => {
|
||||
const dateHash = _.groupBy(scoreBoardlist, "date");
|
||||
const values = useMemo(() => {
|
||||
const dateHash = _.groupBy(scoreBoardlist, "date");
|
||||
|
||||
let ret = {
|
||||
todayBody: 0,
|
||||
@@ -35,7 +35,7 @@ export function ScoreboardTargetsTable({bodyshop, scoreBoardlist}) {
|
||||
weeklyBody: 0,
|
||||
toDateBody: 0,
|
||||
toDatePaint: 0,
|
||||
toDateJobs: 0,
|
||||
toDateJobs: 0
|
||||
};
|
||||
|
||||
const today = dayjs();
|
||||
@@ -71,14 +71,11 @@ export function ScoreboardTargetsTable({bodyshop, scoreBoardlist}) {
|
||||
startOfMonth = startOfMonth.add(1, "day");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}, [scoreBoardlist]);
|
||||
return ret;
|
||||
}, [scoreBoardlist]);
|
||||
|
||||
return (
|
||||
<Card
|
||||
title={t("scoreboard.labels.targets")}
|
||||
extra={<ScoreboardJobsList scoreBoardlist={scoreBoardlist} />}
|
||||
>
|
||||
<Card title={t("scoreboard.labels.targets")} extra={<ScoreboardJobsList scoreBoardlist={scoreBoardlist} />}>
|
||||
<Row gutter={rowGutter}>
|
||||
<Col xs={24} sm={{ offset: 0, span: 4 }} lg={{ span: 4 }}>
|
||||
<Statistic
|
||||
@@ -97,49 +94,31 @@ export function ScoreboardTargetsTable({bodyshop, scoreBoardlist}) {
|
||||
/>
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
title={t("scoreboard.labels.dailyactual")}
|
||||
value={values.todayBody.toFixed(1)}
|
||||
/>
|
||||
<Statistic title={t("scoreboard.labels.dailyactual")} value={values.todayBody.toFixed(1)} />
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
title={t("scoreboard.labels.weeklytarget")}
|
||||
value={Util.WeeklyTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyBodyTarget,
|
||||
bodyshop
|
||||
)}
|
||||
value={Util.WeeklyTargetHrs(bodyshop.scoreboard_target.dailyBodyTarget, bodyshop)}
|
||||
/>
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
title={t("scoreboard.labels.weeklyactual")}
|
||||
value={values.weeklyBody.toFixed(1)}
|
||||
/>
|
||||
<Statistic title={t("scoreboard.labels.weeklyactual")} value={values.weeklyBody.toFixed(1)} />
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
title={t("scoreboard.labels.monthlytarget")}
|
||||
value={Util.MonthlyTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyBodyTarget,
|
||||
bodyshop
|
||||
)}
|
||||
value={Util.MonthlyTargetHrs(bodyshop.scoreboard_target.dailyBodyTarget, bodyshop)}
|
||||
/>
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
title={t("scoreboard.labels.asoftodaytarget")}
|
||||
value={Util.AsOfTodayTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyBodyTarget,
|
||||
bodyshop
|
||||
)}
|
||||
value={Util.AsOfTodayTargetHrs(bodyshop.scoreboard_target.dailyBodyTarget, bodyshop)}
|
||||
/>
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
title={t("scoreboard.labels.todateactual")}
|
||||
value={values.toDateBody.toFixed(1)}
|
||||
/>
|
||||
<Statistic title={t("scoreboard.labels.todateactual")} value={values.toDateBody.toFixed(1)} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
@@ -153,31 +132,16 @@ export function ScoreboardTargetsTable({bodyshop, scoreBoardlist}) {
|
||||
<Statistic value={values.todayPaint.toFixed(1)} />
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
value={Util.WeeklyTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyPaintTarget,
|
||||
bodyshop
|
||||
)}
|
||||
/>
|
||||
<Statistic value={Util.WeeklyTargetHrs(bodyshop.scoreboard_target.dailyPaintTarget, bodyshop)} />
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic value={values.weeklyPaint.toFixed(1)} />
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
value={Util.MonthlyTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyPaintTarget,
|
||||
bodyshop
|
||||
)}
|
||||
/>
|
||||
<Statistic value={Util.MonthlyTargetHrs(bodyshop.scoreboard_target.dailyPaintTarget, bodyshop)} />
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
value={Util.AsOfTodayTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyPaintTarget,
|
||||
bodyshop
|
||||
)}
|
||||
/>
|
||||
<Statistic value={Util.AsOfTodayTargetHrs(bodyshop.scoreboard_target.dailyPaintTarget, bodyshop)} />
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic value={values.toDatePaint.toFixed(1)} />
|
||||
@@ -188,67 +152,40 @@ export function ScoreboardTargetsTable({bodyshop, scoreBoardlist}) {
|
||||
</Row>
|
||||
<Row>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
value={"\u00A0"}
|
||||
prefix={t("scoreboard.labels.total")}
|
||||
/>
|
||||
<Statistic value={"\u00A0"} prefix={t("scoreboard.labels.total")} />
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
value={(values.todayPaint + values.todayBody).toFixed(1)}
|
||||
/>
|
||||
<Statistic value={(values.todayPaint + values.todayBody).toFixed(1)} />
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
value={(
|
||||
Util.WeeklyTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyBodyTarget,
|
||||
bodyshop
|
||||
) +
|
||||
Util.WeeklyTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyPaintTarget,
|
||||
bodyshop
|
||||
)
|
||||
Util.WeeklyTargetHrs(bodyshop.scoreboard_target.dailyBodyTarget, bodyshop) +
|
||||
Util.WeeklyTargetHrs(bodyshop.scoreboard_target.dailyPaintTarget, bodyshop)
|
||||
).toFixed(1)}
|
||||
/>
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
value={(values.weeklyPaint + values.weeklyBody).toFixed(1)}
|
||||
/>
|
||||
<Statistic value={(values.weeklyPaint + values.weeklyBody).toFixed(1)} />
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
value={(
|
||||
Util.MonthlyTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyBodyTarget,
|
||||
bodyshop
|
||||
) +
|
||||
Util.MonthlyTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyPaintTarget,
|
||||
bodyshop
|
||||
)
|
||||
Util.MonthlyTargetHrs(bodyshop.scoreboard_target.dailyBodyTarget, bodyshop) +
|
||||
Util.MonthlyTargetHrs(bodyshop.scoreboard_target.dailyPaintTarget, bodyshop)
|
||||
).toFixed(1)}
|
||||
/>
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
value={(
|
||||
Util.AsOfTodayTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyBodyTarget,
|
||||
bodyshop
|
||||
) +
|
||||
Util.AsOfTodayTargetHrs(
|
||||
bodyshop.scoreboard_target.dailyPaintTarget,
|
||||
bodyshop
|
||||
)
|
||||
Util.AsOfTodayTargetHrs(bodyshop.scoreboard_target.dailyBodyTarget, bodyshop) +
|
||||
Util.AsOfTodayTargetHrs(bodyshop.scoreboard_target.dailyPaintTarget, bodyshop)
|
||||
).toFixed(1)}
|
||||
/>
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
value={(values.toDatePaint + values.toDateBody).toFixed(1)}
|
||||
/>
|
||||
<Statistic value={(values.toDatePaint + values.toDateBody).toFixed(1)} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
@@ -256,10 +193,7 @@ export function ScoreboardTargetsTable({bodyshop, scoreBoardlist}) {
|
||||
</Row>
|
||||
<Row>
|
||||
<Col {...statSpans}>
|
||||
<Statistic
|
||||
value={"\u00A0"}
|
||||
prefix={t("scoreboard.labels.jobs")}
|
||||
/>
|
||||
<Statistic value={"\u00A0"} prefix={t("scoreboard.labels.jobs")} />
|
||||
</Col>
|
||||
<Col {...statSpans}>
|
||||
<Statistic value={values.todayJobs} />
|
||||
@@ -279,7 +213,4 @@ export function ScoreboardTargetsTable({bodyshop, scoreBoardlist}) {
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(ScoreboardTargetsTable);
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ScoreboardTargetsTable);
|
||||
|
||||
@@ -1,54 +1,48 @@
|
||||
import dayjs from "../../utils/day";
|
||||
|
||||
export const CalculateWorkingDaysThisMonth = () =>
|
||||
dayjs().endOf("month").businessDaysInMonth().length;
|
||||
export const CalculateWorkingDaysThisMonth = () => dayjs().endOf("month").businessDaysInMonth().length;
|
||||
|
||||
export const CalculateWorkingDaysInPeriod = (start, end) =>
|
||||
dayjs(end).businessDiff(dayjs(start));
|
||||
export const CalculateWorkingDaysInPeriod = (start, end) => dayjs(end).businessDiff(dayjs(start));
|
||||
|
||||
export const CalculateWorkingDaysAsOfToday = () =>
|
||||
dayjs().businessDaysInMonth().length;
|
||||
export const CalculateWorkingDaysAsOfToday = () => dayjs().businessDaysInMonth().length;
|
||||
|
||||
export const CalculateWorkingDaysLastMonth = () =>
|
||||
dayjs().subtract(1, "month").endOf("month").businessDaysInMonth().length;
|
||||
dayjs().subtract(1, "month").endOf("month").businessDaysInMonth().length;
|
||||
|
||||
export const WeeklyTargetHrs = (dailyTargetHrs) =>
|
||||
dailyTargetHrs * CalculateWorkingDaysInPeriod(dayjs().startOf("week"), dayjs().endOf("week"));
|
||||
dailyTargetHrs * CalculateWorkingDaysInPeriod(dayjs().startOf("week"), dayjs().endOf("week"));
|
||||
|
||||
export const WeeklyTargetHrsInPeriod = (dailyTargetHrs, start, end) =>
|
||||
dailyTargetHrs * CalculateWorkingDaysInPeriod(start, end);
|
||||
dailyTargetHrs * CalculateWorkingDaysInPeriod(start, end);
|
||||
|
||||
export const MonthlyTargetHrs = (dailyTargetHrs) =>
|
||||
dailyTargetHrs * CalculateWorkingDaysThisMonth();
|
||||
export const MonthlyTargetHrs = (dailyTargetHrs) => dailyTargetHrs * CalculateWorkingDaysThisMonth();
|
||||
|
||||
export const LastMonthTargetHrs = (dailyTargetHrs) =>
|
||||
dailyTargetHrs * CalculateWorkingDaysLastMonth();
|
||||
export const LastMonthTargetHrs = (dailyTargetHrs) => dailyTargetHrs * CalculateWorkingDaysLastMonth();
|
||||
|
||||
export const AsOfTodayTargetHrs = (dailyTargetHrs) =>
|
||||
dailyTargetHrs * CalculateWorkingDaysAsOfToday();
|
||||
export const AsOfTodayTargetHrs = (dailyTargetHrs) => dailyTargetHrs * CalculateWorkingDaysAsOfToday();
|
||||
|
||||
export const AsOfDateTargetHours = (dailyTargetHours, date) =>
|
||||
dailyTargetHours * dayjs(date).businessDiff(dayjs().startOf("month"));
|
||||
dailyTargetHours * dayjs(date).businessDiff(dayjs().startOf("month"));
|
||||
|
||||
export const ListOfDaysInCurrentMonth = () => {
|
||||
const days = [];
|
||||
let dateStart = dayjs().startOf("month");
|
||||
const dateEnd = dayjs().endOf("month");
|
||||
while (dateEnd.diff(dateStart, "day") > 0) {
|
||||
days.push(dateStart.format("YYYY-MM-DD"));
|
||||
dateStart = dateStart.add(1, "day");
|
||||
}
|
||||
days.push(dateEnd.format("YYYY-MM-DD"));
|
||||
return days;
|
||||
const days = [];
|
||||
let dateStart = dayjs().startOf("month");
|
||||
const dateEnd = dayjs().endOf("month");
|
||||
while (dateEnd.diff(dateStart, "day") > 0) {
|
||||
days.push(dateStart.format("YYYY-MM-DD"));
|
||||
dateStart = dateStart.add(1, "day");
|
||||
}
|
||||
days.push(dateEnd.format("YYYY-MM-DD"));
|
||||
return days;
|
||||
};
|
||||
|
||||
export const ListDaysBetween = ({start, end}) => {
|
||||
const days = [];
|
||||
let dateStart = dayjs(start);
|
||||
const dateEnd = dayjs(end);
|
||||
while (dateEnd.diff(dateStart, "day") >= 0) {
|
||||
days.push(dateStart.format("YYYY-MM-DD"));
|
||||
dateStart = dateStart.add(1, "day");
|
||||
}
|
||||
return days;
|
||||
};
|
||||
export const ListDaysBetween = ({ start, end }) => {
|
||||
const days = [];
|
||||
let dateStart = dayjs(start);
|
||||
const dateEnd = dayjs(end);
|
||||
while (dateEnd.diff(dateStart, "day") >= 0) {
|
||||
days.push(dateStart.format("YYYY-MM-DD"));
|
||||
dateStart = dateStart.add(1, "day");
|
||||
}
|
||||
return days;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user