-
Notifications
You must be signed in to change notification settings - Fork 188
feat: pagination on billing ui table #2350
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
Open
HarshMN2345
wants to merge
4
commits into
main
Choose a base branch
from
feat-SER-347-Add-pagination-new-billing-ui
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,9 @@ import { redirect } from '@sveltejs/kit'; | |
import type { PageLoad } from './$types'; | ||
import { isCloud } from '$lib/system'; | ||
|
||
export const load: PageLoad = async ({ parent, depends }) => { | ||
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load'; | ||
|
||
export const load: PageLoad = async ({ parent, depends, url, route }) => { | ||
const { organization, scopes, currentPlan, countryList, locale } = await parent(); | ||
|
||
if (!scopes.includes('billing.read')) { | ||
|
@@ -18,6 +20,8 @@ export const load: PageLoad = async ({ parent, depends }) => { | |
depends(Dependencies.CREDIT); | ||
depends(Dependencies.INVOICES); | ||
depends(Dependencies.ADDRESS); | ||
//aggregation reloads on page param changes | ||
depends('billing:aggregation'); | ||
|
||
const billingAddressId = (organization as Organization)?.billingAddressId; | ||
const billingAddressPromise: Promise<Address> = billingAddressId | ||
|
@@ -33,9 +37,14 @@ export const load: PageLoad = async ({ parent, depends }) => { | |
*/ | ||
let billingAggregation = null; | ||
try { | ||
const currentPage = getPage(url) || 1; | ||
const limit = getLimit(url, route, 5); | ||
const offset = pageToOffset(currentPage, limit); | ||
billingAggregation = await sdk.forConsole.billing.getAggregation( | ||
organization.$id, | ||
(organization as Organization)?.billingAggregationId | ||
(organization as Organization)?.billingAggregationId, | ||
limit, | ||
offset | ||
); | ||
ItzNotABug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} catch (e) { | ||
// ignore error | ||
|
@@ -83,6 +92,11 @@ export const load: PageLoad = async ({ parent, depends }) => { | |
areCreditsSupported, | ||
countryList, | ||
locale, | ||
nextPlan: billingPlanDowngrade | ||
nextPlan: billingPlanDowngrade, | ||
// expose pagination for components | ||
limit: getLimit(url, route, 5), | ||
offset: pageToOffset(getPage(url) || 1, getLimit(url, route, 5)), | ||
// unique key to force component refresh on page change | ||
aggregationKey: `agg:${getPage(url) || 1}:${getLimit(url, route, 5)}` | ||
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. why not just invalidate the dependency? |
||
}; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets make a const in Dependencies for this.