Skip to content

Commit 18ad1af

Browse files
committed
fix: bug with no results on storage page (#7411)
## [Dashboard] Fix: Add optional chaining to prevent undefined errors in YourFilesSection ## Notes for the reviewer Added optional chaining to prevent potential undefined errors when accessing `pinnedFilesQuery.data.result` properties in the YourFilesSection component. This ensures the component handles cases where the data or result might be undefined more gracefully. ## How to test Verify that the YourFilesSection component renders correctly when data is loading or when the API returns undefined values. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved reliability when displaying pinned files by preventing errors if data is missing or incomplete. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent e70e9b9 commit 18ad1af

File tree

1 file changed

+4
-4
lines changed
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/storage

1 file changed

+4
-4
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/storage/your-files.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ export const YourFilesSection = (props: { authToken: string }) => {
137137
pageSize: pageSize,
138138
});
139139

140-
const showPagination = pinnedFilesQuery.data
140+
const showPagination = pinnedFilesQuery.data?.result
141141
? pinnedFilesQuery.data.result.count > pageSize
142142
: false;
143143

144-
const totalPages = pinnedFilesQuery.data
144+
const totalPages = pinnedFilesQuery.data?.result
145145
? Math.ceil(pinnedFilesQuery.data.result.count / pageSize)
146146
: 0;
147147

148-
const pinnedFilesToShow = pinnedFilesQuery.data
148+
const pinnedFilesToShow = pinnedFilesQuery.data?.result
149149
? pinnedFilesQuery.data.result.pinnedFiles
150150
: undefined;
151151

@@ -206,7 +206,7 @@ export const YourFilesSection = (props: { authToken: string }) => {
206206
</TableBody>
207207
</Table>
208208

209-
{pinnedFilesQuery.data && pinnedFilesQuery.data.result.count === 0 && (
209+
{pinnedFilesQuery.data?.result?.count === 0 && (
210210
<div className="flex min-h-[250px] items-center justify-center rounded-lg">
211211
No Pinned Files
212212
</div>

0 commit comments

Comments
 (0)