Prompt file imported from oleksa-karpenko/LLeague (
.github/prompts/add-component.prompt.md). Copyright stays with the author.
Create a new React component or page in the frontend.
Ask me whether it's a page (route screen → src/pages/) or a reusable component (src/components/).
Then:
- Function component, TypeScript, single quotes + semicolons, 2-space indent. Default export for pages.
- Data: use TanStack Query (
useQuery/useMutation) for server state; call typed functions fromsrc/api/endpoints.ts(neverfetchdirectly). CatchApiErrorfor error display. - Reuse shared primitives from
src/components/ui.tsx(ErrorBanner,Spinner,.btn/.card/.inputclasses) andLayoutwhere appropriate. - Respect
erasableSyntaxOnly: no parameter properties, no runtimeenum, nonamespace. - If it's a page, wire the route in
src/App.tsx(guard withProtectedRouteif admin-only). - Add a colocated
*.test.tsx(Vitest + RTL) covering the main interaction — see.github/instructions/frontend-tests.instructions.md.
Finally: cd frontend && npm run lint && npm run typecheck && npm run format:check && npm run test.