-
-
- props.onSearchInput?.(value)}
- />
-
- {props.filters}
-
+ // One wrapping row, ordered by width — the same shape as DataTable's
+ // toolbar. Phones: search and actions share the first line and the
+ // filters take the next one; nothing is squeezed into a fixed row, where
+ // the search box shrank to a sliver and a filter painted over its icon.
+ // From `sm`: search, filters, then actions pushed to the right edge.
+
+
+ props.onSearchInput?.(value)}
+ />
+
+
+ {props.filters}
+
- {props.actions}
+ {props.actions}
);
diff --git a/src/components/ui/pagination-controls.tsx b/src/components/ui/pagination-controls.tsx
deleted file mode 100644
index 720d975..0000000
--- a/src/components/ui/pagination-controls.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Button } from "@/components/ui/button";
-import { IconChevronLeft, IconChevronRight } from "@/components/ui/icons";
-import { useT } from "@/stores/preferences-context";
-
-export function PaginationControls(props: {
- page: number;
- totalPages: number;
- onPageChange: (page: number) => void;
-}) {
- const t = useT();
- return (
-
- props.onPageChange(Math.max(0, props.page - 1))}
- >
-
- {t("common.prev")}
-
-
- {t("common.pageOf", { page: props.page + 1, total: props.totalPages })}
-
- = props.totalPages - 1}
- onClick={() => props.onPageChange(Math.min(props.totalPages - 1, props.page + 1))}
- >
- {t("common.next")}
-
-
-
- );
-}
diff --git a/src/components/ui/table-pagination.tsx b/src/components/ui/table-pagination.tsx
index 5717174..a26dbd3 100644
--- a/src/components/ui/table-pagination.tsx
+++ b/src/components/ui/table-pagination.tsx
@@ -1,55 +1,78 @@
+import { Show } from "solid-js";
import { Button } from "@/components/ui/button";
import { IconChevronLeft, IconChevronRight } from "@/components/ui/icons";
+import { cn } from "@/lib/cn";
import { useT } from "@/stores/preferences-context";
export type TablePaginationProps = {
/** Zero-based current page index. */
pageIndex: number;
pageCount: number;
- pageSize: number;
+ /** With `total`, prints "a-b / total"; without either only the page counter shows. */
+ pageSize?: number;
/** Total row count (across all pages). */
- total: number;
+ total?: number;
onPageChange: (pageIndex: number) => void;
+ class?: string;
};
-/** Footer: "X kayıttan a-b arası" + prev/next + "page / total". */
+/**
+ * Footer: "a-b / total" + prev / "page / count" / next, on one row at every
+ * width. The buttons are full touch targets on phones and compact from `sm`
+ * up. A single page keeps the row count but drops the buttons — two disabled
+ * arrows around "1 / 1" only take room.
+ */
export function TablePagination(props: TablePaginationProps) {
const t = useT();
- const start = () => (props.total === 0 ? 0 : props.pageIndex * props.pageSize + 1);
- const end = () => Math.min((props.pageIndex + 1) * props.pageSize, props.total);
+ const hasRange = () => props.total != null && props.pageSize != null;
+ const start = () => (!props.total || !props.pageSize ? 0 : props.pageIndex * props.pageSize + 1);
+ const end = () => Math.min((props.pageIndex + 1) * (props.pageSize ?? 0), props.total ?? 0);
+ const navButton = "h-10 w-10 gap-1 px-0 text-xs sm:h-7 sm:w-auto sm:px-1.5 sm:text-[11px]";
return (
-
-
- {t("common.pageRange", { start: start(), end: end(), total: props.total })}
+ // Nothing to count and nowhere to go: an empty frame would only take room.
+ 1}>
+
+
+ {t("common.pageRange", { start: start(), end: end(), total: props.total ?? 0 })}
-
- props.onPageChange(Math.max(0, props.pageIndex - 1))}
- >
-
- {t("common.prev")}
-
-
- {t("common.pageOf", { page: props.pageIndex + 1, total: props.pageCount })}
-
- = props.pageCount - 1}
- onClick={() => props.onPageChange(Math.min(props.pageCount - 1, props.pageIndex + 1))}
- >
- {t("common.next")}
-
-
-
+
1}>
+
+ props.onPageChange(Math.max(0, props.pageIndex - 1))}
+ >
+
+ {t("common.prev")}
+
+
+ {t("common.pageOf", { page: props.pageIndex + 1, total: props.pageCount })}
+
+ = props.pageCount - 1}
+ onClick={() => props.onPageChange(Math.min(props.pageCount - 1, props.pageIndex + 1))}
+ >
+ {t("common.next")}
+
+
+
+
+
);
}
diff --git a/src/components/ui/table-row-actions.tsx b/src/components/ui/table-row-actions.tsx
index 637afd2..57aa46b 100644
--- a/src/components/ui/table-row-actions.tsx
+++ b/src/components/ui/table-row-actions.tsx
@@ -34,10 +34,11 @@ export function TableRowActions(props: { label: string; actions: TableRowAction[
class={props.compact
? "inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-muted-foreground outline-hidden transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-expanded:bg-muted data-expanded:text-foreground"
: "inline-flex h-8 min-w-[78px] cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-border/80 bg-muted/45 px-2 text-xs font-semibold text-foreground outline-hidden transition-colors hover:border-primary/30 hover:bg-primary/8 hover:text-primary-text focus-visible:ring-2 focus-visible:ring-ring data-expanded:border-primary/30 data-expanded:bg-primary/10 data-expanded:text-primary-text"}
+ data-row-actions-trigger
aria-label={props.label}
title={props.label}
>
- {!props.compact && {props.triggerLabel ?? t("common.action")} }
+ {!props.compact && {props.triggerLabel ?? t("common.action")} }
@@ -64,6 +65,7 @@ export function TableRowActions(props: { label: string; actions: TableRowAction[
{(action) => (
1}>
@@ -132,9 +132,9 @@ export function ProfileMemberships(props: {
1}>
diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts
index b5eb249..a452aaf 100644
--- a/src/i18n/locales/en.ts
+++ b/src/i18n/locales/en.ts
@@ -91,7 +91,6 @@ export const en: Dict = {
"classGroups.selectTeacher": "Select a teacher",
"classGroups.yourClass": "Class",
"classGroups.searchPlaceholder": "Search by class, grade or homeroom teacher…",
- "classGroups.allGrades": "All grades",
"classGroups.studentsCount": "{count} students",
"classGroups.noGrade": "No grade",
"classGroups.attendanceRate": "Attendance",
@@ -485,7 +484,6 @@ export const en: Dict = {
"roster.studentClass": "Class",
"roster.teacher": "Teacher",
"roster.class": "Class",
- "roster.classAll": "Class: All",
"roster.term": "Term",
"roster.termAll": "Term: All",
"roster.mastery": "Topic mastery",
@@ -658,6 +656,7 @@ export const en: Dict = {
"common.prev": "Previous",
"common.next": "Next",
"common.pageOf": "{page} / {total}",
+ "common.pagination": "Pagination",
"common.noResults": "No results.",
"common.scrollHint": "Scroll horizontally",
"common.noMatches": "Nothing matches your search.",
@@ -710,6 +709,7 @@ export const en: Dict = {
"aiStudio.run.ended": "Ended",
"aiStudio.run.length": "Length",
"aiStudio.library.title": "Your generated library",
+ "aiStudio.backToLibrary": "Back to library",
"aiStudio.library.description": "Every summary and podcast you produced, newest first.",
"aiStudio.library.count": "{count} outputs",
"aiStudio.library.empty": "Your generated content will appear here",
diff --git a/src/i18n/locales/tr.ts b/src/i18n/locales/tr.ts
index 2efed93..33219c1 100644
--- a/src/i18n/locales/tr.ts
+++ b/src/i18n/locales/tr.ts
@@ -87,7 +87,6 @@ export const tr: Dict = {
"classGroups.selectTeacher": "Bir öğretmen seç",
"classGroups.yourClass": "Şube",
"classGroups.searchPlaceholder": "Şube, sınıf veya danışman ara…",
- "classGroups.allGrades": "Tüm sınıflar",
"classGroups.studentsCount": "{count} öğrenci",
"classGroups.noGrade": "Sınıf yok",
"classGroups.attendanceRate": "Devam",
@@ -481,7 +480,6 @@ export const tr: Dict = {
"roster.studentClass": "Sınıfı",
"roster.teacher": "Öğretmen",
"roster.class": "Sınıf",
- "roster.classAll": "Sınıf: Tümü",
"roster.term": "Dönem",
"roster.termAll": "Dönem: Tümü",
"roster.mastery": "Konu yetkinliği",
@@ -654,6 +652,7 @@ export const tr: Dict = {
"common.prev": "Önceki",
"common.next": "Sonraki",
"common.pageOf": "{page} / {total}",
+ "common.pagination": "Sayfalar",
"common.noResults": "Sonuç yok.",
"common.scrollHint": "Yatay kaydır",
"common.noMatches": "Aramanızla eşleşen kayıt yok.",
@@ -706,6 +705,7 @@ export const tr: Dict = {
"aiStudio.run.ended": "Bitti",
"aiStudio.run.length": "Uzunluk",
"aiStudio.library.title": "Üretim kitaplığın",
+ "aiStudio.backToLibrary": "Kitaplığa dön",
"aiStudio.library.description": "Ürettiğin her özet ve podcast, en yenisi üstte.",
"aiStudio.library.count": "{count} çıktı",
"aiStudio.library.empty": "Ürettiğin içerikler burada görünecek",
diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts
index 2aca214..e54819d 100644
--- a/src/i18n/messages.ts
+++ b/src/i18n/messages.ts
@@ -80,7 +80,6 @@ export type MessageKey =
| "classGroups.selectTeacher"
| "classGroups.yourClass"
| "classGroups.searchPlaceholder"
- | "classGroups.allGrades"
| "classGroups.studentsCount"
| "classGroups.noGrade"
| "classGroups.attendanceRate"
@@ -450,7 +449,6 @@ export type MessageKey =
| "roster.studentClass"
| "roster.teacher"
| "roster.class"
- | "roster.classAll"
| "roster.term"
| "roster.termAll"
| "roster.mastery"
@@ -642,6 +640,7 @@ export type MessageKey =
| "common.prev"
| "common.next"
| "common.pageOf"
+ | "common.pagination"
| "common.noResults"
| "common.scrollHint"
| "common.noMatches"
@@ -694,6 +693,7 @@ export type MessageKey =
| "aiStudio.run.ended"
| "aiStudio.run.length"
| "aiStudio.library.title"
+ | "aiStudio.backToLibrary"
| "aiStudio.library.description"
| "aiStudio.library.count"
| "aiStudio.library.empty"
diff --git a/src/lib/create-page-size.test.ts b/src/lib/create-page-size.test.ts
new file mode 100644
index 0000000..dca442f
--- /dev/null
+++ b/src/lib/create-page-size.test.ts
@@ -0,0 +1,15 @@
+import { compactPageSize } from "@/lib/create-page-size";
+
+it("halves a page for phones, never below five", () => {
+ expect(compactPageSize(10)).toBe(5);
+ expect(compactPageSize(8)).toBe(5);
+ expect(compactPageSize(12)).toBe(6);
+ expect(compactPageSize(15)).toBe(8);
+ expect(compactPageSize(20)).toBe(10);
+});
+
+it("leaves an already short page alone", () => {
+ expect(compactPageSize(5)).toBe(5);
+ expect(compactPageSize(4)).toBe(4);
+ expect(compactPageSize(1)).toBe(1);
+});
diff --git a/src/lib/create-page-size.ts b/src/lib/create-page-size.ts
new file mode 100644
index 0000000..a3d87c8
--- /dev/null
+++ b/src/lib/create-page-size.ts
@@ -0,0 +1,25 @@
+import { createMediaQuery } from "@/lib/create-media-query";
+
+/** Below Tailwind's `sm` breakpoint — the width where tables turn into cards. */
+export const COMPACT_SCREEN_QUERY = "(max-width: 639px)";
+
+/**
+ * Rows per page on a phone for a list that shows `desktop` rows on a wide
+ * screen. A table row becomes a four- or five-line card there, so the same
+ * count is several screens tall: half as many, never fewer than five, and a
+ * list that is already short keeps its own size.
+ */
+export function compactPageSize(desktop: number): number {
+ return Math.min(desktop, Math.max(5, Math.ceil(desktop / 2)));
+}
+
+/**
+ * A page size that follows the screen: `desktop` on wide screens,
+ * `compactPageSize(desktop)` on phones. Callers that page on the server pass
+ * the accessor into their fetch source, so a rotation refetches the right
+ * slice; callers keeping a page index should reset it when this changes.
+ */
+export function createResponsivePageSize(desktop: number): () => number {
+ const compact = createMediaQuery(COMPACT_SCREEN_QUERY);
+ return () => (compact() ? compactPageSize(desktop) : desktop);
+}
diff --git a/src/pages/classes-page.tsx b/src/pages/classes-page.tsx
index 5309c67..7b8a262 100644
--- a/src/pages/classes-page.tsx
+++ b/src/pages/classes-page.tsx
@@ -232,10 +232,10 @@ function ClassesContent() {
filters={
0}>
({ value: g, label: g }))]}
+ labelPrefix={t("classGroups.grade")}
+ options={[{ value: "all", label: t("common.all") }, ...grades().map((g) => ({ value: g, label: g }))]}
value={gradeFilter()}
onChange={setGradeFilter}
- class="min-w-44"
/>
}
diff --git a/src/pages/courses-page.tsx b/src/pages/courses-page.tsx
index 8e477f4..fef8275 100644
--- a/src/pages/courses-page.tsx
+++ b/src/pages/courses-page.tsx
@@ -1,4 +1,5 @@
import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js";
+import { createResponsivePageSize } from "@/lib/create-page-size";
import { createResource } from "@/lib/create-resource";
import { useNavigate, useSearch } from "@tanstack/solid-router";
import { getCourses, postCourse } from "@/api/courses";
@@ -16,7 +17,7 @@ import { IconPlus } from "@/components/ui/icons";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { PageSpinner } from "@/components/ui/page-spinner";
-import { PaginationControls } from "@/components/ui/pagination-controls";
+import { TablePagination } from "@/components/ui/table-pagination";
import { Select } from "@/components/ui/select";
import { courseKindLabel } from "@/lib/course-kind";
import { SidePanel } from "@/components/ui/side-panel";
@@ -56,6 +57,7 @@ function CoursesContent() {
// any şube has.
const [taughtFilter, setTaughtFilter] = createSignal("all");
const [page, setPage] = createSignal(0);
+ const pageSize = createResponsivePageSize(PAGE_SIZE);
const [search, setSearch] = createSignal("");
const [error, setError] = createSignal("");
const [pending, setPending] = createSignal(false);
@@ -68,7 +70,7 @@ function CoursesContent() {
setPageKind(routeSearch().kind);
});
createEffect(() => {
- pageKind(); taughtFilter(); search(); setPage(0);
+ pageKind(); taughtFilter(); search(); pageSize(); setPage(0);
});
const [limits, { refetch: refetchLimits }] = createResource(() => canCreate() ? getLimits() : null);
@@ -87,8 +89,8 @@ function CoursesContent() {
return matchesSearch(query, course.title, course.description, personLabel(course.creator));
});
});
- const totalPages = createMemo(() => Math.max(1, Math.ceil(filteredCourses().length / PAGE_SIZE)));
- const visibleCourses = createMemo(() => filteredCourses().slice(page() * PAGE_SIZE, (page() + 1) * PAGE_SIZE));
+ const totalPages = createMemo(() => Math.max(1, Math.ceil(filteredCourses().length / pageSize())));
+ const visibleCourses = createMemo(() => filteredCourses().slice(page() * pageSize(), (page() + 1) * pageSize()));
const createCourse = async (event: SubmitEvent) => {
event.preventDefault();
@@ -200,7 +202,7 @@ function CoursesContent() {
)}
-
+
diff --git a/src/pages/exam-detail-page.tsx b/src/pages/exam-detail-page.tsx
index 3d9e5d3..80e6529 100644
--- a/src/pages/exam-detail-page.tsx
+++ b/src/pages/exam-detail-page.tsx
@@ -1,5 +1,6 @@
import { Link, useLocation, useNavigate } from "@tanstack/solid-router";
-import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js";
+import { For, Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js";
+import { createResponsivePageSize } from "@/lib/create-page-size";
import { createResource } from "@/lib/create-resource";
import type { ColumnDef } from "@tanstack/solid-table";
import { deleteExamById } from "@/api/exams";
@@ -33,7 +34,6 @@ import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";
import { EmptyState } from "@/components/ui/empty-state";
import { IconCalendarDays, IconChart, IconChevronDown, IconClipboardCheck, IconClock, IconEdit, IconExam, IconEye, IconRefresh, IconSchool, IconTrash } from "@/components/ui/icons";
import { Input } from "@/components/ui/input";
-import { PaginationControls } from "@/components/ui/pagination-controls";
import { PageSpinner } from "@/components/ui/page-spinner";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { SidePanel } from "@/components/ui/side-panel";
@@ -116,6 +116,8 @@ function ExamDetailContent() {
const [removeUserId, setRemoveUserId] = createSignal
(null);
const [gradeOpen, setGradeOpen] = createSignal(false);
const [resultPage, setResultPage] = createSignal(0);
+ const resultPageSize = createResponsivePageSize(RESULT_PAGE_SIZE);
+ createEffect(on(resultPageSize, () => setResultPage(0), { defer: true }));
const [answerSheetUserId, setAnswerSheetUserId] = createSignal(null);
const answerSheetOpen = () => answerSheetUserId() != null;
const [answerMark, setAnswerMark] = createSignal("0");
@@ -153,11 +155,11 @@ function ExamDetailContent() {
);
const [results, { refetch: refetchResults }] = createResource(
- () => (hasCourseManagementRights() ? [id(), resultPage()] as const : null),
+ () => (hasCourseManagementRights() ? [id(), resultPage(), resultPageSize()] as const : null),
async (source) => {
if (!source) return { items: [], total: 0, limit: RESULT_PAGE_SIZE, offset: 0 };
- const [examId, page] = source;
- return getExamResults(examId, { limit: RESULT_PAGE_SIZE, offset: page * RESULT_PAGE_SIZE });
+ const [examId, page, size] = source;
+ return getExamResults(examId, { limit: size, offset: page * size });
},
);
const [gradeResults, { refetch: refetchGradeResults }] = createResource(
@@ -258,7 +260,7 @@ function ExamDetailContent() {
async (examId) => examId ? getExamLive(examId) : null,
);
const resultTotal = () => results()?.total ?? 0;
- const resultTotalPages = () => Math.max(1, Math.ceil(resultTotal() / RESULT_PAGE_SIZE));
+ const resultTotalPages = () => Math.max(1, Math.ceil(resultTotal() / resultPageSize()));
const setClampedAnswerMark = (value: string) => {
if (value === "") {
setAnswerMark(value);
@@ -735,10 +737,20 @@ function ExamDetailContent() {
when={(results()?.items ?? []).length > 0}
fallback={ }
>
-
- RESULT_PAGE_SIZE}>
-
-
+ {/* Server-paged: the table's own pager drives the fetch, so a
+ phone's smaller page never shows up as a second pager
+ slicing the fetched page again. */}
+
diff --git a/src/pages/meals-page.tsx b/src/pages/meals-page.tsx
index 0dbc048..98ac31f 100644
--- a/src/pages/meals-page.tsx
+++ b/src/pages/meals-page.tsx
@@ -1,4 +1,5 @@
-import { For, Show, Suspense, createMemo, createSignal } from "solid-js";
+import { For, Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js";
+import { createResponsivePageSize } from "@/lib/create-page-size";
import { createResource } from "@/lib/create-resource";
import { getLimits } from "@/api/limits";
import { getMealMenuBookings, getMealMenus, postMealMenu } from "@/api/meals";
@@ -16,7 +17,7 @@ import { IconPlus } from "@/components/ui/icons";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { PageSpinner } from "@/components/ui/page-spinner";
-import { PaginationControls } from "@/components/ui/pagination-controls";
+import { TablePagination } from "@/components/ui/table-pagination";
import { Select } from "@/components/ui/select";
import { SidePanel } from "@/components/ui/side-panel";
import { inputDateToIso, isoDateToInput } from "@/lib/datetime-input";
@@ -38,6 +39,8 @@ function MealsContent() {
const { locale } = usePreferences();
const canManage = () => hasMinRole(auth.user()?.role, "manager");
const [page, setPage] = createSignal(0);
+ const pageSize = createResponsivePageSize(PAGE_SIZE);
+ createEffect(on(pageSize, () => setPage(0), { defer: true }));
const [from, setFrom] = createSignal(today());
const [slot, setSlot] = createSignal("all");
const [showCreate, setShowCreate] = createSignal(false);
@@ -50,11 +53,11 @@ function MealsContent() {
const [settings] = createResource(() => getSettings());
const [limits, { refetch: refetchLimits }] = createResource(() => canManage() ? getLimits() : null);
const [menus, { refetch }] = createResource(
- () => [from(), page()] as const,
- async ([start, index]) => getMealMenus({ from: start || undefined, limit: PAGE_SIZE, offset: index * PAGE_SIZE }),
+ () => [from(), page(), pageSize()] as const,
+ async ([start, index, size]) => getMealMenus({ from: start || undefined, limit: size, offset: index * size }),
);
const visible = createMemo(() => slot() === "all" ? menus()?.items ?? [] : (menus()?.items ?? []).filter((menu) => menu.slot === slot()));
- const totalPages = createMemo(() => Math.max(1, Math.ceil((menus()?.total ?? 0) / PAGE_SIZE)));
+ const totalPages = createMemo(() => Math.max(1, Math.ceil((menus()?.total ?? 0) / pageSize())));
// Real occupancy = confirmed bookings / capacity, both true fields — not the
// fabricated İyi/Takipte/Risk badge Figma shows. `getMealMenuBookings` is
@@ -111,7 +114,7 @@ function MealsContent() {
void refetch()} />
0} fallback={ }>
{(menu) => }
-
+
diff --git a/src/pages/messages-page.tsx b/src/pages/messages-page.tsx
index d570d1f..68165c5 100644
--- a/src/pages/messages-page.tsx
+++ b/src/pages/messages-page.tsx
@@ -8,7 +8,7 @@ import {
} from "solid-js";
import { createResource } from "@/lib/create-resource";
import { RouteGuard } from "@/components/layout/route-guard";
-import { PaginationControls } from "@/components/ui/pagination-controls";
+import { TablePagination } from "@/components/ui/table-pagination";
import { Button } from "@/components/ui/button";
import {
IconArchive,
@@ -421,10 +421,10 @@ export default function MessagesPage() {
limit}>
diff --git a/src/pages/notes-page.tsx b/src/pages/notes-page.tsx
index 03235fc..c946ffa 100644
--- a/src/pages/notes-page.tsx
+++ b/src/pages/notes-page.tsx
@@ -1,4 +1,5 @@
-import { Show, Suspense, createEffect, createMemo, createSignal } from "solid-js";
+import { Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js";
+import { createResponsivePageSize } from "@/lib/create-page-size";
import { createResource } from "@/lib/create-resource";
import { useLocation, useNavigate } from "@tanstack/solid-router";
import { deleteNoteById } from "@/api/notes";
@@ -13,7 +14,7 @@ import { NoteList } from "@/components/notes/note-list";
import { Button } from "@/components/ui/button";
import { IconPlus, IconUploadCloud } from "@/components/ui/icons";
import { PageSpinner } from "@/components/ui/page-spinner";
-import { PaginationControls } from "@/components/ui/pagination-controls";
+import { TablePagination } from "@/components/ui/table-pagination";
import { SidePanel } from "@/components/ui/side-panel";
import { createFlash } from "@/lib/flash";
import { loadListPage, totalPages as pagesOf } from "@/lib/list-page";
@@ -43,13 +44,15 @@ function NotesContent() {
if (location().searchStr.includes("action=import")) setImportOpen(true);
});
const [page, setPage] = createSignal(0);
+ const pageSize = createResponsivePageSize(NOTE_PAGE_SIZE);
+ createEffect(on(pageSize, () => setPage(0), { defer: true }));
const [list, { refetch }] = createResource(
- () => page(),
- async (currentPage) =>
+ () => ({ page: page(), size: pageSize() }),
+ async (source) =>
loadListPage({
- page: currentPage,
- pageSize: NOTE_PAGE_SIZE,
+ page: source.page,
+ pageSize: source.size,
clientMode: false,
fetch: getNotes,
}),
@@ -57,7 +60,7 @@ function NotesContent() {
const total = () => list()?.total ?? 0;
const pageItems = () => list()?.items ?? [];
- const totalPages = createMemo(() => pagesOf(total(), NOTE_PAGE_SIZE));
+ const totalPages = createMemo(() => pagesOf(total(), pageSize()));
const safePage = createMemo(() => Math.min(page(), totalPages() - 1));
const wrap = async (fn: () => Promise, okMessage: string) => {
@@ -129,8 +132,8 @@ function NotesContent() {
}, t("common.deleted"))
}
/>
- NOTE_PAGE_SIZE}>
-
+ pageSize()}>
+
diff --git a/src/pages/payments-page.tsx b/src/pages/payments-page.tsx
index 7fde63d..5b02df7 100644
--- a/src/pages/payments-page.tsx
+++ b/src/pages/payments-page.tsx
@@ -1,5 +1,6 @@
import { useLocation, useNavigate } from "@tanstack/solid-router";
import { For, Index, Show, Suspense, createEffect, createMemo, createSignal, onCleanup } from "solid-js";
+import { createResponsivePageSize } from "@/lib/create-page-size";
import { createResource } from "@/lib/create-resource";
import type { ColumnDef } from "@tanstack/solid-table";
import {
@@ -118,10 +119,12 @@ function PaymentsContent() {
onCleanup(() => clearTimeout(queryTimer));
const [studentPage, setStudentPage] = createSignal(0);
- // Reset to page 1 whenever the query or plan filter changes underneath it.
+ const studentPageSize = createResponsivePageSize(STUDENT_PAGE_SIZE);
+ // Reset to page 1 whenever the query, plan filter or page size changes underneath it.
createEffect(() => {
debouncedQuery();
planFilter();
+ studentPageSize();
setStudentPage(0);
});
@@ -134,7 +137,7 @@ function PaymentsContent() {
// (already name-resolved) plan roster and filters/pages it client-side —
// a plan's assignees are a small, bounded list on their own.
const [studentsPage, { refetch: refetchStudents }] = createResource(
- () => ({ plan: planFilter(), q: debouncedQuery(), page: studentPage(), size: STUDENT_PAGE_SIZE }),
+ () => ({ plan: planFilter(), q: debouncedQuery(), page: studentPage(), size: studentPageSize() }),
async ({ plan, q, page, size }): Promise<{ items: PersonRef[]; total: number }> => {
if (plan) {
const assignments = await getPlanAssignments(plan, { limit: 500 });
@@ -650,7 +653,7 @@ function PaymentsContent() {
enablePagination
manualPagination={{
pageIndex: studentPage(),
- pageSize: STUDENT_PAGE_SIZE,
+ pageSize: studentPageSize(),
total: studentsTotal(),
onPageChange: setStudentPage,
}}
diff --git a/src/pages/question-bank-page.tsx b/src/pages/question-bank-page.tsx
index a50ec7e..4b40f97 100644
--- a/src/pages/question-bank-page.tsx
+++ b/src/pages/question-bank-page.tsx
@@ -1,5 +1,6 @@
import { useNavigate } from "@tanstack/solid-router";
-import { Show, Suspense, createEffect, createMemo, createSignal } from "solid-js";
+import { Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js";
+import { createResponsivePageSize } from "@/lib/create-page-size";
import { createResource } from "@/lib/create-resource";
import type { ColumnDef } from "@tanstack/solid-table";
import { deleteBankQuestionById, getBankQuestions } from "@/api/bank-questions";
@@ -45,6 +46,8 @@ function QuestionBankContent() {
const visibilityFilter = () => (bankTab() === "school" ? "school" : "all") as "all" | "private" | "school";
const [subjectFilter, setSubjectFilter] = createSignal("all");
const [page, setPage] = createSignal(0);
+ const pageSize = createResponsivePageSize(BANK_PAGE_SIZE);
+ createEffect(on(pageSize, () => setPage(0), { defer: true }));
const [query, setQuery, debouncedQuery] = createDebouncedSignal();
const [createOpen, setCreateOpen] = createSignal(false);
const [editing, setEditing] = createSignal(null);
@@ -58,6 +61,7 @@ function QuestionBankContent() {
const [list, { refetch }] = createResource(
() => ({
page: page(),
+ size: pageSize(),
owner: ownerFilter(),
subject: subjectFilter(),
visibility: visibilityFilter(),
@@ -65,8 +69,8 @@ function QuestionBankContent() {
}),
async (filters) => {
const result = await getBankQuestions({
- limit: BANK_PAGE_SIZE,
- offset: filters.page * BANK_PAGE_SIZE,
+ limit: filters.size,
+ offset: filters.page * filters.size,
...(filters.owner === "me" ? { owner: "me" } : {}),
...(filters.subject !== "all" ? { subject: filters.subject } : {}),
...(filters.visibility !== "all" ? { visibility: filters.visibility } : {}),
@@ -84,7 +88,7 @@ function QuestionBankContent() {
// Deleting the last row of the last page shrinks the page count under the
// current page; the table then hides its pagination bar entirely and the user
// is stranded with no control to get back. Same clamp as exam-questions-panel.
- const pageCount = () => Math.max(1, Math.ceil(total() / BANK_PAGE_SIZE));
+ const pageCount = () => Math.max(1, Math.ceil(total() / pageSize()));
createEffect(() => {
if (page() >= pageCount()) setPage(pageCount() - 1);
});
@@ -267,7 +271,7 @@ function QuestionBankContent() {
setPage(0);
}}
enablePagination
- manualPagination={{ pageIndex: page(), pageSize: BANK_PAGE_SIZE, total: total(), onPageChange: setPage }}
+ manualPagination={{ pageIndex: page(), pageSize: pageSize(), total: total(), onPageChange: setPage }}
empty={t("bank.empty")}
storageKey="question-bank"
onRowClick={(question) => navigate({ to: "/question-bank/$id", params: { id: question.id } })}
diff --git a/src/pages/staff-work-page.tsx b/src/pages/staff-work-page.tsx
index d0c6d10..f17c94c 100644
--- a/src/pages/staff-work-page.tsx
+++ b/src/pages/staff-work-page.tsx
@@ -1,4 +1,5 @@
import { For, Show, createEffect, createMemo, createSignal } from "solid-js";
+import { createResponsivePageSize } from "@/lib/create-page-size";
import { createResource } from "@/lib/create-resource";
import type { ColumnDef } from "@tanstack/solid-table";
import { deleteWorkEntryById } from "@/api/work";
@@ -23,7 +24,7 @@ import { DatePicker } from "@/components/ui/date-picker";
import { IconChevronRight, IconEdit, IconTrash } from "@/components/ui/icons";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
-import { PaginationControls } from "@/components/ui/pagination-controls";
+import { TablePagination } from "@/components/ui/table-pagination";
import { SidePanel } from "@/components/ui/side-panel";
import { TableRowActions } from "@/components/ui/table-row-actions";
import { formatDateTime, formatDurationMinutes } from "@/lib/format";
@@ -145,6 +146,7 @@ function StaffWorkContent() {
const [staffSearch, setStaffSearch] = createSignal("");
const [staffPage, setStaffPage] = createSignal(0);
+ const peoplePageSize = createResponsivePageSize(PEOPLE_PAGE_SIZE);
const entryRows = () => entries().items;
const peopleLoading = () => people.loading;
@@ -155,10 +157,11 @@ function StaffWorkContent() {
const q = staffSearch().trim();
return q ? people().filter((person) => searchPerson(person, q)) : people();
});
- const staffPageCount = createMemo(() => Math.max(1, Math.ceil(filteredPeople().length / PEOPLE_PAGE_SIZE)));
- const pagedPeople = createMemo(() => filteredPeople().slice(staffPage() * PEOPLE_PAGE_SIZE, staffPage() * PEOPLE_PAGE_SIZE + PEOPLE_PAGE_SIZE));
+ const staffPageCount = createMemo(() => Math.max(1, Math.ceil(filteredPeople().length / peoplePageSize())));
+ const pagedPeople = createMemo(() => filteredPeople().slice(staffPage() * peoplePageSize(), (staffPage() + 1) * peoplePageSize()));
createEffect(() => {
staffSearch();
+ peoplePageSize();
setStaffPage(0);
});
@@ -326,7 +329,7 @@ function StaffWorkContent() {
)}
-