From ffdfad1223d9dfe7ed46905673edf7007f043073 Mon Sep 17 00:00:00 2001 From: bcjang Date: Wed, 26 Mar 2025 15:31:15 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=ED=99=94=20=ED=99=94=EB=A9=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/RouteInfo.js | 6 +- src/apis/Data.js | 32 +++ src/components/ServiceManage/index.js | 2 + .../searchBar/DataInitSearchBar.js | 132 +++++++++ src/i18n.js | 2 + src/pages/UserManage/DataInitView.js | 257 ++++++++++++++++++ src/pages/UserManage/index.js | 2 +- src/styles/Components.js | 70 +++++ 8 files changed, 499 insertions(+), 4 deletions(-) create mode 100644 src/apis/Data.js create mode 100644 src/components/ServiceManage/searchBar/DataInitSearchBar.js create mode 100644 src/pages/UserManage/DataInitView.js diff --git a/src/RouteInfo.js b/src/RouteInfo.js index 2b30051..3d6cf37 100644 --- a/src/RouteInfo.js +++ b/src/RouteInfo.js @@ -9,12 +9,11 @@ import { AdminView, AuthSetting, AuthSettingUpdate, - BusinessLogView, - CaliumRequest, + CaliumRequest, DataInitView, LogView, } from './pages/UserManage'; import { EconomicIndex, UserIndex } from './pages/IndexManage'; -import { LandInfoView, CryptView, GameLogView, UserView } from './pages/DataManage'; +import { LandInfoView, CryptView, GameLogView, UserView, BusinessLogView, } from './pages/DataManage'; import { Board, Event, @@ -50,6 +49,7 @@ const RouteInfo = () => { } /> } /> } /> + } /> } /> diff --git a/src/apis/Data.js b/src/apis/Data.js new file mode 100644 index 0000000..4a29024 --- /dev/null +++ b/src/apis/Data.js @@ -0,0 +1,32 @@ +//사용자 관리 - 데이터 api 연결 + +import { Axios } from '../utils'; + + +export const InitData = async (token, params) => { + try { + const res = await Axios.post('/api/v1/data/init-data', params, { + headers: { Authorization: `Bearer ${token}` }, + }); + + return res.data; + } catch (e) { + if (e instanceof Error) { + throw new Error('InitData Error', e); + } + } +}; + +export const InitHistoryList = async (token, params) => { + try { + const res = await Axios.post(`/api/v1/data/init-list`, params, { + headers: { Authorization: `Bearer ${token}` }, + }); + + return res.data; + } catch (e) { + if (e instanceof Error) { + throw new Error('InitHistoryList Error', e); + } + } +}; \ No newline at end of file diff --git a/src/components/ServiceManage/index.js b/src/components/ServiceManage/index.js index 08efd7b..6bfe6e4 100644 --- a/src/components/ServiceManage/index.js +++ b/src/components/ServiceManage/index.js @@ -16,6 +16,7 @@ import LandAuctionSearchBar from './searchBar/LandAuctionSearchBar' import MailListSearchBar from './searchBar/MailListSearchBar'; import LandInfoSearchBar from './searchBar/LandInfoSearchBar'; import BusinessLogSearchBar from './searchBar/BusinessLogSearchBar'; +import DataInitSearchBar from './searchBar/DataInitSearchBar'; //etc import ReportListSummary from './ReportListSummary'; import WhiteListSearchBar from './WhiteListRegistBar'; @@ -27,6 +28,7 @@ export { MailListSearchBar, LandInfoSearchBar, BusinessLogSearchBar, + DataInitSearchBar, ReportListAnswerModal, ReportListDetailModal, ReportListSearchBar, diff --git a/src/components/ServiceManage/searchBar/DataInitSearchBar.js b/src/components/ServiceManage/searchBar/DataInitSearchBar.js new file mode 100644 index 0000000..46869d8 --- /dev/null +++ b/src/components/ServiceManage/searchBar/DataInitSearchBar.js @@ -0,0 +1,132 @@ +import { BtnWrapper, InputLabel, TextInput } from '../../../styles/Components'; +import Button from '../../common/button/Button'; +import { SearchBarLayout, SearchPeriod } from '../../common/SearchBar'; +import { useCallback, useEffect, useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { InitHistoryList } from '../../../apis/Data'; + +export const useDataInitSearch = (token, setAlertMsg) => { + const { t } = useTranslation(); + + const [searchParams, setSearchParams] = useState({ + tran_id: '', + start_dt: (() => { + return new Date(); + })(), + end_dt: (() => { + return new Date(); + })(), + }); + + const [loading, setLoading] = useState(false); + const [data, setData] = useState(null); + + useEffect(() => { + const initialLoad = async () => { + await fetchData(searchParams); + }; + + initialLoad(); + }, [token]); + + const fetchData = useCallback(async (params) => { + if (!token) return; + + try { + setLoading(true); + const result = await InitHistoryList( + token, + params + ); + if(result.result === "ERROR_LOG_MEMORY_LIMIT"){ + setAlertMsg(t('LOG_MEMORY_LIMIT_WARNING')) + }else if(result.result === "ERROR_MONGODB_QUERY"){ + setAlertMsg(t('LOG_MONGGDB_QUERY_WARNING')) + } + setData(result.data); + return result.data; + } catch (error) { + console.error('Error fetching auction data:', error); + throw error; + } finally { + setLoading(false); + } + }, [token]); + + const updateSearchParams = useCallback((newParams) => { + setSearchParams(prev => ({ + ...prev, + ...newParams + })); + }, []); + + const handleSearch = useCallback(async (newParams = {}) => { + const updatedParams = { + ...searchParams, + ...newParams, + }; + updateSearchParams(updatedParams); + return await fetchData(updatedParams); + }, [searchParams, fetchData]); + + const handleReset = useCallback(async () => { + const now = new Date(); + const resetParams = { + tran_id: '', + start_dt: now, + end_dt: now, + }; + setSearchParams(resetParams); + return await fetchData(resetParams); + }, [fetchData]); + + return { + searchParams, + loading, + data, + handleSearch, + handleReset, + updateSearchParams + }; +}; + +const DataInitSearchBar = ({ searchParams, onSearch, onReset }) => { + const handleSubmit = event => { + event.preventDefault(); + + onSearch(searchParams); + }; + + const searchList = [ + <> + 트랜잭션 ID + onSearch({ tran_id: e.target.value })} + /> + , + <> + 일자 + onSearch({ start_dt: date }, false)} + endDate={searchParams.end_dt} + handleEndDate={date => onSearch({ end_dt: date }, false)} + /> + , + <>,<>,<>, + <> + +