Archive several saved articles at once

React · React · intermediate · modification

Readers asked for a way to clear out their reading list without opening each article, so the table now has a checkbox per row and an `Archive selected (N)` button. `src/api/readingList.js` adds `archiveArticles(ids)` for the new archive endpoint. `src/reading/ArticleTable.jsx` keeps one checked flag per article, renders the checkbox column next to the existing `Hide read` filtering and computes the ids the button sends. `src/reading/ReadingListPage.jsx` runs the archive request, disables the button while it is in flight, reloads the list on success and shows an error message on failure. `src/reading/ArticleTable.test.jsx` (new) adds component tests for the selection and the archive button.

Reading-list SPA on React 18.3 (Vite, function components, plain `fetch`). Tests run with `npm test`: Vitest 2 with @testing-library/react 16 in jsdom. Existing and unchanged: the router renders `ReadingListPage` at `/reading-list` for a signed-in reader; requests are same-origin and carry the session cookie, and the server's CSRF check accepts same-origin JSON requests like this one. `GET /api/reading-list` returns the reader's saved articles that are not archived, newest first, at most 200, as `[{ id, title, url, siteName, savedLabel, read }]`: `id` a unique non-empty string, `title` and `siteName` non-empty strings, `url` an absolute http(s) URL, `savedLabel` the save date already formatted by the API (for example `Oct 30`), `read` a boolean. `POST /api/reading-list/archive` (shipped in the backend already) takes `{ "ids": [...] }` with 1 to 200 ids, archives them in one transaction and answers 204; on any error it archives nothing and answers 4xx or 5xx. The articles do not change while the page shows them: the list has no live updates, and `ArticleTable` is mounted afresh for every load because the page renders the loading state in its place. The table's existing classes are styled in `src/reading/reading.css` (unchanged) with theme tokens.

Requirements

Files touched

Review this PR

React practice