Refactored job line edit modal to use redux so that it can be an independent form. Created general modals reducer to manage all modals.
This commit is contained in:
@@ -1,31 +1,33 @@
|
||||
import { Input, Modal } from "antd";
|
||||
import { Modal, Form } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export default function JobLinesUpsertModalComponent({
|
||||
visible,
|
||||
changeVisibility,
|
||||
lineState,
|
||||
setLineState,
|
||||
updateExistingLine,
|
||||
insertNewLine
|
||||
jobLine,
|
||||
handleOk,
|
||||
handleCancel,
|
||||
handleSubmit,
|
||||
form
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const handleChange = e => {
|
||||
setLineState({ ...lineState, [e.target.name]: e.target.value });
|
||||
};
|
||||
//const { getFieldDecorator, isFieldsTouched, resetFields } = form;
|
||||
console.log("jobLine", jobLine);
|
||||
return (
|
||||
<Modal
|
||||
title={lineState.id ? t("joblines.label.edit") : t("joblines.label.new")}
|
||||
title={
|
||||
jobLine && jobLine.id
|
||||
? t("joblines.labels.edit")
|
||||
: t("joblines.labels.new")
|
||||
}
|
||||
visible={visible}
|
||||
okText={t("general.labels.save")}
|
||||
onOk={() => {
|
||||
lineState.id ? updateExistingLine() : insertNewLine();
|
||||
}}
|
||||
onCancel={() => {
|
||||
changeVisibility(false);
|
||||
}}>
|
||||
<Input.TextArea rows={8} value={lineState.text} onChange={handleChange} />
|
||||
onOk={handleOk}
|
||||
onCancel={handleCancel}
|
||||
>
|
||||
<Form onSubmit={handleSubmit} autoComplete={"off"}>
|
||||
{JSON.stringify(jobLine)}
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user