|
|
|
@ -7,21 +7,10 @@ import { DatePicker, Tooltip, Select, Input as InputAntd } from 'antd';
|
|
|
|
|
import moment from 'moment'; |
|
|
|
|
import 'antd/dist/antd.css'; |
|
|
|
|
import { formatRupiah, formatNumber } from '../../../const/CustomFunc' |
|
|
|
|
import { ROLE_SEARCH } from '../../../const/ApiConst' |
|
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
|
const { Option } = Select |
|
|
|
|
|
|
|
|
|
const token = window.localStorage.getItem('token'); |
|
|
|
|
const company_id = localStorage.getItem("company_id") |
|
|
|
|
const config = { |
|
|
|
|
headers: |
|
|
|
|
{ |
|
|
|
|
Authorization: `Bearer ${token}`, |
|
|
|
|
"Content-type": `application/json` |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList }) => { |
|
|
|
|
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList, role_name, companyList, company_id }) => { |
|
|
|
|
const [openDialogMap, setOpenDialogMap] = useState(false) |
|
|
|
|
|
|
|
|
|
const [id, setId] = useState(0) |
|
|
|
@ -39,6 +28,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
|
|
|
|
|
const [ktpNumber, setKtpNumber] = useState('') |
|
|
|
|
const [biayaPerJam, setBiayaPerJam] = useState('') |
|
|
|
|
const [roleId, setRoleId] = useState('') |
|
|
|
|
const [scompany_id, setCompanyId] = useState(null); |
|
|
|
|
const [address, setAddress] = useState('') |
|
|
|
|
const [divisionId, setDivisionId] = useState('') |
|
|
|
|
const [statusResource, setStatusResource] = useState('active') |
|
|
|
@ -55,6 +45,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
|
|
|
|
|
setPhoneNo(dataEdit.phone_number) |
|
|
|
|
setEmail(dataEdit.email) |
|
|
|
|
setGender(dataEdit.gender) |
|
|
|
|
setCompanyId(dataEdit.company_id) |
|
|
|
|
setBirthDate(dataEdit.birth_date ? moment(dataEdit.birth_date) : "") |
|
|
|
|
setBirthPlace(dataEdit.birth_place) |
|
|
|
|
setBloodType(dataEdit.blood_type) |
|
|
|
@ -82,6 +73,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
|
|
|
|
|
setRoleId('') |
|
|
|
|
setDivisionId('') |
|
|
|
|
setAddress('') |
|
|
|
|
setCompanyId(null) |
|
|
|
|
setStatusResource('active') |
|
|
|
|
setStatusRestriction(false) |
|
|
|
|
} |
|
|
|
@ -117,7 +109,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
|
|
|
|
|
address, |
|
|
|
|
status_resource: statusResource, |
|
|
|
|
status_boundary: statusRestriction, |
|
|
|
|
company_id: company_id |
|
|
|
|
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (birthDate && birthDate != "") { |
|
|
|
@ -165,7 +157,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
|
|
|
|
|
address, |
|
|
|
|
status_resource: statusResource, |
|
|
|
|
status_boundary: statusRestriction, |
|
|
|
|
company_id: company_id |
|
|
|
|
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (birthDate && birthDate != "") { |
|
|
|
@ -176,6 +168,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const onChangeCompanyProject = (val) => { |
|
|
|
|
setCompanyId(val); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleCancel = () => { |
|
|
|
|
closeDialog('cancel', 'none') |
|
|
|
|
} |
|
|
|
@ -307,13 +303,31 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
|
|
|
|
|
</Row> |
|
|
|
|
|
|
|
|
|
<Row> |
|
|
|
|
<Col md={6}> |
|
|
|
|
<Label className="capitalize">Status</Label> |
|
|
|
|
<Select style={{ width: "100%" }} defaultValue={statusResource} onChange={(e) => setStatusResource(e)}> |
|
|
|
|
<Option value={'active'}>Active</Option> |
|
|
|
|
<Option value={'inactive'}>Inactive</Option> |
|
|
|
|
</Select> |
|
|
|
|
</Col> |
|
|
|
|
{ |
|
|
|
|
role_name === 'Super Admin' && ( |
|
|
|
|
<Col md={6}> |
|
|
|
|
<FormGroup> |
|
|
|
|
<Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label> |
|
|
|
|
<Select |
|
|
|
|
showSearch |
|
|
|
|
filterOption={(inputValue, option) => |
|
|
|
|
option.children.toLowerCase().includes(inputValue.toLowerCase()) |
|
|
|
|
} |
|
|
|
|
value={scompany_id} |
|
|
|
|
defaultValue={scompany_id} |
|
|
|
|
onChange={onChangeCompanyProject} |
|
|
|
|
style={{ width: "100%" }} |
|
|
|
|
> |
|
|
|
|
{companyList.map((res) => ( |
|
|
|
|
<Option key={res.id} value={res.id}> |
|
|
|
|
{res.company_name} |
|
|
|
|
</Option> |
|
|
|
|
))} |
|
|
|
|
</Select> |
|
|
|
|
</FormGroup> |
|
|
|
|
</Col> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
<Col md={6}> |
|
|
|
|
<Label className="capitalize">{t('restrictions')}</Label> |
|
|
|
|
<Select style={{ width: "100%" }} defaultValue={statusRestriction} onChange={(e) => setStatusRestriction(e)}> |
|
|
|
@ -321,6 +335,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
|
|
|
|
|
<Option value={false}>Tidak</Option> |
|
|
|
|
</Select> |
|
|
|
|
</Col> |
|
|
|
|
<Col md={6}> |
|
|
|
|
<Label className="capitalize">Status</Label> |
|
|
|
|
<Select style={{ width: "100%" }} defaultValue={statusResource} onChange={(e) => setStatusResource(e)}> |
|
|
|
|
<Option value={'active'}>Active</Option> |
|
|
|
|
<Option value={'inactive'}>Inactive</Option> |
|
|
|
|
</Select> |
|
|
|
|
</Col> |
|
|
|
|
<Col md={6}> |
|
|
|
|
<FormGroup> |
|
|
|
|
<Label className="capitalize">{t('address')}</Label> |
|
|
|
|