frontend: optimized fetching behaviour

This commit is contained in:
Johannes Lötzsch 2022-03-10 11:50:33 +01:00
parent d48e138422
commit 38a9850142
1 changed files with 6 additions and 4 deletions

View File

@ -6,11 +6,13 @@ import HostOfferLookupTable from "./HostOfferLookupTable";
type HostLookupWrapperProps = Record<string, never> type HostLookupWrapperProps = Record<string, never>
const HostOfferLookupWrapper = ({}: HostLookupWrapperProps) => { const HostOfferLookupWrapper = ({}: HostLookupWrapperProps) => {
const {data, isFetching} = useGetOffersQuery({auth: testAuth as Auth}, {staleTime: 60 * 1000}) const staleTimeMinutes = 60 // hotfix till table settings by user (columns width, filters, sort options, …) are persisted
const {data, isFetching} = useGetOffersQuery({auth: testAuth as Auth}, {staleTime: staleTimeMinutes * 60 * 1000})
return <>{ return <>
(!isFetching && data?.get_offers) ? <HostOfferLookupTable data={data}/> : "loading…" { isFetching && <p> loading </p> }
}</> { data?.get_offers && <HostOfferLookupTable data={data}/> }
</>
} }
export default HostOfferLookupWrapper export default HostOfferLookupWrapper