From 18d278465d539ebb2ad826b9485e1cb2dbc46870 Mon Sep 17 00:00:00 2001 From: "focp212@naver.com" Date: Fri, 17 Oct 2025 17:52:36 +0900 Subject: [PATCH] faq --- src/pages/support/faq/list-page.tsx | 53 ++++++++++++++++++++++++----- src/pages/support/qna/list-page.tsx | 9 ++--- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/pages/support/faq/list-page.tsx b/src/pages/support/faq/list-page.tsx index 53ea630..1f4326f 100644 --- a/src/pages/support/faq/list-page.tsx +++ b/src/pages/support/faq/list-page.tsx @@ -2,10 +2,10 @@ import { ChangeEvent, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { PATHS } from '@/shared/constants/paths'; import { useNavigate } from '@/shared/lib/hooks/use-navigate'; -import { HeaderType } from '@/entities/common/model/types'; +import { DefaultRequestPagination, HeaderType } from '@/entities/common/model/types'; import { useFaqListMutation } from '@/entities/support/api/use-faq-list-mutation'; import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant'; -import { FaqItem } from '@/entities/support/model/types'; +import { FaqItem, FaqListParams, FaqListResponse } from '@/entities/support/model/types'; import { SupportFaqItem } from '@/entities/support/ui/faq-item'; import { useSetHeaderTitle, @@ -13,12 +13,34 @@ import { useSetFooterMode, useSetOnBack } from '@/widgets/sub-layout/use-sub-layout'; +import useIntersectionObserver from '@/widgets/intersection-observer'; export const FaqListPage = () => { const { navigate } = useNavigate(); const { t } = useTranslation(); - const [pageParam, setPageParam] = useState(DEFAULT_PAGE_PARAM); + const [onActionIntersect, setOnActionIntersect] = useState(false); + const onIntersect: IntersectionObserverCallback = (entries: Array) => { + 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 [pageParam, setPageParam] = useState(DEFAULT_PAGE_PARAM); + const [nextCursor, setNextCursor] = useState(null); const [searchCl, setSearchCl] = useState('HEAD'); const [searchValue, setSearchValue] = useState(''); const [selectedCategory, setSelectedCategory] = useState(''); @@ -33,16 +55,30 @@ export const FaqListPage = () => { const { mutateAsync: faqList } = useFaqListMutation(); const callList = () => { - let listParams = { + setOnActionIntersect(false); + let listParams: FaqListParams = { category: selectedCategory, searchCl: (!!searchValue)? searchCl: null, searchValue: searchValue, ...{page: pageParam} }; - faqList(listParams).then((rs) => { - console.log(rs) - setResultList(rs.content); + faqList(listParams).then((rs: FaqListResponse) => { + setResultList([ + ...resultList, + ...rs.content + ]); + if(rs.hasNext){ + setNextCursor(rs.nextCursor); + setPageParam({ + ...pageParam, + cursor: rs.nextCursor + }); + setOnActionIntersect(true); + } + else{ + setNextCursor(null); + } }); }; @@ -125,7 +161,8 @@ export const FaqListPage = () => {
- { getFaqList() } + { getFaqList() } +
diff --git a/src/pages/support/qna/list-page.tsx b/src/pages/support/qna/list-page.tsx index 7e66dd1..0995c39 100644 --- a/src/pages/support/qna/list-page.tsx +++ b/src/pages/support/qna/list-page.tsx @@ -18,10 +18,9 @@ import useIntersectionObserver from '@/widgets/intersection-observer'; export const QnaListPage = () => { const { navigate } = useNavigate(); - const [onActionIntersect, setOnActionIntersect] = useState(false); - - const onIntersect: IntersectionObserverCallback = (entries: Array) => { + const [onActionIntersect, setOnActionIntersect] = useState(false); + const onIntersect: IntersectionObserverCallback = (entries: Array) => { entries.forEach((entry: IntersectionObserverEntry) => { if(entry.isIntersecting){ console.log('Element is now intersecting with the root. [' + onActionIntersect + ']'); @@ -40,7 +39,6 @@ export const QnaListPage = () => { onIntersect }); - const midOptions = useStore.getState().UserStore.selectOptionsMids; const userMid = useStore.getState().UserStore.mid; const { t } = useTranslation(); @@ -50,7 +48,6 @@ export const QnaListPage = () => { const [nextCursor, setNextCursor] = useState(null); const [statusCode, setStatusCode] = useState(''); // 02, 03 const [resultList, setResultList] = useState>([]); - useSetHeaderTitle(t('support.qna.title')); useSetHeaderType(HeaderType.LeftArrow); @@ -108,7 +105,7 @@ export const QnaListPage = () => { contents={ resultList[i]?.contents } answer={ resultList[i]?.answer } > - ) + ); } return rs; };