From cf4b25c9427519436e854f7bc0d5377cfcf66d38 Mon Sep 17 00:00:00 2001 From: Arman Date: Fri, 23 Jun 2023 17:15:42 +0200 Subject: [PATCH] refactor: usage --- src/lib/components/index.ts | 1 + src/lib/components/progressBarBig.svelte | 31 +++++ .../invoices/+page.svelte | 113 ++++++++++-------- .../invoices/+page.ts | 21 ++++ .../usage/[[period]]/+page.svelte | 14 ++- 5 files changed, 131 insertions(+), 49 deletions(-) create mode 100644 src/lib/components/progressBarBig.svelte create mode 100644 src/routes/console/organization-[organization]/invoices/+page.ts diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts index 6cfea4d81..2f4c5a5df 100644 --- a/src/lib/components/index.ts +++ b/src/lib/components/index.ts @@ -56,4 +56,5 @@ export { default as ClickableList } from './clickableList.svelte'; export { default as ClickableListItem } from './clickableListItem.svelte'; export { default as Id } from './id.svelte'; export { default as ProgressBar } from './progressBar.svelte'; +export { default as ProgressBarBig } from './progressBarBig.svelte'; export { default as ProjectUsage } from './projectUsage.svelte'; diff --git a/src/lib/components/progressBarBig.svelte b/src/lib/components/progressBarBig.svelte new file mode 100644 index 000000000..52c94f394 --- /dev/null +++ b/src/lib/components/progressBarBig.svelte @@ -0,0 +1,31 @@ + + +
+
+
+

+ {used} + {unit} +

+

{progress}%

+
+

+ {max} + {unit} +

+
+
+
diff --git a/src/routes/console/organization-[organization]/invoices/+page.svelte b/src/routes/console/organization-[organization]/invoices/+page.svelte index cefa2947f..b338ae831 100644 --- a/src/routes/console/organization-[organization]/invoices/+page.svelte +++ b/src/routes/console/organization-[organization]/invoices/+page.svelte @@ -1,5 +1,12 @@ @@ -20,50 +29,58 @@
Invoices
- - - Date - Status - Amount Due - Invoce # - - - - {#each invoices as invoice, i} - - test - - test - - $1BILLION - test - - - - - { - console.log('test'); - }}>View invoice - - { - console.log('test'); - }}>Download PDF - - - - - {/each} - - + {#if data.invoices?.total} + + + Date + Status + Amount Due + Invoce # + + + + + {#each [] as invoice, i} + + test + + test + + $1BILLION + test + + + + + + View invoice + + { + console.log('test'); + }}>Download PDF + + + + + {/each} + + +
+

Total results: {data.invoices?.total}

+ +
+ {:else} + + You have no payment history. After you receive your first invoice, you'll see it here. + + {/if} diff --git a/src/routes/console/organization-[organization]/invoices/+page.ts b/src/routes/console/organization-[organization]/invoices/+page.ts new file mode 100644 index 000000000..7867ce5c1 --- /dev/null +++ b/src/routes/console/organization-[organization]/invoices/+page.ts @@ -0,0 +1,21 @@ +import { Query } from '@appwrite.io/console'; +import { sdk } from '$lib/stores/sdk'; +import { getPage, pageToOffset } from '$lib/helpers/load'; +import { PAGE_LIMIT } from '$lib/constants'; +import type { PageLoad } from './$types'; + +export const load: PageLoad = async ({ params, url }) => { + const page = getPage(url); + // const limit = getLimit(url, route, CARD_LIMIT); + const offset = pageToOffset(page, PAGE_LIMIT); + + return { + offset, + invoices: await sdk.forConsole.projects.list([ + Query.offset(offset), + Query.limit(PAGE_LIMIT), + Query.equal('teamId', params.organization), + Query.orderDesc('$createdAt') + ]) + }; +}; diff --git a/src/routes/console/organization-[organization]/usage/[[period]]/+page.svelte b/src/routes/console/organization-[organization]/usage/[[period]]/+page.svelte index f091efc12..27850d1fc 100644 --- a/src/routes/console/organization-[organization]/usage/[[period]]/+page.svelte +++ b/src/routes/console/organization-[organization]/usage/[[period]]/+page.svelte @@ -1,6 +1,6 @@