Added some additional save indiactors BOD-134

This commit is contained in:
Patrick Fic
2020-08-21 17:17:36 -07:00
parent 4a92ef03cc
commit dd1016eef3
13 changed files with 127 additions and 81 deletions

View File

@@ -9,11 +9,14 @@ export default function ContractCreatePageComponent({
form,
selectedJobState,
selectedCarState,
loading,
}) {
const { t } = useTranslation();
return (
<div>
<Button htmlType="submit">{t("general.actions.create")}</Button>
<Button type="primary" onClick={() => form.submit()} loading={loading}>
{t("general.actions.create")}
</Button>
<ContractJobsContainer selectedJobState={selectedJobState} />
<ContractCarsContainer selectedCarState={selectedCarState} />
<ContractLicenseDecodeButton form={form} />

View File

@@ -23,6 +23,7 @@ export function ContractCreatePageContainer({ bodyshop, setBreadcrumbs }) {
const { t } = useTranslation();
const history = useHistory();
const location = useLocation();
const [loading, setLoading] = useState(false);
const selectedCarState = useState(null);
const selectedJobState = useState(
(location.state && location.state.jobId) || null
@@ -31,6 +32,7 @@ export function ContractCreatePageContainer({ bodyshop, setBreadcrumbs }) {
const handleFinish = (values) => {
if (!!selectedCarState[0] && !!selectedJobState[0]) {
setLoading(true);
insertContract({
variables: {
contract: {
@@ -61,6 +63,7 @@ export function ContractCreatePageContainer({ bodyshop, setBreadcrumbs }) {
message: t("contracts.errors.selectjobandcar"),
});
}
setLoading(false);
};
useEffect(() => {
@@ -84,9 +87,11 @@ export function ContractCreatePageContainer({ bodyshop, setBreadcrumbs }) {
form={form}
layout="vertical"
autoComplete="no"
initialValues={{ status: "contracts.status.new" }}
onFinish={handleFinish}
>
<ContractCreatePageComponent
loading={loading}
form={form}
selectedJobState={selectedJobState}
selectedCarState={selectedCarState}