diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..4de672b --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +# API base URL (override default production URL if needed) +# VITE_API_BASE_URL=https://api.pennyzo.com/api/v1/general diff --git a/README.md b/README.md index 7842b89..b683ffb 100644 --- a/README.md +++ b/README.md @@ -55,3 +55,41 @@ src/ - `npm run dev` - Runs the app in development mode with Vite - `npm run build` - Builds the app for production - `npm run preview` - Preview the production build locally + +## Backend Integration Guide + +Base URL: `https://api.pennyzo.com/api/v1/general` (configurable via `VITE_API_BASE_URL`) + +- HTTP client: `src/lib/http.ts` (handles JSON, form, and auth header) +- Auth state: `src/context/AuthContext.tsx` (stores JWT token, loads `auth/me`) +- Endpoints: `src/lib/api/*` + - `system.ts`: `/system/health`, `/system/` + - `auth.ts`: `/auth/*` (verify email/resend/login/me/forgot/reset/change) + - `registration.ts`: `/registration/*` (register + rules + health) + - `users.ts`: `/users/*` (profile/company/gst/upgrade/stats/membership-info) + +### UI flows → endpoints + +- Registration modal `WaitlistForm`: `POST /registration/register` + - Maps UI fields to API and enforces rules: + - GST Registered → send `gst_number`, `cin_number=null`, `pan_number=null` + - Non-GST PRIVATE_LIMITED/LLP → send `cin_number`, `pan_number=null` + - Non-GST PARTNERSHIP/PROPRIETORSHIP/SOLE_INDIVIDUAL/OTHERS → send `pan_number`, `cin_number=null` +- Login modal `LoginPage`: `POST /auth/login` as `application/x-www-form-urlencoded` with `username`, `password`; then `GET /auth/me`. +- Forgot password button calls `POST /auth/forgot-password` with the entered email. + +### Types and config + +- Types: `src/types/api.ts` +- Config: set `VITE_API_BASE_URL` in `.env` (see `.env.example`). + +### Quick health check + +``` +curl -X GET "https://api.pennyzo.com/api/v1/general/system/health" +``` + +### Error handling + +- Non-2xx responses are surfaced with `error.message` when provided by backend. +- Invalid token on `auth/me` clears stored token. diff --git a/src/App.tsx b/src/App.tsx index bb7904f..2b34399 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,9 +8,11 @@ import WhyPennyzoSection from './components/WhyPennyzoSection'; import Footer from './components/Footer'; import LiveCounter from './components/LiveCounter'; import WaitlistForm from './components/WaitlistForm'; +import LoginPage from './components/LoginPage'; function App() { const [showWaitlistForm, setShowWaitlistForm] = useState(false); + const [showLogin, setShowLogin] = useState(false); const openWaitlistForm = () => setShowWaitlistForm(true); const closeWaitlistForm = () => setShowWaitlistForm(false); @@ -28,8 +30,8 @@ function App() { {/* Main Content */}