From bcfd8228a232f04166c20e4f1aab749808f482d7 Mon Sep 17 00:00:00 2001 From: farhantock Date: Tue, 5 Dec 2023 13:57:17 +0700 Subject: [PATCH] add company_id --- src/views/SimproV2/Divisi/DialogForm.js | 140 ++++++++++++------------ 1 file changed, 71 insertions(+), 69 deletions(-) diff --git a/src/views/SimproV2/Divisi/DialogForm.js b/src/views/SimproV2/Divisi/DialogForm.js index 62ce6c2..ee43a37 100644 --- a/src/views/SimproV2/Divisi/DialogForm.js +++ b/src/views/SimproV2/Divisi/DialogForm.js @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react' import { - Modal, ModalHeader, ModalBody, ModalFooter, - Button, Form, FormGroup, Label, Input, Col, Row + Modal, ModalHeader, ModalBody, ModalFooter, + Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; import { Select } from 'antd'; import 'antd/dist/antd.css'; @@ -10,30 +10,30 @@ import InputColor from "./InputColor"; import "./styles.css"; import "rc-color-picker/assets/index.css"; const { Option } = Select -const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataDivisions }) => { - const [id, setId] = useState(0) - const [name, setName] = useState('') - const [parent, setParent] = useState(null) - const [description, setDescription] = useState('') +const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataDivisions, company_id }) => { + const [id, setId] = useState(0) + const [name, setName] = useState('') + const [parent, setParent] = useState(null) + const [description, setDescription] = useState('') const [color, setColor] = useState('') - const { t } = useTranslation() + const { t } = useTranslation() - const onChangeParent = (val) => { - setParent(val) - } + const onChangeParent = (val) => { + setParent(val) + } - useEffect(() => { - if (typeDialog === "Edit") { - setId(dataEdit.id) - setDescription(dataEdit.description) - setName(dataEdit.name) + useEffect(() => { + if (typeDialog === "Edit") { + setId(dataEdit.id) + setDescription(dataEdit.description) + setName(dataEdit.name) setParent(dataEdit.parent) setColor(dataEdit.color) - } else { - setId(0) + } else { + setId(0) setColor('') - } - }, [dataEdit, openDialog]) + } + }, [dataEdit, openDialog]) const validation = () => { if (!name || name === "") { @@ -51,7 +51,8 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi name, description, parent, - color + color, + company_id } closeDialog('save', data); } else { @@ -60,7 +61,8 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi name, description, parent, - color + color, + company_id } closeDialog('edit', data); } @@ -70,34 +72,34 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi setParent(null) setColor('') } - } - const handleCancel = () => { - closeDialog('cancel', 'none') - setId(0) - setDescription('') + } + const handleCancel = () => { + closeDialog('cancel', 'none') + setId(0) + setDescription('') setName('') setParent(null) - } + } - const renderForm = () => { - return ( -
+ const renderForm = () => { + return ( + - - * Wajib diisi. - + + * Wajib diisi. + - - - - - setName(e.target.value)} - placeholder={t('inputName')} - /> - + + + + + setName(e.target.value)} + placeholder={t('inputName')} + /> + @@ -116,13 +118,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi - - - - setDescription(e.target.value)} placeholder={t('inputDescription')} /> - - - + + + + setDescription(e.target.value)} placeholder={t('inputDescription')} /> + + + @@ -131,25 +133,25 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi -
- ) - } + + ) + } - return ( - <> - - {typeDialog == "Save" ? `Add` : "Edit"} {t('division')} - - {renderForm()} - - - {' '} - - - - - ) + return ( + <> + + {typeDialog == "Save" ? `Add` : "Edit"} {t('division')} + + {renderForm()} + + + {' '} + + + + + ) }