페이징 구조 수정
This commit is contained in:
@@ -21,7 +21,6 @@ export const FaqListPage = () => {
|
||||
|
||||
const [onActionIntersect, setOnActionIntersect] = useState<boolean>(false);
|
||||
const [pageParam, setPageParam] = useState<DefaultRequestPagination>(DEFAULT_PAGE_PARAM);
|
||||
const [nextCursor, setNextCursor] = useState<string | null>(null);
|
||||
const [searchValue, setSearchValue] = useState<string>('');
|
||||
const [selectedCategory, setSelectedCategory] = useState<string>('');
|
||||
const [resultList, setResultList] = useState<Array<FaqItem>>([]);
|
||||
@@ -39,7 +38,7 @@ export const FaqListPage = () => {
|
||||
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');
|
||||
}
|
||||
}
|
||||
@@ -64,16 +63,8 @@ export const FaqListPage = () => {
|
||||
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;
|
||||
}
|
||||
|
||||
faqList(listParams).then((rs: FaqListResponse) => {
|
||||
@@ -87,11 +78,17 @@ export const FaqListPage = () => {
|
||||
setResultList(rs.content);
|
||||
}
|
||||
if(rs.hasNext){
|
||||
setNextCursor(rs.nextCursor);
|
||||
setPageParam({
|
||||
...pageParam,
|
||||
...{ cursor: rs.nextCursor }
|
||||
});
|
||||
setOnActionIntersect(true);
|
||||
}
|
||||
else{
|
||||
setNextCursor(null);
|
||||
setPageParam({
|
||||
...pageParam,
|
||||
...{ cursor: null }
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -127,7 +124,6 @@ export const FaqListPage = () => {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setNextCursor(null);
|
||||
callList();
|
||||
}, [selectedCategory]);
|
||||
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ export const QnaListPage = () => {
|
||||
const [onActionIntersect, setOnActionIntersect] = useState<boolean>(false);
|
||||
const [mid, setMid] = useState<string>(userMid);
|
||||
const [pageParam, setPageParam] = useState<DefaultRequestPagination>(DEFAULT_PAGE_PARAM);
|
||||
const [nextCursor, setNextCursor] = useState<string | null>(null);
|
||||
const [statusCode, setStatusCode] = useState<string>(''); // 02, 03
|
||||
const [resultList, setResultList] = useState<Array<QnaItem>>([]);
|
||||
|
||||
@@ -43,13 +42,10 @@ export const QnaListPage = () => {
|
||||
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');
|
||||
}
|
||||
}
|
||||
else{
|
||||
console.log('Element is no longer intersecting with the root.');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -67,13 +63,7 @@ export const QnaListPage = () => {
|
||||
page: pageParam
|
||||
}
|
||||
};
|
||||
if(type === 'page'){
|
||||
if(listParams.page){
|
||||
listParams.page.cursor = nextCursor;
|
||||
}
|
||||
}
|
||||
else{
|
||||
setNextCursor(null);
|
||||
if(type !== 'page'){
|
||||
if(listParams.page){
|
||||
listParams.page.cursor = null;
|
||||
}
|
||||
@@ -90,11 +80,17 @@ export const QnaListPage = () => {
|
||||
setResultList(rs.content);
|
||||
}
|
||||
if(rs.hasNext){
|
||||
setNextCursor(rs.nextCursor);
|
||||
setPageParam({
|
||||
...pageParam,
|
||||
...{ cursor: rs.nextCursor }
|
||||
});
|
||||
setOnActionIntersect(true);
|
||||
}
|
||||
else{
|
||||
setNextCursor(null);
|
||||
setPageParam({
|
||||
...pageParam,
|
||||
...{ cursor: null }
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -126,13 +122,8 @@ export const QnaListPage = () => {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setNextCursor(null);
|
||||
callList();
|
||||
}, [statusCode]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
}, [resultList]);
|
||||
}, [mid, statusCode]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -172,7 +163,7 @@ export const QnaListPage = () => {
|
||||
</div>
|
||||
<div className="inq-list" >
|
||||
{ getQnaList() }
|
||||
<div ref={setTarget}></div>
|
||||
<div ref={ setTarget }></div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="apply-row">
|
||||
|
||||
Reference in New Issue
Block a user