feat: Complete Sprints 3 & 4 - Email, Reschedule, OCR, Upload, Contact Forms

Sprint 3 - Crisis y Agenda (100%):
- Implement SMTP email service with nodemailer
- Create email templates (reschedule, daily agenda, course inquiry)
- Add appointment reschedule functionality with modal
- Add Google Calendar updateEvent function
- Create scheduled job for daily agenda email at 10 PM
- Add manual trigger endpoint for testing

Sprint 4 - Pagos y Roles (100%):
- Add Payment proof upload with OCR (tesseract.js, pdf-parse)
- Extract data from proofs (amount, date, reference, sender, bank)
- Create PaymentUpload component with drag & drop
- Add course contact form to /cursos page
- Update Services button to navigate to /servicios
- Add Reschedule button to Assistant and Therapist dashboards
- Add PaymentUpload component to Assistant dashboard
- Add eventId field to Appointment model
- Add OCR-extracted fields to Payment model
- Update Prisma schema and generate client
- Create API endpoints for reschedule, upload-proof, courses contact
- Create manual trigger endpoint for daily agenda job
- Initialize daily agenda job in layout.tsx

Dependencies added:
- nodemailer, node-cron, tesseract.js, sharp, pdf-parse, @types/nodemailer

Files created/modified:
- src/infrastructure/email/smtp.ts
- src/lib/email/templates/*
- src/jobs/send-daily-agenda.ts
- src/app/api/calendar/reschedule/route.ts
- src/app/api/payments/upload-proof/route.ts
- src/app/api/contact/courses/route.ts
- src/app/api/jobs/trigger-agenda/route.ts
- src/components/dashboard/RescheduleModal.tsx
- src/components/dashboard/PaymentUpload.tsx
- src/components/forms/CourseContactForm.tsx
- src/app/dashboard/asistente/page.tsx (updated)
- src/app/dashboard/terapeuta/page.tsx (updated)
- src/app/cursos/page.tsx (updated)
- src/components/layout/Services.tsx (updated)
- src/infrastructure/external/calendar.ts (updated)
- src/app/layout.tsx (updated)
- prisma/schema.prisma (updated)
- src/lib/validations.ts (updated)
- src/lib/env.ts (updated)

Tests:
- TypeScript typecheck: No errors
- ESLint: Only warnings (img tags, react-hooks)
- Production build: Successful

Documentation:
- Updated CHANGELOG.md with Sprint 3/4 changes
- Updated PROGRESS.md with 100% completion status
- Updated TASKS.md with completed tasks
This commit is contained in:
Marco Gallegos
2026-02-02 20:45:32 -06:00
parent 5f651f2a9d
commit 423f96022a
94 changed files with 17763 additions and 50 deletions

93
.env.example Normal file
View File

@@ -0,0 +1,93 @@
# Environment Variables - Gloria Platform
# Copy this file to .env and fill in your actual values
# NEVER commit .env to version control
# ============================================
# Application
# ============================================
NODE_ENV=development
APP_URL=http://localhost:3000
APP_NAME=Gloria Platform
# ============================================
# Database (SQLite)
# ============================================
DATABASE_URL="file:./dev.db"
# ============================================
# Redis (Cache & Sessions)
# ============================================
REDIS_URL=redis://localhost:6379
REDIS_PASSWORD=
# ============================================
# Next.js
# ============================================
NEXTAUTH_SECRET=your-secret-key-here-change-this-in-production
NEXTAUTH_URL=http://localhost:3000
# ============================================
# Email (SMTP)
# ============================================
# SMTP server configuration for sending emails
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
SMTP_FROM_NAME=Gloria Niño - Terapia
SMTP_FROM_EMAIL=no-reply@glorianino.com
# Email recipients
ADMIN_EMAIL=admin@glorianino.com
# ============================================
# Evolution API (WhatsApp)
# ============================================
EVOLUTION_API_URL=https://api.evolution-api.com
EVOLUTION_API_KEY=your-evolution-api-key-here
EVOLUTION_INSTANCE_ID=gloria-instance
# ============================================
# Google Calendar
# ============================================
GOOGLE_CALENDAR_ID=primary
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://localhost:3000/api/auth/callback/google
# ============================================
# File Uploads
# ============================================
MAX_FILE_SIZE=5242880
ALLOWED_FILE_TYPES=image/jpeg,image/png,application/pdf
# ============================================
# Security
# ============================================
# Session expiration in seconds (1 hour = 3600)
SESSION_MAX_AGE=3600
# Rate limiting
RATE_LIMIT_MAX=100
RATE_LIMIT_WINDOW=900000
# ============================================
# Audio Notes
# ============================================
AUDIO_MAX_DURATION=300
AUDIO_EXPIRY_DAYS=7
# ============================================
# WhatsApp Messages
# ============================================
WHATSAPP_PHONE_NUMBER=+57XXXXXXXXXX
# ============================================
# Development
# ============================================
# Enable debug logging
DEBUG=false
# Enable Prisma Studio
PRISMA_STUDIO_ENABLED=true