2022-03-09 15:39:15 +01:00
|
|
|
import React from 'react'
|
2022-03-11 16:44:52 +01:00
|
|
|
import { Auth, useGetOffersQuery } from "../../codegen/generates"
|
2022-03-09 15:39:15 +01:00
|
|
|
import testAuth from '../util/testAuth.json'
|
2022-03-11 16:44:52 +01:00
|
|
|
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) => {
|
2022-03-11 16:44:52 +01:00
|
|
|
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
|
2022-03-11 16:44:52 +01:00
|
|
|
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 <>
|
2022-03-11 16:44:52 +01:00
|
|
|
{ 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
|