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

34 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-03-09 15:39:15 +01:00
import React from 'react'
import { Auth, useGetOffersQuery } from "../../codegen/generates"
2022-03-09 15:39:15 +01:00
import testAuth from '../util/testAuth.json'
import HostOfferLookupTable from "./HostOfferLookupTable"
import { Box } from "@mui/material"
import { useTranslation } from 'react-i18next'
2022-03-09 15:39:15 +01:00
type HostLookupWrapperProps = Record<string, never>
const HostOfferLookupWrapper = ({}: HostLookupWrapperProps) => {
const { t } = useTranslation()
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, error} = 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>{ t('loading…') }</p> }
{ error && <p>{ t('An error occurred while trying to get data from the backend.') }</p> }
{ data && !data.get_offers && <p>{ t('Seems like you have no permissions. Please try to login again.') }</p> }
2022-03-11 11:25:02 +01:00
{ data?.get_offers && <Box sx={{
display: 'flex',
alignItems: 'stretch',
flexDirection: 'column',
2022-03-11 14:28:09 +01:00
height: '100vh'}}>
2022-03-11 11:25:02 +01:00
<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