Browse Source

add form color

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

25
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) => {
@ -24,8 +28,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
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 = () => {
@ -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