- 자금이체 입금확인증 다운로드 API 추가

- 분리승인 누락 CSS 추가
- 알림톡 리스트 수정
This commit is contained in:
HyeonJongKim
2025-10-22 09:59:40 +09:00
parent ead259e91e
commit 1e7f13d5cc
6 changed files with 346 additions and 54 deletions

View File

@@ -1,20 +1,20 @@
import { PATHS } from '@/shared/constants/paths';
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
import { HeaderType, SortTypeKeys } from '@/entities/common/model/types';
import { DefaultRequestPagination, HeaderType, SortTypeKeys } from '@/entities/common/model/types';
import { IMAGE_ROOT } from '@/shared/constants/common';
import {
import {
useSetHeaderTitle,
useSetHeaderType,
useSetFooterMode,
useSetOnBack
} from '@/widgets/sub-layout/use-sub-layout';
import { useEffect, useState } from 'react';
import { JSX, useEffect, useState } from 'react';
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
import {
import {
AlimtalkAlimCl,
AlimtalkListContent,
AlimtalkSearchCl,
AlimTalkSendCl,
AlimtalkListContent,
AlimtalkSearchCl,
AlimTalkSendCl,
AlimtalkSendType,
ExtensionAlimtalkDownloadExcelParams,
ExtensionAlimtalkDownloadExcelResponse,
@@ -27,15 +27,37 @@ import { useExtensionAlimtalkDownloadExcelMutation } from '@/entities/additional
import { ListDateGroup } from '@/entities/additional-service/ui/list-date-group';
import { AdditionalServiceCategory } from '@/entities/additional-service/model/types';
import { useStore } from '@/shared/model/store';
import useIntersectionObserver from '@/widgets/intersection-observer';
export const AlimtalkListPage = () => {
const { navigate } = useNavigate();
const userMid = useStore.getState().UserStore.mid;
const [onActionIntersect, setOnActionIntersect] = useState<boolean>(false);
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
entries.forEach((entry: IntersectionObserverEntry) => {
if (entry.isIntersecting) {
console.log('Element is now intersecting with the root. [' + onActionIntersect + ']');
if (onActionIntersect) {
callList();
}
}
else {
console.log('Element is no longer intersecting with the root.');
}
});
};
const { setTarget } = useIntersectionObserver({
threshold: 1,
onIntersect
});
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
const [listItems, setListItems] = useState<Record<string, Array<AlimtalkListContent>>>({});
const [listItems, setListItems] = useState<Array<AlimtalkListContent>>([]);
const [filterOn, setFilterOn] = useState<boolean>(false);
const [pageParam, setPageParam] = useState(DEFAULT_PAGE_PARAM);
const [nextCursor, setNextCursor] = useState<string | null>(null);
const [pageParam, setPageParam] = useState<DefaultRequestPagination>(DEFAULT_PAGE_PARAM);
const [mid, setMid] = useState<string>(userMid);
const [searchCl, setSearchCl] = useState<AlimtalkSearchCl>(AlimtalkSearchCl.BUYER_NAME);
const [searchValue, setSearchValue] = useState<string>();
@@ -45,7 +67,7 @@ export const AlimtalkListPage = () => {
const [toDate, setToDate] = useState<string>(moment().format('YYYYMMDD'));
const [sendType, setSendType] = useState<AlimtalkSendType>(AlimtalkSendType.ALL);
const [sendCl, setSendCl] = useState<AlimTalkSendCl>(AlimTalkSendCl.ALL);
const { mutateAsync: extensionAlimtalkList } = useExtensionAlimtalkListMutation();
const { mutateAsync: extensionAlimtalkDownloadExcel } = useExtensionAlimtalkDownloadExcelMutation();
@@ -57,25 +79,44 @@ export const AlimtalkListPage = () => {
});
const callList = (option?: {
sortType?: SortTypeKeys,
val?: string
sortType?: SortTypeKeys,
resetPage?: boolean
}) => {
pageParam.sortType = (option?.sortType)? option.sortType: sortType;
setPageParam(pageParam);
setOnActionIntersect(false);
const currentPageParam = option?.resetPage
? { ...DEFAULT_PAGE_PARAM, sortType: option?.sortType ?? sortType }
: { ...pageParam, sortType: option?.sortType ?? sortType };
setPageParam(currentPageParam);
let params: ExtensionAlimtalkListParams = {
mid: mid,
searchCl: searchCl,
searchValue: searchValue,
paymentMethod: paymentMethod,
serviceCode: paymentMethod,
fromDate: fromDate,
toDate: toDate,
sendType: sendType,
sendCl: sendCl,
page: pageParam
page: currentPageParam
};
extensionAlimtalkList(params).then((rs: ExtensionAlimtalkListResponse) => {
setListItems(assembleData(rs.content));
setListItems(option?.resetPage ? rs.content : [
...listItems,
...rs.content
]);
if (rs.hasNext) {
setNextCursor(rs.nextCursor);
setPageParam({
...currentPageParam,
cursor: rs.nextCursor
});
setOnActionIntersect(true);
}
else {
setNextCursor(null);
}
});
};
@@ -96,23 +137,6 @@ export const AlimtalkListPage = () => {
});
};
const assembleData = (content: Array<AlimtalkListContent>) => {
let data: any = {};
if(content && content.length > 0){
for(let i=0;i<content?.length;i++){
let date = content[i]?.sendDate?.substring(0, 8);
let groupDate = moment(date).format('YYYYMMDD');
if(!!groupDate && !data.hasOwnProperty(groupDate)){
data[groupDate] = [];
}
if(!!groupDate && data.hasOwnProperty(groupDate)){
data[groupDate].push(content[i]);
}
}
}
return data;
};
const onClickToNavigate = () => {
navigate(PATHS.additionalService.alimtalk.setting);
};
@@ -123,26 +147,61 @@ export const AlimtalkListPage = () => {
setFilterOn(!filterOn);
};
const getAlimtalkList = () => {
let rs = [];
if(Object.keys(listItems).length > 0){
for(const [key, value] of Object.entries(listItems)){
rs.push(
<ListDateGroup
additionalServiceCategory={ AdditionalServiceCategory.Alimtalk }
mid={ mid }
key={ key }
date={ key }
items={ value }
></ListDateGroup>
);
let rs: JSX.Element[] = [];
let date = '';
let list: AlimtalkListContent[] = [];
for (let i = 0; i < listItems.length; i++) {
// sendDate format: "20211018140420" (YYYYMMDDHHmmss)
let sendDate = listItems[i]?.sendDate || '';
let itemDate = sendDate.substring(0, 8);
if (i === 0) {
date = itemDate;
}
if (date !== itemDate) {
// 날짜가 바뀌면 이전 리스트를 푸시
if (list.length > 0) {
rs.push(
<ListDateGroup
additionalServiceCategory={AdditionalServiceCategory.Alimtalk}
mid={mid}
key={date + '-' + i}
date={date}
items={list as any}
></ListDateGroup>
);
}
date = itemDate;
list = [];
}
list.push(listItems[i] as any);
}
if (list.length > 0) {
rs.push(
<ListDateGroup
additionalServiceCategory={AdditionalServiceCategory.Alimtalk}
mid={mid}
key={date + '-last'}
date={date}
items={list as any}
></ListDateGroup>
);
}
return rs;
}
useEffect(() => {
callList();
}, []);
// 필터 조건이 변경되면 첫 페이지부터 다시 시작
callList({ resetPage: true });
}, [
mid,
searchCl,
searchValue,
paymentMethod,
fromDate,
toDate,
sendType,
sendCl
]);
return (
<>
@@ -184,6 +243,7 @@ export const AlimtalkListPage = () => {
<section className="transaction-list">
{ getAlimtalkList() }
<div ref={setTarget}></div>
</section>
</div>
</div>