Browse Source

add form color

pull/2/head
wahyuun 1 year ago
parent
commit
c9267b0a42
  1. 59
      src/views/SimproV2/Divisi/DialogForm.js

59
src/views/SimproV2/Divisi/DialogForm.js

@ -6,12 +6,16 @@ import {
import { Select } from 'antd'; import { Select } from 'antd';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import InputColor from "./InputColor";
import "./styles.css";
import "rc-color-picker/assets/index.css";
const { Option } = Select const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataDivisions }) => { 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 [parent, setParent] = useState(null) const [parent, setParent] = useState(null)
const [description, setDescription] = useState('') const [description, setDescription] = useState('')
const [color, setColor] = useState('')
const { t } = useTranslation() const { t } = useTranslation()
const onChangeParent = (val) => { const onChangeParent = (val) => {
@ -23,9 +27,11 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setId(dataEdit.id) setId(dataEdit.id)
setDescription(dataEdit.description) setDescription(dataEdit.description)
setName(dataEdit.name) setName(dataEdit.name)
setParent(dataEdit.parent) setParent(dataEdit.parent)
setColor(dataEdit.color)
} else { } else {
setId(0) setId(0)
setColor('')
} }
}, [dataEdit, openDialog]) }, [dataEdit, openDialog])
@ -42,17 +48,19 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
if (!err) { if (!err) {
if (typeDialog === "Save") { if (typeDialog === "Save") {
data = { data = {
name: name, name,
description, description,
parent parent,
color
} }
closeDialog('save', data); closeDialog('save', data);
} else { } else {
data = { data = {
id, id,
name: name, name,
description, description,
parent parent,
color
} }
closeDialog('edit', data); closeDialog('edit', data);
} }
@ -60,6 +68,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setDescription('') setDescription('')
setName('') setName('')
setParent(null) setParent(null)
setColor('')
} }
} }
const handleCancel = () => { const handleCancel = () => {
@ -91,22 +100,22 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup> </FormGroup>
</Col> </Col>
<Col md={6}> <Col md={6}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('Parent Division')}</Label> <Label className="capitalize">{t('Parent Division')}</Label>
<Select showSearch <Select showSearch
value={parent} value={parent}
onChange={onChangeParent} onChange={onChangeParent}
style={{ width: '100%' }} style={{ width: '100%' }}
filterOption={(input, option) => option.children.toLowerCase().includes(input.toLowerCase())} filterOption={(input, option) => option.children.toLowerCase().includes(input.toLowerCase())}
> >
{dataDivisions.map((res, idx) => ( {dataDivisions.map((res, idx) => (
<Option key={res['id']} value={res['id']}>{res['displayName']}</Option> <Option key={res['id']} value={res['id']}>{res['displayName']}</Option>
))} ))}
</Select> </Select>
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col md={12}> <Col md={12}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('description')}</Label> <Label className="capitalize">{t('description')}</Label>
@ -114,6 +123,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">{t('color')}</Label>
<InputColor value={color} color={color} onChange={(e) => setColor(e.color)} />
</FormGroup>
</Col>
</Row>
</Form> </Form>
) )
} }

Loading…
Cancel
Save