From 7041d4a6490331f2b74a11ca446b74671c8ca118 Mon Sep 17 00:00:00 2001 From: bcjang Date: Wed, 16 Jul 2025 18:39:30 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9C=A0=EC=A0=80=20=EC=A7=80=ED=91=9C=20?= =?UTF-8?q?=EC=9E=94=EC=A1=B4=EC=9C=A8=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/Indicators.js | 10 +- src/assets/data/options.js | 7 + .../IndexManage/RetentionContent.js | 152 ++++------ .../searchBar/CurrencyIndexSearchBar.js | 5 +- .../searchBar/RetentionSearchBar.js | 287 +++++++++--------- src/components/searchBar/index.js | 3 +- src/i18n.js | 1 + src/pages/DataManage/GameLogView.js | 19 -- src/pages/IndexManage/UserIndex.js | 57 ++-- src/utils/common.js | 20 ++ 10 files changed, 252 insertions(+), 309 deletions(-) diff --git a/src/apis/Indicators.js b/src/apis/Indicators.js index d61171b..27f24d3 100644 --- a/src/apis/Indicators.js +++ b/src/apis/Indicators.js @@ -62,10 +62,14 @@ export const userIndexExport = async (token, filename, sendDate, endDate) => { }; // Retention -export const RetentionIndexView = async (token, start_dt, end_dt) => { +export const RetentionIndexView = async (token, startDate, endDate, order, size, currentPage) => { try { - const res = await Axios.get(`/api/v1/indicators/retention/list?start_dt=${start_dt}&end_dt=${end_dt}`, { - headers: { Authorization: `Bearer ${token}` }, + const res = await Axios.get(`/api/v1/indicators/retention/list?start_dt=${startDate}&end_dt=${endDate} + &orderby=${order}&page_no=${currentPage}&page_size=${size}`, { + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json' + }, }); return res.data.data; diff --git a/src/assets/data/options.js b/src/assets/data/options.js index 2abdaa4..f36a676 100644 --- a/src/assets/data/options.js +++ b/src/assets/data/options.js @@ -19,6 +19,13 @@ export const TabEconomicIndexList = [ // { value: 'instance', name: '인스턴스' }, ]; +export const TabUserIndexList = [ + { value: 'USER', name: '이용자 지표' }, + { value: 'RETENTION', name: '잔존율' }, + // { value: 'SEGMENT', name: 'Segment' }, + // { value: 'PLAYTIME', name: '플레이타임' }, +]; + export const mailSendType = [ { value: 'ALL', name: '전체' }, { value: 'RESERVE_SEND', name: '예약 발송' }, diff --git a/src/components/IndexManage/RetentionContent.js b/src/components/IndexManage/RetentionContent.js index 1bb23ba..4711ead 100644 --- a/src/components/IndexManage/RetentionContent.js +++ b/src/components/IndexManage/RetentionContent.js @@ -1,108 +1,76 @@ -import { Fragment, useEffect, useState } from 'react'; - -import Button from '../../components/common/button/Button'; +import React, { Fragment, useRef } from 'react'; import { TableStyle, TableInfo, ListOption, IndexTableWrap } from '../../styles/Components'; -import { RetentionSearchBar } from '../../components/IndexManage/index'; -import { RetentionIndexExport, RetentionIndexView } from '../../apis'; +import { AnimatedPageWrapper } from '../common/Layout'; +import { useRetentionSearch, RetentionSearchBar } from '../searchBar'; +import { TableSkeleton } from '../Skeleton/TableSkeleton'; +import { numberFormatter } from '../../utils'; +import { ExcelDownButton } from '../common'; +import { useTranslation } from 'react-i18next'; const RetentionContent = () => { + const { t } = useTranslation(); + const tableRef = useRef(null); const token = sessionStorage.getItem('token'); - let d = new Date(); - const START_DATE = new Date(new Date(d.setDate(d.getDate() - 1)).setHours(0, 0, 0, 0)); - const END_DATE = new Date(new Date(d.setDate(d.getDate() - 1)).setHours(24, 0, 0, 0)); - const [dataList, setDataList] = useState([]); - const [resultData, setResultData] = useState([]); - const [retentionData, setRetention] = useState(1); + const { + searchParams, + loading: dataLoading, + data: dataList, + handleSearch, + handleReset, + updateSearchParams + } = useRetentionSearch(token); - const [sendDate, setSendDate] = useState(START_DATE); - const [finishDate, setFinishDate] = useState(END_DATE); - const [excelBtn, setExcelBtn] = useState(true); //true 시 비활성화 - - useEffect(() => { - fetchData(START_DATE, END_DATE); - }, []); - - // Retention 지표 데이터 - const fetchData = async (startDate, endDate) => { - const startDateToLocal = - startDate.getFullYear() + - '-' + - (startDate.getMonth() + 1 < 9 ? '0' + (startDate.getMonth() + 1) : startDate.getMonth() + 1) + - '-' + - (startDate.getDate() < 9 ? '0' + startDate.getDate() : startDate.getDate()); - - const endDateToLocal = - endDate.getFullYear() + - '-' + - (endDate.getMonth() + 1 < 9 ? '0' + (endDate.getMonth() + 1) : endDate.getMonth() + 1) + - '-' + - (endDate.getDate() < 9 ? '0' + endDate.getDate() : endDate.getDate()); - - setDataList(await RetentionIndexView(token, startDateToLocal, endDateToLocal)); - - console.log(dataList); - - setSendDate(startDateToLocal); - setFinishDate(endDateToLocal); - }; - - // 검색 함수 - const handleSearch = (send_dt, end_dt) => { - fetchData(send_dt, end_dt); - setRetention(resultData.retention); - }; - - // 엑셀 다운로드 - const handleXlsxExport = () => { - const fileName = 'Caliverse_Retention_Index.xlsx'; - - if(!excelBtn){ - RetentionIndexExport(token, fileName, sendDate, finishDate); - } - }; return ( - <> - + + { + if (executeSearch) { + handleSearch(newParams); + } else { + updateSearchParams(newParams); + } + }} + onReset={handleReset} + /> -