diff --git a/src/core/PageManager/data/pages/pek-tables.ts b/src/core/PageManager/data/pages/pek-tables.ts index 6237cdd..dbef51e 100644 --- a/src/core/PageManager/data/pages/pek-tables.ts +++ b/src/core/PageManager/data/pages/pek-tables.ts @@ -5,6 +5,7 @@ import { privilegeCheckers } from '../../../../utils/privilegeCheckers'; import { usePekTablesContext } from '../../../../hooks/PekTablesContext'; import PekTablesDropdown from './pek-tables/PekTablesDropdown'; import PekTablesPageWrapper from './pek-tables/PekTablesPageWrapper'; +import PekTablesTable from './pek-tables/PekTablesTable'; // Hook factory for PEK Tables page const createPekTablesHook = () => { @@ -98,17 +99,8 @@ export const pekTablesPageData: GenericPageData = { }, { id: 'pek-tables-table', - type: 'table', - tableConfig: { - hookFactory: createPekTablesHook, - columns: [], // Auto-detect columns - searchable: true, - filterable: true, - sortable: true, - pagination: true, - pageSize: 10, - selectable: true - } + type: 'custom', + customComponent: PekTablesTable } ], diff --git a/src/core/PageManager/data/pages/pek-tables/PekTablesCollapsable.module.css b/src/core/PageManager/data/pages/pek-tables/PekTablesCollapsable.module.css new file mode 100644 index 0000000..dec8245 --- /dev/null +++ b/src/core/PageManager/data/pages/pek-tables/PekTablesCollapsable.module.css @@ -0,0 +1,69 @@ +.collapsableContainer { + width: 100%; + margin-bottom: 1.5rem; + border: 1px solid var(--color-border, #e5e7eb); + border-radius: 8px; + overflow: hidden; + background-color: var(--color-bg, #ffffff); + display: flex; + flex-direction: column; +} + +.collapseButton { + width: 100%; + display: flex; + justify-content: space-between; + align-items: center; + padding: 1rem 1.5rem; + background-color: var(--color-bg-secondary, #f9fafb); + border: none; + border-bottom: 1px solid var(--color-border, #e5e7eb); + cursor: pointer; + transition: background-color 0.2s; + font-family: var(--font-family); +} + +.collapseButton:hover { + background-color: var(--color-hover, #f3f4f6); +} + +.collapseButton:focus { + outline: 2px solid var(--color-primary, #3b82f6); + outline-offset: -2px; +} + +.collapseButtonText { + font-size: 1rem; + font-weight: 600; + color: var(--color-text, #111827); +} + +.collapseIcon { + color: var(--color-text-secondary, #6b7280); + font-size: 1rem; + transition: transform 0.2s; +} + +.collapsableContent { + padding: 0; + animation: slideDown 0.2s ease-out; + height: calc(100vh - 250px); /* Very tall height, starting below dropdown and extending downward */ + min-height: 500px; /* Minimum height for usability */ + max-height: calc(100vh - 150px); /* Maximum height to leave minimal space for other elements */ + overflow-y: auto; + overflow-x: auto; + display: flex; + flex-direction: column; +} + +@keyframes slideDown { + from { + opacity: 0; + max-height: 0; + } + to { + opacity: 1; + max-height: 1000px; + } +} + diff --git a/src/core/PageManager/data/pages/pek-tables/PekTablesCollapsable.tsx b/src/core/PageManager/data/pages/pek-tables/PekTablesCollapsable.tsx new file mode 100644 index 0000000..27e57ad --- /dev/null +++ b/src/core/PageManager/data/pages/pek-tables/PekTablesCollapsable.tsx @@ -0,0 +1,47 @@ +import React, { useState } from 'react'; +import { FaChevronDown, FaChevronUp } from 'react-icons/fa'; +import styles from './PekTablesCollapsable.module.css'; + +interface PekTablesCollapsableProps { + title?: string; + children: React.ReactNode; + defaultCollapsed?: boolean; +} + +const PekTablesCollapsable: React.FC = ({ + title = 'Tabellenansicht', + children, + defaultCollapsed = false +}) => { + const [isCollapsed, setIsCollapsed] = useState(defaultCollapsed); + + const toggleCollapse = () => { + setIsCollapsed(!isCollapsed); + }; + + return ( +
+ + {!isCollapsed && ( +
+ {children} +
+ )} +
+ ); +}; + +export default PekTablesCollapsable; + diff --git a/src/core/PageManager/data/pages/pek-tables/PekTablesTable.tsx b/src/core/PageManager/data/pages/pek-tables/PekTablesTable.tsx new file mode 100644 index 0000000..f9cd28b --- /dev/null +++ b/src/core/PageManager/data/pages/pek-tables/PekTablesTable.tsx @@ -0,0 +1,115 @@ +import React, { useState } from 'react'; +import { FormGenerator } from '../../../../../components/FormGenerator'; +import { usePekTablesContext } from '../../../../../hooks/PekTablesContext'; +import { FaChevronDown, FaChevronUp } from 'react-icons/fa'; +import styles from './PekTablesCollapsable.module.css'; + +const PekTablesTable: React.FC = () => { + const { + tableData, + isLoadingTableData, + tableDataError, + refreshTableData, + selectedTable + } = usePekTablesContext(); + + const [isCollapsed, setIsCollapsed] = useState(true); // Default collapsed to show chat window + + // Debug logging + if (import.meta.env.DEV) { + console.log('📊 PekTablesTable render:', { + selectedTable, + tableDataLength: tableData?.length || 0, + isLoadingTableData, + tableDataError + }); + } + + const toggleCollapse = () => { + setIsCollapsed(!isCollapsed); + }; + + // Show error state if there's an error + if (tableDataError) { + return ( +
+ + {!isCollapsed && ( +
+
+

Fehler beim Laden der Daten: {tableDataError}

+ {refreshTableData && ( + + )} +
+
+ )} +
+ ); + } + + // Only show loading spinner on initial load (when there's no data yet) + const showLoadingSpinner = isLoadingTableData && (!tableData || tableData.length === 0); + + return ( +
+ + {!isCollapsed && ( +
+ {tableData && tableData.length > 0 ? ( + + ) : isLoadingTableData ? ( +
+
Lade Daten...
+
+ ) : ( +
+ Keine Daten verfügbar. Bitte wählen Sie eine Tabelle aus. +
+ )} +
+ )} +
+ ); +}; + +export default PekTablesTable; +