Skip to content

Commit 331f6f0

Browse files
Merge pull request #2037 from appwrite/fix-payment-tables
Update table column types and adjust payment layouts
2 parents 3f3af27 + ee53946 commit 331f6f0

File tree

6 files changed

+58
-37
lines changed

6 files changed

+58
-37
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@appwrite.io/pink-icons": "0.25.0",
2727
"@appwrite.io/pink-icons-svelte": "^2.0.0-RC.1",
2828
"@appwrite.io/pink-legacy": "^1.0.3",
29-
"@appwrite.io/pink-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@ee1b778",
29+
"@appwrite.io/pink-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@973fff2",
3030
"@popperjs/core": "^2.11.8",
3131
"@sentry/sveltekit": "^8.38.0",
3232
"@stripe/stripe-js": "^3.5.0",

pnpm-lock.yaml

Lines changed: 25 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/components/cardGrid.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
</Typography.Text>
1717
{/if}
1818
</Layout.Stack>
19-
<Layout.Stack {gap}>
20-
<slot name="aside" />
21-
</Layout.Stack>
19+
<div style:overflow="hidden">
20+
<Layout.Stack {gap}>
21+
<slot name="aside" />
22+
</Layout.Stack>
23+
</div>
2224
</Layout.GridFraction>
2325
{#if $$slots.actions && !hideFooter}
2426
<span

src/lib/helpers/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ export type TableRootProp = {
6060
selectedAll: boolean;
6161
selectedNone: boolean;
6262
selectedSome: boolean;
63-
columns: Record<PinkColumn['id'], PinkColumn>;
63+
columns: Array<PinkColumn> | number;
64+
columnsMap: Record<PinkColumn['id'], PinkColumn>;
6465
toggle: (id: string) => void;
6566
toggleAll: () => void;
6667
addAvailableId: (id: string) => void;

src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import type { Invoice, InvoiceList } from '$lib/sdk/billing';
88
import { getApiEndpoint, sdk } from '$lib/stores/sdk';
99
import { Query } from '@appwrite.io/console';
10-
import { onMount } from 'svelte';
1110
import { trackEvent } from '$lib/actions/analytics';
1211
import { selectedInvoice, showRetryModal } from './store';
1312
import {
@@ -28,39 +27,42 @@
2827
IconRefresh
2928
} from '@appwrite.io/pink-icons-svelte';
3029
31-
let offset = 0;
32-
let invoiceList: InvoiceList = {
30+
let offset = $state(0);
31+
let invoiceList: InvoiceList = $state({
3332
invoices: [],
3433
total: 0
35-
};
34+
});
3635
3736
const limit = 5;
3837
const endpoint = getApiEndpoint();
3938
40-
onMount(request);
41-
4239
async function request() {
43-
// isLoadingInvoices = true;
4440
invoiceList = await sdk.forConsole.billing.listInvoices(page.params.organization, [
4541
Query.limit(limit),
4642
Query.offset(offset),
4743
Query.orderDesc('$createdAt')
4844
]);
4945
}
5046
51-
$: if (page.url.searchParams.get('type') === 'validate-invoice') {
52-
window.history.replaceState({}, '', page.url.pathname);
53-
request();
54-
}
55-
5647
function retryPayment(invoice: Invoice) {
5748
$selectedInvoice = invoice;
5849
$showRetryModal = true;
5950
}
6051
61-
$: if (offset !== null) {
62-
request();
63-
}
52+
const hasPaymentError = $derived(invoiceList?.invoices.some((invoice) => invoice?.lastError));
53+
54+
$effect(() => {
55+
if (page.url.searchParams.get('type') === 'validate-invoice') {
56+
window.history.replaceState({}, '', page.url.pathname);
57+
request();
58+
}
59+
});
60+
61+
$effect(() => {
62+
if (offset !== null) {
63+
request();
64+
}
65+
});
6466
</script>
6567

6668
<CardGrid>
@@ -71,8 +73,8 @@
7173
<Table.Root
7274
let:root
7375
columns={[
74-
{ id: 'dueDate' },
75-
{ id: 'status', width: { min: 200 } },
76+
{ id: 'dueDate', width: { min: 120 } },
77+
{ id: 'status', width: { min: hasPaymentError ? 200 : 100 } },
7678
{ id: 'amount', width: { min: 120 } },
7779
{ id: 'action', width: 40 }
7880
]}>
@@ -162,10 +164,10 @@
162164
{/each}
163165
</Table.Root>
164166
{#if invoiceList.total > limit}
165-
<div class="u-flex u-main-space-between">
167+
<Layout.Stack direction="row" justifyContent="space-between" alignItems="center">
166168
<p class="text">Total results: {invoiceList.total}</p>
167169
<PaginationInline {limit} bind:offset total={invoiceList.total} hidePages />
168-
</div>
170+
</Layout.Stack>
169171
{/if}
170172
{:else}
171173
<Card.Base>

src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@
115115
<Table.Root
116116
let:root
117117
columns={[
118-
{ id: 'cc', width: 140 },
118+
{ id: 'cc', width: { min: 155 } },
119119
{ id: 'name', width: { min: 140 } },
120-
{ id: 'expiry', width: 100 },
121-
{ id: 'status', width: 110, hide: !hasPaymentError },
120+
{ id: 'expiry', width: { min: 75 } },
121+
{ id: 'status', width: { min: 110 }, hide: !hasPaymentError },
122122
{ id: 'actions', width: 40 }
123123
]}>
124124
<svelte:fragment slot="header" let:root>
125125
<Table.Header.Cell column="cc" {root}>Credit card</Table.Header.Cell>
126126
<Table.Header.Cell column="name" {root}>Name</Table.Header.Cell>
127-
<Table.Header.Cell column="expiry" {root}>Expiration date</Table.Header.Cell>
127+
<Table.Header.Cell column="expiry" {root}>Expiration</Table.Header.Cell>
128128
<Table.Header.Cell column="status" {root} />
129129
<Table.Header.Cell column="actions" {root} />
130130
</svelte:fragment>

0 commit comments

Comments
 (0)