|
|
@ -1,7 +1,7 @@ |
|
|
|
import React, { useEffect, useState } from 'react' |
|
|
|
import React, { useEffect, useState } from 'react' |
|
|
|
import { |
|
|
|
import { |
|
|
|
Modal, ModalHeader, ModalBody, ModalFooter, |
|
|
|
Modal, ModalHeader, ModalBody, ModalFooter, |
|
|
|
Button, Form, FormGroup, Label, Input, Col, Row |
|
|
|
Button, Form, FormGroup, Label, Input, Col, Row |
|
|
|
} from 'reactstrap'; |
|
|
|
} from 'reactstrap'; |
|
|
|
import { DatePicker, Tooltip, Select } from 'antd'; |
|
|
|
import { DatePicker, Tooltip, Select } from 'antd'; |
|
|
|
import { formatRupiah, formatNumber } from '../../../const/CustomFunc' |
|
|
|
import { formatRupiah, formatNumber } from '../../../const/CustomFunc' |
|
|
@ -9,112 +9,109 @@ 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) |
|
|
|
setName(dataEdit.name) |
|
|
|
setUnitPrice(dataEdit.unit_price) |
|
|
|
setParent(dataEdit.parent) |
|
|
|
setUom(dataEdit.uom) |
|
|
|
} else { |
|
|
|
setName(dataEdit.name) |
|
|
|
setId(0) |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
}, [dataEdit, openDialog]) |
|
|
|
setId(0) |
|
|
|
|
|
|
|
} |
|
|
|
const handleSave = () => { |
|
|
|
}, [dataEdit, openDialog]) |
|
|
|
let data = ''; |
|
|
|
|
|
|
|
if (typeDialog === "Save") { |
|
|
|
const handleSave = () => { |
|
|
|
data = { |
|
|
|
let data = ''; |
|
|
|
name: name, |
|
|
|
if (typeDialog === "Save") { |
|
|
|
description, |
|
|
|
data = { |
|
|
|
parent |
|
|
|
name: name, |
|
|
|
} |
|
|
|
description |
|
|
|
closeDialog('save', data); |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
data = { |
|
|
|
closeDialog('save', data); |
|
|
|
id, |
|
|
|
} else { |
|
|
|
name: name, |
|
|
|
data = { |
|
|
|
description, |
|
|
|
id, |
|
|
|
parent |
|
|
|
name: name, |
|
|
|
} |
|
|
|
description |
|
|
|
closeDialog('edit', data); |
|
|
|
} |
|
|
|
} |
|
|
|
closeDialog('edit', data); |
|
|
|
setId(0) |
|
|
|
} |
|
|
|
setDescription('') |
|
|
|
setId(0) |
|
|
|
} |
|
|
|
setDescription('') |
|
|
|
const handleCancel = () => { |
|
|
|
|
|
|
|
closeDialog('cancel', 'none') |
|
|
|
} |
|
|
|
setId(0) |
|
|
|
|
|
|
|
setDescription('') |
|
|
|
const handleCancel = () => { |
|
|
|
} |
|
|
|
closeDialog('cancel', 'none') |
|
|
|
|
|
|
|
setId(0) |
|
|
|
const renderForm = () => { |
|
|
|
|
|
|
|
return ( |
|
|
|
setDescription('') |
|
|
|
<Form> |
|
|
|
|
|
|
|
<Row> |
|
|
|
} |
|
|
|
<Col md={6}> |
|
|
|
|
|
|
|
<FormGroup> |
|
|
|
|
|
|
|
<Label className="capitalize">Name</Label> |
|
|
|
|
|
|
|
<Input type="text" value={name} onChange={(e) => setName(e.target.value)}/> |
|
|
|
|
|
|
|
</FormGroup> |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
</Row> |
|
|
|
const renderForm = () => { |
|
|
|
<Row> |
|
|
|
return ( |
|
|
|
<Col md={6}> |
|
|
|
<Form> |
|
|
|
<FormGroup> |
|
|
|
<Row> |
|
|
|
<Label className="capitalize">Parent</Label> |
|
|
|
<Col md={6}> |
|
|
|
<Select showSearch |
|
|
|
<FormGroup> |
|
|
|
value={parent} |
|
|
|
<Label className="capitalize">Name</Label> |
|
|
|
onChange={onChangeParent} |
|
|
|
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={`Input name...`} /> |
|
|
|
style={{ width: '100%' }} |
|
|
|
</FormGroup> |
|
|
|
filterOption={(input, option) => option.children.toLowerCase().includes(input.toLowerCase())} |
|
|
|
</Col> |
|
|
|
> |
|
|
|
<Col md={6}> |
|
|
|
{dataDivisions.map((res, idx) => ( |
|
|
|
<FormGroup> |
|
|
|
<Option key={idx} value={idx}>{res}</Option> |
|
|
|
<Label className="capitalize">Description</Label> |
|
|
|
))} |
|
|
|
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={`Description ...`} /> |
|
|
|
</Select> |
|
|
|
</FormGroup> |
|
|
|
</FormGroup> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
</Form> |
|
|
|
<Row> |
|
|
|
) |
|
|
|
<Col md={6}> |
|
|
|
} |
|
|
|
<FormGroup> |
|
|
|
|
|
|
|
<Label className="capitalize">Description</Label> |
|
|
|
|
|
|
|
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)}/> |
|
|
|
return ( |
|
|
|
</FormGroup> |
|
|
|
<> |
|
|
|
</Col> |
|
|
|
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}> |
|
|
|
</Row> |
|
|
|
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Resource</ModalHeader> |
|
|
|
</Form> |
|
|
|
<ModalBody> |
|
|
|
) |
|
|
|
{renderForm()} |
|
|
|
} |
|
|
|
</ModalBody> |
|
|
|
|
|
|
|
<ModalFooter> |
|
|
|
|
|
|
|
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '} |
|
|
|
return ( |
|
|
|
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button> |
|
|
|
<> |
|
|
|
</ModalFooter> |
|
|
|
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}> |
|
|
|
</Modal> |
|
|
|
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Resource</ModalHeader> |
|
|
|
|
|
|
|
<ModalBody> |
|
|
|
{/* <DialogMap |
|
|
|
{renderForm()} |
|
|
|
openDialog={openDialogMap} |
|
|
|
</ModalBody> |
|
|
|
closeDialog={handleCloseDialogMap} |
|
|
|
<ModalFooter> |
|
|
|
toggleDialog={() => toggleMapDialog} |
|
|
|
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '} |
|
|
|
dataEdit={dataEdit} |
|
|
|
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button> |
|
|
|
workArea_={workArea} |
|
|
|
</ModalFooter> |
|
|
|
lat_={lat} |
|
|
|
</Modal> |
|
|
|
lon_={lon} |
|
|
|
</> |
|
|
|
radius_={radius} |
|
|
|
) |
|
|
|
/> */} |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|