From 80bb589553b1e82e32e077281a1e531d6ab05512 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Fri, 1 Jul 2022 13:06:54 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20mpower=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commons/ApiUrl.js | 8 ++--- src/contexts/JWTContext.js | 2 +- src/views/biz/board/ModifyBoardForm.jsx | 4 +-- src/views/biz/pboard/PublicBoard.jsx | 39 ++++++++++++------------- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/commons/ApiUrl.js b/src/commons/ApiUrl.js index a4dfe59..a0bd325 100644 --- a/src/commons/ApiUrl.js +++ b/src/commons/ApiUrl.js @@ -10,13 +10,13 @@ export const GET_DASHBOARD = '/api/v1/ctgy/dashboard'; export const GET_PUBLIC_BOARD_LIST = '/api/v2/ctgy/pboard'; export const SAVE_PUBLIC_BOARD_HIT_CNT = '/api/v2/ctgy/pboard/hit/'; export const SAVE_PUBLIC_BOARD = '/api/v2/ctgy/file/pboard'; -export const REMOVE_PUBLIC_BOARD = '/api/v1/ctgy/file/pboard/'; +export const REMOVE_PUBLIC_BOARD = '/api/v2/ctgy/file/pboard/'; // 게시판 export const GET_BOARD_LIST = '/api/v2/ctgy/board'; -export const SAVE_BOARD_HIT_CNT = '/api/v1/ctgy/board/hit/'; -export const SAVE_BOARD = '/api/v1/ctgy/board'; -export const REMOVE_BOARD = '/api/v1/ctgy/board/'; +export const SAVE_BOARD_HIT_CNT = '/api/v2/ctgy/board/hit/'; +export const SAVE_BOARD = '/api/v2/ctgy/board'; +export const REMOVE_BOARD = '/api/v2/ctgy/board/'; // 주정차 의견 진술 export const GET_PARKING_LIST = '/api/v1/ctgy/parking'; diff --git a/src/contexts/JWTContext.js b/src/contexts/JWTContext.js index 86880cc..a7d3ad6 100755 --- a/src/contexts/JWTContext.js +++ b/src/contexts/JWTContext.js @@ -62,7 +62,7 @@ export const JWTProvider = ({ children }) => { // TODO: verifyToken ?? if (accessToken && verifyToken(accessToken)) { setLocalStorage(ACCESS_TOKEN_NAME, accessToken); - const response = await axios.get('/api/v1/ctgy/user/info'); + const response = await axios.get('/api/v2/ctgy/user/info'); console.log(response); // TODO : 적용 필요 const { userid, email, name, accesstype } = response.data; diff --git a/src/views/biz/board/ModifyBoardForm.jsx b/src/views/biz/board/ModifyBoardForm.jsx index a31dbf4..2b45d2a 100644 --- a/src/views/biz/board/ModifyBoardForm.jsx +++ b/src/views/biz/board/ModifyBoardForm.jsx @@ -20,7 +20,7 @@ const ModifyBoardForm = (props) => { const quillRef = useRef(); const [subject, setSubject] = useState(rowData.ciTitle); const [contents, setContents] = useState(rowData.ciContents); - const [pass, setPass] = useState(rowData.ciPass); + const [pass, setPass] = useState(''); const onList = () => { setOpen(false); @@ -43,7 +43,7 @@ const ModifyBoardForm = (props) => { showAlert.show('내용은 필수입니다.'); return; } - if (pass === undefined || pass === '') { + if (owner && (pass === undefined || pass === '')) { showAlert.show('비밀번호는 필수입니다.'); return; } diff --git a/src/views/biz/pboard/PublicBoard.jsx b/src/views/biz/pboard/PublicBoard.jsx index c573656..39a82a8 100644 --- a/src/views/biz/pboard/PublicBoard.jsx +++ b/src/views/biz/pboard/PublicBoard.jsx @@ -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') {