diff --git a/src/views/Master/MasterRoles/index.js b/src/views/Master/MasterRoles/index.js index e3bf9c1..215b551 100644 --- a/src/views/Master/MasterRoles/index.js +++ b/src/views/Master/MasterRoles/index.js @@ -17,8 +17,8 @@ const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/"; const config = { headers: { - Authorization : `Bearer ${token}`, - "Content-type" : `application/json` + Authorization: `Bearer ${token}`, + "Content-type": `application/json` } }; @@ -34,24 +34,24 @@ export default class index extends Component { alertNotDelete: false, currentPage: 1, dataEdit: null, - dataExport:[], + dataExport: [], dataGs: [], dataIdHo: [], dataTable: [], dialogMenuForm: false, idDelete: 0, - idRoles:0, - menuRoles:[], + idRoles: 0, + menuRoles: [], openDialog: false, page: 0, rowsPerPage: LENGTH_DATA, search: "", tooltipDelete: false, tooltipEdit: false, - tooltipExport:false, - tooltipImport:false, + tooltipExport: false, + tooltipImport: false, tooltipMenu: false, - tooltipTambah:false, + tooltipTambah: false, totalPage: 0, typeDialog: 'Save', } @@ -61,22 +61,22 @@ export default class index extends Component { title: 'Action', dataIndex: '', key: 'x', - className:'nowrap', + className: 'nowrap', render: (text, record) => <> - this.handleMenuRoles(text.id)}> + this.handleMenuRoles(text.id)}> - this.handleDelete(text.id)}> + this.handleDelete(text.id)}> - this.handleEdit(text)}> + this.handleEdit(text)}> , }, - { title: 'Nama Role', dataIndex: 'name', key: 'name', className:"nowrap" }, + { title: 'Nama Role', dataIndex: 'name', key: 'name', className: "nowrap" }, { title: 'Description', dataIndex: 'description', key: 'description' }, ] } @@ -102,12 +102,12 @@ export default class index extends Component { } const formData = { - "paging": {"start": start, "length": this.state.rowsPerPage}, + "paging": { "start": start, "length": this.state.rowsPerPage }, "columns": [ - {"name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND"} + { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" } ], "joins": [], - "orders": {"columns": ["id"], "ascending": false} + "orders": { "columns": ["id"], "ascending": false } } const result = await axios @@ -115,9 +115,9 @@ export default class index extends Component { .then(res => res) .catch((error) => error.response); - if(result && result.data && result.data.code == 200){ + if (result && result.data && result.data.code == 200) { this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord }); - }else{ + } else { NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); } } @@ -142,7 +142,7 @@ export default class index extends Component { } handleCloseDialogMr = (type, data) => { - if(type==="save"){ + if (type === "save") { this.saveMenuRoles(data) } this.setState({ dialogMenuForm: false }) @@ -174,15 +174,15 @@ export default class index extends Component { saveRole = async (data) => { const formData = { - name:data.name, - description:data.description + name: data.name, + description: data.description } const result = await axios.post(ROLE_ADD, formData, config) .then(res => res) .catch((error) => error.response); - if(result && result.data && result.data.code===200){ + if (result && result.data && result.data.code === 200) { this.getDataRoles(); NotificationManager.success(`Data role berhasil ditambah`, 'Success!!'); } else { @@ -193,15 +193,15 @@ export default class index extends Component { editRole = async (data) => { const formData = { - name:data.name, - description:data.description + name: data.name, + description: data.description } const url = ROLE_EDIT(data.id) const result = await axios.put(url, formData, config) .then(res => res) .catch((error) => error.response); - if(result && result.data && result.data.code===200){ + if (result && result.data && result.data.code === 200) { this.getDataRoles(); NotificationManager.success(`Data role berhasil diedit`, 'Success!!'); } else { @@ -236,17 +236,17 @@ export default class index extends Component { this.setState(prevState => ({ tooltipEdit: !prevState.tooltipEdit })) } else if (param === "delete") { this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete })) - } else if(param === "menu"){ + } else if (param === "menu") { this.setState(prevState => ({ tooltipMenu: !prevState.tooltipMenu })) } else if (param === "tambah") { this.setState(prevState => ({ tooltipTambah: !prevState.tooltipTambah })) - } else if (param === "export") { + } else if (param === "export") { this.setState(prevState => ({ tooltipExport: !prevState.tooltipExport })) } } dataNotAvailable = () => { - if(this.state.dataTable.length===0){ + if (this.state.dataTable.length === 0) { return ( Not Data Available @@ -257,12 +257,12 @@ export default class index extends Component { handleMenuRoles = async (id) => { const formData = { - "paging": {"start": 0, "length": -1}, + "paging": { "start": 0, "length": -1 }, "columns": [ - {"name": "role_id", "logic_operator": "=", "value": `${id}`, "operator": "AND"} + { "name": "role_id", "logic_operator": "=", "value": `${id}`, "operator": "AND" } ], "joins": [], - "orders": {"columns": ["id"], "ascending": false} + "orders": { "columns": ["id"], "ascending": false } } const result = await axios @@ -270,7 +270,7 @@ export default class index extends Component { .then(res => res) .catch((error) => error.response); if (result && result.data && result.data.code == 200) { - this.setState({ menuRoles:result.data.data,idRoles:id },() => { + this.setState({ menuRoles: result.data.data, idRoles: id }, () => { this.handleOpenDialogMr(); }); } else { @@ -279,16 +279,16 @@ export default class index extends Component { saveMenuRoles = async (dataArray) => { let payloadArray = dataArray || [] - if(payloadArray.length > 0){ + if (payloadArray.length > 0) { await this.deleteCurrentRoleMenu(payloadArray[0].roles_id) } let promises = [] let result = [] - dataArray.map((val, index)=> { - if(val.checked===true){ + dataArray.map((val, index) => { + if (val.checked === true) { const formData = { - menu_id:val.menu_id, - role_id:val.roles_id + menu_id: val.menu_id, + role_id: val.roles_id } promises.push(axios.post(ROLEMENU_ADD, formData, config) .then(res => result.push(res))) @@ -296,8 +296,8 @@ export default class index extends Component { }) await Promise.all(promises); - if(result){ - if(result.length > 0){ + if (result) { + if (result.length > 0) { if (result[0].data.code === 200) { this.getDataRoles(); NotificationManager.success('Data roles berhasil ditambahkan!!', 'Success!!'); @@ -326,24 +326,24 @@ export default class index extends Component { let url = BASE_URL + "roles.php?act=get_data"; const formData = new FormData(); formData.append('field', 'name'); - if(this.state.search !== ""){ + if (this.state.search !== "") { formData.append('value', this.state.search); } const result = await axios - .post(url,formData) + .post(url, formData) .then(res => res) .catch((error) => error.response); if (result && result.data && result.statusText == "OK") { - const dataRes = result.data.data|| []; + const dataRes = result.data.data || []; const dataExport = []; - dataRes.map((val,index)=> { + dataRes.map((val, index) => { let row = { - Nama:val.name, - Deskripsi:val.description + Nama: val.name, + Deskripsi: val.description } dataExport.push(row); }) - this.setState({ dataExport:dataExport },()=> { + this.setState({ dataExport: dataExport }, () => { this.exportExcel(); }); } else { @@ -361,7 +361,7 @@ export default class index extends Component { } render() { - const { tooltipTambah,tooltipExport,dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete,tooltipMenu } = this.state + const { tooltipTambah, tooltipExport, dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, tooltipMenu } = this.state let noSeq = 0; return (
@@ -385,7 +385,7 @@ export default class index extends Component { confirmBtnText="Can't Delete" confirmBtnBsStyle="danger" title="Data can't be delete!" - onConfirm={() => this.setState({ alertNotDelete: false})} + onConfirm={() => this.setState({ alertNotDelete: false })} > Data tipe roles tidak dapat di hapus!! @@ -417,7 +417,7 @@ export default class index extends Component { - + @@ -432,7 +432,7 @@ export default class index extends Component { bordered={false} /> <> - this.handleDelete(text.id)}> + this.handleDelete(text.id)}> - this.handleEdit(text)}> + this.handleEdit(text)}> , }, diff --git a/src/views/SimproV2/Divisi/index.js b/src/views/SimproV2/Divisi/index.js index 6f4df45..acab2bd 100644 --- a/src/views/SimproV2/Divisi/index.js +++ b/src/views/SimproV2/Divisi/index.js @@ -5,7 +5,7 @@ import SweetAlert from 'react-bootstrap-sweetalert'; import axios from "../../../const/interceptorApi" import moment from 'moment' import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; -import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH} from '../../../const/ApiConst'; +import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH } from '../../../const/ApiConst'; import { DownloadOutlined } from '@ant-design/icons'; import { NotificationContainer, NotificationManager } from 'react-notifications'; import { Pagination, Button, Tooltip } from 'antd'; @@ -67,7 +67,7 @@ const ProjectType = ({ params }) => { .then(res => res) .catch((error) => error.response); - if (listDivions&& listDivions.data && listDivions.data.code == 200) { + if (listDivions && listDivions.data && listDivions.data.code == 200) { let arr = [] for (const v in listDivions.data.data) { arr.push(listDivions.data.data[v]) @@ -274,10 +274,10 @@ const ProjectType = ({ params }) => { - handleDelete(n.id)}> + handleDelete(n.id)}> - handleEdit(n)}> + handleEdit(n)}> {n.displayName} diff --git a/src/views/SimproV2/Presence/index.js b/src/views/SimproV2/Presence/index.js index 529ac8c..85070f0 100644 --- a/src/views/SimproV2/Presence/index.js +++ b/src/views/SimproV2/Presence/index.js @@ -12,7 +12,7 @@ const { RangePicker } = DatePicker; const token = window.localStorage.getItem('token'); -const Index = ({params}) => { +const Index = ({ params }) => { const [dataTable, setDatatable] = useState([]) const [search, setSearch] = useState('') const [currentPage, setCurrentPage] = useState(1) @@ -27,23 +27,23 @@ const Index = ({params}) => { const pageName = params.name; const config = { - headers: - { - Authorization : `Bearer ${token}`, - "Content-type" : `application/json` + headers: + { + Authorization: `Bearer ${token}`, + "Content-type": `application/json` } }; - useEffect(()=> { - getDataPresence(); - },[search,currentPage,rowsPerPage, startDate, endDate]) + useEffect(() => { + getDataPresence(); + }, [search, currentPage, rowsPerPage, startDate, endDate]) - useEffect(()=> { + useEffect(() => { const cekData = dataExport || [] - if(cekData.length > 0){ + if (cekData.length > 0) { exportExcel() } - },[dataExport]) + }, [dataExport]) const handleSearch = e => { const value = e.target.value @@ -64,35 +64,35 @@ const Index = ({params}) => { let dateEnd = moment(endDate).format("YYYY-MM-DD 23:59:59"); const payload = { - "paging": {"start": start, "length": rowsPerPage}, + "paging": { "start": start, "length": rowsPerPage }, "columns": [ - {"name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users"}, - {"name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd}, + { "name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users" }, + { "name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd }, ], "joins": [{ - "name":"m_users", - "column_join":"user_id", - "column_results":[ - "name", - "ktp_number" - ] - }], - "orders": {"columns": ["id"], "ascending": false} + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "name", + "ktp_number" + ] + }], + "orders": { "columns": ["id"], "ascending": false } } - - + + const result = await axios .post(PRESENCE_SEARCH, payload, config) .then(res => res) .catch((error) => error.response); - if(result && result.data && result.data.code == 200){ + if (result && result.data && result.data.code == 200) { setDatatable(result.data.data); console.log("resdata", result.data.data) setTotalPage(result.data.totalRecord); - }else{ + } else { NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); } } @@ -105,17 +105,17 @@ const Index = ({params}) => { .get(url, config) .then(res => res) .catch((error) => error.response); - if(result && result.data.code==200){ - let dataRes = result.data.data - let dataImage = { - name, - url:dataRes.image - } - console.log("dataImage", dataImage) - await setDataImage(dataImage) - setOpenImage(true) - }else{ - NotificationManager.error('Data image tidak ditemukan!', 'Failed'); + if (result && result.data.code == 200) { + let dataRes = result.data.data + let dataImage = { + name, + url: dataRes.image + } + console.log("dataImage", dataImage) + await setDataImage(dataImage) + setOpenImage(true) + } else { + NotificationManager.error('Data image tidak ditemukan!', 'Failed'); } } @@ -125,8 +125,8 @@ const Index = ({params}) => { } const toggleDialogImage = () => { - if(openImage){ - setDataImage(null) + if (openImage) { + setDataImage(null) } setOpenImage(!openImage) } @@ -140,20 +140,20 @@ const Index = ({params}) => { } const renderDurasiKerja = (jamMasuk, jamKeluar) => { - if(jamMasuk && jamKeluar){ + if (jamMasuk && jamKeluar) { let start = moment(jamMasuk), end = moment(jamKeluar); let diff = end.diff(start); let result = moment.utc(diff).format('HH:mm:ss'); - if(result){ + if (result) { return result; - }else{ + } else { return "-" } - - }else{ + + } else { return "-" } } @@ -164,51 +164,51 @@ const Index = ({params}) => { let dateEnd = moment(endDate).format("YYYY-MM-DD 23:59:59"); const payload = { - "paging": {"start": 0, "length": -1}, + "paging": { "start": 0, "length": -1 }, "columns": [ - {"name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users"}, - {"name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd}, + { "name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users" }, + { "name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd }, ], "joins": [{ - "name":"m_users", - "column_join":"user_id", - "column_results":[ - "name", - "ktp_number" - ] - }], - "orders": {"columns": ["id"], "ascending": false} + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "name", + "ktp_number" + ] + }], + "orders": { "columns": ["id"], "ascending": false } } - - + + const result = await axios .post(PRESENCE_SEARCH, payload, config) .then(res => res) .catch((error) => error.response); - if(result && result.data && result.data.code == 200){ + if (result && result.data && result.data.code == 200) { let resData = result.data.data; console.log("resdata", resData) const excelData = []; resData.map((val, index) => { let dataRow = { - "NIK/ID Card": val.join_first_ktp_number ? val.join_first_ktp_number : '-', - "Nama Human Resource": val.join_first_name ? val.join_first_name : '', - "Tanggal Kehadiran" : val.date_presence ? moment(val.date_presence).format("D-M-YYYY") : '-', - "Jam Masuk" : val.clock_in ? moment(val.clock_in).format("D-M-YYYY HH:mm:ss") : '-', - "Jam Keluar": val.clock_out ? moment(val.clock_out).format("D-M-YYYY HH:mm:ss") : '-', - "Durasi Kerja" : renderDurasiKerja(val.clock_in, val.clock_out), - "Clock-in Location": val.clock_in_loc && val.clock_in_loc !== '' ? val.clock_in_loc : '-', - "Clock-out Location": val.clock_out_loc && val.clock_out_loc !== '' ? val.clock_out_loc : '-' + "NIK/ID Card": val.join_first_ktp_number ? val.join_first_ktp_number : '-', + "Nama Human Resource": val.join_first_name ? val.join_first_name : '', + "Tanggal Kehadiran": val.date_presence ? moment(val.date_presence).format("D-M-YYYY") : '-', + "Jam Masuk": val.clock_in ? moment(val.clock_in).format("D-M-YYYY HH:mm:ss") : '-', + "Jam Keluar": val.clock_out ? moment(val.clock_out).format("D-M-YYYY HH:mm:ss") : '-', + "Durasi Kerja": renderDurasiKerja(val.clock_in, val.clock_out), + "Clock-in Location": val.clock_in_loc && val.clock_in_loc !== '' ? val.clock_in_loc : '-', + "Clock-out Location": val.clock_out_loc && val.clock_out_loc !== '' ? val.clock_out_loc : '-' } excelData.push(dataRow) }) await setDataExport(excelData); - }else{ + } else { NotificationManager.error('Gagal Export Data!!', 'Failed'); - } + } } @@ -216,10 +216,10 @@ const Index = ({params}) => { const dataExcel = dataExport || []; const fileName = `Data ${pageName}.xlsx`; const ws = XLSX.utils.json_to_sheet(dataExcel); - const wb = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`); + const wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`); - XLSX.writeFile(wb, fileName); + XLSX.writeFile(wb, fileName); setDataExport([]) } const renderTable = useMemo(() => { @@ -241,13 +241,15 @@ const Index = ({params}) => { , }, { title: 'NIK/ID Card', dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' }, - { title: 'Nama Human Resource', dataIndex: 'join_first_name', key: 'join_first_name' }, - { title: 'Tanggal Kehadiran', dataIndex: 'date_presence', key: 'date_presence', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY") : "-"}
) }, + { title: 'Nama HR', dataIndex: 'join_first_name', key: 'join_first_name' }, + { title: 'Tanggal', dataIndex: 'date_presence', key: 'date_presence', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY") : "-"}
) }, { title: 'Jam Masuk', dataIndex: 'clock_in', key: 'clock_in', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}
) }, { title: 'Jam Keluar', dataIndex: 'clock_out', key: 'clock_out', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}
) }, { title: 'Durasi Kerja', render: (text, record) => (
{renderDurasiKerja(record.clock_in, record.clock_out)}
) }, - { title: 'Clock-in Location', dataIndex: 'clock_in_loc', key: 'clock_in_loc', render: (text, record) => <>{text && text !== '' ? text : '-'} }, - { title: 'Clock-out Location', dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => <>{text && text !== '' ? text : '-'} }, + { title: 'Lokasi Masuk', dataIndex: 'clock_in_loc', key: 'clock_in_loc', render: (text, record) => <>{text && text !== '' ? text : '-'} }, + { title: 'Lokasi Pulang', dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => <>{text && text !== '' ? text : '-'} }, + { title: 'Area Kerja In', dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => <>{text && text !== '' ? text : '-'} }, + { title: 'Area Kerja Out', dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => <>{text && text !== '' ? text : '-'} }, ]; return ( { }, [dataTable]) const handleDatePicker = (date, dateString) => { - setStartDate(date[0]) - setEndDate(date[1]) + setStartDate(date[0]) + setEndDate(date[1]) } const handleChangeDay = (e) => { const val = e.target.value; setCurrentDay(val) - if(val==="today"){ + if (val === "today") { + setStartDate(moment(moment().format("YYYY-M-D"))) + setEndDate(moment(moment().format("YYYY-M-D"))) + setCurrentPage(1) + } else if (val === "3 day") { + setStartDate(moment(moment().subtract(3, "days").format("YYYY-M-D"))) + setEndDate(moment(moment().format("YYYY-M-D"))) + setCurrentPage(1) + } else if (val === "7 day") { + setStartDate(moment(moment().subtract(7, "days").format("YYYY-M-D"))) + setEndDate(moment(moment().format("YYYY-M-D"))) + setCurrentPage(1) + } else { setStartDate(moment(moment().format("YYYY-M-D"))) setEndDate(moment(moment().format("YYYY-M-D"))) setCurrentPage(1) - }else if(val==="3 day"){ - setStartDate(moment(moment().subtract(3, "days").format("YYYY-M-D"))) - setEndDate(moment(moment().format("YYYY-M-D"))) - setCurrentPage(1) - }else if(val==="7 day"){ - setStartDate(moment(moment().subtract(7, "days").format("YYYY-M-D"))) - setEndDate(moment(moment().format("YYYY-M-D"))) - setCurrentPage(1) - }else{ - setStartDate(moment(moment().format("YYYY-M-D"))) - setEndDate(moment(moment().format("YYYY-M-D"))) - setCurrentPage(1) } } - + return (
+ openDialog={openImage} + closeDialog={closeDialogImage} + toggleDialog={toggleDialogImage} + dataImage={dataImage} + />

{pageName}

- + -
-
-
- handleChangeDay(e)} defaultValue={currentDay}> - - - - -
-
- {' '} - -
-
- +
+
+
+ handleChangeDay(e)} defaultValue={currentDay}> + + + + +
+
+ {' '} + +
+ +
{renderTable} { - + @@ -311,11 +311,11 @@ const Satuan = ({ params }) => {
- handleDelete(n.id)}> + handleDelete(n.id)}> - handleEdit(n)}> + handleEdit(n)}> {n.name}