Skip to content

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

Merged
merged 2 commits into from
Apr 29, 2025
Merged

PM-589 Fix Load more logic #1055

merged 2 commits into from
Apr 29, 2025

Conversation

himaniraghav3
Copy link
Collaborator

Related JIRA Ticket:

https://topcoder.atlassian.net/browse/PM-589

What's in this PR?

Add logic to Show load more button only when there is more data to load

@@ -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] || []

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if data is not null or undefined before accessing data.length to prevent potential runtime errors.

@@ -129,7 +129,7 @@ const CopilotOpportunityList: FC<{}> = () => {
<Table
columns={tableColumns}
data={tableData}
moreToLoad={isValidating || opportunities.length > 0}
moreToLoad={hasMoreOpportunities}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable hasMoreOpportunities should be defined and initialized properly in the component to ensure it accurately reflects whether there are more opportunities to load. Verify that hasMoreOpportunities is correctly set and updated based on the data source.

@kkartunov kkartunov merged commit 150e438 into dev Apr 29, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants