From 772edd101648e55484d1e6ae1bf667b93ee9b166 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Wed, 7 Sep 2022 17:16:47 +0700 Subject: [PATCH] implement hierarchy --- src/views/SimproV2/Divisi/DialogForm.js | 2 +- src/views/SimproV2/Divisi/index.js | 83 +++---------------------- 2 files changed, 9 insertions(+), 76 deletions(-) diff --git a/src/views/SimproV2/Divisi/DialogForm.js b/src/views/SimproV2/Divisi/DialogForm.js index 18bfe90..732ed83 100644 --- a/src/views/SimproV2/Divisi/DialogForm.js +++ b/src/views/SimproV2/Divisi/DialogForm.js @@ -79,7 +79,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi filterOption={(input, option) => option.children.toLowerCase().includes(input.toLowerCase())} > {dataDivisions.map((res, idx) => ( - + ))} diff --git a/src/views/SimproV2/Divisi/index.js b/src/views/SimproV2/Divisi/index.js index ce158ee..6f4df45 100644 --- a/src/views/SimproV2/Divisi/index.js +++ b/src/views/SimproV2/Divisi/index.js @@ -58,13 +58,6 @@ const ProjectType = ({ params }) => { getDataProjectType() }, [currentPage, rowsPerPage, search]) - useEffect(() => { - const cekData = dataExport || [] - if (cekData.length > 0) { - exportExcel() - } - }, [dataExport]) - const getDataProjectType = async () => { let start = 0; @@ -79,7 +72,6 @@ const ProjectType = ({ params }) => { for (const v in listDivions.data.data) { arr.push(listDivions.data.data[v]) } - console.log(arr); setDataDivisions(arr); } else { NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); @@ -134,48 +126,6 @@ const ProjectType = ({ params }) => { setTypeDialog(type) } - const handleExportExcel = async () => { - let start = 0; - const payload = { - "paging": { "start": start, "length": -1 }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" } - ], - "joins": [], - "orders": { "columns": ["id"], "ascending": false } - } - - const result = await axios - .post(DIVISI_SEARCH, payload) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - let resData = result.data.data; - const excelData = []; - resData.map((val, index) => { - let dataRow = { - "Nama": val.name, - "Deskripsi": val.description, - } - excelData.push(dataRow) - }) - await setDataExport(excelData); - } else { - NotificationManager.error('Gagal Export Data!!', 'Failed'); - } - } - - const exportExcel = () => { - 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}`); - XLSX.writeFile(wb, fileName); - setDataExport([]) - } - const handleEdit = (data) => { setDataEdit(data) handleOpenDialog('Edit'); @@ -203,7 +153,7 @@ const ProjectType = ({ params }) => { .catch((error) => error.response); if (result && result.data && result.data.code === 200) { getDataProjectType() - NotificationManager.success(`Data project type berhasil ditambah`, 'Success!!'); + NotificationManager.success(`Data berhasil ditambah`, 'Success!!'); } else { NotificationManager.error(`${result.data.message}`, 'Failed!!'); } @@ -217,9 +167,9 @@ const ProjectType = ({ params }) => { .catch((error) => error.response); if (result && result.data && result.data.code === 200) { getDataProjectType(); - NotificationManager.success(`Data project type berhasil diedit`, 'Success!!'); + NotificationManager.success(`Data berhasil diedit`, 'Success!!'); } else { - NotificationManager.error(`Data project type gagal di edit`, `Failed!!`); + NotificationManager.error(`Data gagal di edit`, `Failed!!`); } } @@ -237,11 +187,11 @@ const ProjectType = ({ params }) => { getDataProjectType() setIdDelete(0) setAlertDelete(false) - NotificationManager.success(`Data project type berhasil dihapus!`, 'Success!!'); + NotificationManager.success(`Data berhasil dihapus!`, 'Success!!'); } else { setIdDelete(0) setAlertDelete(false) - NotificationManager.error(`Data project type gagal dihapus!}`, 'Failed!!'); + NotificationManager.error(`Data gagal dihapus!}`, 'Failed!!'); } } @@ -262,7 +212,7 @@ const ProjectType = ({ params }) => { if (dataTable.length === 0) { return ( - Tidak ada data project type + Belum ada data. ) } @@ -299,15 +249,9 @@ const ProjectType = ({ params }) => {

{pageName}

- - - - + - - - @@ -329,31 +273,20 @@ const ProjectType = ({ params }) => { return ( - handleDelete(n.id)}> - handleEdit(n)}> - {n.name} + {n.displayName} {n.description} ) })} -