Added owners detail fields and owner jobs list.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { Form, notification } from "antd";
|
||||
import React from "react";
|
||||
import { useMutation } from "react-apollo";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { UPDATE_OWNER } from "../../graphql/owners.queries";
|
||||
import OwnerDetailFormComponent from "./owner-detail-form.component";
|
||||
|
||||
function OwnerDetailFormContainer({ form, owner, refetch }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [updateOwner] = useMutation(UPDATE_OWNER);
|
||||
|
||||
const handleSubmit = e => {
|
||||
e.preventDefault();
|
||||
|
||||
form.validateFieldsAndScroll((err, values) => {
|
||||
if (err) {
|
||||
notification["error"]({
|
||||
message: t("owners.errors.validationtitle"),
|
||||
description: t("owners.errors.validation")
|
||||
});
|
||||
}
|
||||
if (!err) {
|
||||
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();
|
||||
form.resetFields();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Form onSubmit={handleSubmit} autoComplete="off">
|
||||
<OwnerDetailFormComponent form={form} owner={owner} />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
export default Form.create({ name: "OwnerDetailFormContainer" })(
|
||||
OwnerDetailFormContainer
|
||||
);
|
||||
Reference in New Issue
Block a user