Repository navigation
create publisher UI - #23
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Number: Issue #7
Summary
Adds an "Add Publisher" flow to the Publishers page: a button opens a modal form that posts to the new
POST /api/publishersbackend endpoint, with client-side validation, loading state, error handling, and an automatic list refresh on success.Context / Motivation
Ticket: Frontend — Create Publisher. The backend now exposes
POST /api/publishers(see companion backend PR); this closes the loop by letting a user actually create a Publisher from the UI instead of only viewing/filtering the existing list.Scope of Changes
src/components/AddPublisherModal.tsx(new) — modal component with a Name field. Handles client-side validation (required, ≤200 chars, mirroring the backend's limit), a submitting/loading state that disables the form and prevents duplicate submissions, inline display of both validation errors and API errors, and closes via Cancel button, overlay click, or Escape key (all disabled while a request is in flight).src/pages/PublishersPage.tsx— added an "Add Publisher" button in a new page header row; opens the modal, and on successful creation closes it and refreshes the publisher list.src/hooks/usePublishers.ts— added arefetch()function to the hook's return value so the page can re-trigger the existing list query after a create, without changing any of its filter/pagination state.src/api/client.ts— addedcreatePublisher()(POST helper) and a sharedextractErrorMessage()used by both GET and POST calls, which reads the backend'sErrorDto.errorfield out of a failed response body so API error messages (e.g. the 409 conflict text) are shown to the user instead of a generic "request failed" message.src/api/types.ts— addedCreatePublisherRequestandApiErrorResponsetypes.src/App.css— styles for the modal overlay/dialog, the new page-header layout, and a.primarybutton variant, consistent with the app's existing light/dark theme tokens.Testing Instructions
Acceptance Criteria
POST /api/publishers)Code Review Notes
usePublishers'srefetch()is implemented via an internal reload-token counter rather than exposing a way to mutatedatadirectly, so it re-runs the exact same query the page already has configured (same filters/page) rather than needing the caller to know the fetch inusePublishers'srefetch()is implemented via an internal reload-token counter rather than exposing a way to mutatedatadirectly, so it re-runs the exact same query the page already has configured (same filters/page) ratherthan needing the caller to know the fetch in
more explicit success message is wanted.
Related Issues / Tickets