import React, { useEffect, useMemo } from 'react'; import { useDispatcher } from '../hooks/useDispatcher'; import ExcelTable from '../components/ExcelTable'; const DispatcherView = () => { const { data, loading, fetchData } = useDispatcher(); useEffect(() => { fetchData(); }, [fetchData]); const columns = useMemo(() => { if (!data || data.length === 0) return []; // Take the first item to generate columns const firstItem = data[0]; return Object.keys(firstItem).map(key => ({ field: key, header: key.replace(/_/g, ' '), // Simple formatter: replace underscores with spaces width: 150, // Default width className: 'text-xs' })); }, [data]); const filterDefs = useMemo(() => { // Create filters for all columns by default, or maybe just some specific ones? // For "advanced filters", let's just enable all of them as 'select' type for now return columns.map(col => ({ field: col.field, label: col.header, type: 'select' })); }, [columns]); return (
Visualização de dados do Dispatcher.