2024-01-04 09:01:35 +00:00
import React , { useCallback , useEffect , useRef , useState } from 'react' ;
import { Link , useLocation } from "react-router-dom" ;
2024-01-05 08:31:38 +00:00
import URL from "constants/url" ;
2024-01-04 09:01:35 +00:00
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin' ;
2024-01-05 08:31:38 +00:00
import EgovPaging from "components/EgovPaging" ;
import * as EgovNet from "api/egovFetch" ;
import { itemIdxByPage } from "utils/calc" ;
import Button from "react-bootstrap/Button" ;
2023-12-26 06:35:38 +00:00
function List ( props ) {
2024-01-04 09:01:35 +00:00
const location = useLocation ( ) ;
const [ searchCondition , setSearchCondition ] = useState ( location . state ? . searchCondition || { pageIndex : 1 , searchCnd : '0' , searchWrd : '' } ) ; // 기존 조회에서 접근 했을 시 || 신규로 접근 했을 시
const [ listTag , setListTag ] = useState ( [ ] ) ;
const [ paginationInfo , setPaginationInfo ] = useState ( { } ) ;
const cndRef = useRef ( ) ;
const wrdRef = useRef ( ) ;
const retrieveList = useCallback ( ( searchCondition ) => {
2024-01-05 08:31:38 +00:00
const params = "?" ;
2024-01-04 09:01:35 +00:00
EgovNet . requestFetch (
2024-01-05 08:31:38 +00:00
'/admin/users/list' + params ,
2024-01-04 09:01:35 +00:00
{
2024-01-05 08:31:38 +00:00
method : "GET"
2024-01-04 09:01:35 +00:00
} ,
( resp ) => {
setPaginationInfo ( resp . result . paginationInfo ) ;
let mutListTag = [ ] ;
2024-01-05 08:31:38 +00:00
const resultCnt = parseInt ( resp . result . contentCnt ) ;
const currentPageNo = resp . result . paginationInfo . pageIndex ;
const pageSize = resp . result . paginationInfo . rowCnt ;
2024-01-04 09:01:35 +00:00
2024-01-05 08:31:38 +00:00
setListTag ( [ ] ) ;
2024-01-04 09:01:35 +00:00
// 리스트 항목 구성
2024-01-05 08:31:38 +00:00
resp . result . userList . forEach ( function ( item , index ) {
2024-01-04 09:01:35 +00:00
const listIdx = itemIdxByPage ( resultCnt , currentPageNo , pageSize , index ) ;
mutListTag . push (
2024-01-05 08:31:38 +00:00
< div >
< span > { item . userSe } < / span >
< span > { item . userId } < / span >
< span > { item . userNm } < / span >
< span > { item . email } < / span >
< span > { item . phoneNum } < / span >
< span > { item . useYn } < / span >
< span > < Button variant = { "danger" } size = { "sm" } > 삭제 < / Button > < / span >
< / div >
) ;
/ * < L i n k t o = { { p a t h n a m e : U R L . A D M I N _ N O T I C E _ D E T A I L } }
2024-01-04 09:01:35 +00:00
state = { {
nttId : item . nttId ,
searchCondition : searchCondition
} }
key = { listIdx } className = "list_item" >
< div > { listIdx } < / div >
{ ( item . replyLc * 1 ? true : false ) &&
< > < div className = "al reply" >
{ item . nttSj }
< / div > < / > }
{ ( item . replyLc * 1 ? false : true ) &&
< > < div className = "al" >
{ item . nttSj }
< / div > < / > }
< div > { item . frstRegisterNm } < / div >
< div > { item . frstRegisterPnttm } < / div >
< div > { item . inqireCo } < / div >
2024-01-05 08:31:38 +00:00
< / Link > * /
2024-01-04 09:01:35 +00:00
} ) ;
if ( ! mutListTag . length ) mutListTag . push ( < p className = "no_data" key = "0" > 검색된 결과가 없습니다 . < / p > ) ; // 게시판 목록 초기값
setListTag ( mutListTag ) ;
} ,
function ( resp ) {
console . log ( "err response : " , resp ) ;
}
) ;
} , [ ] ) ;
useEffect ( ( ) => {
retrieveList ( searchCondition ) ;
} , [ ] ) ;
2023-12-26 06:35:38 +00:00
return (
< div className = "container" >
2024-01-04 09:01:35 +00:00
< div className = "c_wrap" >
< div className = "location" >
< ul >
< li > < Link to = { URL . MAIN } className = "home" > Home < / Link > < / li >
< li > 사이트관리 < / li >
< li > 사용자 관리 < / li >
< li > < Link to = { URL . ADMIN _ _USERS _ _LIST } > 사용자 목록 < / Link > < / li >
< / ul >
< / div >
< div className = "layout" >
{ /* <!-- Navigation --> */ }
< EgovLeftNav activeKey = { "1" } > < / EgovLeftNav >
< div className = "contents NOTICE_LIST" id = "contents" >
{ /* <!-- 본문 --> */ }
< div className = "top_tit" >
< h1 className = "tit_1" > 사용자 목록 < / h1 >
< / div >
< h2 className = "tit_2" > < / h2 >
{ /* <!-- 검색조건 --> */ }
< div className = "condition" >
< ul >
< li className = "third_1 L" >
< label className = "f_select" htmlFor = "sel1" >
< select id = "sel1" title = "조건" defaultValue = { searchCondition . searchCnd } ref = { cndRef }
onChange = { e => { cndRef . current . value = e . target . value ; } } >
< option value = "0" > 전체 < / option >
< option value = "1" > 일반사용자 < / option >
< option value = "2" > 관리자 < / option >
< / select >
< / label >
< / li >
< li className = "third_1 L" >
< label className = "f_select" htmlFor = "sel1" >
< select id = "sel1" title = "조건" defaultValue = { searchCondition . searchCnd } ref = { cndRef }
onChange = { e => { cndRef . current . value = e . target . value ; } } >
2024-01-05 08:31:38 +00:00
< option value = "id" > 아이디 < / option >
< option value = "name" > 이름 < / option >
< option value = "email" > 이메일 < / option >
< option value = "phoneNum" > 전화번호 < / option >
2024-01-04 09:01:35 +00:00
< / select >
< / label >
< / li >
< li className = "third_2 R" >
< span className = "f_search w_500" >
< input type = "text" name = "" defaultValue = { searchCondition . searchWrd } placeholder = "" ref = { wrdRef }
onChange = { e => {
wrdRef . current . value = e . target . value ;
} }
/ >
< button type = "button"
onClick = { ( ) => {
retrieveList ( { ... searchCondition , pageIndex : 1 , searchCnd : cndRef . current . value , searchWrd : wrdRef . current . value } ) ;
} } > 조회 < / button >
< / span >
< / li >
{ / * { m a s t e r B o a r d . b b s U s e F l a g = = = ' Y ' & &
< li >
< Link to = { URL . ADMIN _NOTICE _CREATE } state = { { bbsId : bbsId } } className = "btn btn_blue_h46 pd35" > 등록 < / Link >
< / li >
} * / }
< / ul >
< / div >
< div className = "board_list BRD002" >
< div className = "head" >
< span > 구분 < / span >
< span > 아이디 < / span >
< span > 이름 < / span >
< span > 이메일 < / span >
< span > 전화번호 < / span >
< span > 상태 < / span >
< span > 삭제 < / span >
< / div >
< div className = "result" >
{ listTag }
< / div >
< / div >
< div className = "board_bot" >
2024-01-05 08:31:38 +00:00
< EgovPaging pagination = { paginationInfo }
moveToPage = { passedPage => {
retrieveList ( {
... searchCondition ,
pageIndex : passedPage ,
searchCnd : cndRef . current . value ,
searchWrd : wrdRef . current . value
} )
} } / >
2024-01-04 09:01:35 +00:00
< / div >
< / div >
< / div >
< / div >
2023-12-26 06:35:38 +00:00
< / div >
) ;
}
export default List ;