diff --git a/egovframe-template-simple-react-contribution/public/assets/images/narae.jpg b/egovframe-template-simple-react-contribution/public/assets/images/narae.jpg new file mode 100644 index 0000000..9c1d3e8 Binary files /dev/null and b/egovframe-template-simple-react-contribution/public/assets/images/narae.jpg differ diff --git a/egovframe-template-simple-react-contribution/src/css/base.css b/egovframe-template-simple-react-contribution/src/css/base.css index 972041a..03ab88f 100644 --- a/egovframe-template-simple-react-contribution/src/css/base.css +++ b/egovframe-template-simple-react-contribution/src/css/base.css @@ -104,9 +104,11 @@ button {cursor: pointer;} .ml10 {margin-left: 10px !important;} .pb10 {padding-bottom: 10px !important;} -.bg-fa {background: #FAFAFA;} +.bg-fa {background: #FAFAFA !important;} -.text-4c6 {color: #4C6C84;} -.text-224 {color: #22498E;} +.text-4c6 {color: #4C6C84 !important;} +.text-224 {color: #22498E !important;} -.clickable{cursor: pointer;} \ No newline at end of file +.clickable{cursor: pointer;} + +.MuiTab-root.Mui-selected { color: #22498E; } diff --git a/egovframe-template-simple-react-contribution/src/pages/main/EgovLogin.jsx b/egovframe-template-simple-react-contribution/src/pages/main/EgovLogin.jsx new file mode 100644 index 0000000..84a0588 --- /dev/null +++ b/egovframe-template-simple-react-contribution/src/pages/main/EgovLogin.jsx @@ -0,0 +1,197 @@ +import React, {useCallback, useEffect, useRef, useState} from "react"; +import {getLocalItem, setLocalItem} from "utils/storage"; +import * as EgovNet from "api/egovFetch"; +import CODE from "constants/code"; +import {parseJwt} from "../../utils/parseJwt"; +import URL from "constants/url"; +import IdFindForm from "../login/IdFindForm"; +import PwFindForm from "../login/PwFindForm"; +import Row from "react-bootstrap/Row"; +import Col from "react-bootstrap/Col"; +import Form from "react-bootstrap/Form"; +import {Link, useLocation, useNavigate} from "react-router-dom"; +import Modal from "react-bootstrap/Modal"; + + +function EgovLoginContent(props) { + const navigate = useNavigate(); + const location = useLocation(); + + const sessionUser = parseJwt(getLocalItem('accessToken')); + + const [userInfo, setUserInfo] = useState({ username: '', password: 'default', email: '', userSe: 'ACC_TP02'}); + // eslint-disable-next-line no-unused-vars + + const [saveIDFlag, setSaveIDFlag] = useState(false); + + const [findModalState, setFindModalState] = useState(false); + const [modalTitle, setModalTitle] = useState(); + const [modalBody, setModalBody] = useState(); + const handleClose = () => setFindModalState(false); + const handleShow = () => setFindModalState(true); + + const checkRef = useRef(); + + const KEY_ID = "KEY_ID"; + const KEY_SAVE_ID_FLAG = "KEY_SAVE_ID_FLAG"; + + const handleSaveIDFlag = () => { + setLocalItem(KEY_SAVE_ID_FLAG, !saveIDFlag) + setSaveIDFlag(!saveIDFlag); + }; + + useEffect(() => { + let idFlag = getLocalItem(KEY_SAVE_ID_FLAG); + if (idFlag === null) { + setSaveIDFlag(false); + // eslint-disable-next-line react-hooks/exhaustive-deps + idFlag = false; + } else { + setSaveIDFlag(idFlag); + } + + if (idFlag === false) { + setLocalItem(KEY_ID, ""); + } else { + } + }, []); + + useEffect(() => { + let data = getLocalItem(KEY_ID); + if (data !== null) { + setUserInfo({ username: data, password: 'default', email: '', userSe: 'ACC_TP02' }); + } + }, []); + + const submitFormHandler = (e) => { + console.log("EgovLoginContent submitFormHandler()"); + + const loginUrl = "/auth/login" + const requestOptions = { + method: "POST", + headers: { + 'Content-type': 'application/json' + }, + body: JSON.stringify(userInfo) + } + + EgovNet.requestFetch(loginUrl, + requestOptions, + (resp) => { + if(resp !== undefined){ + if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) { + let accessToken = resp?.accessToken || null; + let resultVO = parseJwt(accessToken); + let refreshToken = resp?.refreshToken || null; + + // setSessionItem('accessToken', accessToken); + setLocalItem('accessToken', accessToken); + setLocalItem('refreshToken', refreshToken); + // setSessionItem('loginUser', resultVO); + props.onChangeLogin(resultVO); + if (saveIDFlag) { + setLocalItem(KEY_ID, resultVO?.id); + } + // PC와 Mobile 열린메뉴 닫기 + document.querySelector('.all_menu.WEB').classList.add('closed'); + document.querySelector('.btnAllMenu').classList.remove('active'); + document.querySelector('.btnAllMenu').title = '전체메뉴 닫힘'; + document.querySelector('.all_menu.Mobile').classList.add('closed'); + } else { + alert(resp.resultMessage) + } + } + }) + } + + const idFindModal = useCallback( + ()=> { + setModalTitle("아이디 찾기") + setModalBody(IdFindForm) + handleShow(); + } + ) + const pwFindModal = () => { + setModalTitle("비밀번호 찾기") + setModalBody(PwFindForm) + handleShow(); + } + + + return ( + <> + {sessionUser != null ? ( +
+ + 최근검색어 + 전체삭제 + +
+
+ {/*
최근 검색한 내용이 없습니다.
*/} +
검색어
+
검색어
+
검색어검색어검색어검색어검색어검색어검색어검색어
+
검색어
+
검색어
+
검색어
+
+
+
+
+ + Q&A 접수현황 + 0 개 + +
+
+ + 즐겨찾기 + 바로가기 > + +
+
+
+ ) : ( + <> +
+ 로그인 +
+ + setUserInfo({ ...userInfo, username: e.target.value })} /> +
+
+ + setUserInfo({ ...userInfo, password: e.target.value })} /> +
+ + + + + + 아이디 찾기 + | + 비밀번호 찾기 + + + +
+
+ 회원가입 +
+ + + + {modalTitle} + + {modalBody} + + + )} + + ); +} + +export default EgovLoginContent; \ No newline at end of file diff --git a/egovframe-template-simple-react-contribution/src/pages/main/EgovMain.jsx b/egovframe-template-simple-react-contribution/src/pages/main/EgovMain.jsx index 5152813..a0bdaa2 100644 --- a/egovframe-template-simple-react-contribution/src/pages/main/EgovMain.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/main/EgovMain.jsx @@ -1,5 +1,5 @@ -import React, { useState, useEffect, useCallback } from 'react'; -import { Link, useLocation } from 'react-router-dom'; +import React, {useState, useEffect, useCallback, useRef} from 'react'; +import { Link, useLocation, useNavigate } from 'react-router-dom'; import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; import Button from 'react-bootstrap/Button'; @@ -14,6 +14,18 @@ import "slick-carousel/slick/slick-theme.css"; import * as EgovNet from 'api/egovFetch'; import URL from 'constants/url'; +import EgovLogin from "../main/EgovLogin"; +import {parseJwt} from "../../utils/parseJwt"; +import {getLocalItem, setLocalItem} from "utils/storage"; +import CODE from "../../constants/code"; + + +function a11yProps(index) { + return { + id: `wrapped-tab-${index}`, + 'aria-controls': `wrapped-tabpanel-${index}`, + }; +} function EgovMain(props) { console.group("EgovMain"); @@ -21,8 +33,26 @@ function EgovMain(props) { console.log("EgovMain [props] : ", props); const location = useLocation(); + const navigate = useNavigate(); console.log("EgovMain [location] : ", location); + const [user, setUser] = useState(parseJwt(getLocalItem('accessToken')) || null); + console.log(user); + + const handlePlusClick = () => { + const urls = [ + URL.SUPPORT_LIST_NOCODE+'/KCSC-NTC', + URL.COMMITTEE_PROGRESS, + URL.SUPPORT_LIST_NOCODE+'/KCSC-NOT', + URL.SUPPORT_RESEARCH, + URL.SUPPORT_LIST_NOCODE+'/KCSC-TEC', + URL.SUPPORT_LIST_NOCODE+'/KCSC-NWS' + ]; + if (value >= 0 && value < urls.length) { + navigate(urls[value]); + } + }; + const settings = { dots: false, infinite: true, @@ -55,7 +85,6 @@ function EgovMain(props) { // 필요한 만큼 배너 이미지를 추가합니다. ]; - // TAB 상태를 정의합니다. const [value, setValue] = useState(0); const handleChange = (event, newValue) => { @@ -63,87 +92,124 @@ function EgovMain(props) { }; // eslint-disable-next-line no-unused-vars - const [noticeBoard, setNoticeBoard] = useState(); - // eslint-disable-next-line no-unused-vars - const [gallaryBoard, setGallaryBoard] = useState(); - const [noticeListTag, setNoticeListTag] = useState(); - const [gallaryListTag, setGallaryListTag] = useState(); + // const [noticeBoard, setNoticeBoard] = useState(); + // // eslint-disable-next-line no-unused-vars + // const [gallaryBoard, setGallaryBoard] = useState(); + // const [noticeListTag, setNoticeListTag] = useState(); + // const [gallaryListTag, setGallaryListTag] = useState(); + // + // const retrieveList = useCallback(() => { + // console.groupCollapsed("EgovMain.retrieveList()"); + // + // + // const retrieveListURL = '/'; + // const requestOptions = { + // method: "POST", + // + // headers: { + // 'Content-type': 'application/json' + // }, + // body: JSON.stringify() + // } + // + // EgovNet.requestFetch(retrieveListURL, + // requestOptions, + // (resp) => { + // + // setNoticeBoard(resp.result.notiList); + // setGallaryBoard(resp.result.galList); + // + // let mutNotiListTag = []; + // mutNotiListTag.push(
  • 검색된 결과가 없습니다.
  • ); // 게시판 목록 초기값 + // + // // 리스트 항목 구성 + // resp.result.notiList.forEach(function (item, index) { + // if (index === 0) mutNotiListTag = []; // 목록 초기화 + // mutNotiListTag.push( + //
  • + // + // {item.nttSj} + // {item.frstRegisterPnttm} + // + //
  • + // ); + // }); + // setNoticeListTag(mutNotiListTag); + // + // let mutGallaryListTag = []; + // mutGallaryListTag.push(
  • 검색된 결과가 없습니다.
  • ); // 게시판 목록 초기값 + // + // // 리스트 항목 구성 + // resp.result.galList.forEach(function (item, index) { + // if (index === 0) mutGallaryListTag = []; // 목록 초기화 + // mutGallaryListTag.push( + //
  • + // + // {item.nttSj} + // {item.frstRegisterPnttm} + // + //
  • + // ); + // }); + // setGallaryListTag(mutGallaryListTag); + // }, + // function (resp) { + // console.log("err response : ", resp); + // } + // ); + // console.groupEnd("EgovMain.retrieveList()"); + // },[]); + // + // useEffect(() => { + // retrieveList(); + // }, [retrieveList]); - const retrieveList = useCallback(() => { - console.groupCollapsed("EgovMain.retrieveList()"); - const retrieveListURL = '/'; + const onChangeLogin = (user) => { + setUser(user); + // props.onChangeLogin(user); + } + + const logOutHandler = () => {// 로그인 정보 존재할 때 + const logOutUrl = '/auth/logout'; const requestOptions = { - method: "POST", headers: { - 'Content-type': 'application/json' + 'Content-type': 'application/json', }, - body: JSON.stringify() + credentials: 'include', } - - EgovNet.requestFetch(retrieveListURL, - requestOptions, - (resp) => { - - setNoticeBoard(resp.result.notiList); - setGallaryBoard(resp.result.galList); - - let mutNotiListTag = []; - mutNotiListTag.push(
  • 검색된 결과가 없습니다.
  • ); // 게시판 목록 초기값 - - // 리스트 항목 구성 - resp.result.notiList.forEach(function (item, index) { - if (index === 0) mutNotiListTag = []; // 목록 초기화 - mutNotiListTag.push( -
  • - - {item.nttSj} - {item.frstRegisterPnttm} - -
  • - ); - }); - setNoticeListTag(mutNotiListTag); - - let mutGallaryListTag = []; - mutGallaryListTag.push(
  • 검색된 결과가 없습니다.
  • ); // 게시판 목록 초기값 - - // 리스트 항목 구성 - resp.result.galList.forEach(function (item, index) { - if (index === 0) mutGallaryListTag = []; // 목록 초기화 - mutGallaryListTag.push( -
  • - - {item.nttSj} - {item.frstRegisterPnttm} - -
  • - ); - }); - setGallaryListTag(mutGallaryListTag); - }, + EgovNet.requestFetch(logOutUrl, requestOptions, function (resp) { - console.log("err response : ", resp); + console.log("===>>> logout resp= ", resp); + if (parseInt(resp.resultCode) === parseInt(CODE.RCV_SUCCESS)) { + onChangeLogin({ loginVO: {} }); + setLocalItem('loginUser', {"id":""}); + setLocalItem('accessToken', null); + setLocalItem('refreshToken', null); + window.alert("로그아웃되었습니다!"); + + // PC와 Mobile 열린메뉴 닫기: 2023.04.13(목) 김일국 추가 + document.querySelector('.all_menu.WEB').classList.add('closed'); + document.querySelector('.btnAllMenu').classList.remove('active'); + document.querySelector('.btnAllMenu').title = '전체메뉴 닫힘'; + document.querySelector('.all_menu.Mobile').classList.add('closed'); + onChangeLogin(null); + } } ); - console.groupEnd("EgovMain.retrieveList()"); - },[]); - - useEffect(() => { - retrieveList(); - }, [retrieveList]); + } console.log("------------------------------EgovMain [End]"); console.groupEnd("EgovMain"); @@ -152,9 +218,75 @@ function EgovMain(props) {
    {/* container */}
    -
    -
    -
    +
    +
    실시간 인기키워드
    +
    현재 기준 사용자가 가장 많이 검색하는 키워드입니다.
    +
    2024년 5월 9일 목요일 오전 11:45
    + + +
    1 가설공사
    +
    2 가설공사
    +
    3 가설공사
    +
    4 가설공사가설공사
    +
    5 가설공사
    + + +
      6 가설공사
    +
      7 가설공사가설공사가설공사가설공사
    +
      8 가설공사
    +
      9 가설공사
    +
    10 가설공사
    + +
    +
    +
    +
    자주찾는 서비스
    +
    버튼을 선택하시면 해당 서비스로 이동합니다.
    + + + +
    +
    코드검색
    +
    + + + + +
    +
    코드안내
    +
    + + + + +
    +
    위원회일정
    +
    + + + + +
    +
    전문시방서
    +
    + + +
    +
    +
    +
    {user ? ( + <> + + {user.id} 님. + + + + ) : ('로그인')} +
    +
    + +
    +
    훈령/예규/지침
    @@ -189,14 +321,16 @@ function EgovMain(props) { - - - - - - + + + + + + + Item 0 @@ -206,7 +340,7 @@ function EgovMain(props) { Item 4 Item 5
    -
    2
    +