mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-19 15:55:26 +02:00
38 lines
979 B
TypeScript
38 lines
979 B
TypeScript
import {ReactElement} from "react"
|
|
import {AxiosError} from "axios"
|
|
|
|
import {useQuery} from "@tanstack/react-query"
|
|
import {List} from "@mui/material"
|
|
|
|
import {DecryptedReportContent, PaginationResult, Report} from "~/server-types"
|
|
import {getReports} from "~/apis"
|
|
import {WithEncryptionRequired} from "~/hocs"
|
|
import {DecryptReport} from "~/components"
|
|
import QueryResult from "~/components/QueryResult"
|
|
import ReportsList from "~/route-widgets/ReportsRoute/ReportsList"
|
|
|
|
function ReportsRoute(): ReactElement {
|
|
const query = useQuery<PaginationResult<Report>, AxiosError>(
|
|
["get_reports"],
|
|
getReports,
|
|
)
|
|
|
|
return (
|
|
<QueryResult<PaginationResult<Report>> query={query}>
|
|
{result => (
|
|
<List>
|
|
<DecryptReport reports={result.items}>
|
|
{reports => (
|
|
<ReportsList
|
|
reports={reports as DecryptedReportContent[]}
|
|
/>
|
|
)}
|
|
</DecryptReport>
|
|
</List>
|
|
)}
|
|
</QueryResult>
|
|
)
|
|
}
|
|
|
|
export default WithEncryptionRequired(ReportsRoute)
|