ALIEZ 3 viikkoa sitten
vanhempi
commit
dfe6314abb

+ 4 - 3
src/app/[locale]/courses/[slug]/files-list-client.tsx

@@ -12,7 +12,7 @@ type Props = {
 };
 };
 
 
 export function CourseFilesListClient({ goodsId, allHref, allLabel }: Props) {
 export function CourseFilesListClient({ goodsId, allHref, allLabel }: Props) {
-  const pageSize = 10;
+  const pageSize = 9;
   const [page, setPage] = useState(1);
   const [page, setPage] = useState(1);
   const [files, setFiles] = useState<CourseFile[] | null>(null);
   const [files, setFiles] = useState<CourseFile[] | null>(null);
   const [total, setTotal] = useState(0);
   const [total, setTotal] = useState(0);
@@ -40,8 +40,9 @@ export function CourseFilesListClient({ goodsId, allHref, allLabel }: Props) {
   }, [goodsId, page]);
   }, [goodsId, page]);
 
 
   const loading = files === null;
   const loading = files === null;
+  const totalPages = Math.ceil(total / pageSize) || 1;
   const canPrev = page > 1 && !loading;
   const canPrev = page > 1 && !loading;
-  const canNext = !loading && page * pageSize < total;
+  const canNext = !loading && page < totalPages;
   const previewDurationMs = 220;
   const previewDurationMs = 220;
   const [iframeLoadFailed, setIframeLoadFailed] = useState(false);
   const [iframeLoadFailed, setIframeLoadFailed] = useState(false);
 
 
@@ -210,7 +211,7 @@ export function CourseFilesListClient({ goodsId, allHref, allLabel }: Props) {
           {t("videoPrevPage")}
           {t("videoPrevPage")}
         </button>
         </button>
         <span className="text-sm text-slate-500">
         <span className="text-sm text-slate-500">
-          {t("videoCurrentPage", { page })}
+          {t("videoPageOfTotal", { page, totalPages })}
         </span>
         </span>
         <button
         <button
           type="button"
           type="button"

+ 4 - 3
src/app/[locale]/courses/[slug]/videos-list-client.tsx

@@ -12,7 +12,7 @@ type Props = {
 };
 };
 
 
 export function CourseVideosListClient({ goodsId, allHref, allLabel }: Props) {
 export function CourseVideosListClient({ goodsId, allHref, allLabel }: Props) {
-  const pageSize = 10;
+  const pageSize = 9;
   const [page, setPage] = useState(1);
   const [page, setPage] = useState(1);
   const [videos, setVideos] = useState<CourseVideo[] | null>(null);
   const [videos, setVideos] = useState<CourseVideo[] | null>(null);
   const [total, setTotal] = useState(0);
   const [total, setTotal] = useState(0);
@@ -40,8 +40,9 @@ export function CourseVideosListClient({ goodsId, allHref, allLabel }: Props) {
   }, [goodsId, page]);
   }, [goodsId, page]);
 
 
   const loading = videos === null;
   const loading = videos === null;
+  const totalPages = Math.ceil(total / pageSize) || 1;
   const canPrev = page > 1 && !loading;
   const canPrev = page > 1 && !loading;
-  const canNext = !loading && page * pageSize < total;
+  const canNext = !loading && page < totalPages;
   const playUrl = activeVideo?.playUrl?.trim() ?? "";
   const playUrl = activeVideo?.playUrl?.trim() ?? "";
   const modalDurationMs = 220;
   const modalDurationMs = 220;
 
 
@@ -170,7 +171,7 @@ export function CourseVideosListClient({ goodsId, allHref, allLabel }: Props) {
           {t("videoPrevPage")}
           {t("videoPrevPage")}
         </button>
         </button>
         <span className="text-sm text-slate-500">
         <span className="text-sm text-slate-500">
-          {t("videoCurrentPage", { page })}
+          {t("videoPageOfTotal", { page, totalPages })}
         </span>
         </span>
         <button
         <button
           type="button"
           type="button"