|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
import { useQuery } from 'react-query';
|
|
|
|
|
import { useCallback, useEffect, useState } from 'react';
|
|
|
|
|
|
|
|
|
|
// material-ui
|
|
|
|
|
import { Button, Grid, Link } from '@mui/material';
|
|
|
|
@ -80,24 +79,24 @@ const PublicBoard = () => {
|
|
|
|
|
{ headerName: '조회수', headerAlign: 'center', field: 'inHit', align: 'right', width: 80 }
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
|
page: rowsState.page,
|
|
|
|
|
size: rowsState.pageSize
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const search = async () => {
|
|
|
|
|
const res = await findPublicBoards(params);
|
|
|
|
|
if (res && res.data) {
|
|
|
|
|
setTotalCount(res.count);
|
|
|
|
|
setRowsState((prevState) => ({ ...prevState, rows: res.data }));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
useQuery(['pboards', params.page, params.size], search);
|
|
|
|
|
// const { isLoading, data, isError } = useQuery(['pboards', params.page, params.size], search);
|
|
|
|
|
|
|
|
|
|
// useEffect(() => {
|
|
|
|
|
// search();
|
|
|
|
|
// }, [search]); // rowsState.page, rowsState.pageSize, rowsState.rows]);
|
|
|
|
|
const search = useCallback(() => {
|
|
|
|
|
const params = {
|
|
|
|
|
page: rowsState.page,
|
|
|
|
|
size: rowsState.pageSize
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
findPublicBoards(params).then((response) => {
|
|
|
|
|
// console.log(response);
|
|
|
|
|
if (response && response.data) {
|
|
|
|
|
setTotalCount(response.count);
|
|
|
|
|
setRowsState((prevState) => ({ ...prevState, rows: response.data }));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, [rowsState.page, rowsState.pageSize]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
search();
|
|
|
|
|
}, [search]); // rowsState.page, rowsState.pageSize, rowsState.rows]);
|
|
|
|
|
|
|
|
|
|
const handleOnCellClick = (e) => {
|
|
|
|
|
if (e?.field === 'inTitle') {
|
|
|
|
|