Fixed vehicle and owner pages with transition prevention. BOD-127

This commit is contained in:
Patrick Fic
2020-07-13 16:14:49 -07:00
parent cff21c5bdf
commit e2f7566783
6 changed files with 55 additions and 31 deletions

View File

@@ -11,26 +11,37 @@ function OwnerDetailFormContainer({ owner, refetch }) {
const [updateOwner] = useMutation(UPDATE_OWNER);
const handleFinish = (values) => {
updateOwner({
const handleFinish = async (values) => {
const result = await updateOwner({
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 (
<Form
form={form}
onFinish={handleFinish}
autoComplete='off'
layout='vertical'
initialValues={owner}>
autoComplete="off"
layout="vertical"
initialValues={owner}
>
<OwnerDetailFormComponent form={form} />
</Form>
);