Fixed vehicle and owner pages with transition prevention. BOD-127
This commit is contained in:
@@ -3,7 +3,6 @@ import moment from "moment";
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import aamva from "../../utils/aamva";
|
import aamva from "../../utils/aamva";
|
||||||
import aamva_npm from "aamva";
|
|
||||||
import DataLabel from "../data-label/data-label.component";
|
import DataLabel from "../data-label/data-label.component";
|
||||||
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
|
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
|
||||||
|
|
||||||
|
|||||||
@@ -11,26 +11,37 @@ function OwnerDetailFormContainer({ owner, refetch }) {
|
|||||||
|
|
||||||
const [updateOwner] = useMutation(UPDATE_OWNER);
|
const [updateOwner] = useMutation(UPDATE_OWNER);
|
||||||
|
|
||||||
const handleFinish = (values) => {
|
const handleFinish = async (values) => {
|
||||||
updateOwner({
|
const result = await updateOwner({
|
||||||
variables: { ownerId: owner.id, owner: values },
|
variables: { ownerId: owner.id, owner: values },
|
||||||
}).then((r) => {
|
|
||||||
notification["success"]({
|
|
||||||
message: t("owners.successes.save"),
|
|
||||||
});
|
|
||||||
//TODO Better way to reset the field decorators?
|
|
||||||
if (refetch) refetch().then();
|
|
||||||
// resetFields();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!!result.errors) {
|
||||||
|
notification["error"]({
|
||||||
|
message: t("owners.errors.saving", {
|
||||||
|
message: JSON.stringify(result.errors),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
notification["success"]({
|
||||||
|
message: t("owners.successes.save"),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (refetch) await refetch();
|
||||||
|
form.resetFields();
|
||||||
|
form.resetFields();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
onFinish={handleFinish}
|
onFinish={handleFinish}
|
||||||
autoComplete='off'
|
autoComplete="off"
|
||||||
layout='vertical'
|
layout="vertical"
|
||||||
initialValues={owner}>
|
initialValues={owner}
|
||||||
|
>
|
||||||
<OwnerDetailFormComponent form={form} />
|
<OwnerDetailFormComponent form={form} />
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import React, { useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link, useHistory, useLocation } from "react-router-dom";
|
import { Link, useHistory, useLocation } from "react-router-dom";
|
||||||
import PhoneFormatter from "../../utils/PhoneFormatter";
|
import PhoneFormatter from "../../utils/PhoneFormatter";
|
||||||
import { alphaSort } from "../../utils/sorters";
|
|
||||||
|
|
||||||
export default function OwnersListComponent({
|
export default function OwnersListComponent({
|
||||||
loading,
|
loading,
|
||||||
@@ -14,7 +13,10 @@ export default function OwnersListComponent({
|
|||||||
refetch,
|
refetch,
|
||||||
}) {
|
}) {
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
const { page, sortcolumn, sortorder } = search;
|
const {
|
||||||
|
page,
|
||||||
|
// sortcolumn, sortorder
|
||||||
|
} = search;
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ import { Layout, Menu } from "antd";
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { FiLogIn, FiLogOut } from "react-icons/fi";
|
import { FiLogIn, FiLogOut } from "react-icons/fi";
|
||||||
import { MdTimer, MdTimerOff } from "react-icons/md";
|
import { MdTimer } from "react-icons/md";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { selectTechnician } from "../../redux/tech/tech.selectors";
|
|
||||||
import { techLogout } from "../../redux/tech/tech.actions";
|
import { techLogout } from "../../redux/tech/tech.actions";
|
||||||
|
import { selectTechnician } from "../../redux/tech/tech.selectors";
|
||||||
const { Sider } = Layout;
|
const { Sider } = Layout;
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
|||||||
@@ -11,28 +11,39 @@ function VehicleDetailFormContainer({ vehicle, refetch }) {
|
|||||||
const [updateVehicle] = useMutation(UPDATE_VEHICLE);
|
const [updateVehicle] = useMutation(UPDATE_VEHICLE);
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
const handleFinish = (values) => {
|
const handleFinish = async (values) => {
|
||||||
updateVehicle({
|
const result = await updateVehicle({
|
||||||
variables: { vehId: vehicle.id, vehicle: values },
|
variables: { vehId: vehicle.id, vehicle: values },
|
||||||
}).then((r) => {
|
|
||||||
notification["success"]({
|
|
||||||
message: t("vehicles.successes.save"),
|
|
||||||
});
|
|
||||||
//TODO Better way to reset the field decorators?
|
|
||||||
if (refetch) refetch();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!!result.errors) {
|
||||||
|
notification["error"]({
|
||||||
|
message: t("vehicles.errors.saving", {
|
||||||
|
message: JSON.stringify(result.errors),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
notification["success"]({
|
||||||
|
message: t("vehicles.successes.save"),
|
||||||
|
});
|
||||||
|
//TODO Better way to reset the field decorators?
|
||||||
|
if (refetch) await refetch();
|
||||||
|
form.resetFields();
|
||||||
|
form.resetFields();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
onFinish={handleFinish}
|
onFinish={handleFinish}
|
||||||
form={form}
|
form={form}
|
||||||
autoComplete='off'
|
autoComplete="off"
|
||||||
layout='vertical'
|
layout="vertical"
|
||||||
initialValues={{
|
initialValues={{
|
||||||
...vehicle,
|
...vehicle,
|
||||||
v_prod_dt: vehicle.v_prod_dt ? moment(vehicle.v_prod_dt) : null,
|
v_prod_dt: vehicle.v_prod_dt ? moment(vehicle.v_prod_dt) : null,
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<VehicleDetailFormComponent form={form} />
|
<VehicleDetailFormComponent form={form} />
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import queryString from "query-string";
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link, useHistory, useLocation } from "react-router-dom";
|
import { Link, useHistory, useLocation } from "react-router-dom";
|
||||||
import { alphaSort } from "../../utils/sorters";
|
|
||||||
|
|
||||||
export default function VehiclesListComponent({
|
export default function VehiclesListComponent({
|
||||||
loading,
|
loading,
|
||||||
vehicles,
|
vehicles,
|
||||||
@@ -13,7 +11,10 @@ export default function VehiclesListComponent({
|
|||||||
refetch,
|
refetch,
|
||||||
}) {
|
}) {
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
const { page, sortcolumn, sortorder } = search;
|
const {
|
||||||
|
page,
|
||||||
|
//sortcolumn, sortorder
|
||||||
|
} = search;
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
|
|||||||
Reference in New Issue
Block a user