From cd698c92f8807c906ee160c31c663fe4773becbe Mon Sep 17 00:00:00 2001 From: wahyu Date: Wed, 18 Oct 2023 11:50:08 +0700 Subject: [PATCH] fix endline --- .../SimproV2/CreatedProyek/FormAsignHr.js | 492 +++++++++--------- 1 file changed, 246 insertions(+), 246 deletions(-) diff --git a/src/views/SimproV2/CreatedProyek/FormAsignHr.js b/src/views/SimproV2/CreatedProyek/FormAsignHr.js index b02909d..a080fa0 100644 --- a/src/views/SimproV2/CreatedProyek/FormAsignHr.js +++ b/src/views/SimproV2/CreatedProyek/FormAsignHr.js @@ -1,246 +1,246 @@ -import React, { useEffect, useState } from 'react' -import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; -import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; -import { DatePicker, Select } from 'antd'; -import 'antd/dist/antd.css'; -import { formatNumber } from '../../../const/CustomFunc'; -const { Option } = Select - -const FormAsignHr = ({ openDialog, closeDialog, toggleDialog, idTask, dataEdit, dataHr, dataCurrentHr, dataRole }) => { - const [id, setId] = useState(null) - const [typeForm, setTypeForm] = useState('add') - const [user, setUser] = useState(null) - const [rbs, setRbs] = useState("") - const [projectRole, setProjectRole] = useState(null) - const [groupR, setGroupR] = useState("") - const [maxUsed, setMaxUsed] = useState("") - const [standartRate, setStandartRate] = useState("") - const [uomStandartRate, setUomStandartRate] = useState(null) - const [overTimeRate, setOverTimeRate] = useState("") - const [overTimeRateUom, setOverTimeRateUom] = useState(null) - const [costPerUsed, setCostPerUsed] = useState("") - const [accrue, setAccrue] = useState("") - const [baseCalender, setBaseCalender] = useState("") - const [listHr, setListHr] = useState([]) - const [isCustomer, setIsCustomer] = useState(false) - - const handleClearData = () => { - setUser(null) - setRbs("") - setProjectRole(null) - setGroupR("") - setMaxUsed("") - setIsCustomer(false) - setStandartRate("") - setUomStandartRate(null) - setOverTimeRate("") - setOverTimeRateUom(null) - setCostPerUsed("") - setAccrue("") - setBaseCalender("") - } - - useEffect(() => { - let data = dataHr || [] - let availableHr = [] - data.map((val, index) => { - if(dataEdit && dataEdit.user_id){ - if(parseInt(val.id)===parseInt(dataEdit.user_id)){ - availableHr.push(val); - } - } - let check = dataCurrentHr.some(function (x) { - return parseInt(val.id)==parseInt(x.user_id) - }); - if(!check){ - availableHr.push(val); - } - }); - setListHr(availableHr) - }, [dataHr, dataCurrentHr, dataEdit]) - - useEffect(() => { - if (idTask && idTask > 0) { - if(dataEdit && dataEdit!=""){ - setTypeForm('edit') - setId(dataEdit.id) - setUser(dataEdit.user_id) - setRbs(dataEdit.rbs) - setProjectRole(dataEdit.project_role) - setGroupR(dataEdit.group_r) - setMaxUsed(dataEdit.max_used ? formatNumber(dataEdit.max_used.toString()) : '') - setIsCustomer(dataEdit.is_customer) - setStandartRate(dataEdit.standart_rate ? formatNumber(dataEdit.standart_rate.toString()) : '') - setUomStandartRate(dataEdit.uom_standart_rate) - setOverTimeRate(dataEdit.overtime_rate ? formatNumber(dataEdit.overtime_rate.toString()) : '') - setOverTimeRateUom(dataEdit.uom_overtime_rate) - setCostPerUsed(dataEdit.cost_per_used) - setAccrue(dataEdit.accrue_at) - setBaseCalender(dataEdit.base_calender) - }else{ - handleClearData() - setTypeForm('add') - } - } else { - handleClearData() - } - }, [openDialog]) - - const handleSave = () => { - let data = ''; - if (typeForm=="edit") { - data = { - id, - proyek_id: idTask, - user_id:user, - project_role:projectRole, - is_customer: isCustomer, - max_used:maxUsed.replaceAll(".", ""), - standart_rate:standartRate.replaceAll(".", ""), - uom_standart_rate:uomStandartRate, - overtime_rate:overTimeRate.replaceAll(".", ""), - uom_overtime_rate:overTimeRateUom, - } - - closeDialog('edit', data); - } else { - data = { - proyek_id: idTask, - user_id:user, - project_role:projectRole, - is_customer: isCustomer, - max_used:maxUsed.replaceAll(".", ""), - standart_rate:standartRate.replaceAll(".", ""), - uom_standart_rate:uomStandartRate, - overtime_rate:overTimeRate.replaceAll(".", ""), - uom_overtime_rate:overTimeRateUom, - } - closeDialog('add', data); - } - handleClearData() - } - - const handleCancel = () => { - closeDialog('cancel', 'none') - handleClearData() - } - - - const renderForm = () => { - return ( -
- - - - - - - - - - - - - - - - - setMaxUsed(formatNumber(e.target.value))} value={maxUsed} placeholder='' required/> - - - - - - - -
- setStandartRate(formatNumber(e.target.value))} value={standartRate} placeholder='1.000...' /> - -
- / -
- - - - -
- -
- - - setOverTimeRate(formatNumber(e.target.value))} value={overTimeRate} placeholder='1.000...' /> - -
- / -
- - - - -
- - ) - } - - return ( - <> - - {typeForm=="add" ? "Add" : "Edit" } Assign Human Resource - - {renderForm()} - - - {' '} - - - - - ) - -} - -export default FormAsignHr; +import React, { useEffect, useState } from 'react' +import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; +import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; +import { DatePicker, Select } from 'antd'; +import 'antd/dist/antd.css'; +import { formatNumber } from '../../../const/CustomFunc'; +const { Option } = Select + +const FormAsignHr = ({ openDialog, closeDialog, toggleDialog, idTask, dataEdit, dataHr, dataCurrentHr, dataRole }) => { + const [id, setId] = useState(null) + const [typeForm, setTypeForm] = useState('add') + const [user, setUser] = useState(null) + const [rbs, setRbs] = useState("") + const [projectRole, setProjectRole] = useState(null) + const [groupR, setGroupR] = useState("") + const [maxUsed, setMaxUsed] = useState("") + const [standartRate, setStandartRate] = useState("") + const [uomStandartRate, setUomStandartRate] = useState(null) + const [overTimeRate, setOverTimeRate] = useState("") + const [overTimeRateUom, setOverTimeRateUom] = useState(null) + const [costPerUsed, setCostPerUsed] = useState("") + const [accrue, setAccrue] = useState("") + const [baseCalender, setBaseCalender] = useState("") + const [listHr, setListHr] = useState([]) + const [isCustomer, setIsCustomer] = useState(false) + + const handleClearData = () => { + setUser(null) + setRbs("") + setProjectRole(null) + setGroupR("") + setMaxUsed("") + setIsCustomer(false) + setStandartRate("") + setUomStandartRate(null) + setOverTimeRate("") + setOverTimeRateUom(null) + setCostPerUsed("") + setAccrue("") + setBaseCalender("") + } + + useEffect(() => { + let data = dataHr || [] + let availableHr = [] + data.map((val, index) => { + if(dataEdit && dataEdit.user_id){ + if(parseInt(val.id)===parseInt(dataEdit.user_id)){ + availableHr.push(val); + } + } + let check = dataCurrentHr.some(function (x) { + return parseInt(val.id)==parseInt(x.user_id) + }); + if(!check){ + availableHr.push(val); + } + }); + setListHr(availableHr) + }, [dataHr, dataCurrentHr, dataEdit]) + + useEffect(() => { + if (idTask && idTask > 0) { + if(dataEdit && dataEdit!=""){ + setTypeForm('edit') + setId(dataEdit.id) + setUser(dataEdit.user_id) + setRbs(dataEdit.rbs) + setProjectRole(dataEdit.project_role) + setGroupR(dataEdit.group_r) + setMaxUsed(dataEdit.max_used ? formatNumber(dataEdit.max_used.toString()) : '') + setIsCustomer(dataEdit.is_customer) + setStandartRate(dataEdit.standart_rate ? formatNumber(dataEdit.standart_rate.toString()) : '') + setUomStandartRate(dataEdit.uom_standart_rate) + setOverTimeRate(dataEdit.overtime_rate ? formatNumber(dataEdit.overtime_rate.toString()) : '') + setOverTimeRateUom(dataEdit.uom_overtime_rate) + setCostPerUsed(dataEdit.cost_per_used) + setAccrue(dataEdit.accrue_at) + setBaseCalender(dataEdit.base_calender) + }else{ + handleClearData() + setTypeForm('add') + } + } else { + handleClearData() + } + }, [openDialog]) + + const handleSave = () => { + let data = ''; + if (typeForm=="edit") { + data = { + id, + proyek_id: idTask, + user_id:user, + project_role:projectRole, + is_customer: isCustomer, + max_used:maxUsed.replaceAll(".", ""), + standart_rate:standartRate.replaceAll(".", ""), + uom_standart_rate:uomStandartRate, + overtime_rate:overTimeRate.replaceAll(".", ""), + uom_overtime_rate:overTimeRateUom, + } + + closeDialog('edit', data); + } else { + data = { + proyek_id: idTask, + user_id:user, + project_role:projectRole, + is_customer: isCustomer, + max_used:maxUsed.replaceAll(".", ""), + standart_rate:standartRate.replaceAll(".", ""), + uom_standart_rate:uomStandartRate, + overtime_rate:overTimeRate.replaceAll(".", ""), + uom_overtime_rate:overTimeRateUom, + } + closeDialog('add', data); + } + handleClearData() + } + + const handleCancel = () => { + closeDialog('cancel', 'none') + handleClearData() + } + + + const renderForm = () => { + return ( +
+ + + + + + + + + + + + + + + + + setMaxUsed(formatNumber(e.target.value))} value={maxUsed} placeholder='' required/> + + + + + + + +
+ setStandartRate(formatNumber(e.target.value))} value={standartRate} placeholder='1.000...' /> + +
+ / +
+ + + + +
+ +
+ + + setOverTimeRate(formatNumber(e.target.value))} value={overTimeRate} placeholder='1.000...' /> + +
+ / +
+ + + + +
+ + ) + } + + return ( + <> + + {typeForm=="add" ? "Add" : "Edit" } Assign Human Resource + + {renderForm()} + + + {' '} + + + + + ) + +} + +export default FormAsignHr;