페이징 처리 조건 수정
This commit is contained in:
@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from '@/shared/lib/hooks';
|
||||
import useIntersectionObserver from '@/widgets/intersection-observer';
|
||||
import { useStore } from '@/shared/model/store';
|
||||
import { DefaultRequestPagination } from '@/entities/common/model/types';
|
||||
|
||||
export interface AlarmListProps {
|
||||
category: string;
|
||||
@@ -21,8 +22,7 @@ export const AlarmList = ({
|
||||
const userInfo = useStore.getState().UserStore.userInfo;
|
||||
|
||||
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 [appCl, setAppCl] = useState<MERCHANT_ADMIN_APP>(MERCHANT_ADMIN_APP.MERCHANT_ADMIN_APP)
|
||||
const [appNotificationCategory, setAppNotificationCategory] = useState<string>('');
|
||||
const [resultList, setResultList] = useState<Array<AlarmListContent>>([]);
|
||||
@@ -50,7 +50,7 @@ export const AlarmList = ({
|
||||
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');
|
||||
}
|
||||
}
|
||||
@@ -71,21 +71,11 @@ export const AlarmList = ({
|
||||
usrid: userInfo.usrid,
|
||||
appCl: appCl,
|
||||
appNotificationCategory: appNotificationCategory,
|
||||
...{
|
||||
page: pageParam
|
||||
}
|
||||
page: pageParam
|
||||
}
|
||||
|
||||
if(type === 'page'){
|
||||
if(params.page){
|
||||
params.page.cursor = nextCursor;
|
||||
}
|
||||
}
|
||||
else{
|
||||
setNextCursor(null);
|
||||
if(params.page){
|
||||
params.page.cursor = null;
|
||||
}
|
||||
if(type !== 'page' && params.page){
|
||||
params.page.cursor = null;
|
||||
}
|
||||
|
||||
appAlarmList(params).then((rs: AppAlarmListResponse) => {
|
||||
@@ -99,13 +89,24 @@ export const AlarmList = ({
|
||||
else{
|
||||
setResultList(rs.content);
|
||||
}
|
||||
if(rs.hasNext){
|
||||
setNextCursor(rs.nextCursor);
|
||||
setOnActionIntersect(true);
|
||||
if(rs.hasNext
|
||||
&& rs.content.length === DEFAULT_PAGE_PARAM.size
|
||||
){
|
||||
setPageParam({
|
||||
...pageParam,
|
||||
...{ cursor: rs.nextCursor }
|
||||
});
|
||||
}
|
||||
else{
|
||||
setNextCursor(null);
|
||||
setPageParam({
|
||||
...pageParam,
|
||||
...{ cursor: null }
|
||||
});
|
||||
}
|
||||
setOnActionIntersect(
|
||||
!!rs.hasNext
|
||||
&& rs.content.length === DEFAULT_PAGE_PARAM.size
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user