Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 'use client'; import { API } from '@/api'; import { useInfiniteScroll } from '@/hooks/use-group/use-group-infinite-list'; import { useIntersectionObserver } from '@/hooks/use-intersection-observer'; import { GROUP_LIST_PAGE_SIZE, INTERSECTION_OBSERVER_THRESHOLD } from '@/lib/constants/group-list'; import { groupKeys } from '@/lib/query-key/query-key-group'; import { GroupListItemResponse } from '@/types/service/group'; import { ScheduleList } from '../../schedule-list/index'; export const Current = () => { const queryKey = groupKeys.myGroupsList('current') as ['myGroups', 'current']; const { items, error, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading, completedMessage, refetch, } = useInfiniteScroll<GroupListItemResponse, typeof queryKey>({ queryFn: async ({ cursor, size }) => { return await API.groupService.getMyGroups({ type: 'current', cursor, size, myStatuses: ['ATTEND', 'PENDING'], }); }, queryKey, pageSize: GROUP_LIST_PAGE_SIZE, errorMessage: '현재 모임 목록을 불러오는데 실패했습니다.', completedMessage: '모든 현재 모임을 불러왔습니다.', }); const sentinelRef = useIntersectionObserver({ onIntersect: () => { if (hasNextPage && !isFetchingNextPage) { fetchNextPage(); } }, enabled: hasNextPage && error === null, threshold: INTERSECTION_OBSERVER_THRESHOLD, }); return ( <ScheduleList refetch={refetch} completedMessage={completedMessage} emptyStatePath='/' emptyStateType='current' error={error} group={items} hasNextPage={hasNextPage} isFetchingNextPage={isFetchingNextPage} isLoading={isLoading} sentinelRef={sentinelRef} showActions={true} tabType='current' /> ); }; |