Browse Source

update customer selection

pull/1/head
wahyuun 9 months ago
parent
commit
dffb6f58eb
  1. 73
      src/views/SimproV2/ResourceWorker/DialogForm.js
  2. 11
      src/views/SimproV2/ResourceWorker/index.js

73
src/views/SimproV2/ResourceWorker/DialogForm.js

@ -33,7 +33,9 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [divisionId, setDivisionId] = useState('') const [divisionId, setDivisionId] = useState('')
const [statusResource, setStatusResource] = useState('active') const [statusResource, setStatusResource] = useState('active')
const [statusRestriction, setStatusRestriction] = useState(false) const [statusRestriction, setStatusRestriction] = useState(false)
const [statusCustomer, setStatusCustomer] = useState(false)
const { t } = useTranslation() const { t } = useTranslation()
useEffect(() => { useEffect(() => {
if (typeDialog === "Edit" || typeDialog === "Set") { if (typeDialog === "Edit" || typeDialog === "Set") {
setId(dataEdit.id) setId(dataEdit.id)
@ -55,6 +57,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setDivisionId(dataEdit.divisi_id) setDivisionId(dataEdit.divisi_id)
setAddress(dataEdit.address) setAddress(dataEdit.address)
setStatusRestriction(dataEdit.status_boundary) setStatusRestriction(dataEdit.status_boundary)
setStatusCustomer(dataEdit.is_customer)
} else { } else {
setId(0) setId(0)
setResourceName('') setResourceName('')
@ -76,6 +79,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setCompanyId(null) setCompanyId(null)
setStatusResource('active') setStatusResource('active')
setStatusRestriction(false) setStatusRestriction(false)
setStatusCustomer(false)
} }
}, [dataEdit, openDialog]) }, [dataEdit, openDialog])
@ -104,14 +108,17 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
gender, gender,
birth_place: birthPlace, birth_place: birthPlace,
ktp_number: ktpNumber, ktp_number: ktpNumber,
role_id: roleId,
divisi_id: divisionId,
address, address,
status_resource: statusResource, status_resource: statusResource,
status_boundary: statusRestriction, status_boundary: statusRestriction,
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
} }
if(statusCustomer === false) {
data.role_id = roleId;
data.divisi_id = divisionId;
}
if (birthDate && birthDate != "") { if (birthDate && birthDate != "") {
data['birth_date'] = birthDate; data['birth_date'] = birthDate;
} }
@ -153,13 +160,16 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
blood_type: bloodType, blood_type: bloodType,
ktp_number: ktpNumber, ktp_number: ktpNumber,
biaya_per_jam: biayaPerJam.replace('.', ''), biaya_per_jam: biayaPerJam.replace('.', ''),
role_id: roleId,
divisi_id: divisionId,
address, address,
status_resource: statusResource, status_resource: statusResource,
status_boundary: statusRestriction, status_boundary: statusRestriction,
is_customer: statusCustomer,
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
} }
if(statusCustomer === false) {
data.role_id = roleId;
data.divisi_id = divisionId;
}
if (birthDate && birthDate != "") { if (birthDate && birthDate != "") {
data['birth_date'] = birthDate; data['birth_date'] = birthDate;
@ -283,25 +293,28 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
<Row> {
<Col md={6}> statusCustomer === false && (
<FormGroup> <Row>
<Label className="capitalize">{t('roles')} <span style={{ color: "red" }}>*</span></Label> <Col md={6}>
<Select showSearch defaultValue={roleId} onChange={(val) => setRoleId(val)} placeholder={t('selectRole')} style={{ width: '100%' }}> <FormGroup>
{setupSelectRole()} <Label className="capitalize">{t('roles')} <span style={{ color: "red" }}>*</span></Label>
</Select> <Select showSearch defaultValue={roleId} onChange={(val) => setRoleId(val)} placeholder={t('selectRole')} style={{ width: '100%' }}>
</FormGroup> {setupSelectRole()}
</Col> </Select>
<Col md={6}> </FormGroup>
<FormGroup> </Col>
<Label className="capitalize">{t('division')} <span style={{ color: "red" }}>*</span></Label> <Col md={6}>
<Select showSearch defaultValue={divisionId} onChange={(val) => setDivisionId(val)} placeholder={t('selectDivision')} style={{ width: '100%' }}> <FormGroup>
{setupSelectDivisi()} <Label className="capitalize">{t('division')} <span style={{ color: "red" }}>*</span></Label>
</Select> <Select showSearch defaultValue={divisionId} onChange={(val) => setDivisionId(val)} placeholder={t('selectDivision')} style={{ width: '100%' }}>
</FormGroup> {setupSelectDivisi()}
</Col> </Select>
</Row> </FormGroup>
</Col>
</Row>
)
}
<Row> <Row>
{ {
role_name === 'Super Admin' && ( role_name === 'Super Admin' && (
@ -329,8 +342,8 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
) )
} }
<Col md={6}> <Col md={6}>
<Label className="capitalize">{t('restrictions')}</Label> <Label className="capitalize">{t('Customer')}</Label>
<Select style={{ width: "100%" }} defaultValue={statusRestriction} onChange={(e) => setStatusRestriction(e)}> <Select style={{ width: "100%" }} defaultValue={statusCustomer} onChange={(e) => setStatusCustomer(e)}>
<Option value={true}>Ya</Option> <Option value={true}>Ya</Option>
<Option value={false}>Tidak</Option> <Option value={false}>Tidak</Option>
</Select> </Select>
@ -342,13 +355,19 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<Option value={'inactive'}>Inactive</Option> <Option value={'inactive'}>Inactive</Option>
</Select> </Select>
</Col> </Col>
<Col md={6}> <Col md={6} style={{ marginTop:'13px' }}>
<Label className="capitalize">{t('restrictions')}</Label>
<Select style={{ width: "100%" }} defaultValue={statusRestriction} onChange={(e) => setStatusRestriction(e)}>
<Option value={true}>Ya</Option>
<Option value={false}>Tidak</Option>
</Select>
</Col>
<Col md={6} style={{ marginTop:'13px' }}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('address')}</Label> <Label className="capitalize">{t('address')}</Label>
<Input type="textarea" value={address} onChange={(e) => setAddress(e.target.value)} placeholder={t('inputaddress')} /> <Input type="textarea" value={address} onChange={(e) => setAddress(e.target.value)} placeholder={t('inputaddress')} />
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
</Form> </Form>
) )

