Browse Source

update customer selection

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

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

@ -6,7 +6,6 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { useLocation } from "react-router-dom";
import { Pagination, Table, Button, Tooltip, Spin } from 'antd';
@ -101,7 +100,7 @@ const ResourceWorker = ({ params, ...props }) => {
}
if (role_name !== "Super Admin") {
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 {
formData.columns.push(
@ -126,7 +125,7 @@ const ResourceWorker = ({ params, ...props }) => {
if (role_name !== "Super Admin") {
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") {
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 {
payload.group_column.where.push(
@ -380,7 +379,7 @@ const ResourceWorker = ({ params, ...props }) => {
if (role_name !== "Super Admin") {
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 {
payload.group_column.where.push(
@ -593,7 +592,7 @@ const ResourceWorker = ({ params, ...props }) => {
title: t('roles'),
dataIndex: '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: 'Email', dataIndex: 'email', key: 'email' },

Loading…
Cancel
Save