refactor: enhance chat components with type safety and response functionality

- Updated type definitions in ChatWindow and MessageList components for better type safety.
- Improved MessageInput to handle message responses, including a preview feature for replying to messages.
- Enhanced the chat message handling logic to support message references and improve user interaction.
- Refactored notification utility functions to support push notifications and rate limiting for email sending.
- Updated backend schema to accommodate new features related to message responses and notifications.
This commit is contained in:
2025-11-04 20:36:01 -03:00
parent 15374276d5
commit 12db52a8a7
23 changed files with 3195 additions and 503 deletions

View File

@@ -0,0 +1,71 @@
# Script para configurar Push Notifications
# Execute este script após iniciar o Convex (npx convex dev)
Write-Host "🔔 Configurando Push Notifications..." -ForegroundColor Cyan
Write-Host ""
# Verificar se estamos no diretório correto
if (-not (Test-Path "packages/backend")) {
Write-Host "❌ Erro: Execute este script da raiz do projeto" -ForegroundColor Red
exit 1
}
Write-Host "📝 Configurando variáveis de ambiente no Convex..." -ForegroundColor Yellow
Write-Host ""
cd packages/backend
# VAPID Keys geradas
$VAPID_PUBLIC_KEY = "BDerX0lK_hBCLpC7EbuxoJb2EJ7bcCLaHWxkNumVbvrx9w0MmJduHxJOP3WBwBP-SpQGcueMOyHCv7LFK3KnQks"
$VAPID_PRIVATE_KEY = "KWkJLMxCuCPQQiRXIJEt06G4pTdW0FaUN_vMyY02sc4"
$FRONTEND_URL = "http://localhost:5173"
Write-Host "Configurando VAPID_PUBLIC_KEY..." -ForegroundColor Gray
npx convex env set VAPID_PUBLIC_KEY $VAPID_PUBLIC_KEY
Write-Host "Configurando VAPID_PRIVATE_KEY..." -ForegroundColor Gray
npx convex env set VAPID_PRIVATE_KEY $VAPID_PRIVATE_KEY
Write-Host "Configurando FRONTEND_URL..." -ForegroundColor Gray
npx convex env set FRONTEND_URL $FRONTEND_URL
Write-Host ""
Write-Host "✅ Variáveis de ambiente configuradas no Convex!" -ForegroundColor Green
Write-Host ""
cd ../..
# Configurar arquivo .env do frontend
Write-Host "📝 Criando arquivo .env no frontend..." -ForegroundColor Yellow
$envContent = @"
# VAPID Public Key para Push Notifications
VITE_VAPID_PUBLIC_KEY=$VAPID_PUBLIC_KEY
"@
$envPath = "apps/web/.env"
if (Test-Path $envPath) {
Write-Host "⚠️ Arquivo .env já existe. Adicionando VAPID_PUBLIC_KEY..." -ForegroundColor Yellow
# Verificar se já existe a variável
$currentContent = Get-Content $envPath -Raw
if ($currentContent -notmatch "VITE_VAPID_PUBLIC_KEY") {
Add-Content $envPath "`n$envContent"
Write-Host "✅ VAPID_PUBLIC_KEY adicionada ao .env" -ForegroundColor Green
} else {
Write-Host " VITE_VAPID_PUBLIC_KEY já existe no .env" -ForegroundColor Cyan
}
} else {
Set-Content $envPath $envContent
Write-Host "✅ Arquivo .env criado em apps/web/.env" -ForegroundColor Green
}
Write-Host ""
Write-Host "✨ Configuração concluída!" -ForegroundColor Green
Write-Host ""
Write-Host "📋 Próximos passos:" -ForegroundColor Cyan
Write-Host "1. Reinicie o servidor Convex (se estiver rodando)" -ForegroundColor White
Write-Host "2. Reinicie o servidor frontend (se estiver rodando)" -ForegroundColor White
Write-Host "3. Teste as push notifications conforme o guia de testes" -ForegroundColor White
Write-Host ""