STILL BROKEN: Refactored some forms to have bare functionality. Appears that v4 antd has extensive issues.
This commit is contained in:
@@ -5,42 +5,34 @@ import { useTranslation } from "react-i18next";
|
||||
import { UPDATE_OWNER } from "../../graphql/owners.queries";
|
||||
import OwnerDetailFormComponent from "./owner-detail-form.component";
|
||||
|
||||
function OwnerDetailFormContainer({ form, owner, refetch }) {
|
||||
function OwnerDetailFormContainer({ owner, refetch }) {
|
||||
const { t } = useTranslation();
|
||||
const [form] = Form.useForm();
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
const handleFinish = values => {
|
||||
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();
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Form onSubmit={handleSubmit} autoComplete="off">
|
||||
<OwnerDetailFormComponent form={form} owner={owner} />
|
||||
<Form
|
||||
form={form}
|
||||
onFinish={handleFinish}
|
||||
autoComplete="off"
|
||||
initialValues={owner}
|
||||
>
|
||||
<OwnerDetailFormComponent form={form} />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
export default Form.create({ name: "OwnerDetailFormContainer" })(
|
||||
OwnerDetailFormContainer
|
||||
);
|
||||
export default OwnerDetailFormContainer;
|
||||
|
||||
Reference in New Issue
Block a user