11
src/views/SimproV2/ResourceWorker/index.js

@ -6,7 +6,6 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import moment from 'moment' import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { Pagination, Table, Button, Tooltip, Spin } from 'antd'; import { Pagination, Table, Button, Tooltip, Spin } from 'antd';
@ -101,7 +100,7 @@ const ResourceWorker = ({ params, ...props }) => {
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
) )
} else { } else {
formData.columns.push( formData.columns.push(
@ -126,7 +125,7 @@ const ResourceWorker = ({ params, ...props }) => {
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
) )
} }
@ -231,7 +230,7 @@ const ResourceWorker = ({ params, ...props }) => {
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
payload.group_column.where.push( payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
) )
} else { } else {
payload.group_column.where.push( payload.group_column.where.push(
@ -380,7 +379,7 @@ const ResourceWorker = ({ params, ...props }) => {
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
payload.group_column.where.push( payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
) )
} else { } else {
payload.group_column.where.push( payload.group_column.where.push(
@ -593,7 +592,7 @@ const ResourceWorker = ({ params, ...props }) => {
title: t('roles'), title: t('roles'),
dataIndex: 'join_first_name', dataIndex: 'join_first_name',
key: 'join_first_name', key: 'join_first_name',
render: (text, record) => <>{record.join_first_name}</> render: (text, record) => <>{ record.is_customer === true ? 'Customer' : record.join_first_name}</>
}, },
{ title: 'Phone No.', dataIndex: 'phone_number', key: 'phone_number' }, { title: 'Phone No.', dataIndex: 'phone_number', key: 'phone_number' },
{ title: 'Email', dataIndex: 'email', key: 'email' }, { title: 'Email', dataIndex: 'email', key: 'email' },

Loading…
Cancel
Save