페이징 구조 수정

This commit is contained in:
focp212@naver.com
2025-10-24 15:45:43 +09:00
parent f95ace06c1
commit 3a9c480f7a
4 changed files with 132 additions and 83 deletions

View File

@@ -6,7 +6,7 @@ import { useNoticeListMutation } from '@/entities/support/api/use-notice-list-mu
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
import { InformCl, NoticeItem, NoticeListParams, NoticeListResponse, SearchCl } from '@/entities/support/model/types';
import { SupportNoticeItem } from '@/entities/support/ui/notice-item';
import { HeaderType } from '@/entities/common/model/types';
import { DefaultRequestPagination, HeaderType } from '@/entities/common/model/types';
import {
useSetHeaderTitle,
useSetHeaderType,
@@ -20,8 +20,7 @@ export const NoticeListPage = () => {
const { t } = useTranslation();
const [onActionIntersect, setOnActionIntersect] = 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 [informCl, setInformCl] = useState<InformCl | string>('');
const [searchKeyword, setSearchKeyword] = useState<string>('');
const [resultList, setResultList] = useState<Array<NoticeItem>>([]);
@@ -39,7 +38,7 @@ export const NoticeListPage = () => {
entries.forEach((entry: IntersectionObserverEntry) => {
if(entry.isIntersecting){
console.log('Element is now intersecting with the root. [' + onActionIntersect + ']');
if(onActionIntersect && !!nextCursor){
if(onActionIntersect && !!pageParam.cursor){
callList('page');
}
}
@@ -63,16 +62,8 @@ export const NoticeListPage = () => {
page: pageParam
}
};
if(type === 'page'){
if(listParams.page){
listParams.page.cursor = nextCursor;
}
}
else{
setNextCursor(null);
if(listParams.page){
listParams.page.cursor = null;
}
if(type !== 'page' && listParams.page){
listParams.page.cursor = null;
}
noticeList(listParams).then((rs: NoticeListResponse) => {
@@ -86,11 +77,17 @@ export const NoticeListPage = () => {
setResultList(rs.content);
}
if(rs.hasNext){
setNextCursor(rs.nextCursor);
setPageParam({
...pageParam,
...{ cursor: rs.nextCursor }
});
setOnActionIntersect(true);
}
else{
setNextCursor(null);
setPageParam({
...pageParam,
...{ cursor: rs.nextCursor }
});
}
});
};
@@ -121,7 +118,6 @@ export const NoticeListPage = () => {
};
useEffect(() => {
setNextCursor(null);
callList();
}, [informCl]);