Browse Source

feat: set row page in localstorage

pull/1/head
wahyun 7 months ago
parent
commit
83722aa6ca
  1. 13
      src/views/SimproV2/CreatedProyek/index.js

13
src/views/SimproV2/CreatedProyek/index.js

@ -91,6 +91,7 @@ const url = "";
const format = "DD-MM-YYYY"; const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => { const CreatedProyek = ({ params, ...props }) => {
let pageRow = 10;
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '', configApp = {}; let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '', configApp = {};
if (props && props.role_id && props.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.role_id; role_id = props.role_id;
@ -141,7 +142,9 @@ const CreatedProyek = ({ params, ...props }) => {
const [dataK3, setDataK3] = useState([]); // transfer list const [dataK3, setDataK3] = useState([]); // transfer list
const [idDelete, setIdDelete] = useState(0); const [idDelete, setIdDelete] = useState(0);
const [alertDelete, setAlertDelete] = useState(false); const [alertDelete, setAlertDelete] = useState(false);
const [rowsPerPage, setRowsPerPage] = useState(10); const [rowsPerPage, setRowsPerPage] = useState(() => {
return parseInt(localStorage.getItem('pageTable')) || pageRow;
});
const [dataExport, setDataExport] = useState([]); const [dataExport, setDataExport] = useState([]);
const [userProyek, setUserProyek] = useState([]); const [userProyek, setUserProyek] = useState([]);
const [materialProyek, setMaterialProyek] = useState([]); const [materialProyek, setMaterialProyek] = useState([]);
@ -220,6 +223,13 @@ const CreatedProyek = ({ params, ...props }) => {
getDataProyek(); getDataProyek();
}, [search, rowsPerPage, currentPage]); }, [search, rowsPerPage, currentPage]);
useEffect(() => {
const storedPageSize = localStorage.getItem('pageTable');
if (!storedPageSize) {
localStorage.setItem('pageTable', pageRow);
}
}, [pageRow]);
useEffect(() => { useEffect(() => {
if (dataExport.length > 0) { if (dataExport.length > 0) {
exportExcel(); exportExcel();
@ -1392,6 +1402,7 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
const onShowSizeChange = (current, pageSize) => { const onShowSizeChange = (current, pageSize) => {
localStorage.setItem('pageTable', pageSize);
setRowsPerPage(pageSize); setRowsPerPage(pageSize);
}; };

Loading…
Cancel
Save