|
|
@ -58,13 +58,6 @@ const ProjectType = ({ params }) => { |
|
|
|
getDataProjectType() |
|
|
|
getDataProjectType() |
|
|
|
}, [currentPage, rowsPerPage, search]) |
|
|
|
}, [currentPage, rowsPerPage, search]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
const cekData = dataExport || [] |
|
|
|
|
|
|
|
if (cekData.length > 0) { |
|
|
|
|
|
|
|
exportExcel() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, [dataExport]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getDataProjectType = async () => { |
|
|
|
const getDataProjectType = async () => { |
|
|
|
|
|
|
|
|
|
|
|
let start = 0; |
|
|
|
let start = 0; |
|
|
@ -79,7 +72,6 @@ const ProjectType = ({ params }) => { |
|
|
|
for (const v in listDivions.data.data) { |
|
|
|
for (const v in listDivions.data.data) { |
|
|
|
arr.push(listDivions.data.data[v]) |
|
|
|
arr.push(listDivions.data.data[v]) |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(arr); |
|
|
|
|
|
|
|
setDataDivisions(arr); |
|
|
|
setDataDivisions(arr); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
|
|
|
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
|
|
@ -134,48 +126,6 @@ const ProjectType = ({ params }) => { |
|
|
|
setTypeDialog(type) |
|
|
|
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) => { |
|
|
|
const handleEdit = (data) => { |
|
|
|
setDataEdit(data) |
|
|
|
setDataEdit(data) |
|
|
|
handleOpenDialog('Edit'); |
|
|
|
handleOpenDialog('Edit'); |
|
|
@ -203,7 +153,7 @@ const ProjectType = ({ params }) => { |
|
|
|
.catch((error) => error.response); |
|
|
|
.catch((error) => error.response); |
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
getDataProjectType() |
|
|
|
getDataProjectType() |
|
|
|
NotificationManager.success(`Data project type berhasil ditambah`, 'Success!!'); |
|
|
|
NotificationManager.success(`Data berhasil ditambah`, 'Success!!'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
NotificationManager.error(`${result.data.message}`, 'Failed!!'); |
|
|
|
NotificationManager.error(`${result.data.message}`, 'Failed!!'); |
|
|
|
} |
|
|
|
} |
|
|
@ -217,9 +167,9 @@ const ProjectType = ({ params }) => { |
|
|
|
.catch((error) => error.response); |
|
|
|
.catch((error) => error.response); |
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
getDataProjectType(); |
|
|
|
getDataProjectType(); |
|
|
|
NotificationManager.success(`Data project type berhasil diedit`, 'Success!!'); |
|
|
|
NotificationManager.success(`Data berhasil diedit`, 'Success!!'); |
|
|
|
} else { |
|
|
|
} 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() |
|
|
|
getDataProjectType() |
|
|
|
setIdDelete(0) |
|
|
|
setIdDelete(0) |
|
|
|
setAlertDelete(false) |
|
|
|
setAlertDelete(false) |
|
|
|
NotificationManager.success(`Data project type berhasil dihapus!`, 'Success!!'); |
|
|
|
NotificationManager.success(`Data berhasil dihapus!`, 'Success!!'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setIdDelete(0) |
|
|
|
setIdDelete(0) |
|
|
|
setAlertDelete(false) |
|
|
|
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) { |
|
|
|
if (dataTable.length === 0) { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<tr> |
|
|
|
<tr> |
|
|
|
<td align="center" colSpan="3">Tidak ada data project type</td> |
|
|
|
<td align="center" colSpan="3">Belum ada data.</td> |
|
|
|
</tr> |
|
|
|
</tr> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
@ -299,15 +249,9 @@ const ProjectType = ({ params }) => { |
|
|
|
<h4 className="capitalize">{pageName}</h4> |
|
|
|
<h4 className="capitalize">{pageName}</h4> |
|
|
|
<Row> |
|
|
|
<Row> |
|
|
|
<Col> |
|
|
|
<Col> |
|
|
|
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Search`} /> |
|
|
|
<Tooltip title="Add Data"> |
|
|
|
</Col> |
|
|
|
|
|
|
|
<Col> |
|
|
|
|
|
|
|
<Tooltip title="Add Material Resource"> |
|
|
|
|
|
|
|
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> |
|
|
|
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> |
|
|
|
</Tooltip> |
|
|
|
</Tooltip> |
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
|
|
|
|
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> |
|
|
|
|
|
|
|
</Tooltip> |
|
|
|
|
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
</CardHeader> |
|
|
|
</CardHeader> |
|
|
@ -329,31 +273,20 @@ const ProjectType = ({ params }) => { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<tr key={n.id}> |
|
|
|
<tr key={n.id}> |
|
|
|
<td className='nowrap'> |
|
|
|
<td className='nowrap'> |
|
|
|
|
|
|
|
|
|
|
|
<Tooltip title="Hapus"> |
|
|
|
<Tooltip title="Hapus"> |
|
|
|
<i id="TooltipDelete" className="cil-trash fa-lg" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i> |
|
|
|
<i id="TooltipDelete" className="cil-trash fa-lg" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i> |
|
|
|
</Tooltip> |
|
|
|
</Tooltip> |
|
|
|
|
|
|
|
|
|
|
|
<Tooltip title="Edit"> |
|
|
|
<Tooltip title="Edit"> |
|
|
|
<i id="TooltipEdit" className="cil-pencil fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> |
|
|
|
<i id="TooltipEdit" className="cil-pencil fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> |
|
|
|
</Tooltip> |
|
|
|
</Tooltip> |
|
|
|
</td> |
|
|
|
</td> |
|
|
|
<td>{n.name}</td> |
|
|
|
<td>{n.displayName}</td> |
|
|
|
<td>{n.description}</td> |
|
|
|
<td>{n.description}</td> |
|
|
|
</tr> |
|
|
|
</tr> |
|
|
|
) |
|
|
|
) |
|
|
|
})} |
|
|
|
})} |
|
|
|
</tbody> |
|
|
|
</tbody> |
|
|
|
</Table> |
|
|
|
</Table> |
|
|
|
<Pagination |
|
|
|
|
|
|
|
showSizeChanger |
|
|
|
|
|
|
|
onShowSizeChange={onShowSizeChange} |
|
|
|
|
|
|
|
onChange={onPagination} |
|
|
|
|
|
|
|
defaultCurrent={currentPage} |
|
|
|
|
|
|
|
pageSize={rowsPerPage} |
|
|
|
|
|
|
|
total={totalPage} |
|
|
|
|
|
|
|
pageSizeOptions={["10", "15", "20", "25", "30", "35", "40"]} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</CardBody> |
|
|
|
</CardBody> |
|
|
|
</Card> |
|
|
|
</Card> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|