11 KiB
🏍️ Royal Enfield Approval Portal
A modern, enterprise-grade approval and request management system built with React, TypeScript, and Tailwind CSS.
📋 Table of Contents
- Features
- Tech Stack
- Prerequisites
- Installation
- Development
- Project Structure
- Available Scripts
- Configuration
- Contributing
✨ Features
-
🔄 Dual Workflow System
- Custom Request Workflow with user-defined approvers
- Claim Management Workflow (8-step predefined process)
-
📊 Comprehensive Dashboard
- Real-time statistics and metrics
- High-priority alerts
- Recent activity tracking
-
🎯 Request Management
- Create, track, and manage approval requests
- Document upload and management
- Work notes and audit trails
- Spectator and stakeholder management
-
🎨 Modern UI/UX
- Responsive design (mobile, tablet, desktop)
- Dark mode support
- Accessible components (WCAG compliant)
- Royal Enfield brand theming
-
🔔 Notifications
- Real-time toast notifications
- SLA tracking and reminders
- Approval status updates
🛠️ Tech Stack
- Framework: React 18.3+
- Language: TypeScript 5.6+
- Build Tool: Vite 5.4+
- Styling: Tailwind CSS 3.4+
- UI Components: shadcn/ui + Radix UI
- Icons: Lucide React
- Notifications: Sonner
- State Management: React Hooks (useState, useMemo)
📦 Prerequisites
- Node.js: >= 18.0.0
- npm: >= 9.0.0 (or yarn/pnpm)
- Git: Latest version
🚀 Installation
Quick Start Checklist
- Clone the repository
- Install Node.js (>= 18.0.0) and npm (>= 9.0.0)
- Install project dependencies
- Set up environment variables (
.env.local) - Ensure backend API is running (optional for initial setup)
- Start development server
1. Clone the repository
```bash git clone cd Re_Figma_Code ```
2. Install dependencies
```bash npm install ```
3. Set up environment variables
Option A: Automated Setup (Recommended - Unix/Linux/Mac)
Run the setup script to automatically create environment files:
```bash chmod +x setup-env.sh ./setup-env.sh ```
This script will:
- Create
.env.examplewith all required variables - Create
.env.localfor local development - Create
.env.productionwith your production configuration (interactive)
Option B: Manual Setup (Windows or Custom Configuration)
For Windows (PowerShell):
- Create
.env.localfile in the project root:
```powershell
Create .env.local file
New-Item -Path .env.local -ItemType File ```
- Add the following content to
.env.local:
```env
Local Development Environment
VITE_API_BASE_URL=http://localhost:5000/api/v1 VITE_BASE_URL=http://localhost:5000
Okta Authentication Configuration
VITE_OKTA_DOMAIN=your-okta-domain.okta.com VITE_OKTA_CLIENT_ID=your-okta-client-id
Push Notifications (Web Push / VAPID)
VITE_PUBLIC_VAPID_KEY=your-vapid-public-key ```
For Production:
Create .env.production with production values:
```env
Production Environment
VITE_API_BASE_URL=https://your-backend-url.com/api/v1 VITE_BASE_URL=https://your-backend-url.com
Okta Authentication Configuration
VITE_OKTA_DOMAIN=https://your-org.okta.com VITE_OKTA_CLIENT_ID=your-production-client-id
Push Notifications (Web Push / VAPID)
VITE_PUBLIC_VAPID_KEY=your-production-vapid-key ```
Environment Variables Reference
| Variable | Description | Required | Default |
|---|---|---|---|
VITE_API_BASE_URL |
Backend API base URL (with /api/v1) |
Yes | http://localhost:5000/api/v1 |
VITE_BASE_URL |
Base URL for direct file access (without /api/v1) |
Yes | http://localhost:5000 |
VITE_OKTA_DOMAIN |
Okta domain for SSO authentication | Yes* | - |
VITE_OKTA_CLIENT_ID |
Okta client ID for authentication | Yes* | - |
VITE_PUBLIC_VAPID_KEY |
Public VAPID key for web push notifications | No | - |
*Required if using Okta authentication
4. Verify setup
Check that all required files exist:
```bash
Check environment file exists
ls -la .env.local # Unix/Linux/Mac
or
Test-Path .env.local # Windows PowerShell ```
💻 Development
Prerequisites
Before starting development, ensure:
-
Backend API is running:
- The backend should be running on
http://localhost:5000(or your configured URL) - Backend API should be accessible at
/api/v1endpoint - CORS should be configured to allow your frontend origin
- The backend should be running on
-
Environment variables are configured:
.env.localfile exists and contains valid configuration- All required variables are set (see Environment Variables Reference)
-
Node.js and npm versions:
- Verify Node.js version:
node --version(should be >= 18.0.0) - Verify npm version:
npm --version(should be >= 9.0.0)
- Verify Node.js version:
Start development server
```bash npm run dev ```
The application will open at http://localhost:5173 (Vite default port)
Note: If port 5173 is in use, Vite will automatically use the next available port.
Build for production
```bash npm run build ```
Preview production build
```bash npm run preview ```
📁 Project Structure
``` Re_Figma_Code/ ├── src/ │ ├── components/ │ │ ├── ui/ # Reusable UI components (40+) │ │ ├── modals/ # Modal components │ │ ├── figma/ # Figma-specific components │ │ ├── Dashboard.tsx │ │ ├── Layout.tsx │ │ ├── ClaimManagementWizard.tsx │ │ ├── NewRequestWizard.tsx │ │ ├── RequestDetail.tsx │ │ ├── ClaimManagementDetail.tsx │ │ ├── MyRequests.tsx │ │ └── ... │ ├── utils/ │ │ ├── customRequestDatabase.ts │ │ ├── claimManagementDatabase.ts │ │ └── dealerDatabase.ts │ ├── styles/ │ │ └── globals.css │ ├── types/ │ │ └── index.ts # TypeScript type definitions │ ├── App.tsx │ └── main.tsx ├── public/ # Static assets ├── .vscode/ # VS Code settings ├── index.html ├── vite.config.ts ├── tsconfig.json ├── tailwind.config.ts ├── postcss.config.js ├── eslint.config.js ├── .prettierrc ├── .gitignore ├── package.json └── README.md ```
📜 Available Scripts
| Script | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run preview |
Preview production build |
npm run lint |
Run ESLint |
npm run lint:fix |
Fix ESLint errors |
npm run format |
Format code with Prettier |
npm run type-check |
Check TypeScript types |
⚙️ Configuration
TypeScript Path Aliases
The project uses path aliases for cleaner imports:
```typescript import { Button } from '@/components/ui/button'; import { getDealerInfo } from '@/utils/dealerDatabase'; ```
Path aliases are configured in:
tsconfig.json- TypeScript path mappingvite.config.ts- Vite resolver configuration
Tailwind CSS Customization
Custom Royal Enfield colors are defined in tailwind.config.ts:
```typescript colors: { 're-green': '#2d4a3e', 're-gold': '#c9b037', 're-dark': '#1a1a1a', 're-light-green': '#8a9b8e', } ```
Environment Variables
All environment variables must be prefixed with VITE_ to be accessible in the app:
```typescript // Access environment variables const apiUrl = import.meta.env.VITE_API_BASE_URL; const baseUrl = import.meta.env.VITE_BASE_URL; const oktaDomain = import.meta.env.VITE_OKTA_DOMAIN; ```
Important Notes:
- Environment variables are embedded at build time, not runtime
- Changes to
.envfiles require restarting the dev server .env.localtakes precedence over.envin development.env.productionis used when building for production (npm run build)
Backend Integration
To connect to the backend API:
-
Update API base URL in
.env.local: ```env VITE_API_BASE_URL=http://localhost:5000/api/v1 ``` -
Configure CORS in your backend to allow your frontend origin
-
Authentication:
- Configure Okta credentials in environment variables
- Ensure backend validates JWT tokens from Okta
-
API Services:
- API services are located in
src/services/ - All API calls use
axiosconfigured with base URL from environment
- API services are located in
Development vs Production
- Development: Uses
.env.local(git-ignored) - Production: Uses
.env.productionor environment variables set in deployment platform - Never commit:
.env.localor.env.production(use.env.exampleas template)
🔧 Troubleshooting
Common Issues
Port Already in Use
If the default port (5173) is in use:
```bash
Option 1: Kill the process using the port
Windows
netstat -ano | findstr :5173 taskkill /PID /F
Unix/Linux/Mac
lsof -ti:5173 | xargs kill -9
Option 2: Use a different port
npm run dev -- --port 3000 ```
Environment Variables Not Loading
- Ensure variables are prefixed with
VITE_ - Restart the dev server after changing
.envfiles - Check that
.env.localexists in the project root - Verify no typos in variable names
Backend Connection Issues
- Verify backend is running on the configured port
- Check
VITE_API_BASE_URLin.env.localmatches backend URL - Ensure CORS is configured in backend to allow frontend origin
- Check browser console for detailed error messages
Build Errors
```bash
Clear cache and rebuild
rm -rf node_modules/.vite npm run build
Check for TypeScript errors
npm run type-check ```
Getting Help
- Check browser console for errors
- Verify all environment variables are set correctly
- Ensure Node.js and npm versions meet requirements
- Review backend logs for API-related issues
🧪 Testing (Future Enhancement)
Add testing framework:
```bash npm install -D vitest @testing-library/react @testing-library/jest-dom ```
🤝 Contributing
- Follow the existing code style
- Run
npm run lint:fixbefore committing - Run
npm run type-checkto ensure type safety - Write meaningful commit messages
📝 License
Private - Royal Enfield Internal Use Only
👥 Team
Built by the Royal Enfield Development Team
For support or questions, contact the development team.