Feat: Añadidas Palabras Claves. Filtros Historial Ajustados
This commit is contained in:
@@ -20,9 +20,18 @@ const LogsViewer: React.FC<LogsViewerProps> = ({ onAuthError }) => {
|
||||
const [logs, setLogs] = useState<ConversacionLog[]>([]);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// Filtros
|
||||
const [startDate, setStartDate] = useState('');
|
||||
const [endDate, setEndDate] = useState('');
|
||||
// Obtener fecha de hoy en formato YYYY-MM-DD
|
||||
const getTodayDate = () => {
|
||||
const today = new Date();
|
||||
const year = today.getFullYear();
|
||||
const month = String(today.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(today.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
||||
// Filtros con fecha de hoy por defecto
|
||||
const [startDate, setStartDate] = useState(getTodayDate());
|
||||
const [endDate, setEndDate] = useState(getTodayDate());
|
||||
const [search, setSearch] = useState('');
|
||||
|
||||
const [paginationModel, setPaginationModel] = useState({
|
||||
@@ -33,8 +42,19 @@ const LogsViewer: React.FC<LogsViewerProps> = ({ onAuthError }) => {
|
||||
const fetchLogs = useCallback(async () => {
|
||||
try {
|
||||
const params = new URLSearchParams();
|
||||
if (startDate) params.append('startDate', startDate);
|
||||
if (endDate) params.append('endDate', endDate);
|
||||
|
||||
// Agregar fecha de inicio con hora 00:00:00
|
||||
if (startDate) {
|
||||
const startDateTime = `${startDate}T00:00:00`;
|
||||
params.append('startDate', startDateTime);
|
||||
}
|
||||
|
||||
// Agregar fecha de fin con hora 23:59:59
|
||||
if (endDate) {
|
||||
const endDateTime = `${endDate}T23:59:59`;
|
||||
params.append('endDate', endDateTime);
|
||||
}
|
||||
|
||||
if (search) params.append('search', search);
|
||||
|
||||
const response = await apiClient.get(`/api/admin/logs?${params.toString()}`);
|
||||
@@ -47,10 +67,12 @@ const LogsViewer: React.FC<LogsViewerProps> = ({ onAuthError }) => {
|
||||
}
|
||||
}, [onAuthError, startDate, endDate, search]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
// Cargar logs automáticamente con los filtros por defecto (fecha de hoy)
|
||||
fetchLogs();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []); // Carga inicial solamente, o cuando el usuario pulse "Filtrar"
|
||||
}, [fetchLogs]);
|
||||
|
||||
|
||||
|
||||
const columns: GridColDef[] = [
|
||||
|
||||
Reference in New Issue
Block a user