bugfix(BIL01, BIL-02)
Some checks are pending
Deploy Nyla Frontend to Integration / build-and-deploy (push) Waiting to run

This commit is contained in:
Ida 2026-04-17 15:26:12 +02:00
parent 5dd4741a0f
commit ec4592c056
2 changed files with 23 additions and 4 deletions

View file

@ -532,6 +532,10 @@ export function FormGeneratorTable<T extends Record<string, any>>({
// Debounce search term for backend calls
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState(searchTerm);
// Bumped by the refresh button so the backend-refetch useEffect re-runs even
// when no other state (page/filters/sort/search) changed.
const [refreshNonce, setRefreshNonce] = useState(0);
useEffect(() => {
const timer = setTimeout(() => {
setDebouncedSearchTerm(prev => {
@ -608,7 +612,7 @@ export function FormGeneratorTable<T extends Record<string, any>>({
console.error('❌ FormGeneratorTable: Backend refetch failed:', error);
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [debouncedSearchTerm, filters, sortConfigs, currentPage, currentPageSize, supportsBackendPagination]);
}, [debouncedSearchTerm, filters, sortConfigs, currentPage, currentPageSize, supportsBackendPagination, refreshNonce]);
// Refs for action buttons containers to detect clicks outside
const actionButtonsRefs = useRef<Map<number, HTMLDivElement>>(new Map());
@ -1920,7 +1924,22 @@ export function FormGeneratorTable<T extends Record<string, any>>({
},
};
}) : undefined}
onRefresh={onRefresh}
onRefresh={
// The refresh button resets pagination to page 1, clears any
// optimistic hidden-rows state, and bumps `refreshNonce` so the
// backend-refetch useEffect re-runs (even when no state changed).
// When the table supports backend pagination, the external
// onRefresh is skipped to avoid a double-fetch — the useEffect
// already calls hookData.refetch with the correct pagination.
onRefresh
? () => {
if (optimisticallyDeletedIds.size > 0) setOptimisticallyDeletedIds(new Set());
setCurrentPage(1);
setRefreshNonce(n => n + 1);
if (!supportsBackendPagination) onRefresh();
}
: undefined
}
searchable={searchable}
selectable={selectable}
loading={loading}

View file

@ -475,7 +475,7 @@ export const BillingDataView: React.FC = () => {
{ key: 'aicoreProvider', label: t('Anbieter'), type: 'text' as any, sortable: true, filterable: true, width: 120 },
{ key: 'aicoreModel', label: t('Modell'), type: 'text' as any, sortable: true, filterable: true, width: 150 },
{ key: 'featureCode', label: t('Feature'), type: 'text' as any, sortable: true, filterable: true, width: 120 },
{ key: 'amount', label: t('Betrag (CHF)'), type: 'number' as any, sortable: true, width: 120 },
{ key: 'amount', label: t('Betrag (CHF)'), type: 'number' as any, sortable: true, searchable: true, width: 120 },
], [t]);
const totalBalance = useMemo(() => {
@ -609,7 +609,7 @@ export const BillingDataView: React.FC = () => {
fontWeight: chartMode === 'pie' ? 600 : 400,
}}
>
{t('Pie')}
{t('Kreis')}
</button>
<button
onClick={() => setChartMode('bar')}