Skip to content

Commit 1f1e845

Browse files
Merge pull request #1664 from appwrite/feat-invoice-view-download-url
Feat: routes for viewing invoice
2 parents 7e8084b + 96aa042 commit 1f1e845

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323
import { toLocaleDate } from '$lib/helpers/date';
2424
import { formatCurrency } from '$lib/helpers/numbers';
2525
import type { Invoice, InvoiceList } from '$lib/sdk/billing';
26-
import { getApiEndpoint, sdk } from '$lib/stores/sdk';
26+
import { sdk } from '$lib/stores/sdk';
2727
import { Query } from '@appwrite.io/console';
2828
import { onMount } from 'svelte';
2929
import { trackEvent } from '$lib/actions/analytics';
3030
import { selectedInvoice, showRetryModal } from './store';
3131
import { organization } from '$lib/stores/organization';
32+
import { base } from '$app/paths';
3233
3334
let showDropdown = [];
3435
let showFailedError = false;
@@ -41,7 +42,6 @@
4142
};
4243
4344
const limit = 5;
44-
const endpoint = getApiEndpoint();
4545
4646
onMount(request);
4747
@@ -153,14 +153,14 @@
153153
<DropListLink
154154
icon="external-link"
155155
external
156-
href={`${endpoint}/organizations/${$page.params.organization}/invoices/${invoice.$id}/view`}
156+
href={`${base}/organization-${$page.params.organization}/invoices/${invoice.$id}/view`}
157157
on:click={() => (showDropdown[i] = !showDropdown[i])}
158158
event="view_invoice">
159159
View invoice
160160
</DropListLink>
161161
<DropListLink
162162
icon="download"
163-
href={`${endpoint}/organizations/${$page.params.organization}/invoices/${invoice.$id}/download`}
163+
href={`${base}/organization-${$page.params.organization}/invoices/${invoice.$id}/download`}
164164
on:click={() => {
165165
showDropdown[i] = !showDropdown[i];
166166
}}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { getApiEndpoint, sdk } from '$lib/stores/sdk';
2+
import { redirect } from '@sveltejs/kit';
3+
import type { PageLoad } from './$types';
4+
5+
export const load: PageLoad = async ({ params }) => {
6+
// verify invoice exists
7+
const invoice = await sdk.forConsole.billing.getInvoice(params.organization, params.invoiceId);
8+
const endpoint = getApiEndpoint();
9+
10+
return redirect(
11+
302,
12+
`${endpoint}/organizations/${params.organization}/invoices/${invoice.$id}/download`
13+
);
14+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { getApiEndpoint, sdk } from '$lib/stores/sdk';
2+
import { redirect } from '@sveltejs/kit';
3+
import type { PageLoad } from './$types';
4+
5+
export const load: PageLoad = async ({ params }) => {
6+
// verify invoice exists
7+
const invoice = await sdk.forConsole.billing.getInvoice(params.organization, params.invoiceId);
8+
const endpoint = getApiEndpoint();
9+
10+
return redirect(
11+
302,
12+
`${endpoint}/organizations/${params.organization}/invoices/${invoice.$id}/view`
13+
);
14+
};

0 commit comments

Comments
 (0)