첫 커밋

This commit is contained in:
focp212@naver.com
2025-09-05 15:36:48 +09:00
commit 05238b04c1
825 changed files with 176358 additions and 0 deletions

View File

@@ -0,0 +1,187 @@
import moment from 'moment';
import { useEffect, useState } from 'react';
import { IMAGE_ROOT } from '@/shared/constants/common';
import { PATHS } from '@/shared/constants/paths';
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
import { BillingList } from '@/entities/transaction/ui/billing-list';
import { ListItem, PageType, SortByKeys } from '@/entities/transaction/model/types';
import { useBillingListMutation } from '@/entities/transaction/api/use-billing-list-mutation';
import { useDownloadExcelMutation } from '@/entities/transaction/api/use-download-excel-mutation';
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constants';
import { Filter } from '@/entities/transaction/ui/filter';
import { SortOptionsBox } from '@/entities/transaction/ui/sort-options-box';
import { HeaderType } from '@/entities/common/model/types';
import {
useSetOnBack,
useSetHeaderTitle,
useSetHeaderType,
useSetFooterMode
} from '@/widgets/sub-layout/use-sub-layout';
const serviceCodes = [
{name: '전체', key: 'all'},
{name: '진행중', key: 'process'},
{name: '성공', key: 'success'},
{name: '요청취소', key: 'cancel'}
];
export const BillingListPage = () => {
const { navigate } = useNavigate();
const [selectedServiceCode, setSelectedServiceCode] = useState<string>('all');
const [sortBy, setSortBy] = useState<SortByKeys>(SortByKeys.New);
const [listItems, setListItems] = useState({});
const [filterOn, setFilterOn] = useState<boolean>(false);
const [pageParam, setPageParam] = useState(DEFAULT_PAGE_PARAM);
const [fromDate, setFromDate] = useState(moment().subtract(1, 'month').format('YYYYMMDD'));
const [toDate, setToDate] = useState(moment().format('YYYYMMDD'));
useSetHeaderTitle('빌링');
useSetHeaderType(HeaderType.LeftArrow);
useSetOnBack(() => {
navigate(PATHS.home);
});
useSetFooterMode(true);
const { mutateAsync: billingList } = useBillingListMutation();
const { mutateAsync: downloadExcel } = useDownloadExcelMutation();
const callList = (option?: {
sortBy?: string,
val?: string
}) => {
let listSummaryParams = {
moid: 'string',
tid: 'string',
fromDate: fromDate,
toDate: toDate,
stateCode: '0',
serviceCode: (option?.val)? option.val: selectedServiceCode,
minAmount: 0,
maxAmount: 0,
dateCl: 'TRANS',
goodsName: 'string',
cardCode: 'st',
bankCode: 'str',
searchCl: 'CARD_NO',
searchValue: 'string',
};
pageParam.sortBy = (option?.sortBy)? option.sortBy: sortBy;
setPageParam(pageParam);
let listParam = {
...listSummaryParams,
...{page: pageParam}
};
billingList(listParam).then((rs) => {
setListItems(assembleData(rs.content));
});
}
const assembleData = (content: Array<ListItem>) => {
let data: any = {};
if(content && content.length > 0){
for(let i=0;i<content?.length;i++){
let stateDate = content[i]?.stateDate;
let groupDate = stateDate?.substring(0, 8);
if(!!groupDate && !data.hasOwnProperty(groupDate)){
data[groupDate] = [];
}
if(!!groupDate && data.hasOwnProperty(groupDate)){
data[groupDate].push(content[i]);
}
}
}
return data;
};
const onClickToOpenFilter = () => {
setFilterOn(!filterOn);
};
const onClickToDownloadExcel = () => {
// tid??? 확인 필요
downloadExcel({
// tid: tid
}).then((rs) => {
});
};
const onCliCkToSort = (sort: SortByKeys) => {
setSortBy(sort);
callList({sortBy: sort});
};
const onClickToServiceCode = (val: string) => {
setSelectedServiceCode(val);
callList({val: val});
};
useEffect(() => {
callList();
}, []);
return (
<>
<main>
<div className="tab-content">
<div className="tab-pane sub active" id="tab1">
<div className="summary-section">
<div className="credit-controls">
<div>
<input
type="text"
className="credit-period"
value={ moment(fromDate).format('YYYY.MM.DD') + '-' + moment(toDate).format('YYYY.MM.DD') }
readOnly={ true }
/>
<button className="filter-btn">
<img
src={ IMAGE_ROOT + '/ico_setting.svg' }
alt="검색옵션"
onClick={ () => onClickToOpenFilter() }
/>
</button>
</div>
<button className="download-btn">
<img
src={ IMAGE_ROOT + '/ico_download.svg' }
alt="다운로드"
onClick={ () => onClickToDownloadExcel() }
/>
</button>
</div>
</div>
<div className="filter-section">
<SortOptionsBox
sortBy={ sortBy }
onCliCkToSort={ onCliCkToSort }
></SortOptionsBox>
<div className="excrow">
<div className="full-menu-keywords no-padding">
{
serviceCodes.map((value, index) => (
<span
key={ `key-service-code=${ index }` }
className={ `keyword-tag ${(selectedServiceCode === value.key)? 'active': ''}` }
onClick={ () => onClickToServiceCode(value.key) }
>{ value.name }</span>
))
}
</div>
</div>
</div>
<BillingList
listItems={ listItems }
pageType={ PageType.Billing }
></BillingList>
</div>
</div>
</main>
<Filter
filterOn={ filterOn }
setFilterOn={ setFilterOn }
></Filter>
</>
);
};