A React-based web application for managing and tracking scam complaints, integrated with LINE messaging platform.
ScamReport is a comprehensive system for:
- 📝 Collecting scam reports via LINE bot
- 👥 Managing complaints (Admin & Journalist dashboards)
- 💬 Viewing conversation history with complaint titles
- 📊 Analyzing and categorizing scam patterns
- 🔐 Role-based access control (Admin, Journalist, Public)
- Node.js 18+
- npm or yarn
- AWS Lambda (deployed)
- PostgreSQL database
# 1. Clone repository
git clone <repository-url>
cd scamreport-frontend
# 2. Install dependencies
npm install
# 3. Start development server
npm run dev
# 4. Open browser
http://localhost:5173scamreport-frontend/
├── docs/ # 📚 Complete documentation
│ ├── lambda/ # Lambda function code
│ │ └── lambda-complete.js ⭐ Production Lambda
│ ├── testing/ # Test scripts
│ │ └── test-all-endpoints.mjs
│ ├── database/ # Database utilities
│ │ └── db-verify-schema.mjs
│ ├── archive/ # Old versions
│ ├── README.md # Main documentation
│ ├── FRONTEND_INTEGRATION.md
│ └── README_LAMBDA.md
├── src/
│ ├── components/ # React components
│ ├── pages/ # Page components
│ │ ├── admin/ # Admin dashboard
│ │ │ ├── AdminHistory.jsx # Conversation history ⭐
│ │ │ └── AdminDashboard.jsx
│ │ ├── journalist/ # Journalist dashboard
│ │ └── public/ # Public pages
│ ├── services/ # API clients
│ │ └── complaintApi.js # Lambda API client ⭐
│ ├── context/ # React context
│ ├── App.jsx # Main app
│ └── main.jsx # Entry point
├── vite.config.js # Vite configuration ⭐
├── package.json
└── README.md # This file
- View all complaints with pagination
- Filter by status, category, urgency
- Assign to journalists
- Track progress
- View LINE chat history
- Display complaint titles in modal
- Message timeline
- User/Admin identification
- Admin: Full access, user management
- Journalist: Assigned complaints, follow-ups
- Public: Submit complaints (via LINE)
- Live complaint status
- Instant message updates
- Dashboard statistics
Create .env file:
# API Configuration
VITE_API_BASE_URL=https://your-lambda-url.lambda-url.us-east-1.on.aws
VITE_REGION=us-east-1
# Development Only - Test Credentials
VITE_TEST_ADMIN_EMAIL=admin@example.com
VITE_TEST_ADMIN_PASSWORD=your-passwordNote: Copy
.env.exampleto.envand fill in your actual values. See.env.examplefor template.
File: vite.config.js
export default defineConfig({
server: {
proxy: {
'^/(table|users|user|connection)': {
target: process.env.VITE_API_BASE_URL || 'https://your-lambda-url.lambda-url.us-east-1.on.aws',
changeOrigin: true,
secure: false
}
}
}
})Note: The actual Lambda URL is configured in
.envfile (not in this config file).
Benefits:
- ✅ No CORS issues in development
- ✅ Simplified API calls
- ✅ Same code for dev and prod
URL: See .env file (not published in documentation for security)
Format:
https://[function-id].lambda-url.[region].on.aws
| Endpoint | Description | Response |
|---|---|---|
GET /table/complaints |
List complaints | { data: [...], pagination: {...} } |
GET /table/complaints/:id |
Get complaint | { data: {...} } |
GET /table/complaints/:id/messages |
Get messages with title | { messages: [...], complaint_title: "..." } |
GET /table/complaints/:id/summary |
Get summary | { summary: {...}, complaint_title: "..." } |
- Complete Documentation - Start here!
- Lambda Deployment - Deploy Lambda
- Frontend Integration - API usage
- Testing Guide - Test scripts
-
Setting Up:
- Read Quick Start
- Configure environment variables
- Set up Vite proxy
-
Development:
- Use API Client in
src/services/complaintApi.js - Follow component structure
- Test with scripts in
docs/testing/
- Use API Client in
-
Deployment:
- Build:
npm run build - Test:
npm run preview - Deploy
dist/folder
- Build:
cd docs/testing
node test-all-endpoints.mjsExpected: ✅ 100% pass rate (14/14 tests)
npm run dev- Navigate to Admin History
- Click a complaint
- Verify:
- ✅ Modal opens
- ✅ Complaint title displays correctly
- ✅ Messages load
- ✅ No console errors
Error:
Access to XMLHttpRequest has been blocked by CORS policy
Solution:
- Check Vite proxy in
vite.config.js - Restart dev server:
npm run dev - Clear browser cache
Symptoms:
- Modal shows "รายละเอียดการสนทนา" instead of actual title
Solution:
- Test Lambda:
cd docs/testing && node test-all-endpoints.mjs - Verify
complaint_titlein response - Redeploy latest Lambda from
docs/lambda/lambda-complete.js
npm run build
# Output: dist/npm run preview
# Open: http://localhost:4173- React 18 - UI framework
- Vite - Build tool
- React Router - Routing
- Axios - HTTP client
- Tailwind CSS - Styling
- AWS Lambda - Serverless API
- PostgreSQL - Database (RDS)
- node-postgres (pg) - Database driver
- AWS RDS - Database hosting
- AWS Lambda - API hosting
- AWS Cognito - Authentication
✅ Working:
- Complaint management
- Service history tracking
- Message history with titles
- Role-based dashboards
- Lambda API integration
- Database connectivity
- Auto deployment via Vercel
URL: https://scam-report.vercel.app
Lambda API: Configured via environment variables (see .env)
Deployment: Automatic via Vercel
- Push to
main→ Auto deploy to production - Create PR → Auto preview deployment
See VERCEL_DEPLOYMENT.md for details.
Status: ✅ Production Ready & Deployed
Last Updated: 2025-11-12