-
Notifications
You must be signed in to change notification settings - Fork 13
PM-589 Fix Load more logic #1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,7 @@ const CopilotOpportunityList: FC<{}> = () => { | |
const navigate = useNavigate() | ||
|
||
const { | ||
data: opportunities, isValidating, size, setSize, | ||
data: opportunities, hasMoreOpportunities, isValidating, size, setSize, | ||
}: CopilotOpportunitiesResponse = useCopilotOpportunities() | ||
|
||
const tableData = useMemo(() => opportunities.map(opportunity => ({ | ||
|
@@ -129,7 +129,7 @@ const CopilotOpportunityList: FC<{}> = () => { | |
<Table | ||
columns={tableColumns} | ||
data={tableData} | ||
moreToLoad={isValidating || opportunities.length > 0} | ||
moreToLoad={hasMoreOpportunities} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable |
||
onLoadMoreClick={loadMore} | ||
onRowClick={handleRowClick} | ||
removeDefaultSort | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ function copilotOpportunityFactory(data: any): CopilotOpportunity { | |
export interface CopilotOpportunitiesResponse { | ||
isValidating: boolean; | ||
data: CopilotOpportunity[]; | ||
hasMoreOpportunities: boolean; | ||
himaniraghav3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
size: number; | ||
setSize: (size: number) => void; | ||
} | ||
|
@@ -59,7 +60,10 @@ export const useCopilotOpportunities = (): CopilotOpportunitiesResponse => { | |
// Flatten data array | ||
const opportunities = data ? data.flat() : [] | ||
|
||
return { data: opportunities, isValidating, setSize: (s: number) => { setSize(s) }, size } | ||
const lastPage = data[data.length - 1] || [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if |
||
const hasMoreOpportunities = lastPage.length === PAGE_SIZE | ||
|
||
return { data: opportunities, hasMoreOpportunities, isValidating, setSize: (s: number) => { setSize(s) }, size } | ||
} | ||
|
||
export type CopilotOpportunityResponse = SWRResponse<CopilotOpportunity, CopilotOpportunity> | ||
|
Uh oh!
There was an error while loading. Please reload this page.