-
Notifications
You must be signed in to change notification settings - Fork 190
feat: pagination on billing ui table and refactoring it #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
base: main
Are you sure you want to change the base?
Changes from 4 commits
29c12d6
c0e3043
9de7ece
bb41f8f
926d46e
c80dfff
b5ef9b7
31b66ad
9561b48
92963d0
7d9f53f
6b3e79d
0fb6a65
3e07a3d
15ae2d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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'); | ||
HarshMN2345 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
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)}` | ||
|
||
}; | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.