beherbergung/frontend/search/components/ngo/HostOfferLookupWrapper.tsx

29 lines
984 B
TypeScript
Raw Normal View History

2022-03-09 15:39:15 +01:00
import React from 'react'
import {Auth, useGetOffersQuery} from "../../codegen/generates";
import testAuth from '../util/testAuth.json'
import HostOfferLookupTable from "./HostOfferLookupTable";
2022-03-11 11:25:02 +01:00
import {Box} from "@mui/material";
2022-03-09 15:39:15 +01:00
type HostLookupWrapperProps = Record<string, never>
const HostOfferLookupWrapper = ({}: HostLookupWrapperProps) => {
2022-03-10 11:50:33 +01:00
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})
2022-03-09 21:58:51 +01:00
2022-03-10 11:50:33 +01:00
return <>
{ isFetching && <p> loading </p> }
2022-03-11 11:25:02 +01:00
{ data?.get_offers && <Box sx={{
display: 'flex',
alignItems: 'stretch',
flexDirection: 'column',
height: '100%'}}>
<div
style={{flex: '1 1', height: '100%'}}>
<HostOfferLookupTable data={data}/>
</div>
</Box> }
2022-03-10 11:50:33 +01:00
</>
2022-03-09 15:39:15 +01:00
}
export default HostOfferLookupWrapper