Ajuste de vista para las tablas #152

This commit is contained in:
2026-03-04 09:24:27 -06:00
parent 314a96f2c5
commit 6012d0ced8
4 changed files with 162 additions and 109 deletions

View File

@@ -12,6 +12,7 @@ import {
update_conversation_status,
update_recommendation_applied_status,
update_conversation_title,
getMessagesByConversation,
} from '../api/ai.api'
// eslint-disable-next-line node/prefer-node-protocol
@@ -88,6 +89,25 @@ export function useConversationByPlan(planId: string | null) {
})
}
export function useMessagesByChat(conversationId: string | null) {
return useQuery({
// La queryKey debe ser única; incluimos el ID para que se refresque al cambiar de chat
queryKey: ['conversation-messages', conversationId],
// Solo ejecutamos la función si el ID no es null o undefined
queryFn: () => {
if (!conversationId) throw new Error('Conversation ID is required')
return getMessagesByConversation(conversationId)
},
// Importante: 'enabled' controla que no se dispare la petición si no hay ID
enabled: !!conversationId,
// Opcional: Mantener los datos previos mientras se carga la nueva conversación
placeholderData: (previousData) => previousData,
})
}
export function useUpdateRecommendationApplied() {
const qc = useQueryClient()