Bug fixes and formatting for RO guard.

This commit is contained in:
Patrick Fic
2024-04-11 09:49:00 -07:00
parent e5599ff4c4
commit 453236cf3a
11 changed files with 146 additions and 130 deletions

View File

@@ -1,20 +1,19 @@
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState } from "react";
import { LockOutlined } from '@ant-design/icons';
import { Card, Form, Input } from 'antd';
import axios from 'axios';
import { useTranslation } from 'react-i18next';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { selectJobReadOnly } from '../../redux/application/application.selectors';
import { selectBodyshop } from '../../redux/user/user.selectors';
import JobCostingStatistics from '../job-costing-statistics/job-costing-statistics.component';
import LoadingSkeleton from '../loading-skeleton/loading-skeleton.component';
import { Alert, Card } from "antd";
import axios from "axios";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectJobReadOnly } from "../../redux/application/application.selectors";
import { selectBodyshop } from "../../redux/user/user.selectors";
import JobCostingStatistics from "../job-costing-statistics/job-costing-statistics.component";
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
bodyshop: selectBodyshop,
jobRO: selectJobReadOnly,
jobRO: selectJobReadOnly
});
const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
@@ -31,7 +30,7 @@ export function JobCloseRoGuardProfit({ job, jobRO, bodyshop, form, warningCallb
try {
if (job.id) {
setLoading(true);
const { data } = await axios.post('/job/costing', { jobid: job.id });
const { data } = await axios.post("/job/costing", { jobid: job.id });
setCostingData(data);
}
} catch (error) {}
@@ -45,16 +44,19 @@ export function JobCloseRoGuardProfit({ job, jobRO, bodyshop, form, warningCallb
parseFloat(costingData?.summaryData.gppercent) < bodyshop?.md_ro_guard?.totalgppercent_minimum;
useEffect(() => {
if (enforceProfitPassword && typeof warningCallback === 'function') {
warningCallback({ key: 'profit', warning: t('jobs.labels.profitbypassrequired') });
if (enforceProfitPassword && typeof warningCallback === "function") {
warningCallback({ key: "profit", warning: t("jobs.labels.profitbypassrequired") });
}
}, [enforceProfitPassword, t, warningCallback]);
if (loading || !costingData) return <LoadingSkeleton />;
return (
<Card title={t('jobs.labels.profits')} style={{ height: '100%' }}>
<Card title={t("jobs.labels.profits")} style={{ height: "100%" }}>
<JobCostingStatistics summaryData={costingData?.summaryData} onlyGP />
{enforceProfitPassword && (
<Alert style={{ margin: "8px 0px" }} type="warning" message={t("jobs.labels.profitbypassrequired")} />
)}
</Card>
);
}