Added scoreboard edt for added entries BOD-365

This commit is contained in:
Patrick Fic
2020-08-28 16:34:48 -07:00
parent ab4262c238
commit 266b6b0dbb
14 changed files with 241 additions and 23 deletions

View File

@@ -1,5 +1,6 @@
import React from "react";
import { Tag } from "antd";
import Dinero from "dinero.js";
export default function JobsCloseLabMatAllocationTags({
allocationKey,
allocation,
@@ -27,7 +28,7 @@ export default function JobsCloseLabMatAllocationTags({
});
}}
key={idx}
>{`${a.center} - ${a.amount.toFormat()}`}</Tag>
>{`${a.center} - ${Dinero(a.amount).toFormat()}`}</Tag>
))}
</div>
);

View File

@@ -5,7 +5,7 @@ import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { useTranslation } from "react-i18next";
import { logImEXEvent } from "../../firebase/firebase.utils";
import Dinero from "dinero.js";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
});
@@ -28,7 +28,10 @@ export function JobsCloseAutoAllocate({
Object.keys(labmatAllocations).forEach((i) => {
const defaultProfitCenter = defaults.profits[i.toUpperCase()];
if (!!defaultProfitCenter && labmatAllocations[i].total.getAmount() > 0) {
if (
!!defaultProfitCenter &&
Dinero(labmatAllocations[i].total).getAmount() > 0
) {
setLabmatAllocations((st) => {
return {
...st,
@@ -49,7 +52,10 @@ export function JobsCloseAutoAllocate({
Object.keys(partsAllocations).forEach((i) => {
const defaultProfitCenter = defaults.profits[i.toUpperCase()];
if (!!defaultProfitCenter && partsAllocations[i].total.getAmount() > 0) {
if (
!!defaultProfitCenter &&
Dinero(partsAllocations[i].total).getAmount() > 0
) {
setPartsAllocations((st) => {
return {
...st,

View File

@@ -40,8 +40,7 @@ export default function JobCloseLabMatAllocation({
Dinero({
amount: labmatAllocations[alloc].allocations.reduce(
(acc, val) => {
console.log("val :>> ", val);
return acc + val.amount.getAmount();
return acc + Dinero(val.amount).getAmount();
},
0
),
@@ -58,7 +57,7 @@ export default function JobCloseLabMatAllocation({
Dinero({
amount: labmatAllocations[alloc].allocations.reduce(
(acc, val) => {
return acc + val.amount.getAmount();
return acc + Dinero(val.amount).getAmount();
},
0
),

View File

@@ -40,7 +40,7 @@ export default function JobsClosePartsAllocation({
Dinero({
amount: partsAllocations[alloc].allocations.reduce(
(acc, val) => {
return acc + val.amount.getAmount();
return acc + Dinero(val.amount).getAmount();
},
0
),
@@ -57,7 +57,7 @@ export default function JobsClosePartsAllocation({
Dinero({
amount: partsAllocations[alloc].allocations.reduce(
(acc, val) => {
return acc + val.amount.getAmount();
return acc + Dinero(val.amount).getAmount();
},
0
),

View File

@@ -100,7 +100,6 @@ export function ScheduleCalendarHeaderComponent({
</div>
</Popover>
) : null;
console.log("loadData", loadData);
return (
<div className="imex-calendar-load">

View File

@@ -0,0 +1,104 @@
import { Button, Card, Dropdown, Form, InputNumber, notification } from "antd";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import FormDatePicker from "../form-date-picker/form-date-picker.component";
import { useMutation } from "react-apollo";
import { UPDATE_SCOREBOARD_ENTRY } from "../../graphql/scoreboard.queries";
export default function ScoreboardEntryEdit({ entry }) {
const [visible, setVisible] = useState(false);
const [loading, setLoading] = useState(false);
const { t } = useTranslation();
const [updateScoreboardentry] = useMutation(UPDATE_SCOREBOARD_ENTRY);
const handleFinish = async (values) => {
setLoading(true);
const result = await updateScoreboardentry({
variables: { sbId: entry.id, sbInput: values },
});
if (!!result.errors) {
notification["error"]({
message: t("scoreboard.errors.updating", {
message: JSON.stringify(result.errors),
}),
});
return;
} else {
notification["success"]({
message: t("scoredboard.successes.updated"),
});
setVisible(false);
}
setLoading(false);
};
const popContent = (
<Card style={{ padding: "1rem" }}>
<Form
layout="vertical"
initialValues={entry}
onFinish={handleFinish}
onClick={(e) => e.stopPropagation()}
>
<Form.Item
label={t("scoreboard.fields.date")}
name="date"
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<FormDatePicker />
</Form.Item>
<Form.Item
label={t("scoreboard.fields.bodyhrs")}
name="bodyhrs"
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<InputNumber precision={1} />
</Form.Item>
<Form.Item
label={t("scoreboard.fields.painthrs")}
name="painthrs"
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<InputNumber precision={1} />
</Form.Item>
<Button type="primary" loading={loading} htmlType="submit">
{t("general.actions.save")}
</Button>
<Button onClick={() => setVisible(false)}>
{t("general.actions.cancel")}
</Button>
</Form>
</Card>
);
return (
<div>
<Dropdown visible={visible} overlay={popContent}>
<Button
onClick={(e) => {
e.stopPropagation();
setVisible(true);
}}
>
{t("scoreboard.actions.edit")}
</Button>
</Dropdown>
</div>
);
}

View File

@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import ScoreboardRemoveButton from "../scoreboard-remove-button/scorebard-remove-button.component";
import { DateFormatter } from "../../utils/DateFormatter";
import ScoreboardEntryEdit from "../scoreboard-entry-edit/scoreboard-entry-edit.component";
export default function ScoreboardJobsList({ scoreBoardlist }) {
const { t } = useTranslation();
@@ -49,6 +50,7 @@ export default function ScoreboardJobsList({ scoreBoardlist }) {
key: "actions",
render: (text, record) => (
<div>
<ScoreboardEntryEdit entry={record} style={{ zIndex: 15 }} />
<ScoreboardRemoveButton scoreboardId={record.id} />
</div>
),
@@ -56,14 +58,16 @@ export default function ScoreboardJobsList({ scoreBoardlist }) {
];
const overlay = (
<div style={{ width: "50vw" }}>
<div style={{ width: "50vw", padding: "1rem" }}>
<Table
size='small'
size="small"
pagination={false}
columns={columns}
rowKey='id'
rowKey="id"
dataSource={scoreBoardlist}
scroll={{ x: true, y: "15rem" }}
style={{ padding: "1rem" }}
onClick={(e) => e.stopPropagation()}
/>
</div>
);