diff --git a/front/packages/ui/src/fetch-infinite.web.tsx b/front/packages/ui/src/fetch-infinite.web.tsx index 0869b510..526c56c0 100644 --- a/front/packages/ui/src/fetch-infinite.web.tsx +++ b/front/packages/ui/src/fetch-infinite.web.tsx @@ -119,7 +119,7 @@ export const InfiniteFetch = ({ }); const grid = layout.numColumns !== 1; - if (error) return ; + if (error) return addHeader(Header, ); if (empty && items && items.length === 0) { if (typeof empty !== "string") return empty; return ; @@ -147,14 +147,20 @@ export const InfiniteFetch = ({ ))} ); + return addHeader(Header, list); +}; - if (!Header) return list; +const addHeader = ( + Header: ComponentType<{ children: JSX.Element }> | ReactElement | undefined, + children: ReactElement, +) => { + if (!Header) return children; return typeof Header === "function" ? ( -
{list}
+
{children}
) : ( <> {Header} - {list} + {children} ); };