Browse Source

actually finish conversation when creating appointment

Matthew Trejo 2 tháng trước cách đây
mục cha
commit
c184f05901

+ 11 - 0
src/components/chatbot/AppointmentModalFromChat.tsx

@@ -19,6 +19,7 @@ interface AppointmentModalFromChatProps {
   open: boolean;
   onClose: () => void;
   onSuccess?: () => void;
+  onChatComplete?: () => void; // Callback para finalizar el chat después de agendar
   recordId?: string; // ID del Record (reporte médico) asociado a la cita
 }
 
@@ -26,6 +27,7 @@ export const AppointmentModalFromChat = ({
   open,
   onClose,
   onSuccess,
+  onChatComplete,
   recordId,
 }: AppointmentModalFromChatProps) => {
   const [motivoConsulta, setMotivoConsulta] = useState("");
@@ -63,6 +65,15 @@ export const AppointmentModalFromChat = ({
       setMotivoConsulta("");
       onClose();
       onSuccess?.();
+      
+      // Finalizar el chat después de agendar exitosamente
+      if (onChatComplete) {
+        console.log("🎯 [AppointmentModal] Finalizando chat después de agendar cita");
+        // Pequeño delay para que el usuario vea la notificación de éxito
+        setTimeout(() => {
+          onChatComplete();
+        }, 1500);
+      }
     } catch (error) {
       const message = error instanceof Error ? error.message : undefined;
       notifications.appointments.createError(message);

+ 1 - 0
src/components/chatbot/ChatInterface.tsx

@@ -278,6 +278,7 @@ export const ChatInterface = ({ chatType }: ChatInterfaceProps) => {
         open={showAppointmentModal}
         onClose={handleCloseAppointmentModal}
         recordId={appointmentRecordId}
+        onChatComplete={resetChat}
       />
     </div>
   );

+ 1 - 1
src/components/chatbot/MedicalAlertBanner.tsx

@@ -100,7 +100,7 @@ export const MedicalAlertBanner = ({
           ) : (
             <>
               <Calendar className="h-4 w-4 mr-2" />
-              Agendar Cita Ahora
+              Agendar Cita Ahora
             </>
           )}
         </Button>