diff --git a/egovframe-template-simple-react-contribution/src/pages/support/List.jsx b/egovframe-template-simple-react-contribution/src/pages/support/List.jsx index 95668b1..99a6a88 100644 --- a/egovframe-template-simple-react-contribution/src/pages/support/List.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/support/List.jsx @@ -1,5 +1,5 @@ -import React, { useState } from 'react'; -import {Link, useNavigate} from 'react-router-dom'; +import React, {useCallback, useEffect, useState} from 'react'; +import {Link, useLocation, useNavigate, useParams} from 'react-router-dom'; import * as EgovNet from 'api/egovFetch'; import URL from 'constants/url'; @@ -7,6 +7,8 @@ import URL from 'constants/url'; import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; import Button from 'react-bootstrap/Button'; +import {format} from "date-fns"; +import EgovPaging from "../../components/EgovPaging"; function List(){ const navigate = useNavigate(); @@ -14,6 +16,89 @@ function List(){ const goToCreate = () => { navigate('/support/create/KCSC-QA'); }; + const location = useLocation(); + + const {BbsCode} = useParams(); + const [searchCondition, setSearchCondition] = useState(location.state?.searchCondition || { pageIndex: 1, searchCnd: '0', searchKeyword: '', bbsId:BbsCode });// 기존 조회에서 접근 했을 시 || 신규로 접근 했을 시 + const [paginationInfo, setPaginationInfo] = useState({}); + const [listTag, setListTag] = useState([]); + const [categoryList, setCategoryList] = useState([]); + + const [show, setShow] = useState(false); + const [modalBody, setModalBody] = useState(); + const handleClose = () => setShow(false); + const handleShow = () => setShow(true); + + console.log("@@@ BbsCode : " + BbsCode); + + const retrieveList = useCallback((searchCondition) => { + handleClose(); + const params = EgovNet.convParams(searchCondition); + + console.groupCollapsed("EgovAdminPostList.retrieveList()"); + + const retrieveListURL = '/admin/boards/posts/post-list' + params; + + const requestOptions = { + method: "GET", + headers: { + 'Content-type': 'application/json', + + } + } + + EgovNet.requestFetch(retrieveListURL, + requestOptions, + (resp) => { + setPaginationInfo(resp.result.paginationInfo); + setCategoryList(resp.result.categoryList); + console.log("@@@ resultCnt : " + resp.result.resultCnt); + + let mutListTag = []; + setListTag([]); + resp.result.fixedList.forEach(function (item) { + const finalModifiedDate = item?.lastChgDt ? item?.lastChgDt : item?.frstCrtDt; + const formattedDate = finalModifiedDate ? format(finalModifiedDate, "yyyy-MM-dd") : ""; + mutListTag.push( +
}
}검색된 결과가 없습니다.
); // 게시판 목록 초기값 + setListTag(mutListTag); + }, + function (resp) { + console.log("err response : ", resp); + } + ); + console.groupEnd("EgovAdminPostList.retrieveList()"); + },[listTag]); + + useEffect(() => { + retrieveList(searchCondition); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [searchCondition]); return ( @@ -72,7 +157,8 @@ function List(){ {/*검색된 결과가 없습니다.
*/} {/* */} - + {listTag} + {/*
