Redirect to API report when there are 0 reports (#28145)

* redirect to api report when there are 0 reports

* Update apps/studio/pages/project/[ref]/reports/index.tsx

Co-authored-by: Alaister Young <alaister@users.noreply.github.com>

---------

Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
This commit is contained in:
Jordi EnricandAlaister Young authored and GitHub committed 2024-07-23 12:57:17 +02:00
1 parent 4496c5a9ab
commit fe8aec6070
1 file changed
+2 -1
@@ -24,7 +24,8 @@ export const UserReportPage: NextPageWithLayout = () => {
const reports = data.content
.filter((x) => x.type === 'report')
.sort((a, b) => a.name.localeCompare(b.name))
if (reports.length > 1) router.push(`/project/${ref}/reports/${reports[0].id}`)
if (reports.length >= 1) router.push(`/project/${ref}/reports/${reports[0].id}`)
if (reports.length === 0) router.push(`/project/${ref}/reports/api-overview`)
},
})