diff --git a/packages/app/app/[organization]/videos/components/ArchiveVideos.tsx b/packages/app/app/[organization]/videos/components/ArchiveVideos.tsx
index 4e1a52483..938dc10c9 100644
--- a/packages/app/app/[organization]/videos/components/ArchiveVideos.tsx
+++ b/packages/app/app/[organization]/videos/components/ArchiveVideos.tsx
@@ -65,12 +65,12 @@ const ArchiveVideos = ({
return (
<>
- {isLoading ? (
-
- ) : (
-
- )}
-
+
+
>
);
};
diff --git a/packages/app/app/[organization]/videos/components/pagination.tsx b/packages/app/app/[organization]/videos/components/pagination.tsx
index c53f683e8..21c75d32e 100644
--- a/packages/app/app/[organization]/videos/components/pagination.tsx
+++ b/packages/app/app/[organization]/videos/components/pagination.tsx
@@ -1,29 +1,26 @@
'use client';
import { IPagination } from '@/lib/types';
import useSearchParams from '@/lib/hooks/useSearchParams';
-import { Input } from '@/components/ui/input';
-import { Button } from '@/components/ui/button';
import React, { useState } from 'react';
-import { LuArrowLeft, LuArrowRight } from 'react-icons/lu';
import { useEffect } from 'react';
-const Pagination = (props: IPagination) => {
- const [jumpPage, setJumpPage] = useState(props.currentPage);
+const Pagination = ({
+ pagination,
+ setPagination,
+ isLoading,
+}: {
+ pagination: IPagination;
+ setPagination: (pagination: IPagination) => void;
+ isLoading: boolean;
+}) => {
+ const [jumpPage, setJumpPage] = useState(pagination.currentPage);
const { handleTermChange, searchParams } = useSearchParams();
const currentPage = Number(searchParams.get('page')) || 1;
// trigger when reaching bottom of the page
useEffect(() => {
- console.log(
- window.innerHeight,
- document.documentElement.scrollTop,
- document.documentElement.offsetHeight
- );
const handleScroll = () => {
- console.log(
- window.innerHeight + document.documentElement.scrollTop,
- document.documentElement.offsetHeight
- );
+ if (isLoading) return;
if (
window.innerHeight + document.documentElement.scrollTop + 1 <
@@ -31,89 +28,24 @@ const Pagination = (props: IPagination) => {
) {
return;
}
- if (currentPage < props.totalPages) {
- handleTermChange([
- {
- key: 'page',
- value: (currentPage + 1).toString(),
- },
- ]);
+ if (currentPage < pagination.totalPages) {
+ setPagination({
+ currentPage: currentPage + 1,
+ totalPages: pagination.totalPages,
+ totalItems: pagination.totalItems,
+ limit: pagination.limit,
+ });
}
};
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
- }, [currentPage, props.totalPages, handleTermChange]);
+ }, [currentPage, pagination.totalPages, handleTermChange]);
+
+ if (isLoading) {
+ return
Loading...
;
+ }
- return (
-
-
-
Jump to
-
setJumpPage(Number(e.target.value))}
- value={jumpPage}
- className="w-14 text-center"
- />
-
-
-
-
-
- {currentPage} of {props.totalPages}
-
-
-
-
- );
+ return null;
};
export default Pagination;