The PitchPro frontend is a React 18 single-page application built with Vite and TypeScript. It provides a fully-featured admin dashboard for managing sports courts (canchas) and reservations, connecting to the Express backend API over HTTP. The UI is built with MUI v5, data fetching is handled by TanStack Query v5, and all HTTP calls go through a shared Axios instance configured inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSerna14/Final-lenguaje-Avanzado/llms.txt
Use this file to discover all available pages before exploring further.
src/utils/axios.ts.
Prerequisites
- Node.js 18+ and npm or yarn
- The PitchPro Express backend API running locally at
http://localhost:8000(see Backend Setup)
Installation
Navigate to the frontend directory
The React app lives in
starter-vite-ts/ inside the monorepo root:Create the environment file
Create a
.env file at the root of starter-vite-ts/:.env
VITE_HOST_API is read by src/config-global.ts as HOST_API and passed directly to the Axios instance as its baseURL. Every API call in the app is relative to this value.Start the development server
Available Scripts
| Script | Command | Description |
|---|---|---|
dev | vite | Start the Vite development server with HMR on port 5173 |
build | tsc && vite build | Type-check with TypeScript then produce an optimized dist/ bundle |
start | vite preview | Locally preview the production build from dist/ |
lint | eslint "src/**/*.{js,jsx,ts,tsx}" | Run ESLint across all source files |
dev:host | vite --host | Start the dev server exposed on the local network (useful for mobile testing) |
Key Dependencies
| Package | Version | Purpose |
|---|---|---|
react + react-dom | ^18.2.0 | Core React framework for building the SPA |
react-router-dom | ^6.20.1 | Client-side routing (React Router v6) |
@mui/material | ^5.14.20 | MUI v5 component library — all layout, tables, dialogs, and forms |
@tanstack/react-query | ^5.100.14 | Server state management — data fetching, caching, and invalidation |
axios | ^1.6.2 | HTTP client; a shared instance with interceptors lives in src/utils/axios.ts |
react-hook-form | ^7.48.2 | Performant form state management for login, register, and CRUD dialogs |
yup | ^1.3.2 | Schema validation library used to define form rules |
@hookform/resolvers | ^3.3.2 | Bridges Yup schemas into React Hook Form’s validation system |
framer-motion | ^10.16.16 | Declarative animations used throughout the dashboard UI |
@iconify/react | ^4.1.1 | Icon component backed by the Solar icon set |
Connecting to a Custom Backend
The Axios instance is created insrc/utils/axios.ts using HOST_API from src/config-global.ts:
src/utils/axios.ts
HOST_API is read directly from the VITE_HOST_API environment variable:
src/config-global.ts
.env:
.env
src/api/canchas.ts, src/api/reservas.ts) and the auth interceptor will automatically use the new base URL.
Build for Production
tsc), then Vite bundles the app into the dist/ directory with code splitting and asset hashing.
Deploying to Vercel (recommended for SPAs)
Because PitchPro uses client-side routing, all paths must be rewritten to index.html. Add a vercel.json at the repo root (or starter-vite-ts/) with a catch-all rewrite:
vercel.json
_redirects file inside starter-vite-ts/public/:
dist/ verbatim by Vite during the build step.
Auth Flow
How the JWT auth context, token storage, Axios interceptor, and route guards work.
Dashboard
Tour the courts table, reservations list, stat cards, and CRUD dialogs.
Environment Variables
Full reference for all VITE_ variables used by the frontend.
API Overview
REST endpoints exposed by the Express backend the dashboard consumes.