|
|
@ -9,25 +9,22 @@ import moment from 'moment'; |
|
|
|
import 'antd/dist/antd.css'; |
|
|
|
import 'antd/dist/antd.css'; |
|
|
|
const { Option } = Select |
|
|
|
const { Option } = Select |
|
|
|
|
|
|
|
|
|
|
|
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => { |
|
|
|
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataDivisions }) => { |
|
|
|
const [id, setId] = useState(0) |
|
|
|
const [id, setId] = useState(0) |
|
|
|
const [name, setName] = useState('') |
|
|
|
const [name, setName] = useState('') |
|
|
|
const [uom, setUom] = useState('') |
|
|
|
const [parent, setParent] = useState(null) |
|
|
|
const [description, setDescription] = useState('') |
|
|
|
const [description, setDescription] = useState('') |
|
|
|
const [unitPrice, setUnitPrice] = useState() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onChangeParent = (val) => { |
|
|
|
|
|
|
|
setParent(val) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (typeDialog === "Edit") { |
|
|
|
if (typeDialog === "Edit") { |
|
|
|
console.log("cel data Edit", dataEdit) |
|
|
|
|
|
|
|
setId(dataEdit.id) |
|
|
|
setId(dataEdit.id) |
|
|
|
setDescription(dataEdit.description) |
|
|
|
setDescription(dataEdit.description) |
|
|
|
setUnitPrice(dataEdit.unit_price) |
|
|
|
|
|
|
|
setUom(dataEdit.uom) |
|
|
|
|
|
|
|
setName(dataEdit.name) |
|
|
|
setName(dataEdit.name) |
|
|
|
|
|
|
|
setParent(dataEdit.parent) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setId(0) |
|
|
|
setId(0) |
|
|
|
} |
|
|
|
} |
|
|
@ -38,36 +35,28 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi |
|
|
|
if (typeDialog === "Save") { |
|
|
|
if (typeDialog === "Save") { |
|
|
|
data = { |
|
|
|
data = { |
|
|
|
name: name, |
|
|
|
name: name, |
|
|
|
description |
|
|
|
description, |
|
|
|
|
|
|
|
parent |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
closeDialog('save', data); |
|
|
|
closeDialog('save', data); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
data = { |
|
|
|
data = { |
|
|
|
id, |
|
|
|
id, |
|
|
|
name: name, |
|
|
|
name: name, |
|
|
|
description |
|
|
|
description, |
|
|
|
|
|
|
|
parent |
|
|
|
} |
|
|
|
} |
|
|
|
closeDialog('edit', data); |
|
|
|
closeDialog('edit', data); |
|
|
|
} |
|
|
|
} |
|
|
|
setId(0) |
|
|
|
setId(0) |
|
|
|
setDescription('') |
|
|
|
setDescription('') |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleCancel = () => { |
|
|
|
const handleCancel = () => { |
|
|
|
closeDialog('cancel', 'none') |
|
|
|
closeDialog('cancel', 'none') |
|
|
|
setId(0) |
|
|
|
setId(0) |
|
|
|
|
|
|
|
|
|
|
|
setDescription('') |
|
|
|
setDescription('') |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const renderForm = () => { |
|
|
|
const renderForm = () => { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Form> |
|
|
|
<Form> |
|
|
@ -75,13 +64,32 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi |
|
|
|
<Col md={6}> |
|
|
|
<Col md={6}> |
|
|
|
<FormGroup> |
|
|
|
<FormGroup> |
|
|
|
<Label className="capitalize">Name</Label> |
|
|
|
<Label className="capitalize">Name</Label> |
|
|
|
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={`Input name...`} /> |
|
|
|
<Input type="text" value={name} onChange={(e) => setName(e.target.value)}/> |
|
|
|
</FormGroup> |
|
|
|
</FormGroup> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
|
|
|
|
</Row> |
|
|
|
|
|
|
|
<Row> |
|
|
|
|
|
|
|
<Col md={6}> |
|
|
|
|
|
|
|
<FormGroup> |
|
|
|
|
|
|
|
<Label className="capitalize">Parent</Label> |
|
|
|
|
|
|
|
<Select showSearch |
|
|
|
|
|
|
|
value={parent} |
|
|
|
|
|
|
|
onChange={onChangeParent} |
|
|
|
|
|
|
|
style={{ width: '100%' }} |
|
|
|
|
|
|
|
filterOption={(input, option) => option.children.toLowerCase().includes(input.toLowerCase())} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{dataDivisions.map((res, idx) => ( |
|
|
|
|
|
|
|
<Option key={idx} value={idx}>{res}</Option> |
|
|
|
|
|
|
|
))} |
|
|
|
|
|
|
|
</Select> |
|
|
|
|
|
|
|
</FormGroup> |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
</Row> |
|
|
|
|
|
|
|
<Row> |
|
|
|
<Col md={6}> |
|
|
|
<Col md={6}> |
|
|
|
<FormGroup> |
|
|
|
<FormGroup> |
|
|
|
<Label className="capitalize">Description</Label> |
|
|
|
<Label className="capitalize">Description</Label> |
|
|
|
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={`Description ...`} /> |
|
|
|
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)}/> |
|
|
|
</FormGroup> |
|
|
|
</FormGroup> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
@ -102,17 +110,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi |
|
|
|
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button> |
|
|
|
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button> |
|
|
|
</ModalFooter> |
|
|
|
</ModalFooter> |
|
|
|
</Modal> |
|
|
|
</Modal> |
|
|
|
|
|
|
|
|
|
|
|
{/* <DialogMap |
|
|
|
|
|
|
|
openDialog={openDialogMap} |
|
|
|
|
|
|
|
closeDialog={handleCloseDialogMap} |
|
|
|
|
|
|
|
toggleDialog={() => toggleMapDialog} |
|
|
|
|
|
|
|
dataEdit={dataEdit} |
|
|
|
|
|
|
|
workArea_={workArea} |
|
|
|
|
|
|
|
lat_={lat} |
|
|
|
|
|
|
|
lon_={lon} |
|
|
|
|
|
|
|
radius_={radius} |
|
|
|
|
|
|
|
/> */} |
|
|
|
|
|
|
|
</> |
|
|
|
</> |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|