Skip to content

Commit

Permalink
fix: rename total attribute of FilePaginationInfo for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
MellyGray committed Sep 1, 2023
1 parent f662270 commit d695c0c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/files/domain/models/FilePaginationInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ export class FilePaginationInfo {
constructor(
public readonly page: number = 1,
public readonly pageSize: number = 10,
public readonly total: number = 0
public readonly totalFiles: number = 0
) {}

withTotal(total: number): FilePaginationInfo {
return new FilePaginationInfo(this.page, this.pageSize, total)
}
goToPage(page: number): FilePaginationInfo {
return new FilePaginationInfo(page, this.pageSize, this.total)
return new FilePaginationInfo(page, this.pageSize, this.totalFiles)
}

goToPreviousPage(): FilePaginationInfo {
Expand All @@ -27,11 +27,11 @@ export class FilePaginationInfo {
const newPage = Math.ceil((this.page * oldPageSize) / newPageSize)
return newPage > 0 ? newPage : 1
}
return new FilePaginationInfo(getNewPage(this.pageSize, pageSize), pageSize, this.total)
return new FilePaginationInfo(getNewPage(this.pageSize, pageSize), pageSize, this.totalFiles)
}

get totalPages(): number {
return Math.ceil(this.total / this.pageSize)
return Math.ceil(this.totalFiles / this.pageSize)
}

get hasPreviousPage(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function FilesTable({ files, isLoading, paginationInfo }: FilesTableProps
<RowSelectionMessage
rowSelection={rowSelection}
selectAllRows={selectAllRows}
totalFilesCount={paginationInfo.total}
totalFilesCount={paginationInfo.totalFiles}
clearRowSelection={clearRowSelection}
/>
<ZipDownloadLimitMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function useRowSelection(
}
const selectAllRows = () => {
setCurrentPageRowSelection(createRowSelection(paginationInfo.pageSize))
setRowSelection(createRowSelection(paginationInfo.total))
setRowSelection(createRowSelection(paginationInfo.totalFiles))
}
const clearRowSelection = () => {
setCurrentPageRowSelection({})
Expand All @@ -71,7 +71,7 @@ export function useRowSelection(
}
}
const isAllRowsSelected = () => {
return Object.keys(rowSelection).length === paginationInfo.total
return Object.keys(rowSelection).length === paginationInfo.totalFiles
}

useEffect(() => {
Expand Down

0 comments on commit d695c0c

Please sign in to comment.