Browse Source

fix: payload & validation form

pull/1/head
wahyun 8 months ago
parent
commit
6a777a0869
  1. 26
      src/views/SimproV2/ResourceWorker/DialogForm.js
  2. 7
      src/views/SimproV2/ResourceWorker/index.js

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

@ -6,13 +6,11 @@ import {
import { DatePicker, Tooltip, Select, Input as InputAntd } from 'antd'; 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 { formatNumber } from '../../../const/CustomFunc'
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const { Option } = Select const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList, role_name, companyList, company_id }) => { const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList, role_name, companyList, company_id }) => {
const [openDialogMap, setOpenDialogMap] = useState(false)
const [id, setId] = useState(0) const [id, setId] = useState(0)
const [resourceName, setResourceName] = useState('') const [resourceName, setResourceName] = useState('')
const [username, setUsername] = useState('') const [username, setUsername] = useState('')
@ -90,11 +88,19 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
alert("Please input NIK (KTP/ ID Card)"); alert("Please input NIK (KTP/ ID Card)");
return; return;
} }
if (!roleId && roleId === "") { if (!resourceName && resourceName === "") {
alert("Please input name");
return;
}
if (!employeeType && employeeType === "") {
alert("Please input employe type");
return;
}
if (!roleId && roleId === "" && statusCustomer === false) {
alert("Please select the role"); alert("Please select the role");
return; return;
} }
if (!divisionId && divisionId === "") { if (!divisionId && divisionId === "" && statusCustomer === false) {
alert("Please select the division"); alert("Please select the division");
return; return;
} }
@ -117,6 +123,8 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
if(statusCustomer === false) { if(statusCustomer === false) {
data.role_id = roleId; data.role_id = roleId;
data.divisi_id = divisionId; data.divisi_id = divisionId;
} else {
data.is_customer = statusCustomer
} }
if (birthDate && birthDate != "") { if (birthDate && birthDate != "") {
@ -163,12 +171,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
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) { if(statusCustomer === false) {
data.role_id = roleId; data.role_id = roleId;
data.divisi_id = divisionId; data.divisi_id = divisionId;
} else {
data.is_customer = statusCustomer
} }
if (birthDate && birthDate != "") { if (birthDate && birthDate != "") {
@ -274,7 +283,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<Select showSearch value={gender} defaultValue={gender} onChange={(val) => setGender(val)} placeholder={t('selectGender')} style={{ width: '100%' }}> <Select showSearch value={gender} defaultValue={gender} onChange={(val) => setGender(val)} placeholder={t('selectGender')} style={{ width: '100%' }}>
<Option value="Male">Male</Option> <Option value="Male">Male</Option>
<Option value="Female">Female</Option> <Option value="Female">Female</Option>
{/* <Option value="Other">Other</Option> */}
</Select> </Select>
</FormGroup> </FormGroup>
</Col> </Col>
@ -340,7 +348,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<> <>
<Col md={6} style={{ marginTop: statusCustomer === false ? '15px' : '0px' }}> <Col md={6} style={{ marginTop: statusCustomer === false ? '15px' : '0px' }}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('roles')}</Label> <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%' }}> <Select showSearch defaultValue={roleId} onChange={(val) => setRoleId(val)} placeholder={t('selectRole')} style={{ width: '100%' }}>
{setupSelectRole()} {setupSelectRole()}
</Select> </Select>
@ -348,7 +356,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</Col> </Col>
<Col md={6} style={{ marginTop: statusCustomer === false ? '15px' : '0px' }}> <Col md={6} style={{ marginTop: statusCustomer === false ? '15px' : '0px' }}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('division')} </Label> <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%' }}> <Select showSearch defaultValue={divisionId} onChange={(val) => setDivisionId(val)} placeholder={t('selectDivision')} style={{ width: '100%' }}>
{setupSelectDivisi()} {setupSelectDivisi()}
</Select> </Select>

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

@ -4,7 +4,6 @@ import DialogFormUserShift from './DialogFormUserShift';
import React, { useState, useEffect, useMemo } from 'react'; import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert'; import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
@ -14,11 +13,7 @@ import {
} from '../../../const/ApiConst'; } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { import {
formatNumber, checkActMenup
formatRupiah,
formatThousand,
renderFormatRupiah,
checkActMenup,
} from "../../../const/CustomFunc"; } from "../../../const/CustomFunc";
const ResourceWorker = ({ params, ...props }) => { const ResourceWorker = ({ params, ...props }) => {

Loading…
Cancel
Save