Skip to content

Feature: pagination controls#1

Merged
AlexWei2020 merged 3 commits into
mainfrom
feature
Jul 7, 2026
Merged

Feature: pagination controls#1
AlexWei2020 merged 3 commits into
mainfrom
feature

Conversation

@AlexWei2020

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings July 7, 2026 02:43
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
post-back Ready Ready Preview, Comment Jul 7, 2026 2:43am

@AlexWei2020
AlexWei2020 merged commit 5eb1294 into main Jul 7, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds server-backed pagination controls to the postcard listing so the home page no longer needs to load/render the entire dataset at once, and exposes counts to support filter tabs with totals.

Changes:

  • Introduce PostcardFilter/PostcardCounts types for filter/count plumbing.
  • Home page now loads an initial page (default 21) plus grouped status counts and passes them to the client.
  • /api/postcards GET now supports page/pageSize (and returns counts + pagination) and the home client uses it for filter/page navigation and refresh after actions.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
package.json Bumps app version to reflect the new feature.
lib/types.ts Adds shared types for filters and count maps used by API + UI.
app/page.tsx Loads initial paginated results + initial counts and passes new props to the client.
app/home-client.tsx Implements pagination UI, server-driven filtering, and reload-after-mutations.
app/api/postcards/route.ts Adds paginated GET query support and returns counts/pagination metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 8 to 10
// GET /api/postcards -> all postcards (newest first)
// GET /api/postcards?status=available
// GET /api/postcards?mine=1 -> postcards claimed by the current user
Comment on lines +23 to +25
const page = positiveInt(searchParams.get("page"), 1);
const pageSize = Math.min(100, positiveInt(searchParams.get("pageSize"), 21));
const offset = (page - 1) * pageSize;
Comment thread app/home-client.tsx
"use client";

import { useMemo, useState } from "react";
import { useEffect, useMemo, useState } from "react";
Comment thread app/home-client.tsx
Comment on lines +48 to +50
const [pageSize, setPageSize] = useState(initialPageSize);
const [page, setPage] = useState(1);
const [loadingPage, setLoadingPage] = useState(false);
Comment thread app/home-client.tsx
Comment on lines +102 to +107

setFilter(nextFilter);
setPageSize(nextPageSize);
setPage(safePage);
setCounts(nextCounts);
setPostcards(data.postcards || []);
Comment thread app/home-client.tsx
Comment on lines +110 to +112
} finally {
setLoadingPage(false);
}
Comment thread app/home-client.tsx
Comment on lines +293 to +300
onChange={(e) => {
const next = Number(e.target.value);
if (!Number.isFinite(next)) return;
loadPage({
nextPage: 1,
nextPageSize: Math.min(100, Math.max(1, Math.floor(next))),
});
}}
Comment thread app/home-client.tsx
Comment on lines +76 to +78
setLoadingPage(true);
setError(null);
try {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants