Description
Creators repeatedly build similar invoice structures from scratch without a way to discover or reuse templates that others have made public. This issue creates an invoice template marketplace at /templates/marketplace where users can publish their saved templates with a title, description, and category tag, browse and preview templates published by others, and clone a marketplace template into their own template library. The marketplace must be moderated: templates go through a brief review status before appearing publicly.
Technical Context
Add app/templates/marketplace/page.tsx as a paginated gallery using server-side rendering for SEO. Implement app/api/templates/marketplace/route.ts for GET (paginated, filterable by category) and POST (submit for review). Extend the templates data model with { isPublic, reviewStatus: 'pending'|'approved'|'rejected', publishedAt, cloneCount }. Build components/templates/MarketplaceCard.tsx displaying preview thumbnail (render invoice structure as a condensed card), creator alias, clone count, and category badge. The clone action calls POST /api/templates/[id]/clone which deep-copies the template into the requesting user's library. Add an admin-only review queue at app/admin/templates/review/page.tsx gated by a role check. Use next/image with a placeholder skeleton for card thumbnails.
Acceptance Criteria
Description
Creators repeatedly build similar invoice structures from scratch without a way to discover or reuse templates that others have made public. This issue creates an invoice template marketplace at
/templates/marketplacewhere users can publish their saved templates with a title, description, and category tag, browse and preview templates published by others, and clone a marketplace template into their own template library. The marketplace must be moderated: templates go through a brief review status before appearing publicly.Technical Context
Add
app/templates/marketplace/page.tsxas a paginated gallery using server-side rendering for SEO. Implementapp/api/templates/marketplace/route.tsfor GET (paginated, filterable by category) and POST (submit for review). Extend the templates data model with{ isPublic, reviewStatus: 'pending'|'approved'|'rejected', publishedAt, cloneCount }. Buildcomponents/templates/MarketplaceCard.tsxdisplaying preview thumbnail (render invoice structure as a condensed card), creator alias, clone count, and category badge. The clone action callsPOST /api/templates/[id]/clonewhich deep-copies the template into the requesting user's library. Add an admin-only review queue atapp/admin/templates/review/page.tsxgated by a role check. Usenext/imagewith a placeholder skeleton for card thumbnails.Acceptance Criteria
pendingreview record and shows the creator a confirmation with review status trackingapprovedstatus only;pendingandrejectedtemplates are never visible to other users(cloned)suffix and increments the source template'scloneCount