Mobile-first frontend dashboard for candy shop sales management, built to support fast live selling with a lightweight POS-style session flow.
- React + Vite + TypeScript
- Zustand for state
- Zod for validation
- Axios for API calls
- React Router for navigation
- Tailwind CSS for styling
- jsPDF for session reports
- Authentication with JWT persistence
- Dashboard with active session summary and live totals
- Candy management for creating and editing catalog items
- Session screen for composing multi-item orders
- Draft order editing with quantity controls and line subtotals
- Session order history with delete support while the session is open
- Session close flow with PDF generation
- Responsive navigation:
- mobile: bottom navigation
- desktop: sidebar layout
- Start a session from the session screen.
- Add candies from the catalog into the current draft order.
- Adjust quantities before submission.
- Register the full order in one request.
- Review submitted orders in reverse chronological order.
- Delete an incorrect order while the session is still open.
- Close the session and generate the PDF summary.
- Mobile-first selling flow is the primary priority.
- Session summary stays visible while building orders.
- Draft orders must reject empty submissions.
- Draft quantities must stay at
1or higher. - Closed sessions are treated as immutable in the UI.
- The frontend should prefer candy ids from API responses instead of matching by candy name.
src/
api/
components/
hooks/
layouts/
pages/
schemas/
stores/
types/
utils/
Create .env with:
VITE_API_URL=http://localhost:3000If not provided, the app falls back to /api.
pnpm install
pnpm devVite runs by default at http://localhost:5173.
pnpm build
pnpm previewBuild and run with Docker Compose:
docker compose up --buildThe production image serves the built frontend with Nginx on http://localhost:4173.
- JWT header:
Authorization: Bearer <token> 401behavior: clear local auth and redirect to/login- Axios interceptors centralize auth headers and toast-based error handling
Main endpoints used by the UI:
POST /auth/loginGET /candiesPOST /candiesPATCH /candies/:idGET /sessions/open/currentGET /sessions/:idPOST /sessionsPOST /sessions/:id/ordersGET /sessions/:id/ordersDELETE /sessions/:sessionId/orders/:orderIdPATCH /sessions/:id/close
- Session summary responses should provide aggregate totals for the active session.
- Order history responses should provide stable order ids.
- Candy references should include ids whenever possible.
- The frontend will tolerate missing order history by keeping the session summary visible, but correction UI depends on the order endpoints working correctly.
Closing a session generates a PDF report including:
- session id and date
- sold candies
- quantities
- unit prices
- subtotals
- total sold
Table columns:
CandyQtyUnit PriceSubtotal
- Linting is available with
pnpm lint. - The repo does not currently include automated frontend tests.
- Manual QA is important for session start, order submit, order delete, refresh persistence, and session close flows.