diff --git a/src/pages/surveys/index.tsx b/src/pages/surveys/index.tsx index bf8254e8..271832e0 100644 --- a/src/pages/surveys/index.tsx +++ b/src/pages/surveys/index.tsx @@ -1,5 +1,4 @@ -import { Timestamp } from 'firebase/firestore'; - +import { DocumentData, Timestamp } from 'firebase/firestore'; import Image from 'next/image'; import Head from 'next/head'; import { formatDateDistance } from 'shared/utilities/convertTime'; @@ -11,11 +10,14 @@ import SurveyRow from 'features/surveys/components/SurveyRow/SurveyRow'; import { useSurveyListManager } from 'features/surveys/managers/surveyListManager'; import NoSurveys from '../../../public/images/no-surveys.svg'; import Link from 'next/link'; -import { ButtonVariant } from 'shared/components/Button/Button'; +import Button, { ButtonVariant } from 'shared/components/Button/Button'; import ButtonLink from 'shared/components/ButtonLink/ButtonLink'; +import usePagination from 'features/surveys/hooks/usePagination'; +import { ArrowLeftIcon, ArrowRightIcon} from '@heroicons/react/outline'; function SurveyListPage() { const { error, loading, surveysCollection } = useSurveyListManager(); + const { items, canGoNext, canGoPrev, goNext, goPrev, pageIndex } = usePagination(surveysCollection?.docs ?? [], { size: 10 }); return ( <> @@ -34,8 +36,8 @@ function SurveyListPage() { {loading && } {surveysCollection && - (surveysCollection.docs?.length > 0 ? ( - surveysCollection.docs.map((doc) => { + (items?.length > 0 ? ( + items.map((doc) => { const survey = doc.data(); return ( ))} + {(canGoNext || canGoPrev) && ( +
+
+
+
+ )} ); }