elevenlabs-webhook-nodejs 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +27 -0
- package/.dockerignore +6 -0
- package/.env.example +43 -0
- package/BEFORE-PRODUCTION.md +32 -0
- package/Dockerfile +23 -0
- package/SYSTEM_OVERVIEW.md +942 -0
- package/SYSTEM_STATUS.md +332 -0
- package/backup_script/main.py +146 -0
- package/baileys/.dockerignore +7 -0
- package/baileys/Dockerfile +13 -0
- package/baileys/README.md +412 -0
- package/baileys/index.js +499 -0
- package/baileys/package-lock.json +2532 -0
- package/baileys/package.json +25 -0
- package/baileys/server.js +96 -0
- package/baileys/src/config.js +55 -0
- package/baileys/src/middleware/api-key.js +16 -0
- package/baileys/src/routes/accounts.js +51 -0
- package/baileys/src/routes/chats.js +103 -0
- package/baileys/src/routes/webhooks.js +34 -0
- package/baileys/src/services/account-store.js +259 -0
- package/baileys/src/services/webhook-dispatcher.js +161 -0
- package/baileys/src/services/worker-manager.js +597 -0
- package/baileys/src/utils/jid.js +79 -0
- package/baileys/src/utils/logger.js +16 -0
- package/baileys/src/utils/use-mongodb-auth-state.js +122 -0
- package/baileys/worker.js +721 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +84 -0
- package/dist/app.js.map +1 -0
- package/dist/config/agentPrompts.json +19 -0
- package/dist/config/database.d.ts +1 -0
- package/dist/config/database.js +26 -0
- package/dist/config/database.js.map +1 -0
- package/dist/config/env.d.ts +41 -0
- package/dist/config/env.js +81 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +73 -0
- package/dist/config/index.js.map +1 -0
- package/dist/controllers/webhook.controller.d.ts +10 -0
- package/dist/controllers/webhook.controller.js +128 -0
- package/dist/controllers/webhook.controller.js.map +1 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +13 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/hooks/webhookValidator.d.ts +2 -0
- package/dist/hooks/webhookValidator.js +47 -0
- package/dist/hooks/webhookValidator.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/001_session-architecture.d.ts +3 -0
- package/dist/migrations/001_session-architecture.js +119 -0
- package/dist/migrations/001_session-architecture.js.map +1 -0
- package/dist/migrations/002_agent-ref.d.ts +3 -0
- package/dist/migrations/002_agent-ref.js +55 -0
- package/dist/migrations/002_agent-ref.js.map +1 -0
- package/dist/migrations/003_shift-schedule.d.ts +3 -0
- package/dist/migrations/003_shift-schedule.js +48 -0
- package/dist/migrations/003_shift-schedule.js.map +1 -0
- package/dist/migrations/004_invert-shift-to-clinic-hours.d.ts +3 -0
- package/dist/migrations/004_invert-shift-to-clinic-hours.js +27 -0
- package/dist/migrations/004_invert-shift-to-clinic-hours.js.map +1 -0
- package/dist/migrations/005_composite-baileys-chat-ids.d.ts +3 -0
- package/dist/migrations/005_composite-baileys-chat-ids.js +47 -0
- package/dist/migrations/005_composite-baileys-chat-ids.js.map +1 -0
- package/dist/migrations/migration.model.d.ts +18 -0
- package/dist/migrations/migration.model.js +45 -0
- package/dist/migrations/migration.model.js.map +1 -0
- package/dist/migrations/migration.routes.d.ts +2 -0
- package/dist/migrations/migration.routes.js +37 -0
- package/dist/migrations/migration.routes.js.map +1 -0
- package/dist/migrations/migration.runner.d.ts +19 -0
- package/dist/migrations/migration.runner.js +74 -0
- package/dist/migrations/migration.runner.js.map +1 -0
- package/dist/models/ConversationClaim.d.ts +13 -0
- package/dist/models/ConversationClaim.js +44 -0
- package/dist/models/ConversationClaim.js.map +1 -0
- package/dist/models/ConversationEvaluation.d.ts +23 -0
- package/dist/models/ConversationEvaluation.js +92 -0
- package/dist/models/ConversationEvaluation.js.map +1 -0
- package/dist/models/Summary.d.ts +37 -0
- package/dist/models/Summary.js +78 -0
- package/dist/models/Summary.js.map +1 -0
- package/dist/models/Transcription.d.ts +34 -0
- package/dist/models/Transcription.js +71 -0
- package/dist/models/Transcription.js.map +1 -0
- package/dist/models/WhatsAppRecipient.d.ts +23 -0
- package/dist/models/WhatsAppRecipient.js +53 -0
- package/dist/models/WhatsAppRecipient.js.map +1 -0
- package/dist/modules/admin/admin.routes.d.ts +2 -0
- package/dist/modules/admin/admin.routes.js +1966 -0
- package/dist/modules/admin/admin.routes.js.map +1 -0
- package/dist/modules/admin/elevenlabs-test-chat.routes.d.ts +2 -0
- package/dist/modules/admin/elevenlabs-test-chat.routes.js +158 -0
- package/dist/modules/admin/elevenlabs-test-chat.routes.js.map +1 -0
- package/dist/modules/admin/whatsapp-test-chat.routes.d.ts +2 -0
- package/dist/modules/admin/whatsapp-test-chat.routes.js +204 -0
- package/dist/modules/admin/whatsapp-test-chat.routes.js.map +1 -0
- package/dist/modules/agents/agent.model.d.ts +38 -0
- package/dist/modules/agents/agent.model.js +92 -0
- package/dist/modules/agents/agent.model.js.map +1 -0
- package/dist/modules/agents/agent.routes.d.ts +2 -0
- package/dist/modules/agents/agent.routes.js +61 -0
- package/dist/modules/agents/agent.routes.js.map +1 -0
- package/dist/modules/appointment-validation/appointment-validation.model.d.ts +76 -0
- package/dist/modules/appointment-validation/appointment-validation.model.js +118 -0
- package/dist/modules/appointment-validation/appointment-validation.model.js.map +1 -0
- package/dist/modules/appointment-validation/appointment-validation.routes.d.ts +2 -0
- package/dist/modules/appointment-validation/appointment-validation.routes.js +202 -0
- package/dist/modules/appointment-validation/appointment-validation.routes.js.map +1 -0
- package/dist/modules/appointment-validation/appointment-validation.service.d.ts +53 -0
- package/dist/modules/appointment-validation/appointment-validation.service.js +827 -0
- package/dist/modules/appointment-validation/appointment-validation.service.js.map +1 -0
- package/dist/modules/auth/auth.model.d.ts +17 -0
- package/dist/modules/auth/auth.model.js +64 -0
- package/dist/modules/auth/auth.model.js.map +1 -0
- package/dist/modules/auth/auth.routes.d.ts +2 -0
- package/dist/modules/auth/auth.routes.js +202 -0
- package/dist/modules/auth/auth.routes.js.map +1 -0
- package/dist/modules/auth/auth.service.d.ts +28 -0
- package/dist/modules/auth/auth.service.js +183 -0
- package/dist/modules/auth/auth.service.js.map +1 -0
- package/dist/modules/auth/refresh-token.model.d.ts +13 -0
- package/dist/modules/auth/refresh-token.model.js +52 -0
- package/dist/modules/auth/refresh-token.model.js.map +1 -0
- package/dist/modules/billing/billing-alert.model.d.ts +16 -0
- package/dist/modules/billing/billing-alert.model.js +47 -0
- package/dist/modules/billing/billing-alert.model.js.map +1 -0
- package/dist/modules/billing/billing-period-snapshot.model.d.ts +35 -0
- package/dist/modules/billing/billing-period-snapshot.model.js +68 -0
- package/dist/modules/billing/billing-period-snapshot.model.js.map +1 -0
- package/dist/modules/billing/billing.model.d.ts +18 -0
- package/dist/modules/billing/billing.model.js +62 -0
- package/dist/modules/billing/billing.model.js.map +1 -0
- package/dist/modules/billing/billing.routes.d.ts +2 -0
- package/dist/modules/billing/billing.routes.js +63 -0
- package/dist/modules/billing/billing.routes.js.map +1 -0
- package/dist/modules/billing/billing.service.d.ts +69 -0
- package/dist/modules/billing/billing.service.js +498 -0
- package/dist/modules/billing/billing.service.js.map +1 -0
- package/dist/modules/billing/payment.model.d.ts +24 -0
- package/dist/modules/billing/payment.model.js +57 -0
- package/dist/modules/billing/payment.model.js.map +1 -0
- package/dist/modules/calls/call.model.d.ts +41 -0
- package/dist/modules/calls/call.model.js +97 -0
- package/dist/modules/calls/call.model.js.map +1 -0
- package/dist/modules/calls/call.routes.d.ts +2 -0
- package/dist/modules/calls/call.routes.js +103 -0
- package/dist/modules/calls/call.routes.js.map +1 -0
- package/dist/modules/campaigns/campaign.model.d.ts +45 -0
- package/dist/modules/campaigns/campaign.model.js +98 -0
- package/dist/modules/campaigns/campaign.model.js.map +1 -0
- package/dist/modules/campaigns/campaign.routes.d.ts +2 -0
- package/dist/modules/campaigns/campaign.routes.js +323 -0
- package/dist/modules/campaigns/campaign.routes.js.map +1 -0
- package/dist/modules/campaigns/campaign.service.d.ts +11 -0
- package/dist/modules/campaigns/campaign.service.js +86 -0
- package/dist/modules/campaigns/campaign.service.js.map +1 -0
- package/dist/modules/google-calendar/google-calendar.routes.d.ts +2 -0
- package/dist/modules/google-calendar/google-calendar.routes.js +32 -0
- package/dist/modules/google-calendar/google-calendar.routes.js.map +1 -0
- package/dist/modules/inbound-call/inbound-call-config.model.d.ts +20 -0
- package/dist/modules/inbound-call/inbound-call-config.model.js +68 -0
- package/dist/modules/inbound-call/inbound-call-config.model.js.map +1 -0
- package/dist/modules/inbound-call/inbound-call.routes.d.ts +2 -0
- package/dist/modules/inbound-call/inbound-call.routes.js +243 -0
- package/dist/modules/inbound-call/inbound-call.routes.js.map +1 -0
- package/dist/modules/leads/lead.model.d.ts +24 -0
- package/dist/modules/leads/lead.model.js +54 -0
- package/dist/modules/leads/lead.model.js.map +1 -0
- package/dist/modules/leads/lead.routes.d.ts +2 -0
- package/dist/modules/leads/lead.routes.js +201 -0
- package/dist/modules/leads/lead.routes.js.map +1 -0
- package/dist/modules/plans/plan.model.d.ts +25 -0
- package/dist/modules/plans/plan.model.js +59 -0
- package/dist/modules/plans/plan.model.js.map +1 -0
- package/dist/modules/surveys/survey.model.d.ts +30 -0
- package/dist/modules/surveys/survey.model.js +75 -0
- package/dist/modules/surveys/survey.model.js.map +1 -0
- package/dist/modules/surveys/survey.routes.d.ts +2 -0
- package/dist/modules/surveys/survey.routes.js +153 -0
- package/dist/modules/surveys/survey.routes.js.map +1 -0
- package/dist/modules/tenants/tenant.model.d.ts +86 -0
- package/dist/modules/tenants/tenant.model.js +127 -0
- package/dist/modules/tenants/tenant.model.js.map +1 -0
- package/dist/modules/tenants/tenant.routes.d.ts +2 -0
- package/dist/modules/tenants/tenant.routes.js +65 -0
- package/dist/modules/tenants/tenant.routes.js.map +1 -0
- package/dist/modules/users/user.routes.d.ts +2 -0
- package/dist/modules/users/user.routes.js +106 -0
- package/dist/modules/users/user.routes.js.map +1 -0
- package/dist/modules/webhooks/elevenlabs-tool.routes.d.ts +20 -0
- package/dist/modules/webhooks/elevenlabs-tool.routes.js +85 -0
- package/dist/modules/webhooks/elevenlabs-tool.routes.js.map +1 -0
- package/dist/modules/webhooks/elevenlabs-tool.service.d.ts +11 -0
- package/dist/modules/webhooks/elevenlabs-tool.service.js +360 -0
- package/dist/modules/webhooks/elevenlabs-tool.service.js.map +1 -0
- package/dist/modules/webhooks/elevenlabs.routes.d.ts +2 -0
- package/dist/modules/webhooks/elevenlabs.routes.js +34 -0
- package/dist/modules/webhooks/elevenlabs.routes.js.map +1 -0
- package/dist/modules/webhooks/elevenlabs.service.d.ts +6 -0
- package/dist/modules/webhooks/elevenlabs.service.js +512 -0
- package/dist/modules/webhooks/elevenlabs.service.js.map +1 -0
- package/dist/modules/webhooks/unipile.routes.d.ts +2 -0
- package/dist/modules/webhooks/unipile.routes.js +780 -0
- package/dist/modules/webhooks/unipile.routes.js.map +1 -0
- package/dist/modules/whatsapp/appointment.model.d.ts +27 -0
- package/dist/modules/whatsapp/appointment.model.js +58 -0
- package/dist/modules/whatsapp/appointment.model.js.map +1 -0
- package/dist/modules/whatsapp/operator-request.model.d.ts +29 -0
- package/dist/modules/whatsapp/operator-request.model.js +65 -0
- package/dist/modules/whatsapp/operator-request.model.js.map +1 -0
- package/dist/modules/whatsapp/stt-usage.model.d.ts +16 -0
- package/dist/modules/whatsapp/stt-usage.model.js +53 -0
- package/dist/modules/whatsapp/stt-usage.model.js.map +1 -0
- package/dist/modules/whatsapp/whatsapp-chat.model.d.ts +23 -0
- package/dist/modules/whatsapp/whatsapp-chat.model.js +55 -0
- package/dist/modules/whatsapp/whatsapp-chat.model.js.map +1 -0
- package/dist/modules/whatsapp/whatsapp-contact-profile.model.d.ts +23 -0
- package/dist/modules/whatsapp/whatsapp-contact-profile.model.js +54 -0
- package/dist/modules/whatsapp/whatsapp-contact-profile.model.js.map +1 -0
- package/dist/modules/whatsapp/whatsapp-message.model.d.ts +30 -0
- package/dist/modules/whatsapp/whatsapp-message.model.js +52 -0
- package/dist/modules/whatsapp/whatsapp-message.model.js.map +1 -0
- package/dist/modules/whatsapp/whatsapp-session.model.d.ts +33 -0
- package/dist/modules/whatsapp/whatsapp-session.model.js +65 -0
- package/dist/modules/whatsapp/whatsapp-session.model.js.map +1 -0
- package/dist/modules/whatsapp/whatsapp.routes.d.ts +2 -0
- package/dist/modules/whatsapp/whatsapp.routes.js +1237 -0
- package/dist/modules/whatsapp/whatsapp.routes.js.map +1 -0
- package/dist/plugins/cors.d.ts +3 -0
- package/dist/plugins/cors.js +11 -0
- package/dist/plugins/cors.js.map +1 -0
- package/dist/plugins/jwt.d.ts +3 -0
- package/dist/plugins/jwt.js +22 -0
- package/dist/plugins/jwt.js.map +1 -0
- package/dist/plugins/rawBody.d.ts +3 -0
- package/dist/plugins/rawBody.js +16 -0
- package/dist/plugins/rawBody.js.map +1 -0
- package/dist/plugins/rbac.d.ts +5 -0
- package/dist/plugins/rbac.js +29 -0
- package/dist/plugins/rbac.js.map +1 -0
- package/dist/routes/admin.routes.d.ts +2 -0
- package/dist/routes/admin.routes.js +169 -0
- package/dist/routes/admin.routes.js.map +1 -0
- package/dist/routes/health.routes.d.ts +2 -0
- package/dist/routes/health.routes.js +16 -0
- package/dist/routes/health.routes.js.map +1 -0
- package/dist/routes/webhook.routes.d.ts +2 -0
- package/dist/routes/webhook.routes.js +17 -0
- package/dist/routes/webhook.routes.js.map +1 -0
- package/dist/services/ai/base.ai.d.ts +19 -0
- package/dist/services/ai/base.ai.js +120 -0
- package/dist/services/ai/base.ai.js.map +1 -0
- package/dist/services/ai/gemini.service.d.ts +11 -0
- package/dist/services/ai/gemini.service.js +43 -0
- package/dist/services/ai/gemini.service.js.map +1 -0
- package/dist/services/ai/index.d.ts +2 -0
- package/dist/services/ai/index.js +26 -0
- package/dist/services/ai/index.js.map +1 -0
- package/dist/services/ai/openai.service.d.ts +11 -0
- package/dist/services/ai/openai.service.js +50 -0
- package/dist/services/ai/openai.service.js.map +1 -0
- package/dist/services/elevenlabs.service.d.ts +52 -0
- package/dist/services/elevenlabs.service.js +447 -0
- package/dist/services/elevenlabs.service.js.map +1 -0
- package/dist/services/google-calendar.service.d.ts +60 -0
- package/dist/services/google-calendar.service.js +494 -0
- package/dist/services/google-calendar.service.js.map +1 -0
- package/dist/services/inbound-call-schedule.service.d.ts +11 -0
- package/dist/services/inbound-call-schedule.service.js +162 -0
- package/dist/services/inbound-call-schedule.service.js.map +1 -0
- package/dist/services/netgsm.service.d.ts +41 -0
- package/dist/services/netgsm.service.js +89 -0
- package/dist/services/netgsm.service.js.map +1 -0
- package/dist/services/unipile.service.d.ts +41 -0
- package/dist/services/unipile.service.js +149 -0
- package/dist/services/unipile.service.js.map +1 -0
- package/dist/services/whatsapp-agent.service.d.ts +139 -0
- package/dist/services/whatsapp-agent.service.js +2055 -0
- package/dist/services/whatsapp-agent.service.js.map +1 -0
- package/dist/services/whatsapp.service.d.ts +26 -0
- package/dist/services/whatsapp.service.js +206 -0
- package/dist/services/whatsapp.service.js.map +1 -0
- package/dist/templates/index.d.ts +39 -0
- package/dist/templates/index.js +35 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/receptionist.d.ts +2 -0
- package/dist/templates/receptionist.js +39 -0
- package/dist/templates/receptionist.js.map +1 -0
- package/dist/templates/survey.d.ts +2 -0
- package/dist/templates/survey.js +41 -0
- package/dist/templates/survey.js.map +1 -0
- package/dist/types/index.d.ts +173 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.js +105 -0
- package/dist/utils/logger.js.map +1 -0
- package/docker-compose.nestjs.yml +89 -0
- package/docker-compose.yml +78 -0
- package/docs/AI_AGENT_ENHANCEMENT_PLAN.md +164 -0
- package/docs/API.md +1193 -0
- package/docs/API_ENDPOINTS.md +344 -0
- package/docs/ARCHITECTURE.md +305 -0
- package/docs/AUTH_API.md +252 -0
- package/docs/BILLING_SMS_ALERTS.md +94 -0
- package/docs/CHAT_ASSIGNMENT_SYSTEM.md +118 -0
- package/docs/CLIENT_TOOLS_AND_FEATURES.md +337 -0
- package/docs/ELEVENLABS_WEBHOOK_TOOLS.md +644 -0
- package/docs/FRONTEND_CHECKLIST.md +227 -0
- package/docs/IMPLEMENTATION_STATUS.md +470 -0
- package/docs/MIGRATION_GUIDE.md +96 -0
- package/docs/MISSINGS_REPORT.md +507 -0
- package/docs/NESTJS_MIGRATION_REFERENCE.md +5136 -0
- package/docs/PROJECT_DESCRIPTION.md +1038 -0
- package/docs/SCALING.md +148 -0
- package/docs/SESSION_SUMMARY_2026_03_17.md +135 -0
- package/docs/WHATSAPP_AGENT.md +1086 -0
- package/docs/architecture/00-SYSTEM-OVERVIEW.md +318 -0
- package/docs/architecture/01-DATABASE-SCHEMA.md +2564 -0
- package/docs/architecture/02-AUTHENTICATION.md +1040 -0
- package/docs/architecture/03-MULTI-CLINIC.md +742 -0
- package/docs/architecture/04-WHATSAPP-AGENT.md +608 -0
- package/docs/architecture/05-OPERATOR-WORKFLOW.md +444 -0
- package/docs/architecture/06-BAILEYS-MICROSERVICE.md +616 -0
- package/docs/architecture/07-APPOINTMENTS.md +849 -0
- package/docs/architecture/08-VOICE-CALLS.md +470 -0
- package/docs/architecture/09-OUTBOUND-CAMPAIGNS.md +542 -0
- package/docs/architecture/10-CLIENT-TOOLS.md +665 -0
- package/docs/architecture/11-BILLING.md +458 -0
- package/docs/architecture/12-SECURITY.md +216 -0
- package/docs/architecture/13-LOGGING-AUDIT.md +549 -0
- package/docs/architecture/14-META-BUSINESS-API.md +454 -0
- package/docs/architecture/15-AI-MODULE.md +479 -0
- package/docs/architecture/16-BACKGROUND-JOBS.md +469 -0
- package/docs/architecture/17-REALTIME-LIVECHAT.md +447 -0
- package/docs/architecture/18-FILE-STORAGE.md +410 -0
- package/docs/architecture/19-PATIENTS.md +1034 -0
- package/docs/architecture/20-TREATMENTS-AND-PLANS.md +774 -0
- package/docs/architecture/21-BEFORE-AFTER-PHOTOS.md +519 -0
- package/docs/database.md +456 -0
- package/docs/ornek-randevu-onay.csv +3 -0
- package/ecosystem.config.js +16 -0
- package/elevenlabs-convai-api-reference.md +1171 -0
- package/frontend/.dockerignore +2 -0
- package/frontend/Dockerfile +24 -0
- package/frontend/README.md +75 -0
- package/frontend/components.json +25 -0
- package/frontend/eslint.config.js +23 -0
- package/frontend/index.html +13 -0
- package/frontend/nginx.conf +37 -0
- package/frontend/package-lock.json +8709 -0
- package/frontend/package.json +71 -0
- package/frontend/public/favicon.svg +1 -0
- package/frontend/public/icons.svg +24 -0
- package/frontend/src/App.tsx +125 -0
- package/frontend/src/components/error-boundary.tsx +50 -0
- package/frontend/src/components/shared/activity-timeline.tsx +66 -0
- package/frontend/src/components/shared/appointment-calendar.css +80 -0
- package/frontend/src/components/shared/appointment-calendar.tsx +245 -0
- package/frontend/src/components/shared/chat-bubble.tsx +72 -0
- package/frontend/src/components/shared/combobox.tsx +119 -0
- package/frontend/src/components/shared/confirm-dialog.tsx +57 -0
- package/frontend/src/components/shared/data-table-pagination.tsx +97 -0
- package/frontend/src/components/shared/data-table-toolbar.tsx +39 -0
- package/frontend/src/components/shared/empty-state.tsx +27 -0
- package/frontend/src/components/shared/file-upload.tsx +140 -0
- package/frontend/src/components/shared/index.ts +20 -0
- package/frontend/src/components/shared/language-switcher.tsx +29 -0
- package/frontend/src/components/shared/notification-dropdown.tsx +115 -0
- package/frontend/src/components/shared/page-header.tsx +23 -0
- package/frontend/src/components/shared/stat-card.tsx +37 -0
- package/frontend/src/components/shared/status-badge.tsx +70 -0
- package/frontend/src/components/shared/status-dot.tsx +43 -0
- package/frontend/src/components/ui/alert-dialog.tsx +187 -0
- package/frontend/src/components/ui/alert.tsx +76 -0
- package/frontend/src/components/ui/avatar.tsx +109 -0
- package/frontend/src/components/ui/badge.tsx +52 -0
- package/frontend/src/components/ui/breadcrumb.tsx +125 -0
- package/frontend/src/components/ui/button.tsx +60 -0
- package/frontend/src/components/ui/calendar.tsx +219 -0
- package/frontend/src/components/ui/card.tsx +103 -0
- package/frontend/src/components/ui/chart.tsx +371 -0
- package/frontend/src/components/ui/checkbox.tsx +29 -0
- package/frontend/src/components/ui/collapsible.tsx +19 -0
- package/frontend/src/components/ui/command.tsx +194 -0
- package/frontend/src/components/ui/dialog.tsx +158 -0
- package/frontend/src/components/ui/dropdown-menu.tsx +268 -0
- package/frontend/src/components/ui/input-group.tsx +156 -0
- package/frontend/src/components/ui/input.tsx +20 -0
- package/frontend/src/components/ui/label.tsx +20 -0
- package/frontend/src/components/ui/pagination.tsx +130 -0
- package/frontend/src/components/ui/popover.tsx +90 -0
- package/frontend/src/components/ui/progress.tsx +83 -0
- package/frontend/src/components/ui/radio-group.tsx +36 -0
- package/frontend/src/components/ui/scroll-area.tsx +54 -0
- package/frontend/src/components/ui/select.tsx +199 -0
- package/frontend/src/components/ui/separator.tsx +23 -0
- package/frontend/src/components/ui/sheet.tsx +138 -0
- package/frontend/src/components/ui/sidebar.tsx +723 -0
- package/frontend/src/components/ui/skeleton.tsx +13 -0
- package/frontend/src/components/ui/sonner.tsx +47 -0
- package/frontend/src/components/ui/switch.tsx +30 -0
- package/frontend/src/components/ui/table.tsx +114 -0
- package/frontend/src/components/ui/tabs.tsx +82 -0
- package/frontend/src/components/ui/textarea.tsx +18 -0
- package/frontend/src/components/ui/toggle-group.tsx +89 -0
- package/frontend/src/components/ui/toggle.tsx +43 -0
- package/frontend/src/components/ui/tooltip.tsx +64 -0
- package/frontend/src/hooks/use-mobile.ts +19 -0
- package/frontend/src/i18n/index.ts +20 -0
- package/frontend/src/i18n/locales/en.json +786 -0
- package/frontend/src/i18n/locales/tr.json +786 -0
- package/frontend/src/index.css +134 -0
- package/frontend/src/layouts/admin-layout.tsx +111 -0
- package/frontend/src/layouts/app-header.tsx +130 -0
- package/frontend/src/layouts/app-layout.tsx +19 -0
- package/frontend/src/layouts/app-sidebar.tsx +212 -0
- package/frontend/src/layouts/auth-guard.tsx +31 -0
- package/frontend/src/layouts/mobile-sidebar.tsx +120 -0
- package/frontend/src/lib/api.ts +68 -0
- package/frontend/src/lib/hooks/use-appointments.ts +224 -0
- package/frontend/src/lib/hooks/use-availability-blocks.ts +83 -0
- package/frontend/src/lib/hooks/use-chats.ts +236 -0
- package/frontend/src/lib/hooks/use-clinic-detail.ts +171 -0
- package/frontend/src/lib/hooks/use-clinics.ts +37 -0
- package/frontend/src/lib/hooks/use-doctor-calendar.ts +80 -0
- package/frontend/src/lib/hooks/use-examinations.ts +89 -0
- package/frontend/src/lib/hooks/use-medical-history.ts +52 -0
- package/frontend/src/lib/hooks/use-patients.ts +296 -0
- package/frontend/src/lib/hooks/use-photo-sets.ts +118 -0
- package/frontend/src/lib/hooks/use-treatment-plans.ts +152 -0
- package/frontend/src/lib/hooks/use-treatments.ts +125 -0
- package/frontend/src/lib/hooks/use-users.ts +172 -0
- package/frontend/src/lib/utils.ts +6 -0
- package/frontend/src/main.tsx +17 -0
- package/frontend/src/pages/admin/agents/detail.tsx +774 -0
- package/frontend/src/pages/admin/agents/import.tsx +280 -0
- package/frontend/src/pages/admin/agents/index.tsx +245 -0
- package/frontend/src/pages/admin/ai-playground.tsx +543 -0
- package/frontend/src/pages/appointments/create-appointment-dialog.tsx +390 -0
- package/frontend/src/pages/appointments/index.tsx +860 -0
- package/frontend/src/pages/audit/index.tsx +24 -0
- package/frontend/src/pages/auth/login.tsx +194 -0
- package/frontend/src/pages/billing/index.tsx +24 -0
- package/frontend/src/pages/calendar/index.tsx +704 -0
- package/frontend/src/pages/calendar-connections/index.tsx +295 -0
- package/frontend/src/pages/calls/index.tsx +24 -0
- package/frontend/src/pages/campaigns/index.tsx +24 -0
- package/frontend/src/pages/chats/index.tsx +981 -0
- package/frontend/src/pages/clinics/index.tsx +224 -0
- package/frontend/src/pages/clinics/settings.tsx +412 -0
- package/frontend/src/pages/components-showcase.tsx +773 -0
- package/frontend/src/pages/connections/index.tsx +328 -0
- package/frontend/src/pages/dashboard.tsx +50 -0
- package/frontend/src/pages/leads/index.tsx +24 -0
- package/frontend/src/pages/my-schedule/index.tsx +496 -0
- package/frontend/src/pages/patients/create-patient-dialog.tsx +358 -0
- package/frontend/src/pages/patients/detail.tsx +1195 -0
- package/frontend/src/pages/patients/edit-patient-dialog.tsx +387 -0
- package/frontend/src/pages/patients/examinations-tab.tsx +460 -0
- package/frontend/src/pages/patients/index.tsx +381 -0
- package/frontend/src/pages/patients/medical-history-dialog.tsx +207 -0
- package/frontend/src/pages/patients/photo-sets-tab.tsx +616 -0
- package/frontend/src/pages/patients/timeline-tab.tsx +164 -0
- package/frontend/src/pages/patients/treatment-plans-tab.tsx +598 -0
- package/frontend/src/pages/phone-numbers/detail.tsx +427 -0
- package/frontend/src/pages/phone-numbers/index.tsx +455 -0
- package/frontend/src/pages/platform/index.tsx +454 -0
- package/frontend/src/pages/settings/index.tsx +126 -0
- package/frontend/src/pages/treatments/index.tsx +487 -0
- package/frontend/src/pages/users/doctor-profile.tsx +672 -0
- package/frontend/src/pages/users/edit.tsx +329 -0
- package/frontend/src/pages/users/index.tsx +407 -0
- package/frontend/src/pages/validation/index.tsx +24 -0
- package/frontend/src/stores/auth.store.ts +108 -0
- package/frontend/src/stores/ui.store.ts +41 -0
- package/frontend/tsconfig.app.json +32 -0
- package/frontend/tsconfig.json +13 -0
- package/frontend/tsconfig.node.json +26 -0
- package/frontend/vite.config.ts +29 -0
- package/nestjs/.dockerignore +5 -0
- package/nestjs/.env.docker +64 -0
- package/nestjs/.prettierrc +4 -0
- package/nestjs/Dockerfile +36 -0
- package/nestjs/README.md +98 -0
- package/nestjs/eslint.config.mjs +35 -0
- package/nestjs/nest-cli.json +8 -0
- package/nestjs/package-lock.json +13390 -0
- package/nestjs/package.json +114 -0
- package/nestjs/prisma/migrations/20260409161536_add_message_metadata_fields/migration.sql +1746 -0
- package/nestjs/prisma/migrations/20260410140436_add_agent_ai_fields/migration.sql +36 -0
- package/nestjs/prisma/migrations/20260410175519_add_agent_clinic_assignments/migration.sql +21 -0
- package/nestjs/prisma/migrations/20260412094344_make_agent_tenant_optional/migration.sql +2 -0
- package/nestjs/prisma/migrations/20260412110008_add_admin_chat_sessions/migration.sql +47 -0
- package/nestjs/prisma/migrations/migration_lock.toml +3 -0
- package/nestjs/prisma/schema.prisma +1843 -0
- package/nestjs/prisma/seed.ts +375 -0
- package/nestjs/prisma.config.ts +14 -0
- package/nestjs/src/admin/admin.controller.ts +27 -0
- package/nestjs/src/admin/admin.module.ts +16 -0
- package/nestjs/src/admin/admin.service.ts +91 -0
- package/nestjs/src/admin/ai-chat-session.service.ts +454 -0
- package/nestjs/src/admin/ai-test.controller.ts +191 -0
- package/nestjs/src/admin/superadmin.controller.ts +106 -0
- package/nestjs/src/agents/agents.controller.ts +262 -0
- package/nestjs/src/agents/agents.module.ts +13 -0
- package/nestjs/src/agents/agents.service.ts +733 -0
- package/nestjs/src/agents/dto/create-agent.dto.ts +99 -0
- package/nestjs/src/agents/dto/index.ts +2 -0
- package/nestjs/src/agents/dto/update-agent.dto.ts +148 -0
- package/nestjs/src/app.module.ts +115 -0
- package/nestjs/src/appointment-validation/appointment-validation.controller.ts +194 -0
- package/nestjs/src/appointment-validation/appointment-validation.module.ts +16 -0
- package/nestjs/src/appointment-validation/appointment-validation.service.ts +450 -0
- package/nestjs/src/appointment-validation/dto/create-batch.dto.ts +105 -0
- package/nestjs/src/appointment-validation/dto/index.ts +1 -0
- package/nestjs/src/appointment-validation/processors/validation-dispatch.processor.ts +26 -0
- package/nestjs/src/appointment-validation/processors/validation-sync.processor.ts +23 -0
- package/nestjs/src/appointments/appointments.controller.ts +268 -0
- package/nestjs/src/appointments/appointments.module.ts +13 -0
- package/nestjs/src/appointments/appointments.service.ts +773 -0
- package/nestjs/src/appointments/dto/create-appointment.dto.ts +72 -0
- package/nestjs/src/appointments/dto/index.ts +4 -0
- package/nestjs/src/appointments/dto/query-appointments.dto.ts +60 -0
- package/nestjs/src/appointments/dto/update-appointment.dto.ts +43 -0
- package/nestjs/src/appointments/dto/update-status.dto.ts +18 -0
- package/nestjs/src/appointments/processors/reminder.processor.ts +243 -0
- package/nestjs/src/audit/audit.controller.ts +84 -0
- package/nestjs/src/audit/audit.decorator.ts +20 -0
- package/nestjs/src/audit/audit.interceptor.ts +67 -0
- package/nestjs/src/audit/audit.interfaces.ts +15 -0
- package/nestjs/src/audit/audit.module.ts +12 -0
- package/nestjs/src/audit/audit.service.ts +177 -0
- package/nestjs/src/auth/auth.controller.ts +116 -0
- package/nestjs/src/auth/auth.module.ts +25 -0
- package/nestjs/src/auth/auth.service.ts +612 -0
- package/nestjs/src/auth/dto/change-password.dto.ts +13 -0
- package/nestjs/src/auth/dto/forgot-password.dto.ts +8 -0
- package/nestjs/src/auth/dto/index.ts +6 -0
- package/nestjs/src/auth/dto/login.dto.ts +13 -0
- package/nestjs/src/auth/dto/refresh.dto.ts +8 -0
- package/nestjs/src/auth/dto/register.dto.ts +28 -0
- package/nestjs/src/auth/dto/reset-password.dto.ts +13 -0
- package/nestjs/src/auth/permissions.config.ts +85 -0
- package/nestjs/src/availability-blocks/availability-blocks.controller.ts +83 -0
- package/nestjs/src/availability-blocks/availability-blocks.module.ts +10 -0
- package/nestjs/src/availability-blocks/availability-blocks.service.ts +202 -0
- package/nestjs/src/billing/billing.controller.ts +104 -0
- package/nestjs/src/billing/billing.module.ts +12 -0
- package/nestjs/src/billing/billing.service.ts +398 -0
- package/nestjs/src/billing/dto/index.ts +2 -0
- package/nestjs/src/billing/dto/query-billing.dto.ts +29 -0
- package/nestjs/src/billing/dto/record-payment.dto.ts +60 -0
- package/nestjs/src/billing/processors/alerts.processor.ts +216 -0
- package/nestjs/src/billing/processors/snapshot.processor.ts +181 -0
- package/nestjs/src/calls/calls.controller.ts +92 -0
- package/nestjs/src/calls/calls.module.ts +10 -0
- package/nestjs/src/calls/calls.service.ts +359 -0
- package/nestjs/src/calls/dto/index.ts +1 -0
- package/nestjs/src/calls/dto/query-calls.dto.ts +46 -0
- package/nestjs/src/clinics/clinics.controller.ts +226 -0
- package/nestjs/src/clinics/clinics.module.ts +11 -0
- package/nestjs/src/clinics/clinics.service.ts +203 -0
- package/nestjs/src/clinics/dto/create-clinic.dto.ts +40 -0
- package/nestjs/src/clinics/dto/create-meta-connection.dto.ts +44 -0
- package/nestjs/src/clinics/dto/index.ts +4 -0
- package/nestjs/src/clinics/dto/update-clinic.dto.ts +133 -0
- package/nestjs/src/clinics/dto/update-meta-connection.dto.ts +22 -0
- package/nestjs/src/clinics/meta-connections.service.ts +210 -0
- package/nestjs/src/common/decorators/accessible-clinics.decorator.ts +9 -0
- package/nestjs/src/common/decorators/current-user.decorator.ts +10 -0
- package/nestjs/src/common/decorators/features.decorator.ts +7 -0
- package/nestjs/src/common/decorators/index.ts +4 -0
- package/nestjs/src/common/decorators/permissions.decorator.ts +13 -0
- package/nestjs/src/common/gateways/events.gateway.ts +157 -0
- package/nestjs/src/common/guards/clinic-access.guard.ts +40 -0
- package/nestjs/src/common/guards/features.guard.ts +38 -0
- package/nestjs/src/common/guards/index.ts +5 -0
- package/nestjs/src/common/guards/jwt-auth.guard.ts +54 -0
- package/nestjs/src/common/guards/permissions.guard.ts +50 -0
- package/nestjs/src/common/guards/superadmin.guard.ts +35 -0
- package/nestjs/src/common/interceptors/request-context.interceptor.ts +32 -0
- package/nestjs/src/common/interceptors/superadmin-tenant.interceptor.ts +42 -0
- package/nestjs/src/common/interfaces/jwt-payload.interface.ts +11 -0
- package/nestjs/src/config/config.module.ts +13 -0
- package/nestjs/src/database/database.module.ts +9 -0
- package/nestjs/src/database/prisma.service.ts +20 -0
- package/nestjs/src/database/tenant-context.ts +27 -0
- package/nestjs/src/google-calendar/google-calendar.controller.ts +259 -0
- package/nestjs/src/google-calendar/google-calendar.module.ts +10 -0
- package/nestjs/src/google-calendar/google-calendar.service.ts +811 -0
- package/nestjs/src/integrations/ai/ai.interface.ts +74 -0
- package/nestjs/src/integrations/ai/ai.module.ts +11 -0
- package/nestjs/src/integrations/ai/ai.service.ts +148 -0
- package/nestjs/src/integrations/ai/providers/anthropic.provider.ts +146 -0
- package/nestjs/src/integrations/ai/providers/openai.provider.ts +158 -0
- package/nestjs/src/integrations/elevenlabs/elevenlabs.module.ts +8 -0
- package/nestjs/src/integrations/elevenlabs/elevenlabs.service.ts +226 -0
- package/nestjs/src/integrations/encryption/encryption.module.ts +9 -0
- package/nestjs/src/integrations/encryption/encryption.service.ts +31 -0
- package/nestjs/src/integrations/image/image.module.ts +9 -0
- package/nestjs/src/integrations/image/image.service.ts +61 -0
- package/nestjs/src/integrations/meta-business/meta-business.module.ts +10 -0
- package/nestjs/src/integrations/meta-business/meta-instagram.service.ts +94 -0
- package/nestjs/src/integrations/meta-business/meta-webhook.service.ts +52 -0
- package/nestjs/src/integrations/meta-business/meta-whatsapp.service.ts +254 -0
- package/nestjs/src/integrations/minio/minio.module.ts +9 -0
- package/nestjs/src/integrations/minio/minio.service.ts +88 -0
- package/nestjs/src/integrations/netgsm/netgsm.module.ts +8 -0
- package/nestjs/src/integrations/netgsm/netgsm.service.ts +17 -0
- package/nestjs/src/integrations/tektippay/tektippay.module.ts +8 -0
- package/nestjs/src/integrations/tektippay/tektippay.service.ts +23 -0
- package/nestjs/src/leads/dto/index.ts +2 -0
- package/nestjs/src/leads/dto/query-leads.dto.ts +50 -0
- package/nestjs/src/leads/dto/update-lead.dto.ts +26 -0
- package/nestjs/src/leads/leads.controller.ts +184 -0
- package/nestjs/src/leads/leads.module.ts +10 -0
- package/nestjs/src/leads/leads.service.ts +375 -0
- package/nestjs/src/logging/logging.controller.ts +82 -0
- package/nestjs/src/logging/logging.module.ts +11 -0
- package/nestjs/src/logging/logging.service.ts +180 -0
- package/nestjs/src/main.ts +86 -0
- package/nestjs/src/outbound-campaigns/dto/create-campaign.dto.ts +47 -0
- package/nestjs/src/outbound-campaigns/dto/index.ts +3 -0
- package/nestjs/src/outbound-campaigns/dto/update-campaign.dto.ts +31 -0
- package/nestjs/src/outbound-campaigns/dto/upload-entries.dto.ts +35 -0
- package/nestjs/src/outbound-campaigns/outbound-campaigns.controller.ts +307 -0
- package/nestjs/src/outbound-campaigns/outbound-campaigns.module.ts +13 -0
- package/nestjs/src/outbound-campaigns/outbound-campaigns.service.ts +471 -0
- package/nestjs/src/outbound-campaigns/processors/campaign-dispatch.processor.ts +366 -0
- package/nestjs/src/patients/documents.service.ts +231 -0
- package/nestjs/src/patients/dto/create-examination.dto.ts +34 -0
- package/nestjs/src/patients/dto/create-note.dto.ts +14 -0
- package/nestjs/src/patients/dto/create-patient.dto.ts +86 -0
- package/nestjs/src/patients/dto/create-photo-set.dto.ts +32 -0
- package/nestjs/src/patients/dto/index.ts +10 -0
- package/nestjs/src/patients/dto/update-examination.dto.ts +29 -0
- package/nestjs/src/patients/dto/update-medical-history.dto.ts +47 -0
- package/nestjs/src/patients/dto/update-patient.dto.ts +87 -0
- package/nestjs/src/patients/dto/update-photo-set.dto.ts +28 -0
- package/nestjs/src/patients/dto/upload-document.dto.ts +31 -0
- package/nestjs/src/patients/dto/upload-photo.dto.ts +27 -0
- package/nestjs/src/patients/examinations.service.ts +271 -0
- package/nestjs/src/patients/medical-history.service.ts +149 -0
- package/nestjs/src/patients/notes.service.ts +172 -0
- package/nestjs/src/patients/patients.controller.ts +485 -0
- package/nestjs/src/patients/patients.module.ts +22 -0
- package/nestjs/src/patients/patients.service.ts +412 -0
- package/nestjs/src/patients/photo-sets.service.ts +389 -0
- package/nestjs/src/phone-numbers/dto/create-phone-number.dto.ts +57 -0
- package/nestjs/src/phone-numbers/dto/index.ts +3 -0
- package/nestjs/src/phone-numbers/dto/update-phone-number.dto.ts +38 -0
- package/nestjs/src/phone-numbers/dto/update-schedule.dto.ts +39 -0
- package/nestjs/src/phone-numbers/phone-numbers.controller.ts +125 -0
- package/nestjs/src/phone-numbers/phone-numbers.module.ts +10 -0
- package/nestjs/src/phone-numbers/phone-numbers.service.ts +209 -0
- package/nestjs/src/plans/dto/create-plan.dto.ts +70 -0
- package/nestjs/src/plans/dto/index.ts +2 -0
- package/nestjs/src/plans/dto/update-plan.dto.ts +80 -0
- package/nestjs/src/plans/plans.controller.ts +50 -0
- package/nestjs/src/plans/plans.module.ts +10 -0
- package/nestjs/src/plans/plans.service.ts +115 -0
- package/nestjs/src/platform/dto/create-tenant.dto.ts +36 -0
- package/nestjs/src/platform/dto/index.ts +2 -0
- package/nestjs/src/platform/dto/update-tenant-platform.dto.ts +44 -0
- package/nestjs/src/platform/platform.controller.ts +79 -0
- package/nestjs/src/platform/platform.module.ts +10 -0
- package/nestjs/src/platform/platform.service.ts +301 -0
- package/nestjs/src/queue/queue.module.ts +56 -0
- package/nestjs/src/redis/redis.module.ts +20 -0
- package/nestjs/src/tenants/dto/index.ts +1 -0
- package/nestjs/src/tenants/dto/update-tenant.dto.ts +15 -0
- package/nestjs/src/tenants/tenants.controller.ts +45 -0
- package/nestjs/src/tenants/tenants.module.ts +10 -0
- package/nestjs/src/tenants/tenants.service.ts +41 -0
- package/nestjs/src/tools/adapters/elevenlabs-http.adapter.ts +51 -0
- package/nestjs/src/tools/adapters/elevenlabs-ws.adapter.ts +59 -0
- package/nestjs/src/tools/handlers/calendar.tools.ts +441 -0
- package/nestjs/src/tools/handlers/notification.tools.ts +34 -0
- package/nestjs/src/tools/handlers/operator.tools.ts +303 -0
- package/nestjs/src/tools/handlers/patient.tools.ts +242 -0
- package/nestjs/src/tools/handlers/payment.tools.ts +43 -0
- package/nestjs/src/tools/handlers/validation.tools.ts +152 -0
- package/nestjs/src/tools/tool-registry.service.ts +221 -0
- package/nestjs/src/tools/tool.decorator.ts +16 -0
- package/nestjs/src/tools/tool.interfaces.ts +26 -0
- package/nestjs/src/tools/tools.module.ts +50 -0
- package/nestjs/src/treatments/dto/create-plan-item.dto.ts +27 -0
- package/nestjs/src/treatments/dto/create-treatment-plan.dto.ts +69 -0
- package/nestjs/src/treatments/dto/create-treatment.dto.ts +59 -0
- package/nestjs/src/treatments/dto/index.ts +6 -0
- package/nestjs/src/treatments/dto/update-plan-item.dto.ts +23 -0
- package/nestjs/src/treatments/dto/update-treatment-plan.dto.ts +22 -0
- package/nestjs/src/treatments/dto/update-treatment.dto.ts +70 -0
- package/nestjs/src/treatments/treatment-plans.service.ts +362 -0
- package/nestjs/src/treatments/treatments.controller.ts +265 -0
- package/nestjs/src/treatments/treatments.module.ts +14 -0
- package/nestjs/src/treatments/treatments.service.ts +165 -0
- package/nestjs/src/users/doctor-profiles.service.ts +202 -0
- package/nestjs/src/users/dto/index.ts +4 -0
- package/nestjs/src/users/dto/invite-user.dto.ts +52 -0
- package/nestjs/src/users/dto/update-clinic-assignments.dto.ts +9 -0
- package/nestjs/src/users/dto/update-doctor-profile.dto.ts +49 -0
- package/nestjs/src/users/dto/update-user.dto.ts +41 -0
- package/nestjs/src/users/users.controller.ts +142 -0
- package/nestjs/src/users/users.module.ts +11 -0
- package/nestjs/src/users/users.service.ts +250 -0
- package/nestjs/src/webhooks/elevenlabs-tool.controller.ts +66 -0
- package/nestjs/src/webhooks/elevenlabs-webhook.controller.ts +60 -0
- package/nestjs/src/webhooks/meta-webhook.controller.ts +178 -0
- package/nestjs/src/webhooks/processors/elevenlabs-webhook.processor.ts +28 -0
- package/nestjs/src/webhooks/webhooks.module.ts +17 -0
- package/nestjs/src/whatsapp/chat-context.service.ts +281 -0
- package/nestjs/src/whatsapp/dto/add-blacklist.dto.ts +13 -0
- package/nestjs/src/whatsapp/dto/index.ts +2 -0
- package/nestjs/src/whatsapp/dto/send-message.dto.ts +14 -0
- package/nestjs/src/whatsapp/listeners/meta-message.listener.ts +579 -0
- package/nestjs/src/whatsapp/meta-auth.controller.ts +268 -0
- package/nestjs/src/whatsapp/meta-instagram-auth.controller.ts +244 -0
- package/nestjs/src/whatsapp/operator.service.ts +692 -0
- package/nestjs/src/whatsapp/processors/cost-sweep.processor.ts +130 -0
- package/nestjs/src/whatsapp/processors/grace.processor.ts +191 -0
- package/nestjs/src/whatsapp/processors/message-buffer.processor.ts +138 -0
- package/nestjs/src/whatsapp/processors/message-cleanup.processor.ts +148 -0
- package/nestjs/src/whatsapp/processors/meta-token-refresh.processor.ts +114 -0
- package/nestjs/src/whatsapp/processors/operator-expiry.processor.ts +105 -0
- package/nestjs/src/whatsapp/processors/profile-update.processor.ts +234 -0
- package/nestjs/src/whatsapp/processors/session-cleanup.processor.ts +178 -0
- package/nestjs/src/whatsapp/processors/session-labels.processor.ts +248 -0
- package/nestjs/src/whatsapp/whatsapp-agent.service.ts +2506 -0
- package/nestjs/src/whatsapp/whatsapp-recovery.service.ts +117 -0
- package/nestjs/src/whatsapp/whatsapp.controller.ts +398 -0
- package/nestjs/src/whatsapp/whatsapp.module.ts +51 -0
- package/nestjs/src/whatsapp/whatsapp.service.ts +592 -0
- package/nestjs/test/app.e2e-spec.ts +25 -0
- package/nestjs/test/jest-e2e.json +9 -0
- package/nestjs/tsconfig.build.json +4 -0
- package/nestjs/tsconfig.json +25 -0
- package/nginx.example.conf +18 -0
- package/package.json +47 -0
- package/scripts/addRecipient.ts +48 -0
- package/scripts/listRecipients.ts +31 -0
- package/scripts/migrate-agent-ref.ts +86 -0
- package/scripts/migrate-sessions.ts +183 -0
- package/scripts/promote.ts +27 -0
- package/scripts/retrigger.ts +84 -0
- package/scripts/seed.ts +435 -0
- package/scripts/testSend.ts +63 -0
- package/src/app.ts +85 -0
- package/src/config/agentPrompts.json +19 -0
- package/src/config/database.ts +21 -0
- package/src/config/env.ts +94 -0
- package/src/config/index.ts +86 -0
- package/src/controllers/webhook.controller.ts +150 -0
- package/src/errors/index.ts +9 -0
- package/src/hooks/webhookValidator.ts +55 -0
- package/src/index.ts +68 -0
- package/src/migrations/001_session-architecture.ts +138 -0
- package/src/migrations/002_agent-ref.ts +65 -0
- package/src/migrations/003_shift-schedule.ts +55 -0
- package/src/migrations/004_invert-shift-to-clinic-hours.ts +30 -0
- package/src/migrations/005_composite-baileys-chat-ids.ts +60 -0
- package/src/migrations/migration.model.ts +27 -0
- package/src/migrations/migration.routes.ts +40 -0
- package/src/migrations/migration.runner.ts +112 -0
- package/src/models/ConversationClaim.ts +17 -0
- package/src/models/ConversationEvaluation.ts +91 -0
- package/src/models/Summary.ts +77 -0
- package/src/models/Transcription.ts +68 -0
- package/src/models/WhatsAppRecipient.ts +37 -0
- package/src/modules/admin/admin.routes.ts +2385 -0
- package/src/modules/admin/elevenlabs-test-chat.routes.ts +193 -0
- package/src/modules/admin/whatsapp-test-chat.routes.ts +244 -0
- package/src/modules/agents/agent.model.ts +93 -0
- package/src/modules/agents/agent.routes.ts +65 -0
- package/src/modules/appointment-validation/appointment-validation.model.ts +163 -0
- package/src/modules/appointment-validation/appointment-validation.routes.ts +275 -0
- package/src/modules/appointment-validation/appointment-validation.service.ts +1028 -0
- package/src/modules/auth/auth.model.ts +42 -0
- package/src/modules/auth/auth.routes.ts +199 -0
- package/src/modules/auth/auth.service.ts +210 -0
- package/src/modules/auth/refresh-token.model.ts +26 -0
- package/src/modules/billing/billing-alert.model.ts +28 -0
- package/src/modules/billing/billing-period-snapshot.model.ts +68 -0
- package/src/modules/billing/billing.model.ts +42 -0
- package/src/modules/billing/billing.routes.ts +67 -0
- package/src/modules/billing/billing.service.ts +562 -0
- package/src/modules/billing/payment.model.ts +42 -0
- package/src/modules/calls/call.model.ts +102 -0
- package/src/modules/calls/call.routes.ts +118 -0
- package/src/modules/campaigns/campaign.model.ts +111 -0
- package/src/modules/campaigns/campaign.routes.ts +402 -0
- package/src/modules/campaigns/campaign.service.ts +99 -0
- package/src/modules/google-calendar/google-calendar.routes.ts +31 -0
- package/src/modules/inbound-call/inbound-call-config.model.ts +49 -0
- package/src/modules/inbound-call/inbound-call.routes.ts +289 -0
- package/src/modules/leads/lead.model.ts +40 -0
- package/src/modules/leads/lead.routes.ts +246 -0
- package/src/modules/logs/log.model.ts +27 -0
- package/src/modules/logs/log.routes.ts +102 -0
- package/src/modules/plans/plan.model.ts +45 -0
- package/src/modules/surveys/survey.model.ts +70 -0
- package/src/modules/surveys/survey.routes.ts +187 -0
- package/src/modules/tenants/tenant.model.ts +181 -0
- package/src/modules/tenants/tenant.routes.ts +78 -0
- package/src/modules/users/user.routes.ts +126 -0
- package/src/modules/webhooks/elevenlabs-tool.routes.ts +94 -0
- package/src/modules/webhooks/elevenlabs-tool.service.ts +491 -0
- package/src/modules/webhooks/elevenlabs.routes.ts +34 -0
- package/src/modules/webhooks/elevenlabs.service.ts +565 -0
- package/src/modules/webhooks/unipile.routes.ts +917 -0
- package/src/modules/whatsapp/appointment.model.ts +47 -0
- package/src/modules/whatsapp/operator-request.model.ts +58 -0
- package/src/modules/whatsapp/stt-usage.model.ts +30 -0
- package/src/modules/whatsapp/whatsapp-chat.model.ts +39 -0
- package/src/modules/whatsapp/whatsapp-contact-profile.model.ts +41 -0
- package/src/modules/whatsapp/whatsapp-message.model.ts +41 -0
- package/src/modules/whatsapp/whatsapp-session.model.ts +60 -0
- package/src/modules/whatsapp/whatsapp.routes.ts +1435 -0
- package/src/plugins/cors.ts +7 -0
- package/src/plugins/jwt.ts +18 -0
- package/src/plugins/rawBody.ts +12 -0
- package/src/plugins/rbac.ts +24 -0
- package/src/routes/admin.routes.ts +208 -0
- package/src/routes/health.routes.ts +12 -0
- package/src/routes/webhook.routes.ts +12 -0
- package/src/services/ai/base.ai.ts +132 -0
- package/src/services/ai/gemini.service.ts +41 -0
- package/src/services/ai/index.ts +24 -0
- package/src/services/ai/openai.service.ts +48 -0
- package/src/services/elevenlabs.service.ts +532 -0
- package/src/services/google-calendar.service.ts +656 -0
- package/src/services/inbound-call-schedule.service.ts +174 -0
- package/src/services/netgsm.service.ts +128 -0
- package/src/services/unipile.service.ts +200 -0
- package/src/services/whatsapp-agent.service.ts +2479 -0
- package/src/services/whatsapp.service.ts +245 -0
- package/src/templates/index.ts +71 -0
- package/src/templates/receptionist.ts +44 -0
- package/src/templates/survey.ts +44 -0
- package/src/types/index.ts +218 -0
- package/src/utils/logger.ts +83 -0
- package/tsconfig.json +19 -0
- package/web/.dockerignore +4 -0
- package/web/Dockerfile +18 -0
- package/web/README.md +73 -0
- package/web/components.json +23 -0
- package/web/eslint.config.js +23 -0
- package/web/index.html +14 -0
- package/web/nginx.conf +18 -0
- package/web/package-lock.json +10292 -0
- package/web/package.json +48 -0
- package/web/public/favicon.ico +0 -0
- package/web/public/vite.svg +1 -0
- package/web/src/App.tsx +191 -0
- package/web/src/assets/react.svg +1 -0
- package/web/src/components/Layout.tsx +261 -0
- package/web/src/components/LeadConversation.tsx +251 -0
- package/web/src/components/ProtectedRoute.tsx +20 -0
- package/web/src/components/conversation-review/CardAudioPlayer.tsx +200 -0
- package/web/src/components/conversation-review/CardEvaluation.tsx +351 -0
- package/web/src/components/conversation-review/CardMetadata.tsx +44 -0
- package/web/src/components/conversation-review/ConversationCard.tsx +95 -0
- package/web/src/components/conversation-review/ReviewContainer.tsx +120 -0
- package/web/src/components/conversation-review/ReviewFilters.tsx +88 -0
- package/web/src/components/empty-state.tsx +15 -0
- package/web/src/components/page-header.tsx +19 -0
- package/web/src/components/page-loader.tsx +32 -0
- package/web/src/components/pagination.tsx +38 -0
- package/web/src/components/stat-card.tsx +27 -0
- package/web/src/components/status-badge.tsx +125 -0
- package/web/src/components/ui/alert.tsx +66 -0
- package/web/src/components/ui/badge.tsx +48 -0
- package/web/src/components/ui/button.tsx +64 -0
- package/web/src/components/ui/card.tsx +92 -0
- package/web/src/components/ui/checkbox.tsx +32 -0
- package/web/src/components/ui/dialog.tsx +158 -0
- package/web/src/components/ui/dropdown-menu.tsx +255 -0
- package/web/src/components/ui/input.tsx +21 -0
- package/web/src/components/ui/label.tsx +22 -0
- package/web/src/components/ui/progress.tsx +29 -0
- package/web/src/components/ui/select.tsx +188 -0
- package/web/src/components/ui/separator.tsx +28 -0
- package/web/src/components/ui/sheet.tsx +123 -0
- package/web/src/components/ui/skeleton.tsx +13 -0
- package/web/src/components/ui/sonner.tsx +35 -0
- package/web/src/components/ui/table.tsx +116 -0
- package/web/src/components/ui/tabs.tsx +89 -0
- package/web/src/components/ui/textarea.tsx +18 -0
- package/web/src/components/ui/tooltip.tsx +57 -0
- package/web/src/components/whatsapp/ChatDetail.tsx +417 -0
- package/web/src/components/whatsapp/ChatHeader.tsx +78 -0
- package/web/src/components/whatsapp/ChatList.tsx +107 -0
- package/web/src/components/whatsapp/ChatListItem.tsx +60 -0
- package/web/src/components/whatsapp/MessageBubble.tsx +46 -0
- package/web/src/components/whatsapp/MessageInput.tsx +63 -0
- package/web/src/components/whatsapp/MessageStream.tsx +135 -0
- package/web/src/components/whatsapp/SessionDivider.tsx +65 -0
- package/web/src/components/whatsapp/SessionHistory.tsx +119 -0
- package/web/src/components/whatsapp/settings/AiSettingsTab.tsx +268 -0
- package/web/src/components/whatsapp/settings/CalendarTab.tsx +339 -0
- package/web/src/components/whatsapp/settings/ConnectionTab.tsx +236 -0
- package/web/src/components/whatsapp/settings/NotificationsTab.tsx +109 -0
- package/web/src/components/whatsapp/settings/OperatorTab.tsx +303 -0
- package/web/src/contexts/AuthContext.tsx +103 -0
- package/web/src/index.css +130 -0
- package/web/src/lib/api.ts +92 -0
- package/web/src/lib/utils.ts +6 -0
- package/web/src/main.tsx +10 -0
- package/web/src/pages/AppointmentDetail.tsx +206 -0
- package/web/src/pages/AppointmentValidation.tsx +157 -0
- package/web/src/pages/AppointmentValidationDetail.tsx +617 -0
- package/web/src/pages/AppointmentValidationNew.tsx +1005 -0
- package/web/src/pages/Appointments.tsx +283 -0
- package/web/src/pages/Billing.tsx +126 -0
- package/web/src/pages/CallDetail.tsx +293 -0
- package/web/src/pages/CallSettings.tsx +313 -0
- package/web/src/pages/Calls.tsx +188 -0
- package/web/src/pages/CampaignDetail.tsx +216 -0
- package/web/src/pages/CampaignNew.tsx +277 -0
- package/web/src/pages/CampaignResults.tsx +185 -0
- package/web/src/pages/Campaigns.tsx +171 -0
- package/web/src/pages/Dashboard.tsx +336 -0
- package/web/src/pages/InboundSchedule.tsx +246 -0
- package/web/src/pages/LeadDetail.tsx +183 -0
- package/web/src/pages/Leads.tsx +258 -0
- package/web/src/pages/Login.tsx +99 -0
- package/web/src/pages/Register.tsx +129 -0
- package/web/src/pages/Settings.tsx +133 -0
- package/web/src/pages/SurveyDetail.tsx +232 -0
- package/web/src/pages/SurveyPreview.tsx +179 -0
- package/web/src/pages/Surveys.tsx +207 -0
- package/web/src/pages/Users.tsx +199 -0
- package/web/src/pages/WhatsApp.tsx +147 -0
- package/web/src/pages/WhatsAppSettings.tsx +215 -0
- package/web/src/pages/admin/AdminBaileysMessageLog.tsx +331 -0
- package/web/src/pages/admin/AdminBaileysRawMessages.tsx +318 -0
- package/web/src/pages/admin/AdminConversationReview.tsx +116 -0
- package/web/src/pages/admin/AdminCredits.tsx +467 -0
- package/web/src/pages/admin/AdminElevenLabsAgentDetail.tsx +332 -0
- package/web/src/pages/admin/AdminElevenLabsAgents.tsx +164 -0
- package/web/src/pages/admin/AdminElevenLabsBatchCallDetail.tsx +214 -0
- package/web/src/pages/admin/AdminElevenLabsBatchCalls.tsx +293 -0
- package/web/src/pages/admin/AdminElevenLabsConversationDetail.tsx +230 -0
- package/web/src/pages/admin/AdminElevenLabsConversations.tsx +228 -0
- package/web/src/pages/admin/AdminElevenLabsInboundCalls.tsx +293 -0
- package/web/src/pages/admin/AdminElevenLabsPhoneNumbers.tsx +506 -0
- package/web/src/pages/admin/AdminElevenLabsTestChat.tsx +258 -0
- package/web/src/pages/admin/AdminElevenLabsWebhooks.tsx +289 -0
- package/web/src/pages/admin/AdminEvaluationDashboard.tsx +520 -0
- package/web/src/pages/admin/AdminLeads.tsx +339 -0
- package/web/src/pages/admin/AdminLogs.tsx +283 -0
- package/web/src/pages/admin/AdminMigrations.tsx +247 -0
- package/web/src/pages/admin/AdminPlans.tsx +313 -0
- package/web/src/pages/admin/AdminSystem.tsx +391 -0
- package/web/src/pages/admin/AdminTenantBillableItems.tsx +464 -0
- package/web/src/pages/admin/AdminTenantDetail.tsx +1317 -0
- package/web/src/pages/admin/AdminTenants.tsx +274 -0
- package/web/src/pages/admin/AdminWhatsApp.tsx +618 -0
- package/web/src/pages/admin/AdminWhatsAppTestChat.tsx +328 -0
- package/web/src/types/index.ts +242 -0
- package/web/tsconfig.app.json +32 -0
- package/web/tsconfig.json +13 -0
- package/web/tsconfig.node.json +26 -0
- package/web/vite.config.ts +23 -0
|
@@ -0,0 +1,1005 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
import * as XLSX from 'xlsx';
|
|
4
|
+
import api from '@/lib/api';
|
|
5
|
+
import { PageHeader } from '@/components/page-header';
|
|
6
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
7
|
+
import { Button } from '@/components/ui/button';
|
|
8
|
+
import { Input } from '@/components/ui/input';
|
|
9
|
+
import { Label } from '@/components/ui/label';
|
|
10
|
+
import { Textarea } from '@/components/ui/textarea';
|
|
11
|
+
import { Badge } from '@/components/ui/badge';
|
|
12
|
+
import {
|
|
13
|
+
Select,
|
|
14
|
+
SelectContent,
|
|
15
|
+
SelectItem,
|
|
16
|
+
SelectTrigger,
|
|
17
|
+
SelectValue,
|
|
18
|
+
} from '@/components/ui/select';
|
|
19
|
+
import { Separator } from '@/components/ui/separator';
|
|
20
|
+
import { Checkbox } from '@/components/ui/checkbox';
|
|
21
|
+
import { toast } from 'sonner';
|
|
22
|
+
import {
|
|
23
|
+
Loader2Icon, UploadIcon, ArrowLeftIcon, ArrowRightIcon, CheckIcon,
|
|
24
|
+
AlertTriangleIcon, FileSpreadsheetIcon, XIcon, CopyIcon, EyeIcon,
|
|
25
|
+
CheckCircle2Icon, XCircleIcon, InfoIcon, ClipboardPasteIcon,
|
|
26
|
+
} from 'lucide-react';
|
|
27
|
+
|
|
28
|
+
type FieldKey = 'patient_name' | 'patient_phone' | 'appointment_date' | 'appointment_time' | 'doctor_name' | 'department' | 'notes' | 'external_id';
|
|
29
|
+
|
|
30
|
+
interface FieldDef {
|
|
31
|
+
key: FieldKey;
|
|
32
|
+
label: string;
|
|
33
|
+
required: boolean;
|
|
34
|
+
hint: string;
|
|
35
|
+
validate?: (v: string) => boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface RowValidation {
|
|
39
|
+
rowIndex: number;
|
|
40
|
+
errors: string[];
|
|
41
|
+
warnings: string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ─── Field Definitions ──────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
const ALL_FIELDS: FieldDef[] = [
|
|
47
|
+
{ key: 'patient_name', label: 'Hasta Adi', required: true, hint: 'Ad Soyad', validate: v => v.length >= 2 },
|
|
48
|
+
{ key: 'patient_phone', label: 'Telefon', required: true, hint: '+905xx veya 05xx', validate: v => v.replace(/[^+\d]/g, '').length >= 10 },
|
|
49
|
+
{ key: 'appointment_date', label: 'Randevu Tarihi', required: true, hint: 'YYYY-MM-DD veya GG.AA.YYYY', validate: v => /\d/.test(v) },
|
|
50
|
+
{ key: 'appointment_time', label: 'Randevu Saati', required: true, hint: 'HH:MM', validate: v => /\d/.test(v) },
|
|
51
|
+
{ key: 'doctor_name', label: 'Doktor', required: false, hint: 'Dr. Ad Soyad' },
|
|
52
|
+
{ key: 'department', label: 'Bolum', required: false, hint: 'Poliklinik / Birim' },
|
|
53
|
+
{ key: 'notes', label: 'Not', required: false, hint: 'Ek bilgi' },
|
|
54
|
+
{ key: 'external_id', label: 'Harici ID', required: false, hint: 'Randevu no / HBS kodu' },
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const REQUIRED_FIELDS = ALL_FIELDS.filter(f => f.required);
|
|
58
|
+
const OPTIONAL_FIELDS = ALL_FIELDS.filter(f => !f.required);
|
|
59
|
+
|
|
60
|
+
// ─── Auto-detect patterns (partial + fuzzy) ─────────────────
|
|
61
|
+
|
|
62
|
+
const AUTO_PATTERNS: { pattern: RegExp; field: FieldKey }[] = [
|
|
63
|
+
{ pattern: /^(hasta\s*a[dı]|ad\s*soyad|patient\s*name|isim|name|ad[ıi]?\s*soyad[ıi]?)$/i, field: 'patient_name' },
|
|
64
|
+
{ pattern: /(telefon|phone|tel|numara|gsm|cep|mobil|mobile)/i, field: 'patient_phone' },
|
|
65
|
+
{ pattern: /(randevu\s*tarih|appointment\s*date|tarih|date|gun)/i, field: 'appointment_date' },
|
|
66
|
+
{ pattern: /(randevu\s*saat|appointment\s*time|saat|time|zaman)/i, field: 'appointment_time' },
|
|
67
|
+
{ pattern: /(doktor|doctor|dr\b|hekim|uzman)/i, field: 'doctor_name' },
|
|
68
|
+
{ pattern: /(bol[uü]m|department|birim|poliklinik|klinik|servis)/i, field: 'department' },
|
|
69
|
+
{ pattern: /^(not|notes?|a[cç][ıi]klama|bilgi|memo|yorum)$/i, field: 'notes' },
|
|
70
|
+
{ pattern: /(randevu.*(no|id|kod)|appointment.*(id|no|code)|harici.*id|external.*id|hbs|protokol|id)/i, field: 'external_id' },
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
function autoDetectMapping(headers: string[]): Partial<Record<FieldKey, string>> {
|
|
74
|
+
const result: Partial<Record<FieldKey, string>> = {};
|
|
75
|
+
const used = new Set<string>();
|
|
76
|
+
|
|
77
|
+
for (const { pattern, field } of AUTO_PATTERNS) {
|
|
78
|
+
if (result[field]) continue;
|
|
79
|
+
const match = headers.find(h => pattern.test(h.trim()) && !used.has(h));
|
|
80
|
+
if (match) {
|
|
81
|
+
result[field] = match;
|
|
82
|
+
used.add(match);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ─── Excel date/time normalization ──────────────────────────
|
|
89
|
+
|
|
90
|
+
function normalizeDate(raw: string): string {
|
|
91
|
+
if (!raw) return '';
|
|
92
|
+
// Already YYYY-MM-DD
|
|
93
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(raw)) return raw;
|
|
94
|
+
|
|
95
|
+
// DD.MM.YYYY or DD/MM/YYYY
|
|
96
|
+
const dmy = raw.match(/^(\d{1,2})[./](\d{1,2})[./](\d{4})$/);
|
|
97
|
+
if (dmy) return `${dmy[3]}-${dmy[2].padStart(2, '0')}-${dmy[1].padStart(2, '0')}`;
|
|
98
|
+
|
|
99
|
+
// MM/DD/YYYY (US format)
|
|
100
|
+
const mdy = raw.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
101
|
+
if (mdy) {
|
|
102
|
+
const m = parseInt(mdy[1]), d = parseInt(mdy[2]);
|
|
103
|
+
if (m > 12) return `${mdy[3]}-${String(d).padStart(2, '0')}-${String(m).padStart(2, '0')}`;
|
|
104
|
+
return `${mdy[3]}-${String(m).padStart(2, '0')}-${String(d).padStart(2, '0')}`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Excel serial number (e.g. 45366)
|
|
108
|
+
const serial = parseFloat(raw);
|
|
109
|
+
if (!isNaN(serial) && serial > 30000 && serial < 100000) {
|
|
110
|
+
const d = XLSX.SSF.parse_date_code(serial);
|
|
111
|
+
if (d) return `${d.y}-${String(d.m).padStart(2, '0')}-${String(d.d).padStart(2, '0')}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return raw;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function normalizeTime(raw: string): string {
|
|
118
|
+
if (!raw) return '';
|
|
119
|
+
// Already HH:MM or HH:MM:SS
|
|
120
|
+
if (/^\d{1,2}:\d{2}(:\d{2})?$/.test(raw)) return raw.substring(0, 5);
|
|
121
|
+
|
|
122
|
+
// Excel serial fraction (0.0–1.0 = 00:00–24:00)
|
|
123
|
+
const frac = parseFloat(raw);
|
|
124
|
+
if (!isNaN(frac) && frac >= 0 && frac < 1) {
|
|
125
|
+
const totalMins = Math.round(frac * 24 * 60);
|
|
126
|
+
const h = Math.floor(totalMins / 60);
|
|
127
|
+
const m = totalMins % 60;
|
|
128
|
+
return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// "10.30" → "10:30"
|
|
132
|
+
const dotTime = raw.match(/^(\d{1,2})\.(\d{2})$/);
|
|
133
|
+
if (dotTime) return `${dotTime[1].padStart(2, '0')}:${dotTime[2]}`;
|
|
134
|
+
|
|
135
|
+
return raw;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function normalizePhone(raw: string): string {
|
|
139
|
+
if (!raw) return '';
|
|
140
|
+
let cleaned = raw.replace(/[\s\-().]/g, '');
|
|
141
|
+
// Turkish local number starting with 0
|
|
142
|
+
if (/^0[5]\d{9}$/.test(cleaned)) cleaned = '+9' + cleaned;
|
|
143
|
+
// 10-digit Turkish number without prefix
|
|
144
|
+
else if (/^5\d{9}$/.test(cleaned)) cleaned = '+90' + cleaned;
|
|
145
|
+
// Already has +
|
|
146
|
+
else if (!cleaned.startsWith('+') && cleaned.length >= 10) cleaned = '+' + cleaned;
|
|
147
|
+
return cleaned;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ─── Component ──────────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
export default function AppointmentValidationNew() {
|
|
153
|
+
const navigate = useNavigate();
|
|
154
|
+
const [step, setStep] = useState(1);
|
|
155
|
+
const dropRef = useRef<HTMLDivElement>(null);
|
|
156
|
+
const [dragOver, setDragOver] = useState(false);
|
|
157
|
+
const [inputMode, setInputMode] = useState<'file' | 'paste'>('file');
|
|
158
|
+
const [pasteText, setPasteText] = useState('');
|
|
159
|
+
|
|
160
|
+
// Step 1 state
|
|
161
|
+
const [callDate, setCallDate] = useState(new Date().toISOString().split('T')[0]);
|
|
162
|
+
const [callStartTime, setCallStartTime] = useState('09:00');
|
|
163
|
+
const [callEndTime, setCallEndTime] = useState('18:00');
|
|
164
|
+
const [maxRetries, setMaxRetries] = useState(2);
|
|
165
|
+
const [fileName, setFileName] = useState('');
|
|
166
|
+
const [fileSize, setFileSize] = useState(0);
|
|
167
|
+
const [sheetNames, setSheetNames] = useState<string[]>([]);
|
|
168
|
+
const [selectedSheet, setSelectedSheet] = useState('');
|
|
169
|
+
const [workbook, setWorkbook] = useState<XLSX.WorkBook | null>(null);
|
|
170
|
+
const [columns, setColumns] = useState<string[]>([]);
|
|
171
|
+
const [rows, setRows] = useState<string[][]>([]);
|
|
172
|
+
const [batchName, setBatchName] = useState('');
|
|
173
|
+
|
|
174
|
+
// Step 2 state
|
|
175
|
+
const [mapping, setMapping] = useState<Partial<Record<FieldKey, string>>>({});
|
|
176
|
+
const [previewColumn, setPreviewColumn] = useState<string | null>(null);
|
|
177
|
+
const [skipEmptyRows, setSkipEmptyRows] = useState(true);
|
|
178
|
+
|
|
179
|
+
// Step 3 state
|
|
180
|
+
const [submitting, setSubmitting] = useState(false);
|
|
181
|
+
|
|
182
|
+
// ─── File Parsing ───────────────────────────────────────────
|
|
183
|
+
|
|
184
|
+
function parseFile(file: File) {
|
|
185
|
+
setFileName(file.name);
|
|
186
|
+
setFileSize(file.size);
|
|
187
|
+
const reader = new FileReader();
|
|
188
|
+
reader.onload = (evt) => {
|
|
189
|
+
try {
|
|
190
|
+
const data = new Uint8Array(evt.target?.result as ArrayBuffer);
|
|
191
|
+
const wb = XLSX.read(data, { type: 'array', cellDates: false, raw: true });
|
|
192
|
+
setWorkbook(wb);
|
|
193
|
+
setSheetNames(wb.SheetNames);
|
|
194
|
+
|
|
195
|
+
// Auto-select first sheet
|
|
196
|
+
loadSheet(wb, wb.SheetNames[0]);
|
|
197
|
+
|
|
198
|
+
if (!batchName) {
|
|
199
|
+
const datePart = new Date().toLocaleDateString('tr-TR', { day: 'numeric', month: 'long', year: 'numeric' });
|
|
200
|
+
setBatchName(`Randevu Onay - ${datePart}`);
|
|
201
|
+
}
|
|
202
|
+
} catch {
|
|
203
|
+
toast.error('Dosya okunamadi. Gecerli bir CSV veya Excel dosyasi secin.');
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
reader.readAsArrayBuffer(file);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function loadSheet(wb: XLSX.WorkBook, sheetName: string) {
|
|
210
|
+
setSelectedSheet(sheetName);
|
|
211
|
+
const ws = wb.Sheets[sheetName];
|
|
212
|
+
const jsonData = XLSX.utils.sheet_to_json<string[]>(ws, { header: 1, defval: '', raw: true });
|
|
213
|
+
|
|
214
|
+
if (jsonData.length < 2) {
|
|
215
|
+
toast.error('Sayfada yeterli veri yok (en az 1 baslik + 1 veri satiri gerekli)');
|
|
216
|
+
setColumns([]);
|
|
217
|
+
setRows([]);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const headers = jsonData[0].map(h => String(h).trim()).filter(Boolean);
|
|
222
|
+
const dataRows = jsonData.slice(1)
|
|
223
|
+
.map(row => headers.map((_, ci) => String(row[ci] ?? '').trim()))
|
|
224
|
+
.filter(row => row.some(cell => cell !== ''));
|
|
225
|
+
|
|
226
|
+
setColumns(headers);
|
|
227
|
+
setRows(dataRows);
|
|
228
|
+
setMapping(autoDetectMapping(headers));
|
|
229
|
+
|
|
230
|
+
toast.success(`"${sheetName}" sayfasindan ${dataRows.length} satir yuklendi`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ─── Drag & Drop ───────────────────────────────────────────
|
|
234
|
+
|
|
235
|
+
const handleDrop = useCallback((e: React.DragEvent) => {
|
|
236
|
+
e.preventDefault();
|
|
237
|
+
setDragOver(false);
|
|
238
|
+
const file = e.dataTransfer.files?.[0];
|
|
239
|
+
if (!file) return;
|
|
240
|
+
const ext = file.name.split('.').pop()?.toLowerCase();
|
|
241
|
+
if (!['csv', 'xlsx', 'xls'].includes(ext || '')) {
|
|
242
|
+
toast.error('Sadece CSV, XLSX, XLS dosyalari desteklenir');
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
parseFile(file);
|
|
246
|
+
}, [batchName]);
|
|
247
|
+
|
|
248
|
+
const handleFileInput = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
249
|
+
const file = e.target.files?.[0];
|
|
250
|
+
if (file) parseFile(file);
|
|
251
|
+
}, [batchName]);
|
|
252
|
+
|
|
253
|
+
function clearFile() {
|
|
254
|
+
setFileName('');
|
|
255
|
+
setFileSize(0);
|
|
256
|
+
setWorkbook(null);
|
|
257
|
+
setSheetNames([]);
|
|
258
|
+
setSelectedSheet('');
|
|
259
|
+
setColumns([]);
|
|
260
|
+
setRows([]);
|
|
261
|
+
setMapping({});
|
|
262
|
+
setPasteText('');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function parseCsvText(text: string) {
|
|
266
|
+
const lines = text.split(/\r?\n/).map(l => l.trim()).filter(Boolean);
|
|
267
|
+
if (lines.length < 2) {
|
|
268
|
+
toast.error('En az 1 baslik + 1 veri satiri gerekli');
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Detect delimiter: tab, semicolon, or comma
|
|
273
|
+
const firstLine = lines[0];
|
|
274
|
+
const delimiter = firstLine.includes('\t') ? '\t' : firstLine.includes(';') ? ';' : ',';
|
|
275
|
+
|
|
276
|
+
const headers = firstLine.split(delimiter).map(h => h.replace(/^"|"$/g, '').trim()).filter(Boolean);
|
|
277
|
+
const dataRows = lines.slice(1)
|
|
278
|
+
.map(line => {
|
|
279
|
+
const cells = line.split(delimiter).map(c => c.replace(/^"|"$/g, '').trim());
|
|
280
|
+
return headers.map((_, ci) => cells[ci] || '');
|
|
281
|
+
})
|
|
282
|
+
.filter(row => row.some(cell => cell !== ''));
|
|
283
|
+
|
|
284
|
+
if (dataRows.length === 0) {
|
|
285
|
+
toast.error('Veri satiri bulunamadi');
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
setColumns(headers);
|
|
290
|
+
setRows(dataRows);
|
|
291
|
+
setMapping(autoDetectMapping(headers));
|
|
292
|
+
setFileName('Yapistirilan veri');
|
|
293
|
+
setFileSize(text.length);
|
|
294
|
+
setSheetNames([]);
|
|
295
|
+
setWorkbook(null);
|
|
296
|
+
|
|
297
|
+
if (!batchName) {
|
|
298
|
+
const datePart = new Date().toLocaleDateString('tr-TR', { day: 'numeric', month: 'long', year: 'numeric' });
|
|
299
|
+
setBatchName(`Randevu Onay - ${datePart}`);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
toast.success(`${dataRows.length} satir yuklendi`);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// ─── Column Mapping Helpers ────────────────────────────────
|
|
306
|
+
|
|
307
|
+
function updateMapping(field: FieldKey, column: string) {
|
|
308
|
+
setMapping(prev => ({ ...prev, [field]: column === '__none__' ? undefined : column }));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function getMappedValue(row: string[], field: FieldKey): string {
|
|
312
|
+
const col = mapping[field];
|
|
313
|
+
if (!col) return '';
|
|
314
|
+
const idx = columns.indexOf(col);
|
|
315
|
+
return idx >= 0 ? (row[idx] || '') : '';
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function getColumnSamples(col: string): string[] {
|
|
319
|
+
const idx = columns.indexOf(col);
|
|
320
|
+
if (idx < 0) return [];
|
|
321
|
+
return rows.slice(0, 8).map(r => r[idx]).filter(Boolean);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Which columns are already assigned to another field
|
|
325
|
+
const assignedColumns = useMemo(() => {
|
|
326
|
+
const set = new Set<string>();
|
|
327
|
+
Object.values(mapping).forEach(v => { if (v) set.add(v); });
|
|
328
|
+
return set;
|
|
329
|
+
}, [mapping]);
|
|
330
|
+
|
|
331
|
+
// ─── Validation ────────────────────────────────────────────
|
|
332
|
+
|
|
333
|
+
const validatedRows = useMemo<RowValidation[]>(() => {
|
|
334
|
+
if (!mapping.patient_name || !mapping.patient_phone || !mapping.appointment_date || !mapping.appointment_time) return [];
|
|
335
|
+
|
|
336
|
+
return rows.map((row, i) => {
|
|
337
|
+
const errors: string[] = [];
|
|
338
|
+
const warnings: string[] = [];
|
|
339
|
+
|
|
340
|
+
const name = getMappedValue(row, 'patient_name');
|
|
341
|
+
const phone = getMappedValue(row, 'patient_phone');
|
|
342
|
+
const date = getMappedValue(row, 'appointment_date');
|
|
343
|
+
const time = getMappedValue(row, 'appointment_time');
|
|
344
|
+
|
|
345
|
+
if (!name) errors.push('Hasta adi bos');
|
|
346
|
+
if (!phone) errors.push('Telefon bos');
|
|
347
|
+
else if (normalizePhone(phone).replace(/[^+\d]/g, '').length < 10) warnings.push('Telefon gecersiz');
|
|
348
|
+
if (!date) errors.push('Tarih bos');
|
|
349
|
+
if (!time) errors.push('Saat bos');
|
|
350
|
+
|
|
351
|
+
return { rowIndex: i, errors, warnings };
|
|
352
|
+
});
|
|
353
|
+
}, [rows, mapping, columns]);
|
|
354
|
+
|
|
355
|
+
const errorCount = validatedRows.filter(r => r.errors.length > 0).length;
|
|
356
|
+
const warningCount = validatedRows.filter(r => r.warnings.length > 0 && r.errors.length === 0).length;
|
|
357
|
+
const validCount = validatedRows.filter(r => r.errors.length === 0).length;
|
|
358
|
+
|
|
359
|
+
// Duplicate phone detection
|
|
360
|
+
const duplicatePhones = useMemo(() => {
|
|
361
|
+
if (!mapping.patient_phone) return 0;
|
|
362
|
+
const phones = rows.map(r => {
|
|
363
|
+
const raw = getMappedValue(r, 'patient_phone');
|
|
364
|
+
return normalizePhone(raw);
|
|
365
|
+
}).filter(Boolean);
|
|
366
|
+
return phones.length - new Set(phones).size;
|
|
367
|
+
}, [rows, mapping, columns]);
|
|
368
|
+
|
|
369
|
+
// Effective rows (skip rows with errors if enabled)
|
|
370
|
+
const effectiveRows = useMemo(() => {
|
|
371
|
+
if (!skipEmptyRows) return rows;
|
|
372
|
+
return rows.filter((_, i) => {
|
|
373
|
+
const v = validatedRows[i];
|
|
374
|
+
return !v || v.errors.length === 0;
|
|
375
|
+
});
|
|
376
|
+
}, [rows, validatedRows, skipEmptyRows]);
|
|
377
|
+
|
|
378
|
+
const missingRequired = REQUIRED_FIELDS.filter(f => !mapping[f.key]);
|
|
379
|
+
const canGoStep2 = columns.length > 0 && rows.length > 0 && !!batchName && !!callDate;
|
|
380
|
+
const canGoStep3 = missingRequired.length === 0;
|
|
381
|
+
|
|
382
|
+
// ─── Build Entries ─────────────────────────────────────────
|
|
383
|
+
|
|
384
|
+
function buildEntries() {
|
|
385
|
+
return effectiveRows.map((row, i) => {
|
|
386
|
+
const rawData: Record<string, string> = {};
|
|
387
|
+
columns.forEach((col, ci) => { rawData[col] = row[ci] || ''; });
|
|
388
|
+
|
|
389
|
+
return {
|
|
390
|
+
row_index: i + 1,
|
|
391
|
+
external_id: getMappedValue(row, 'external_id'),
|
|
392
|
+
patient_name: getMappedValue(row, 'patient_name'),
|
|
393
|
+
patient_phone: normalizePhone(getMappedValue(row, 'patient_phone')),
|
|
394
|
+
appointment_date: normalizeDate(getMappedValue(row, 'appointment_date')),
|
|
395
|
+
appointment_time: normalizeTime(getMappedValue(row, 'appointment_time')),
|
|
396
|
+
doctor_name: getMappedValue(row, 'doctor_name'),
|
|
397
|
+
department: getMappedValue(row, 'department'),
|
|
398
|
+
notes: getMappedValue(row, 'notes'),
|
|
399
|
+
raw_data: rawData,
|
|
400
|
+
};
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
async function handleCreate() {
|
|
405
|
+
setSubmitting(true);
|
|
406
|
+
try {
|
|
407
|
+
const entries = buildEntries();
|
|
408
|
+
const { data } = await api.post('/appointment-validation', {
|
|
409
|
+
name: batchName,
|
|
410
|
+
call_schedule: {
|
|
411
|
+
call_date: callDate,
|
|
412
|
+
call_start_time: callStartTime,
|
|
413
|
+
call_end_time: callEndTime,
|
|
414
|
+
max_concurrent: 3,
|
|
415
|
+
max_retries: maxRetries,
|
|
416
|
+
retry_delay_minutes: 30,
|
|
417
|
+
},
|
|
418
|
+
column_mapping: {
|
|
419
|
+
patient_name: mapping.patient_name || '',
|
|
420
|
+
patient_phone: mapping.patient_phone || '',
|
|
421
|
+
appointment_date: mapping.appointment_date || '',
|
|
422
|
+
appointment_time: mapping.appointment_time || '',
|
|
423
|
+
doctor_name: mapping.doctor_name || undefined,
|
|
424
|
+
department: mapping.department || undefined,
|
|
425
|
+
notes: mapping.notes || undefined,
|
|
426
|
+
external_id: mapping.external_id || undefined,
|
|
427
|
+
},
|
|
428
|
+
entries,
|
|
429
|
+
});
|
|
430
|
+
toast.success('Kampanya olusturuldu');
|
|
431
|
+
navigate(`/appointment-validation/${data.batch._id}`);
|
|
432
|
+
} catch (err: any) {
|
|
433
|
+
toast.error(err.response?.data?.error || 'Olusturulamadi');
|
|
434
|
+
} finally {
|
|
435
|
+
setSubmitting(false);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// ─── Render ────────────────────────────────────────────────
|
|
440
|
+
|
|
441
|
+
return (
|
|
442
|
+
<div className="p-4 sm:p-6 space-y-6 max-w-5xl">
|
|
443
|
+
<div className="flex items-center gap-3">
|
|
444
|
+
<Button variant="ghost" size="sm" onClick={() => navigate('/appointment-validation')}>
|
|
445
|
+
<ArrowLeftIcon className="size-4" />
|
|
446
|
+
</Button>
|
|
447
|
+
<PageHeader title="Yeni Randevu Onay Kampanyasi" />
|
|
448
|
+
</div>
|
|
449
|
+
|
|
450
|
+
{/* Step Indicators */}
|
|
451
|
+
<div className="flex items-center gap-2">
|
|
452
|
+
{[
|
|
453
|
+
{ n: 1, label: 'Dosya & Ayarlar' },
|
|
454
|
+
{ n: 2, label: 'Kolon Esleme' },
|
|
455
|
+
{ n: 3, label: 'Onay & Olustur' },
|
|
456
|
+
].map(({ n, label }) => (
|
|
457
|
+
<div key={n} className="flex items-center gap-2">
|
|
458
|
+
<button
|
|
459
|
+
onClick={() => { if (n < step) setStep(n); }}
|
|
460
|
+
disabled={n > step}
|
|
461
|
+
className={`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors ${
|
|
462
|
+
n === step ? 'bg-primary text-primary-foreground' :
|
|
463
|
+
n < step ? 'bg-primary/20 text-primary cursor-pointer hover:bg-primary/30' :
|
|
464
|
+
'bg-muted text-muted-foreground'
|
|
465
|
+
}`}
|
|
466
|
+
>
|
|
467
|
+
{n < step ? <CheckIcon className="size-4" /> : n}
|
|
468
|
+
</button>
|
|
469
|
+
{n < 3 && <div className={`w-8 sm:w-16 h-0.5 ${n < step ? 'bg-primary/40' : 'bg-muted'}`} />}
|
|
470
|
+
<span className={`text-xs hidden sm:inline ${n === step ? 'text-foreground font-medium' : 'text-muted-foreground'}`}>
|
|
471
|
+
{label}
|
|
472
|
+
</span>
|
|
473
|
+
{n < 3 && <div className="w-2" />}
|
|
474
|
+
</div>
|
|
475
|
+
))}
|
|
476
|
+
</div>
|
|
477
|
+
|
|
478
|
+
{/* ═══════════════ Step 1: File Upload ═══════════════ */}
|
|
479
|
+
{step === 1 && (
|
|
480
|
+
<div className="space-y-5">
|
|
481
|
+
<Card>
|
|
482
|
+
<CardHeader className="pb-3">
|
|
483
|
+
<div className="flex items-center justify-between">
|
|
484
|
+
<CardTitle className="text-base">Veri Yukle</CardTitle>
|
|
485
|
+
{!columns.length && (
|
|
486
|
+
<div className="flex rounded-md border overflow-hidden">
|
|
487
|
+
<button
|
|
488
|
+
onClick={() => setInputMode('file')}
|
|
489
|
+
className={`px-3 py-1.5 text-xs font-medium transition-colors flex items-center gap-1.5 ${
|
|
490
|
+
inputMode === 'file' ? 'bg-primary text-primary-foreground' : 'hover:bg-muted'
|
|
491
|
+
}`}
|
|
492
|
+
>
|
|
493
|
+
<FileSpreadsheetIcon className="size-3.5" /> Dosya
|
|
494
|
+
</button>
|
|
495
|
+
<button
|
|
496
|
+
onClick={() => setInputMode('paste')}
|
|
497
|
+
className={`px-3 py-1.5 text-xs font-medium transition-colors flex items-center gap-1.5 border-l ${
|
|
498
|
+
inputMode === 'paste' ? 'bg-primary text-primary-foreground' : 'hover:bg-muted'
|
|
499
|
+
}`}
|
|
500
|
+
>
|
|
501
|
+
<ClipboardPasteIcon className="size-3.5" /> Yapistir
|
|
502
|
+
</button>
|
|
503
|
+
</div>
|
|
504
|
+
)}
|
|
505
|
+
</div>
|
|
506
|
+
</CardHeader>
|
|
507
|
+
<CardContent>
|
|
508
|
+
{!fileName && inputMode === 'file' ? (
|
|
509
|
+
/* Drop zone */
|
|
510
|
+
<div
|
|
511
|
+
ref={dropRef}
|
|
512
|
+
onDragOver={e => { e.preventDefault(); setDragOver(true); }}
|
|
513
|
+
onDragLeave={() => setDragOver(false)}
|
|
514
|
+
onDrop={handleDrop}
|
|
515
|
+
className={`border-2 border-dashed rounded-lg p-10 text-center transition-colors ${
|
|
516
|
+
dragOver ? 'border-primary bg-primary/5' : 'border-muted-foreground/25 hover:border-primary/50'
|
|
517
|
+
}`}
|
|
518
|
+
>
|
|
519
|
+
<UploadIcon className={`size-10 mx-auto mb-3 ${dragOver ? 'text-primary' : 'text-muted-foreground/50'}`} />
|
|
520
|
+
<p className="text-sm text-muted-foreground mb-1">
|
|
521
|
+
Dosyanizi buraya suruleyip birakin
|
|
522
|
+
</p>
|
|
523
|
+
<p className="text-xs text-muted-foreground mb-3">veya</p>
|
|
524
|
+
<label className="cursor-pointer">
|
|
525
|
+
<Button variant="outline" size="sm" asChild>
|
|
526
|
+
<span>
|
|
527
|
+
<FileSpreadsheetIcon className="size-4 mr-2" />
|
|
528
|
+
Dosya Sec
|
|
529
|
+
</span>
|
|
530
|
+
</Button>
|
|
531
|
+
<input type="file" accept=".csv,.xlsx,.xls" onChange={handleFileInput} className="hidden" />
|
|
532
|
+
</label>
|
|
533
|
+
<p className="text-[11px] text-muted-foreground/60 mt-3">
|
|
534
|
+
Desteklenen formatlar: CSV, XLSX, XLS
|
|
535
|
+
</p>
|
|
536
|
+
</div>
|
|
537
|
+
) : !fileName && inputMode === 'paste' ? (
|
|
538
|
+
/* Paste area */
|
|
539
|
+
<div className="space-y-3">
|
|
540
|
+
<Textarea
|
|
541
|
+
value={pasteText}
|
|
542
|
+
onChange={e => setPasteText(e.target.value)}
|
|
543
|
+
placeholder={"Hasta Adi,Telefon,Randevu Tarihi,Randevu Saati,Doktor,Bolum\nAhmet Yilmaz,05551234567,15.03.2026,10:30,Dr. Mehmet,Ortopedi"}
|
|
544
|
+
rows={8}
|
|
545
|
+
className="font-mono text-xs"
|
|
546
|
+
/>
|
|
547
|
+
<div className="flex items-center justify-between">
|
|
548
|
+
<p className="text-[11px] text-muted-foreground">
|
|
549
|
+
Ilk satir baslik, sonraki satirlar veri. Ayirac: virgul, noktali virgul veya tab.
|
|
550
|
+
</p>
|
|
551
|
+
<Button
|
|
552
|
+
size="sm"
|
|
553
|
+
onClick={() => parseCsvText(pasteText)}
|
|
554
|
+
disabled={!pasteText.trim()}
|
|
555
|
+
>
|
|
556
|
+
<ClipboardPasteIcon className="size-4 mr-2" /> Verileri Yukle
|
|
557
|
+
</Button>
|
|
558
|
+
</div>
|
|
559
|
+
</div>
|
|
560
|
+
) : (
|
|
561
|
+
/* File loaded */
|
|
562
|
+
<div className="space-y-4">
|
|
563
|
+
<div className="flex items-center gap-3 p-3 rounded-lg bg-muted/50">
|
|
564
|
+
<FileSpreadsheetIcon className="size-8 text-green-600 shrink-0" />
|
|
565
|
+
<div className="flex-1 min-w-0">
|
|
566
|
+
<p className="text-sm font-medium truncate">{fileName}</p>
|
|
567
|
+
<p className="text-xs text-muted-foreground">
|
|
568
|
+
{(fileSize / 1024).toFixed(1)} KB · {rows.length} satir · {columns.length} kolon
|
|
569
|
+
</p>
|
|
570
|
+
</div>
|
|
571
|
+
<Button variant="ghost" size="sm" onClick={clearFile}>
|
|
572
|
+
<XIcon className="size-4" />
|
|
573
|
+
</Button>
|
|
574
|
+
</div>
|
|
575
|
+
|
|
576
|
+
{/* Sheet picker (multi-sheet Excel) */}
|
|
577
|
+
{sheetNames.length > 1 && (
|
|
578
|
+
<div className="space-y-2">
|
|
579
|
+
<Label>Sayfa Secimi</Label>
|
|
580
|
+
<div className="flex flex-wrap gap-2">
|
|
581
|
+
{sheetNames.map(name => (
|
|
582
|
+
<Button
|
|
583
|
+
key={name}
|
|
584
|
+
variant={selectedSheet === name ? 'default' : 'outline'}
|
|
585
|
+
size="sm"
|
|
586
|
+
onClick={() => workbook && loadSheet(workbook, name)}
|
|
587
|
+
>
|
|
588
|
+
{name}
|
|
589
|
+
</Button>
|
|
590
|
+
))}
|
|
591
|
+
</div>
|
|
592
|
+
</div>
|
|
593
|
+
)}
|
|
594
|
+
|
|
595
|
+
{/* Data preview */}
|
|
596
|
+
{columns.length > 0 && (
|
|
597
|
+
<div className="space-y-2">
|
|
598
|
+
<div className="flex items-center justify-between">
|
|
599
|
+
<Label>Veri Onizleme</Label>
|
|
600
|
+
<span className="text-xs text-muted-foreground">ilk 5 / {rows.length} satir</span>
|
|
601
|
+
</div>
|
|
602
|
+
<div className="border rounded-md overflow-x-auto max-h-[280px]">
|
|
603
|
+
<table className="w-full text-xs">
|
|
604
|
+
<thead className="bg-muted/50 sticky top-0">
|
|
605
|
+
<tr>
|
|
606
|
+
<th className="text-center p-2 font-medium text-muted-foreground w-8">#</th>
|
|
607
|
+
{columns.map((col, i) => (
|
|
608
|
+
<th key={i} className="text-left p-2 font-medium whitespace-nowrap">{col}</th>
|
|
609
|
+
))}
|
|
610
|
+
</tr>
|
|
611
|
+
</thead>
|
|
612
|
+
<tbody>
|
|
613
|
+
{rows.slice(0, 5).map((row, ri) => (
|
|
614
|
+
<tr key={ri} className="border-t hover:bg-muted/30">
|
|
615
|
+
<td className="text-center p-2 text-muted-foreground">{ri + 1}</td>
|
|
616
|
+
{columns.map((_, ci) => (
|
|
617
|
+
<td key={ci} className="p-2 whitespace-nowrap max-w-[200px] truncate">{row[ci]}</td>
|
|
618
|
+
))}
|
|
619
|
+
</tr>
|
|
620
|
+
))}
|
|
621
|
+
</tbody>
|
|
622
|
+
</table>
|
|
623
|
+
</div>
|
|
624
|
+
</div>
|
|
625
|
+
)}
|
|
626
|
+
</div>
|
|
627
|
+
)}
|
|
628
|
+
</CardContent>
|
|
629
|
+
</Card>
|
|
630
|
+
|
|
631
|
+
{/* Batch settings — only show after file loaded */}
|
|
632
|
+
{columns.length > 0 && (
|
|
633
|
+
<Card>
|
|
634
|
+
<CardHeader className="pb-3">
|
|
635
|
+
<CardTitle className="text-base">Kampanya Ayarlari</CardTitle>
|
|
636
|
+
</CardHeader>
|
|
637
|
+
<CardContent className="space-y-4">
|
|
638
|
+
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
639
|
+
<div className="space-y-2 sm:col-span-2">
|
|
640
|
+
<Label>Kampanya Adi *</Label>
|
|
641
|
+
<Input value={batchName} onChange={e => setBatchName(e.target.value)} placeholder="Randevu Onay - Mart 2026" />
|
|
642
|
+
</div>
|
|
643
|
+
<div className="space-y-2">
|
|
644
|
+
<Label>Arama Tarihi *</Label>
|
|
645
|
+
<Input type="date" value={callDate} onChange={e => setCallDate(e.target.value)} />
|
|
646
|
+
</div>
|
|
647
|
+
<div className="space-y-2">
|
|
648
|
+
<Label>Tekrar Deneme</Label>
|
|
649
|
+
<Select value={String(maxRetries)} onValueChange={v => setMaxRetries(Number(v))}>
|
|
650
|
+
<SelectTrigger>
|
|
651
|
+
<SelectValue />
|
|
652
|
+
</SelectTrigger>
|
|
653
|
+
<SelectContent>
|
|
654
|
+
<SelectItem value="0">Tekrar yok</SelectItem>
|
|
655
|
+
<SelectItem value="1">1 tekrar</SelectItem>
|
|
656
|
+
<SelectItem value="2">2 tekrar</SelectItem>
|
|
657
|
+
<SelectItem value="3">3 tekrar</SelectItem>
|
|
658
|
+
</SelectContent>
|
|
659
|
+
</Select>
|
|
660
|
+
</div>
|
|
661
|
+
<div className="space-y-2">
|
|
662
|
+
<Label>Baslangic Saati</Label>
|
|
663
|
+
<Input type="time" value={callStartTime} onChange={e => setCallStartTime(e.target.value)} />
|
|
664
|
+
</div>
|
|
665
|
+
<div className="space-y-2">
|
|
666
|
+
<Label>Bitis Saati</Label>
|
|
667
|
+
<Input type="time" value={callEndTime} onChange={e => setCallEndTime(e.target.value)} />
|
|
668
|
+
</div>
|
|
669
|
+
</div>
|
|
670
|
+
<p className="text-[11px] text-muted-foreground">
|
|
671
|
+
Aramalar belirtilen tarih ve saat araliginda yapilir. Cevapsiz/basarisiz aramalar otomatik tekrar denenir. Agent ve telefon numarasi admin panelinden yapilandirilir.
|
|
672
|
+
</p>
|
|
673
|
+
</CardContent>
|
|
674
|
+
</Card>
|
|
675
|
+
)}
|
|
676
|
+
|
|
677
|
+
<div className="flex justify-end">
|
|
678
|
+
<Button onClick={() => setStep(2)} disabled={!canGoStep2} size="lg">
|
|
679
|
+
Kolon Esleme <ArrowRightIcon className="size-4 ml-2" />
|
|
680
|
+
</Button>
|
|
681
|
+
</div>
|
|
682
|
+
</div>
|
|
683
|
+
)}
|
|
684
|
+
|
|
685
|
+
{/* ═══════════════ Step 2: Column Mapping ═══════════════ */}
|
|
686
|
+
{step === 2 && (
|
|
687
|
+
<div className="space-y-5">
|
|
688
|
+
<Card>
|
|
689
|
+
<CardHeader className="pb-3">
|
|
690
|
+
<CardTitle className="text-base">Kolon Esleme</CardTitle>
|
|
691
|
+
<p className="text-sm text-muted-foreground">
|
|
692
|
+
Dosyadaki her kolonu ilgili alana esleyin. Otomatik esleme yapildi, kontrol edip gerekirse degistirin.
|
|
693
|
+
</p>
|
|
694
|
+
</CardHeader>
|
|
695
|
+
<CardContent className="space-y-6">
|
|
696
|
+
{/* Mapping rows */}
|
|
697
|
+
<div className="space-y-1">
|
|
698
|
+
{ALL_FIELDS.map(field => {
|
|
699
|
+
const selectedCol = mapping[field.key];
|
|
700
|
+
const samples = selectedCol ? getColumnSamples(selectedCol) : [];
|
|
701
|
+
const isAssigned = !!selectedCol;
|
|
702
|
+
|
|
703
|
+
return (
|
|
704
|
+
<div key={field.key} className="group">
|
|
705
|
+
<div className="flex items-center gap-3 py-2">
|
|
706
|
+
{/* Field label */}
|
|
707
|
+
<div className="w-40 shrink-0">
|
|
708
|
+
<div className="flex items-center gap-1.5">
|
|
709
|
+
{isAssigned ? (
|
|
710
|
+
<CheckCircle2Icon className="size-4 text-green-500 shrink-0" />
|
|
711
|
+
) : field.required ? (
|
|
712
|
+
<XCircleIcon className="size-4 text-red-400 shrink-0" />
|
|
713
|
+
) : (
|
|
714
|
+
<div className="size-4 rounded-full border-2 border-muted-foreground/30 shrink-0" />
|
|
715
|
+
)}
|
|
716
|
+
<span className="text-sm font-medium">{field.label}</span>
|
|
717
|
+
{field.required && <span className="text-red-500 text-xs">*</span>}
|
|
718
|
+
</div>
|
|
719
|
+
<p className="text-[11px] text-muted-foreground ml-5.5 pl-[22px]">{field.hint}</p>
|
|
720
|
+
</div>
|
|
721
|
+
|
|
722
|
+
{/* Arrow */}
|
|
723
|
+
<ArrowRightIcon className="size-4 text-muted-foreground/40 shrink-0" />
|
|
724
|
+
|
|
725
|
+
{/* Column select */}
|
|
726
|
+
<div className="flex-1 max-w-sm">
|
|
727
|
+
<Select value={selectedCol || '__none__'} onValueChange={v => updateMapping(field.key, v)}>
|
|
728
|
+
<SelectTrigger className={isAssigned ? 'border-green-200 bg-green-50/50' : field.required ? 'border-red-200' : ''}>
|
|
729
|
+
<SelectValue placeholder="Kolon secin" />
|
|
730
|
+
</SelectTrigger>
|
|
731
|
+
<SelectContent>
|
|
732
|
+
<SelectItem value="__none__">{field.required ? '-- Secilmedi --' : '-- Yok --'}</SelectItem>
|
|
733
|
+
{columns.map(col => {
|
|
734
|
+
const isUsed = assignedColumns.has(col) && mapping[field.key] !== col;
|
|
735
|
+
const colSamples = getColumnSamples(col);
|
|
736
|
+
return (
|
|
737
|
+
<SelectItem key={col} value={col} disabled={isUsed}>
|
|
738
|
+
<div className="flex items-center gap-2">
|
|
739
|
+
<span className={isUsed ? 'text-muted-foreground line-through' : ''}>{col}</span>
|
|
740
|
+
{colSamples.length > 0 && (
|
|
741
|
+
<span className="text-[10px] text-muted-foreground truncate max-w-[150px]">
|
|
742
|
+
({colSamples[0]}{colSamples.length > 1 ? `, ${colSamples[1]}` : ''})
|
|
743
|
+
</span>
|
|
744
|
+
)}
|
|
745
|
+
</div>
|
|
746
|
+
</SelectItem>
|
|
747
|
+
);
|
|
748
|
+
})}
|
|
749
|
+
</SelectContent>
|
|
750
|
+
</Select>
|
|
751
|
+
</div>
|
|
752
|
+
|
|
753
|
+
{/* Sample preview button */}
|
|
754
|
+
{isAssigned && (
|
|
755
|
+
<Button
|
|
756
|
+
variant="ghost"
|
|
757
|
+
size="sm"
|
|
758
|
+
className="px-2"
|
|
759
|
+
onClick={() => setPreviewColumn(previewColumn === selectedCol ? null : selectedCol!)}
|
|
760
|
+
>
|
|
761
|
+
<EyeIcon className="size-3.5" />
|
|
762
|
+
</Button>
|
|
763
|
+
)}
|
|
764
|
+
</div>
|
|
765
|
+
|
|
766
|
+
{/* Inline sample preview */}
|
|
767
|
+
{previewColumn === selectedCol && selectedCol && (
|
|
768
|
+
<div className="ml-[180px] mb-2 p-2 rounded bg-muted/50 text-xs space-y-0.5">
|
|
769
|
+
<p className="font-medium text-muted-foreground mb-1">"{selectedCol}" ornekleri:</p>
|
|
770
|
+
{samples.slice(0, 6).map((s, i) => (
|
|
771
|
+
<div key={i} className="font-mono">{s}</div>
|
|
772
|
+
))}
|
|
773
|
+
</div>
|
|
774
|
+
)}
|
|
775
|
+
|
|
776
|
+
{field.key !== 'notes' && <Separator className="opacity-50" />}
|
|
777
|
+
</div>
|
|
778
|
+
);
|
|
779
|
+
})}
|
|
780
|
+
</div>
|
|
781
|
+
</CardContent>
|
|
782
|
+
</Card>
|
|
783
|
+
|
|
784
|
+
{/* Validation summary + mapped preview */}
|
|
785
|
+
{canGoStep3 && (
|
|
786
|
+
<Card>
|
|
787
|
+
<CardHeader className="pb-3">
|
|
788
|
+
<CardTitle className="text-base">Eslenmis Veri Onizleme</CardTitle>
|
|
789
|
+
<div className="flex flex-wrap gap-3 mt-2">
|
|
790
|
+
<Badge variant="default" className="text-xs gap-1">
|
|
791
|
+
<CheckCircle2Icon className="size-3" /> {validCount} gecerli
|
|
792
|
+
</Badge>
|
|
793
|
+
{warningCount > 0 && (
|
|
794
|
+
<Badge variant="secondary" className="text-xs gap-1 text-yellow-700">
|
|
795
|
+
<AlertTriangleIcon className="size-3" /> {warningCount} uyari
|
|
796
|
+
</Badge>
|
|
797
|
+
)}
|
|
798
|
+
{errorCount > 0 && (
|
|
799
|
+
<Badge variant="destructive" className="text-xs gap-1">
|
|
800
|
+
<XCircleIcon className="size-3" /> {errorCount} hata
|
|
801
|
+
</Badge>
|
|
802
|
+
)}
|
|
803
|
+
{duplicatePhones > 0 && (
|
|
804
|
+
<Badge variant="secondary" className="text-xs gap-1">
|
|
805
|
+
<CopyIcon className="size-3" /> {duplicatePhones} tekrar telefon
|
|
806
|
+
</Badge>
|
|
807
|
+
)}
|
|
808
|
+
</div>
|
|
809
|
+
</CardHeader>
|
|
810
|
+
<CardContent>
|
|
811
|
+
<div className="border rounded-md overflow-x-auto max-h-[320px]">
|
|
812
|
+
<table className="w-full text-xs">
|
|
813
|
+
<thead className="bg-muted/50 sticky top-0">
|
|
814
|
+
<tr>
|
|
815
|
+
<th className="text-center p-2 font-medium w-8">#</th>
|
|
816
|
+
<th className="text-left p-2 font-medium">Hasta</th>
|
|
817
|
+
<th className="text-left p-2 font-medium">Telefon</th>
|
|
818
|
+
<th className="text-left p-2 font-medium">Tarih</th>
|
|
819
|
+
<th className="text-left p-2 font-medium">Saat</th>
|
|
820
|
+
{mapping.doctor_name && <th className="text-left p-2 font-medium">Doktor</th>}
|
|
821
|
+
{mapping.department && <th className="text-left p-2 font-medium">Bolum</th>}
|
|
822
|
+
<th className="text-center p-2 font-medium w-16">Durum</th>
|
|
823
|
+
</tr>
|
|
824
|
+
</thead>
|
|
825
|
+
<tbody>
|
|
826
|
+
{rows.slice(0, 20).map((row, ri) => {
|
|
827
|
+
const v = validatedRows[ri];
|
|
828
|
+
const hasError = v?.errors.length > 0;
|
|
829
|
+
const hasWarning = v?.warnings.length > 0;
|
|
830
|
+
const rawPhone = getMappedValue(row, 'patient_phone');
|
|
831
|
+
const rawDate = getMappedValue(row, 'appointment_date');
|
|
832
|
+
const rawTime = getMappedValue(row, 'appointment_time');
|
|
833
|
+
|
|
834
|
+
return (
|
|
835
|
+
<tr key={ri} className={`border-t ${hasError ? 'bg-red-50/50' : hasWarning ? 'bg-yellow-50/50' : 'hover:bg-muted/30'}`}>
|
|
836
|
+
<td className="text-center p-2 text-muted-foreground">{ri + 1}</td>
|
|
837
|
+
<td className="p-2">{getMappedValue(row, 'patient_name')}</td>
|
|
838
|
+
<td className="p-2 font-mono">
|
|
839
|
+
<span>{rawPhone}</span>
|
|
840
|
+
{rawPhone && normalizePhone(rawPhone) !== rawPhone && (
|
|
841
|
+
<span className="text-muted-foreground ml-1">→ {normalizePhone(rawPhone)}</span>
|
|
842
|
+
)}
|
|
843
|
+
</td>
|
|
844
|
+
<td className="p-2">
|
|
845
|
+
<span>{rawDate}</span>
|
|
846
|
+
{rawDate && normalizeDate(rawDate) !== rawDate && (
|
|
847
|
+
<span className="text-muted-foreground ml-1">→ {normalizeDate(rawDate)}</span>
|
|
848
|
+
)}
|
|
849
|
+
</td>
|
|
850
|
+
<td className="p-2">
|
|
851
|
+
<span>{rawTime}</span>
|
|
852
|
+
{rawTime && normalizeTime(rawTime) !== rawTime && (
|
|
853
|
+
<span className="text-muted-foreground ml-1">→ {normalizeTime(rawTime)}</span>
|
|
854
|
+
)}
|
|
855
|
+
</td>
|
|
856
|
+
{mapping.doctor_name && <td className="p-2">{getMappedValue(row, 'doctor_name')}</td>}
|
|
857
|
+
{mapping.department && <td className="p-2">{getMappedValue(row, 'department')}</td>}
|
|
858
|
+
<td className="text-center p-2">
|
|
859
|
+
{hasError ? (
|
|
860
|
+
<span className="text-red-500" title={v.errors.join(', ')}>
|
|
861
|
+
<XCircleIcon className="size-4 inline" />
|
|
862
|
+
</span>
|
|
863
|
+
) : hasWarning ? (
|
|
864
|
+
<span className="text-yellow-600" title={v.warnings.join(', ')}>
|
|
865
|
+
<AlertTriangleIcon className="size-4 inline" />
|
|
866
|
+
</span>
|
|
867
|
+
) : (
|
|
868
|
+
<CheckCircle2Icon className="size-4 inline text-green-500" />
|
|
869
|
+
)}
|
|
870
|
+
</td>
|
|
871
|
+
</tr>
|
|
872
|
+
);
|
|
873
|
+
})}
|
|
874
|
+
</tbody>
|
|
875
|
+
</table>
|
|
876
|
+
</div>
|
|
877
|
+
{rows.length > 20 && (
|
|
878
|
+
<p className="text-xs text-muted-foreground mt-2 text-center">
|
|
879
|
+
ve {rows.length - 20} satir daha...
|
|
880
|
+
</p>
|
|
881
|
+
)}
|
|
882
|
+
</CardContent>
|
|
883
|
+
</Card>
|
|
884
|
+
)}
|
|
885
|
+
|
|
886
|
+
<div className="flex justify-between">
|
|
887
|
+
<Button variant="outline" onClick={() => setStep(1)}>
|
|
888
|
+
<ArrowLeftIcon className="size-4 mr-2" /> Geri
|
|
889
|
+
</Button>
|
|
890
|
+
<Button onClick={() => setStep(3)} disabled={!canGoStep3} size="lg">
|
|
891
|
+
Onay <ArrowRightIcon className="size-4 ml-2" />
|
|
892
|
+
</Button>
|
|
893
|
+
</div>
|
|
894
|
+
</div>
|
|
895
|
+
)}
|
|
896
|
+
|
|
897
|
+
{/* ═══════════════ Step 3: Review & Create ═══════════════ */}
|
|
898
|
+
{step === 3 && (
|
|
899
|
+
<div className="space-y-5">
|
|
900
|
+
<Card>
|
|
901
|
+
<CardHeader className="pb-3">
|
|
902
|
+
<CardTitle className="text-base">Kampanya Ozeti</CardTitle>
|
|
903
|
+
</CardHeader>
|
|
904
|
+
<CardContent className="space-y-5">
|
|
905
|
+
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
|
|
906
|
+
<SummaryItem label="Kampanya" value={batchName} />
|
|
907
|
+
<SummaryItem label="Arama Tarihi" value={callDate} />
|
|
908
|
+
<SummaryItem label="Saat Araligi" value={`${callStartTime} - ${callEndTime}`} />
|
|
909
|
+
<SummaryItem label="Tekrar" value={maxRetries === 0 ? 'Yok' : `${maxRetries} kez`} />
|
|
910
|
+
</div>
|
|
911
|
+
|
|
912
|
+
<Separator />
|
|
913
|
+
|
|
914
|
+
{/* Column mapping */}
|
|
915
|
+
<div>
|
|
916
|
+
<h3 className="text-sm font-medium mb-2">Kolon Esleme</h3>
|
|
917
|
+
<div className="flex flex-wrap gap-2">
|
|
918
|
+
{ALL_FIELDS.filter(f => mapping[f.key]).map(f => (
|
|
919
|
+
<Badge key={f.key} variant="secondary" className="text-xs gap-1">
|
|
920
|
+
{f.label} ← <span className="font-mono">{mapping[f.key]}</span>
|
|
921
|
+
</Badge>
|
|
922
|
+
))}
|
|
923
|
+
</div>
|
|
924
|
+
</div>
|
|
925
|
+
|
|
926
|
+
<Separator />
|
|
927
|
+
|
|
928
|
+
{/* Stats */}
|
|
929
|
+
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
|
|
930
|
+
<div className="text-center p-3 rounded-lg bg-muted/50">
|
|
931
|
+
<div className="text-2xl font-bold">{effectiveRows.length}</div>
|
|
932
|
+
<div className="text-xs text-muted-foreground">Aranacak</div>
|
|
933
|
+
</div>
|
|
934
|
+
<div className="text-center p-3 rounded-lg bg-green-50">
|
|
935
|
+
<div className="text-2xl font-bold text-green-600">{validCount}</div>
|
|
936
|
+
<div className="text-xs text-muted-foreground">Gecerli Satir</div>
|
|
937
|
+
</div>
|
|
938
|
+
{errorCount > 0 && (
|
|
939
|
+
<div className="text-center p-3 rounded-lg bg-red-50">
|
|
940
|
+
<div className="text-2xl font-bold text-red-600">{errorCount}</div>
|
|
941
|
+
<div className="text-xs text-muted-foreground">Hatali (atlanacak)</div>
|
|
942
|
+
</div>
|
|
943
|
+
)}
|
|
944
|
+
{duplicatePhones > 0 && (
|
|
945
|
+
<div className="text-center p-3 rounded-lg bg-yellow-50">
|
|
946
|
+
<div className="text-2xl font-bold text-yellow-600">{duplicatePhones}</div>
|
|
947
|
+
<div className="text-xs text-muted-foreground">Tekrar Telefon</div>
|
|
948
|
+
</div>
|
|
949
|
+
)}
|
|
950
|
+
</div>
|
|
951
|
+
|
|
952
|
+
{/* Skip empty rows toggle */}
|
|
953
|
+
{errorCount > 0 && (
|
|
954
|
+
<div className="flex items-center gap-2 p-3 rounded-md bg-yellow-50 border border-yellow-200">
|
|
955
|
+
<Checkbox
|
|
956
|
+
id="skipEmpty"
|
|
957
|
+
checked={skipEmptyRows}
|
|
958
|
+
onCheckedChange={v => setSkipEmptyRows(!!v)}
|
|
959
|
+
/>
|
|
960
|
+
<label htmlFor="skipEmpty" className="text-sm text-yellow-800 cursor-pointer">
|
|
961
|
+
Hatali satirlari atla ({errorCount} satir eksik veri iceriyor)
|
|
962
|
+
</label>
|
|
963
|
+
</div>
|
|
964
|
+
)}
|
|
965
|
+
|
|
966
|
+
{/* Warnings */}
|
|
967
|
+
{warningCount > 0 && (
|
|
968
|
+
<div className="flex items-center gap-2 p-3 rounded-md bg-yellow-50 border border-yellow-200 text-yellow-800 text-sm">
|
|
969
|
+
<AlertTriangleIcon className="size-4 shrink-0" />
|
|
970
|
+
{warningCount} satirdaki telefon numarasi gecersiz gorunuyor.
|
|
971
|
+
</div>
|
|
972
|
+
)}
|
|
973
|
+
|
|
974
|
+
{duplicatePhones > 0 && (
|
|
975
|
+
<div className="flex items-center gap-2 p-3 rounded-md border text-sm text-muted-foreground">
|
|
976
|
+
<InfoIcon className="size-4 shrink-0" />
|
|
977
|
+
{duplicatePhones} tekrar eden telefon numarasi var. Ayni hastanin birden fazla randevusu olabilir.
|
|
978
|
+
</div>
|
|
979
|
+
)}
|
|
980
|
+
</CardContent>
|
|
981
|
+
</Card>
|
|
982
|
+
|
|
983
|
+
<div className="flex justify-between">
|
|
984
|
+
<Button variant="outline" onClick={() => setStep(2)}>
|
|
985
|
+
<ArrowLeftIcon className="size-4 mr-2" /> Geri
|
|
986
|
+
</Button>
|
|
987
|
+
<Button onClick={handleCreate} disabled={submitting || effectiveRows.length === 0} size="lg">
|
|
988
|
+
{submitting && <Loader2Icon className="size-4 mr-2 animate-spin" />}
|
|
989
|
+
{effectiveRows.length} Randevu ile Kampanya Olustur
|
|
990
|
+
</Button>
|
|
991
|
+
</div>
|
|
992
|
+
</div>
|
|
993
|
+
)}
|
|
994
|
+
</div>
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
function SummaryItem({ label, value, mono }: { label: string; value: string; mono?: boolean }) {
|
|
999
|
+
return (
|
|
1000
|
+
<div>
|
|
1001
|
+
<p className="text-xs text-muted-foreground">{label}</p>
|
|
1002
|
+
<p className={`text-sm font-medium truncate ${mono ? 'font-mono text-xs' : ''}`}>{value}</p>
|
|
1003
|
+
</div>
|
|
1004
|
+
);
|
|
1005
|
+
}
|