diff --git a/public/index.html b/public/index.html index 8b8f968..071ba67 100755 --- a/public/index.html +++ b/public/index.html @@ -88,6 +88,7 @@ --> + diff --git a/src/apis/BoardService.js b/src/apis/BoardService.js index fb38ba8..23e3493 100644 --- a/src/apis/BoardService.js +++ b/src/apis/BoardService.js @@ -2,10 +2,13 @@ import { BOARD_LIST_URL } from 'commons/ApiUrl'; import axios from 'utils/axios'; class BoardService { - getBoardList = (params) => - axios.get(BOARD_LIST_URL, { params }).then((r) => { - console.log(r); - return r; - }); + // eslint-disable-next-line no-return-await + getBoardList = async (params) => await axios.get(BOARD_LIST_URL, { params }); + // const res = await axios.get(BOARD_LIST_URL, { params }); + // return res; + // axios.get(BOARD_LIST_URL, { params }).then((r) => { + // console.log(r); + // return r; + // }); } export default new BoardService(); diff --git a/src/ui-component/MuiGridList.jsx b/src/ui-component/MuiGridList.jsx index dfbd7dd..636f7e4 100644 --- a/src/ui-component/MuiGridList.jsx +++ b/src/ui-component/MuiGridList.jsx @@ -1,12 +1,15 @@ +import PropTypes from 'prop-types'; + // material-ui +// import type { GridColumns } from '@mui/x-data-grid/colDef'; import { DataGrid } from '@mui/x-data-grid'; import { Box } from '@mui/material'; import { useTheme } from '@mui/material/styles'; // project imports -const MuiGridList = (props) => { - const { columns, rowsState, totalCount, setRowsState } = props; +const MuiGridList = ({ columns, rowsState, totalCount, setRowsState }) => { + // const { columns, rowsState, totalCount, setRowsState } = props; const theme = useTheme(); return ( @@ -49,4 +52,11 @@ const MuiGridList = (props) => { ); }; +MuiGridList.propTypes = { + columns: PropTypes.array, + rowsState: PropTypes.any, + totalCount: PropTypes.number, + setRowsState: PropTypes.func +}; + export default MuiGridList; diff --git a/src/views/biz/board/BoardList.jsx b/src/views/biz/board/BoardList.jsx index b501060..11769ee 100644 --- a/src/views/biz/board/BoardList.jsx +++ b/src/views/biz/board/BoardList.jsx @@ -9,6 +9,7 @@ import { useTheme } from '@mui/material/styles'; // project imports import CmmService from 'apis/CmmService'; +import boardService from '../../../apis/BoardService'; const columns = [ { headerName: '게시판코드', field: 'ciCode' }, @@ -55,20 +56,21 @@ const BoardList = () => { // loading: false }); - const [ciDiv, setCiDiv] = useState<[ICmmCode]>(); + const [ciDiv, setCiDiv] = useState(); useEffect(() => { - // setRowsState(prev => ({...prev})) - fetch( - // `https://jsonplaceholder.typicode.com/comments?_start=${params.startRow}&_end=${params.endRow}` - `http://localhost:8090/api/v1/ctgy/board?page=${rowsState.page + 1}&size=${rowsState.pageSize}` - ) - .then((r) => r.json()) - .then((data) => { - setTotalCount(data.count); - // setTableData(data.data); - setRowsState((prev) => ({ ...prev, rows: data.data })); - }); + const params = { + page: rowsState.page + 1, + size: rowsState.pageSize + }; + + boardService.getBoardList(params).then((response) => { + console.log(response); + if (response && response.data) { + setTotalCount(response.count); + setRowsState((prevState) => ({ ...prevState, rows: response.data })); + } + }); }, [rowsState.page, rowsState.pageSize]); // rowsState.page, rowsState.pageSize, rowsState.rows]); return ( diff --git a/src/views/biz/board/index.jsx b/src/views/biz/board/index.jsx index e07e26c..7ff3614 100644 --- a/src/views/biz/board/index.jsx +++ b/src/views/biz/board/index.jsx @@ -8,26 +8,14 @@ import { IconSearch } from '@tabler/icons'; // berry ui import MainCard from 'ui-component/cards/MainCard'; -import { useDispatch, useSelector } from 'store'; // project imports import MuiGridList from 'ui-component/MuiGridList'; import boardService from 'apis/BoardService'; const Index = () => { - const dispatch = useDispatch(); const [category, setCategory] = useState('ciTitle'); const [searchTxt, setSearchTxt] = useState(''); - // const handleSearch = async (event: React.ChangeEvent | undefined) => { - // const newString = event?.target.value; - // setSearch(newString); - // - // if (newString) { - // dispatch(filterDetailCards(newString)); - // } else { - // dispatch(getDetailCards()); - // } - // }; const [totalCount, setTotalCount] = useState(0); const [rowsState, setRowsState] = useState({ @@ -70,22 +58,13 @@ const Index = () => { } ]; const handleSearch = async (event) => { - console.log('~~~'); if (event.type === 'keydown' && event.key === 'Enter') { const newString = event?.target.value; setSearchTxt(newString); - - // if (newString) { - // dispatch(filterDetailCards(newString)); - // } else { - // dispatch(getDetailCards()); - // } } }; useEffect(() => { - // setRowsState(prev => ({...prev})) - let params = { page: rowsState.page + 1, size: rowsState.pageSize @@ -98,166 +77,19 @@ const Index = () => { }; } - const res = boardService.getBoardList(params).then((response) => { + boardService.getBoardList(params).then((response) => { + console.log(response); if (response && response.data) { - // setTotalCount(response?.count); + setTotalCount(response.count); setRowsState((prevState) => ({ ...prevState, rows: response.data })); } }); - - // if (res) { - // setTotalCount(res.count); - // setRowsState((prev) => ({ ...prev, rows: res.data })); - // } - // fetch( - // // `https://jsonplaceholder.typicode.com/comments?_start=${params.startRow}&_end=${params.endRow}` - // `http://localhost:8090/api/v1/ctgy/board?page=${rowsState.page + 1}&size=${rowsState.pageSize}${search}` - // ) - // .then((r) => r.json()) - // .then((data) => { - // setTotalCount(data.count); - // // setTableData(data.data); - // setRowsState((prev) => ({ ...prev, rows: data.data })); - // }); }, [rowsState.page, rowsState.pageSize, searchTxt]); // rowsState.page, rowsState.pageSize, rowsState.rows]); return ( - - // - // List - // - // - // - // - // - // } - // size="small" - // /> - // - // - // } - > + - {/* - - - - - Name : - - - - - - - - - - - - Email : - - - - - - - - - - - - Password : - - - - - - - ) - }} - /> - - - - - - - - Contact : - - - - - Please enter your contact - - - - - - - - Profile URL : - - - - - - - ) - }} - /> - - - - - - - - Pincode : - - - - - - - - - - - - Address : - - - - - - - - */} - - {/* */} - {/* */} - + @@ -281,14 +113,12 @@ const Index = () => { - {/* */} - ); diff --git a/src/views/biz/board/public.jsx b/src/views/biz/board/public.jsx index 1a933de..ddd8f5c 100644 --- a/src/views/biz/board/public.jsx +++ b/src/views/biz/board/public.jsx @@ -9,27 +9,13 @@ import LockTwoToneIcon from '@mui/icons-material/LockTwoTone'; // berry ui import MainCard from 'ui-component/cards/MainCard'; -import { useDispatch } from 'store'; -import { getDetailCards, filterDetailCards } from 'store/slices/user'; // project imports import MuiGridList from 'ui-component/MuiGridList'; import InputLabel from 'ui-component/extended/Form/InputLabel'; +import boardService from '../../../apis/BoardService'; const Index = () => { - const dispatch = useDispatch(); - const [search, setSearch] = useState(''); - // const handleSearch = async (event: React.ChangeEvent | undefined) => { - // const newString = event?.target.value; - // setSearch(newString); - // - // if (newString) { - // dispatch(filterDetailCards(newString)); - // } else { - // dispatch(getDetailCards()); - // } - // }; - const [totalCount, setTotalCount] = useState(0); const [rowsState, setRowsState] = useState({ page: 0, @@ -70,59 +56,24 @@ const Index = () => { field: `ciIp` } ]; - const handleSearch = async (event) => { - console.log('~~~'); - if (event.type === 'keydown' && event.key === 'Enter') { - const newString = event?.target.value; - setSearch(newString); - - if (newString) { - dispatch(filterDetailCards(newString)); - } else { - dispatch(getDetailCards()); - } - } - }; useEffect(() => { - // setRowsState(prev => ({...prev})) - fetch( - // `https://jsonplaceholder.typicode.com/comments?_start=${params.startRow}&_end=${params.endRow}` - `http://localhost:8090/api/v1/ctgy/board?page=${rowsState.page + 1}&size=${rowsState.pageSize}` - ) - .then((r) => r.json()) - .then((data) => { - setTotalCount(data.count); - // setTableData(data.data); - setRowsState((prev) => ({ ...prev, rows: data.data })); - }); + const params = { + page: rowsState.page + 1, + size: rowsState.pageSize + }; + + boardService.getBoardList(params).then((response) => { + console.log(response); + if (response && response.data) { + setTotalCount(response.count); + setRowsState((prevState) => ({ ...prevState, rows: response.data })); + } + }); }, [rowsState.page, rowsState.pageSize]); // rowsState.page, rowsState.pageSize, rowsState.rows]); return ( - - // - // List - // - // - // - // - // - // } - // size="small" - // /> - // - // - // } - > - {/* */} + @@ -253,10 +204,7 @@ const Index = () => { - {/* */} - {/* */} - {/* */} ); };