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