diff --git a/src/hooks.client.ts b/src/hooks.client.ts new file mode 100644 index 0000000000..2345ffb2ce --- /dev/null +++ b/src/hooks.client.ts @@ -0,0 +1,13 @@ +import { AppwriteException } from '@appwrite.io/console'; +import type { HandleClientError } from '@sveltejs/kit'; + +export const handleError: HandleClientError = async ({ error, message, status }) => { + if (error instanceof AppwriteException && error.code === 0) { + status = undefined; + message = error.message; + } + return { + message, + status + }; +}; diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index 450aa63756..023ed61ff9 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -134,7 +134,7 @@ bind:value={operatorKey} /> {#if column && operator && !operator?.hideInput} -
+
+ {/if} diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 4b3f685203..3919a26c3d 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -13,9 +13,10 @@ export const ssr = false; export const load: LayoutLoad = async ({ depends, url }) => { depends(Dependencies.ACCOUNT); - redirectTo.set(url.searchParams.get('forceRedirect') || null); - - url.searchParams.delete('forceRedirect'); + if (url.searchParams.has('forceRedirect')) { + redirectTo.set(url.searchParams.get('forceRedirect') || null); + url.searchParams.delete('forceRedirect'); + } try { const account = await sdk.forConsole.account.get<{ organization?: string }>(); diff --git a/src/routes/console/+error.svelte b/src/routes/console/+error.svelte index 9a50e9be7c..33d7695d1e 100644 --- a/src/routes/console/+error.svelte +++ b/src/routes/console/+error.svelte @@ -6,7 +6,7 @@ - {$page.status} + {$page.error.status || 'Invalid Argument'} {$page.error.message} diff --git a/src/routes/console/organization-[organization]/+layout.ts b/src/routes/console/organization-[organization]/+layout.ts index cfd2120572..79eba27f34 100644 --- a/src/routes/console/organization-[organization]/+layout.ts +++ b/src/routes/console/organization-[organization]/+layout.ts @@ -10,6 +10,7 @@ import { headerAlert } from '$lib/stores/headerAlert'; import ProjectsAtRisk from '$lib/components/billing/alerts/projectsAtRisk.svelte'; import { get } from 'svelte/store'; import { preferences } from '$lib/stores/preferences'; +import type { Organization } from '$lib/stores/organization'; export const load: LayoutLoad = async ({ params, depends }) => { depends(Dependencies.ORGANIZATION); @@ -37,7 +38,9 @@ export const load: LayoutLoad = async ({ params, depends }) => { return { header: Header, breadcrumbs: Breadcrumbs, - organization: await sdk.forConsole.teams.get(params.organization), + organization: await (sdk.forConsole.teams.get( + params.organization + ) as Promise), members: await sdk.forConsole.teams.listMemberships(params.organization) }; } catch (e) { diff --git a/src/routes/console/project-[project]/+error.svelte b/src/routes/console/project-[project]/+error.svelte index 243be6e42d..be0053176c 100644 --- a/src/routes/console/project-[project]/+error.svelte +++ b/src/routes/console/project-[project]/+error.svelte @@ -5,6 +5,6 @@ - {$page.status} + {$page.error.status || 'Invalid Argument'}

{$page.error.message}

diff --git a/src/routes/console/project-[project]/+layout.ts b/src/routes/console/project-[project]/+layout.ts index c25d0cd4c4..156a24f343 100644 --- a/src/routes/console/project-[project]/+layout.ts +++ b/src/routes/console/project-[project]/+layout.ts @@ -5,6 +5,7 @@ import type { LayoutLoad } from './$types'; import { preferences } from '$lib/stores/preferences'; import { failedInvoice } from '$lib/stores/billing'; import { isCloud } from '$lib/system'; +import type { Organization } from '$lib/stores/organization'; export const load: LayoutLoad = async ({ params, depends }) => { depends(Dependencies.PROJECT); @@ -22,7 +23,7 @@ export const load: LayoutLoad = async ({ params, depends }) => { return { project, - organization: await sdk.forConsole.teams.get(project.teamId) + organization: await (sdk.forConsole.teams.get(project.teamId) as Promise) }; } catch (e) { error(e.code, e.message); diff --git a/src/routes/console/project-[project]/settings/usage/[[invoice]]/+page.ts b/src/routes/console/project-[project]/settings/usage/[[invoice]]/+page.ts index d29b1e7996..2cb455ae0f 100644 --- a/src/routes/console/project-[project]/settings/usage/[[invoice]]/+page.ts +++ b/src/routes/console/project-[project]/settings/usage/[[invoice]]/+page.ts @@ -1,24 +1,22 @@ +import type { Aggregation, Invoice } from '$lib/sdk/billing'; +import { accumulateUsage } from '$lib/sdk/usage'; import { getSdkForProject, sdk } from '$lib/stores/sdk'; import { Query } from '@appwrite.io/console'; import type { PageLoad } from './$types'; -import type { Organization } from '$lib/stores/organization'; -import type { Aggregation, Invoice } from '$lib/sdk/billing'; -import { accumulateUsage } from '$lib/sdk/usage'; export const load: PageLoad = async ({ params, parent }) => { const { invoice, project } = params; - const parentData = await parent(); - const org = parentData.organization as Organization; + const { organization } = await parent(); - let startDate: string = org.billingCurrentInvoiceDate; - let endDate: string = org.billingNextInvoiceDate; + let startDate: string = organization.billingCurrentInvoiceDate; + let endDate: string = organization.billingNextInvoiceDate; let currentInvoice: Invoice = undefined; let currentAggregation: Aggregation = undefined; if (invoice) { - currentInvoice = await sdk.forConsole.billing.getInvoice(org.$id, invoice); + currentInvoice = await sdk.forConsole.billing.getInvoice(organization.$id, invoice); currentAggregation = await sdk.forConsole.billing.getAggregation( - org.$id, + organization.$id, currentInvoice.aggregationId ); @@ -27,7 +25,7 @@ export const load: PageLoad = async ({ params, parent }) => { } const [invoices, usage] = await Promise.all([ - sdk.forConsole.billing.listInvoices(org.$id, [Query.orderDesc('from')]), + sdk.forConsole.billing.listInvoices(organization.$id, [Query.orderDesc('from')]), /** * Workaround because project id might not be populated yet. */