Merge branch 'main' of github.com:appwrite/console into feat-email-signature-card
No files matched your search
@@ -0,0 +1,23 @@
|
||||
name: Mark stale issues
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # Midnight Runtime
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: "This issue has been labeled as a 'question', indicating that it requires additional information from the requestor. It has been inactive for 7 days. If no further activity occurs, this issue will be closed in 14 days."
|
||||
stale-issue-label: 'stale'
|
||||
days-before-stale: 7
|
||||
days-before-close: 14
|
||||
remove-stale-when-updated: true
|
||||
close-issue-message: 'This issue has been closed due to inactivity. If you still require assistance, please provide the requested information.'
|
||||
close-issue-reason: 'not_planned'
|
||||
operations-per-run: 100
|
||||
only-labels: 'question'
|
||||
@@ -9,12 +9,14 @@
|
||||
import { organization } from '$lib/stores/organization';
|
||||
</script>
|
||||
|
||||
{#if $organization?.$id && $organization?.billingPlan === BillingPlan.STARTER && $readOnly && !hideBillingHeaderRoutes.includes($page.url.pathname)}
|
||||
{#if $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && $readOnly && !hideBillingHeaderRoutes.includes($page.url.pathname)}
|
||||
<HeaderAlert
|
||||
type="error"
|
||||
title={`${$organization.name} usage has reached the ${tierToPlan($organization.billingPlan).name} plan limit`}>
|
||||
<svelte:fragment>
|
||||
Usage for the <b>{$organization.name}</b> organization has reached the limits of the Starter
|
||||
Usage for the <b>{$organization.name}</b> organization has reached the limits of the {tierToPlan(
|
||||
$organization.billingPlan
|
||||
).name}
|
||||
plan. Consider upgrading to increase your resource usage.
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="buttons">
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<script lang="ts">
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
import { formatCurrency } from '$lib/helpers/numbers';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
|
||||
export let couponData: Partial<Coupon> = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
};
|
||||
export let fixedCoupon = false;
|
||||
</script>
|
||||
|
||||
{#if couponData?.credits}
|
||||
<span class="u-flex u-main-space-between">
|
||||
<div class="u-flex u-cross-center u-gap-4">
|
||||
<p class="text">
|
||||
<span class="icon-tag u-color-text-success" aria-hidden="true" />
|
||||
{#if couponData.credits >= 100}
|
||||
{couponData?.code?.toUpperCase()}
|
||||
{:else}
|
||||
<span use:tooltip={{ content: couponData?.code?.toUpperCase() }}>
|
||||
Credits applied
|
||||
</span>
|
||||
{/if}
|
||||
</p>
|
||||
{#if !fixedCoupon}
|
||||
<button
|
||||
type="button"
|
||||
class="button is-text is-only-icon"
|
||||
style="--button-size:1.5rem;"
|
||||
aria-label="Close"
|
||||
title="Close"
|
||||
on:click={() =>
|
||||
(couponData = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
})}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{#if couponData.credits >= 100}
|
||||
<p class="inline-tag" use:tooltip={{ content: formatCurrency(couponData.credits) }}>
|
||||
Credits applied
|
||||
</p>
|
||||
{:else}
|
||||
<span class="u-color-text-success">-{formatCurrency(couponData.credits)}</span>
|
||||
{/if}
|
||||
</span>
|
||||
{/if}
|
||||
@@ -1,15 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
import { FormList, InputChoice, InputNumber } from '$lib/elements/forms';
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import { formatCurrency } from '$lib/helpers/numbers';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import { plansInfo, type Tier } from '$lib/stores/billing';
|
||||
import { CreditsApplied } from '.';
|
||||
|
||||
export let billingPlan: Tier;
|
||||
export let collaborators: string[];
|
||||
export let couponData: Partial<Coupon>;
|
||||
export let billingBudget: number;
|
||||
export let fixedCoupon = false; // If true, the coupon cannot be removed
|
||||
|
||||
const today = new Date();
|
||||
const billingPayDate = new Date(today.getTime() + 30 * 24 * 60 * 60 * 1000);
|
||||
@@ -30,7 +31,10 @@
|
||||
);
|
||||
</script>
|
||||
|
||||
<section class="card u-margin-block-start-32 u-flex u-flex-vertical u-gap-8">
|
||||
<section
|
||||
class="card u-margin-block-start-32 u-flex u-flex-vertical u-gap-8"
|
||||
style:--p-card-padding="1.5rem"
|
||||
style:--p-card-border-radius="var(--border-radius-small)">
|
||||
<span class="u-flex u-main-space-between">
|
||||
<p class="text">{currentPlan.name} plan</p>
|
||||
<p class="text">{formatCurrency(currentPlan.price)}</p>
|
||||
@@ -42,40 +46,7 @@
|
||||
</p>
|
||||
</span>
|
||||
{#if couponData?.status === 'active'}
|
||||
<span class="u-flex u-main-space-between">
|
||||
<div class="u-flex u-cross-center u-gap-4">
|
||||
<p class="text">
|
||||
<span class="icon-tag u-color-text-success" aria-hidden="true" />
|
||||
{#if couponData.credits > 100}
|
||||
{couponData.code.toUpperCase()}
|
||||
{:else}
|
||||
<span use:tooltip={{ content: couponData.code.toUpperCase() }}
|
||||
>Credits applied</span>
|
||||
{/if}
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="button is-text is-only-icon"
|
||||
style="--button-size:1.5rem;"
|
||||
aria-label="Close"
|
||||
title="Close"
|
||||
on:click={() =>
|
||||
(couponData = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
})}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
{#if couponData.credits > 100}
|
||||
<p class="inline-tag" use:tooltip={{ content: formatCurrency(couponData.credits) }}>
|
||||
Credits applied
|
||||
</p>
|
||||
{:else}
|
||||
<span class="u-color-text-success">-{formatCurrency(couponData.credits)}</span>
|
||||
{/if}
|
||||
</span>
|
||||
<CreditsApplied bind:couponData {fixedCoupon} />
|
||||
{/if}
|
||||
<div class="u-sep-block-start" />
|
||||
<span class="u-flex u-main-space-between">
|
||||
|
||||
@@ -5,3 +5,4 @@ export { default as UsageRates } from './usageRates.svelte';
|
||||
export { default as EstimatedTotalBox } from './estimatedTotalBox.svelte';
|
||||
export { default as PlanComparisonBox } from './planComparisonBox.svelte';
|
||||
export { default as EmptyCardCloud } from './emptyCardCloud.svelte';
|
||||
export { default as CreditsApplied } from './creditsApplied.svelte';
|
||||
@@ -13,7 +13,7 @@
|
||||
<SecondaryTabsItem
|
||||
disabled={selectedTab === 'tier-0'}
|
||||
on:click={() => (selectedTab = 'tier-0')}>
|
||||
Starter
|
||||
Free
|
||||
</SecondaryTabsItem>
|
||||
<SecondaryTabsItem
|
||||
disabled={selectedTab === 'tier-1'}
|
||||
@@ -38,7 +38,7 @@
|
||||
{:else if selectedTab === 'tier-1'}
|
||||
<h3 class="u-bold body-text-1">{plan.name} plan</h3>
|
||||
<ul class="un-order-list u-margin-block-start-8">
|
||||
<li>Everything in the Starter plan, plus:</li>
|
||||
<li>Everything in the Free plan, plus:</li>
|
||||
<li>Unlimited databases, buckets, functions</li>
|
||||
<li>{plan.bandwidth}GB bandwidth</li>
|
||||
<li>{plan.storage}GB storage</li>
|
||||
|
||||
@@ -9,137 +9,130 @@
|
||||
TableScroll
|
||||
} from '$lib/elements/table';
|
||||
import { Alert } from '$lib/components';
|
||||
import { plansInfo, type Tier } from '$lib/stores/billing';
|
||||
import { calculateExcess, plansInfo, tierToPlan, type Tier } from '$lib/stores/billing';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { humanFileSize } from '$lib/helpers/sizeConvertion';
|
||||
import { abbreviateNumber, formatCurrency } from '$lib/helpers/numbers';
|
||||
import { abbreviateNumber } from '$lib/helpers/numbers';
|
||||
import { formatNum } from '$lib/helpers/string';
|
||||
import { onMount } from 'svelte';
|
||||
import type { OrganizationUsage } from '$lib/sdk/billing';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { BillingPlan } from '$lib/constants';
|
||||
|
||||
export let excess: {
|
||||
export let tier: Tier;
|
||||
|
||||
const plan = $plansInfo?.get(tier);
|
||||
let excess: {
|
||||
bandwidth?: number;
|
||||
storage?: number;
|
||||
users?: number;
|
||||
executions?: number;
|
||||
members?: number;
|
||||
} = null;
|
||||
export let currentTier: Tier;
|
||||
let usage: OrganizationUsage = null;
|
||||
let showExcess = false;
|
||||
|
||||
const plan = $plansInfo?.get(currentTier);
|
||||
const collaboratorPrice = formatCurrency(plan?.addons.member?.price ?? 0);
|
||||
onMount(async () => {
|
||||
usage = await sdk.forConsole.billing.listUsage(
|
||||
$organization.$id,
|
||||
$organization.billingCurrentInvoiceDate,
|
||||
new Date().toISOString()
|
||||
);
|
||||
excess = calculateExcess(usage, plan, $organization);
|
||||
showExcess = Object.values(excess).some((value) => value > 0);
|
||||
});
|
||||
</script>
|
||||
|
||||
<Alert type="error">
|
||||
<svelte:fragment slot="title">
|
||||
{#if currentTier === BillingPlan.STARTER}
|
||||
Your usage exceeds the {plan.name} plan limits
|
||||
{:else}
|
||||
Changing your plan now will result in removal of organization members and more
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
|
||||
{#if excess?.members > 0}
|
||||
{#if currentTier === BillingPlan.STARTER}
|
||||
The Starter plan has a limit of one organization member. By proceeding, all but the
|
||||
creator of the organization admin will be removed.
|
||||
{:else if currentTier === BillingPlan.PRO}
|
||||
Additional organization members on the Pro plan cost {collaboratorPrice} per member per billing
|
||||
period. By proceeding, you acknowledge your fees may increase in your next billing period.
|
||||
{/if}
|
||||
{/if}
|
||||
{#if excess?.bandwidth > 0 || excess?.executions > 0 || excess?.storage > 0 || excess?.users}
|
||||
Until you reduce your usage, you will be unable to add to the resources listed below in all
|
||||
projects within your organization. The current billing cycle will end on {toLocaleDate(
|
||||
$organization.billingCurrentInvoiceDate
|
||||
)}. Any executions, bandwidth, or messaging usage will be reset at that time.
|
||||
{/if}
|
||||
|
||||
<svelte:fragment slot="buttons">
|
||||
{#if currentTier === BillingPlan.STARTER}
|
||||
{#if showExcess}
|
||||
<Alert type="error" {...$$restProps}>
|
||||
<svelte:fragment slot="title">
|
||||
Your {tierToPlan($organization.billingPlan).name} plan subscription will end on {toLocaleDate(
|
||||
$organization.billingNextInvoiceDate
|
||||
)}
|
||||
</svelte:fragment>
|
||||
Following payment of your final invoice, your organization will switch to the {tierToPlan(
|
||||
BillingPlan.FREE
|
||||
).name} plan. {#if excess?.members > 0}All team members except the owner will be removed on
|
||||
that date.{/if} Service disruptions may occur unless resource usage is reduced.
|
||||
<!-- Any executions, bandwidth, or messaging usage will be reset at that time. -->
|
||||
<svelte:fragment slot="buttons">
|
||||
<Button
|
||||
text
|
||||
external
|
||||
href="https://appwrite.io/docs/advanced/platform/starter#reaching-resource-limits">
|
||||
href="https://appwrite.io/docs/advanced/platform/free#reaching-resource-limits">
|
||||
Learn more
|
||||
</Button>
|
||||
{:else if currentTier === BillingPlan.PRO}
|
||||
<Button
|
||||
text
|
||||
external
|
||||
href="https://appwrite.io/docs/advanced/platform/pro#reaching-resource-limits">
|
||||
Learn more
|
||||
</Button>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</Alert>
|
||||
</svelte:fragment>
|
||||
</Alert>
|
||||
|
||||
<TableScroll noMargin>
|
||||
<TableHeader>
|
||||
<TableCellHead>Resource</TableCellHead>
|
||||
<TableCellHead>Free limit</TableCellHead>
|
||||
<TableCellHead>Excess usage</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#if excess?.members}
|
||||
<TableRow>
|
||||
<TableCellText title="members">Organization members</TableCellText>
|
||||
<TableCellText title="limit">{plan.members} members</TableCellText>
|
||||
<TableCell title="excess">
|
||||
<p class="u-color-text-danger u-flex u-cross-center u-gap-4">
|
||||
<span class="icon-arrow-up" />
|
||||
{excess?.members} members
|
||||
</p>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/if}
|
||||
{#if excess?.storage}
|
||||
<TableRow>
|
||||
<TableCellText title="storage">Storage</TableCellText>
|
||||
<TableCellText title="limit">{plan.storage} GB</TableCellText>
|
||||
<TableCell title="excess">
|
||||
<p class="u-color-text-danger">
|
||||
<span class="icon-arrow-up" />
|
||||
{humanFileSize(excess?.storage)}
|
||||
</p>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/if}
|
||||
{#if excess?.executions}
|
||||
<TableRow>
|
||||
<TableCellText title="executions">Function executions</TableCellText>
|
||||
<TableCellText title="limit">
|
||||
{abbreviateNumber(plan.executions)} executions
|
||||
</TableCellText>
|
||||
<TableCell title="excess">
|
||||
<p class="u-color-text-danger">
|
||||
<span class="icon-arrow-up" />
|
||||
<span
|
||||
title={excess?.executions
|
||||
? excess.executions.toString()
|
||||
: 'executions'}>
|
||||
{formatNum(excess?.executions)} executions
|
||||
</span>
|
||||
</p>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/if}
|
||||
{#if excess?.users}
|
||||
<TableRow>
|
||||
<TableCellText title="users">Users</TableCellText>
|
||||
<TableCellText title="limit">
|
||||
{abbreviateNumber(plan.users)} users
|
||||
</TableCellText>
|
||||
<TableCell title="excess">
|
||||
<p class="u-color-text-danger">
|
||||
<span class="icon-arrow-up" />
|
||||
<span title={excess?.users ? excess.users.toString() : 'users'}>
|
||||
{formatNum(excess?.users)} users
|
||||
</span>
|
||||
</p>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/if}
|
||||
</TableBody>
|
||||
</TableScroll>
|
||||
<TableScroll dense noMargin class="u-margin-block-start-16">
|
||||
<TableHeader>
|
||||
<TableCellHead>Resource</TableCellHead>
|
||||
<TableCellHead>Free limit</TableCellHead>
|
||||
<TableCellHead>Excess usage</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#if excess?.members}
|
||||
<TableRow>
|
||||
<TableCellText title="members">Organization members</TableCellText>
|
||||
<TableCellText title="limit">{plan.members} members</TableCellText>
|
||||
<TableCell title="excess">
|
||||
<p class="u-color-text-danger u-flex u-cross-center u-gap-4">
|
||||
<span class="icon-arrow-up" />
|
||||
{excess?.members} members
|
||||
</p>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/if}
|
||||
{#if excess?.storage}
|
||||
<TableRow>
|
||||
<TableCellText title="storage">Storage</TableCellText>
|
||||
<TableCellText title="limit">{plan.storage} GB</TableCellText>
|
||||
<TableCell title="excess">
|
||||
<p class="u-color-text-danger">
|
||||
<span class="icon-arrow-up" />
|
||||
{humanFileSize(excess?.storage)}
|
||||
</p>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/if}
|
||||
{#if excess?.executions}
|
||||
<TableRow>
|
||||
<TableCellText title="executions">Function executions</TableCellText>
|
||||
<TableCellText title="limit">
|
||||
{abbreviateNumber(plan.executions)} executions
|
||||
</TableCellText>
|
||||
<TableCell title="excess">
|
||||
<p class="u-color-text-danger">
|
||||
<span class="icon-arrow-up" />
|
||||
<span
|
||||
title={excess?.executions
|
||||
? excess.executions.toString()
|
||||
: 'executions'}>
|
||||
{formatNum(excess?.executions)} executions
|
||||
</span>
|
||||
</p>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/if}
|
||||
{#if excess?.users}
|
||||
<TableRow>
|
||||
<TableCellText title="users">Users</TableCellText>
|
||||
<TableCellText title="limit">
|
||||
{abbreviateNumber(plan.users)} users
|
||||
</TableCellText>
|
||||
<TableCell title="excess">
|
||||
<p class="u-color-text-danger">
|
||||
<span class="icon-arrow-up" />
|
||||
<span title={excess?.users ? excess.users.toString() : 'users'}>
|
||||
{formatNum(excess?.users)} users
|
||||
</span>
|
||||
</p>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/if}
|
||||
</TableBody>
|
||||
</TableScroll>
|
||||
{/if}
|
||||
@@ -43,6 +43,7 @@
|
||||
{/if}
|
||||
<InputSelectSearch
|
||||
id="method"
|
||||
required
|
||||
label="Payment method"
|
||||
placeholder="Select payment method"
|
||||
bind:value
|
||||
@@ -86,12 +87,14 @@
|
||||
{:else}
|
||||
<Card
|
||||
isDashed
|
||||
style="--p-card-padding:1rem; --p-card-bg-color: transparent; --p-card-border-radius: 0.5rem"
|
||||
style="--p-card-padding:0.75rem; --p-card-bg-color: transparent; --p-card-border-radius: 0.5rem"
|
||||
isTile>
|
||||
<div class="u-flex u-main-space-between u-cross-center">
|
||||
<p>
|
||||
<span class="icon-exclamation-circle"></span>
|
||||
<span class="text">No saved payment methods</span>
|
||||
<p class="u-flex u-gap-8 u-cross-center">
|
||||
<span
|
||||
class="icon-exclamation u-color-text-warning"
|
||||
style:font-size="var(--icon-size-medium)"></span>
|
||||
<span class="text">A payment method is required</span>
|
||||
</p>
|
||||
<Button secondary on:click={() => (showPaymentModal = true)}>
|
||||
<span class="icon-plus"></span> <span class="text">Add</span>
|
||||
|
||||
@@ -49,14 +49,13 @@
|
||||
}
|
||||
];
|
||||
|
||||
$: isFree = org.billingPlan === BillingPlan.STARTER;
|
||||
$: isFree = org.billingPlan === BillingPlan.FREE;
|
||||
</script>
|
||||
|
||||
<Modal bind:show size="big" headerDivider={false} title="Usage rates">
|
||||
{#if isFree}
|
||||
Usage on the Starter plan is limited for the following resources. Next billing period: {toLocaleDate(
|
||||
nextDate
|
||||
)}.
|
||||
Usage on the {$plansInfo?.get(BillingPlan.FREE).name} plan is limited for the following resources.
|
||||
Next billing period: {toLocaleDate(nextDate)}.
|
||||
{:else if org.billingPlan === BillingPlan.PRO}
|
||||
<p>
|
||||
Usage on the Pro plan will be charged at the end of each billing period at the following
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<ul
|
||||
class="grid-box common-section u-margin-block-start-32"
|
||||
style={`--grid-gap:1.5rem; --grid-item-size:${total > 3 ? '22rem' : '25rem'};`}
|
||||
style={`--grid-gap:1.5rem; --grid-item-size-small-screens: 18rem; --grid-item-size:${total > 3 ? '22rem' : '25rem'};`}
|
||||
data-private>
|
||||
<slot />
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
export let hideFooter = false;
|
||||
</script>
|
||||
|
||||
<Card {danger}>
|
||||
<Card {danger} class={danger ? 'u-padding-inline-start-32' : ''}>
|
||||
<div class="common-section grid-1-2" class:hideOverflow>
|
||||
<div class="grid-1-2-col-1 u-flex u-flex-vertical u-gap-16">
|
||||
<slot />
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
export let fullWidth = false;
|
||||
export let wrapperFullWidth = false;
|
||||
export let position: 'relative' | 'static' = 'relative';
|
||||
export let noMaxWidthList = false;
|
||||
</script>
|
||||
|
||||
<Drop
|
||||
@@ -35,6 +36,7 @@
|
||||
}`}>
|
||||
{#if $$slots.list}
|
||||
<section
|
||||
class:u-max-width-none={noMaxWidthList}
|
||||
class:u-overflow-y-auto={scrollable}
|
||||
class:u-max-height-200={scrollable}
|
||||
class="drop-section">
|
||||
|
||||
@@ -249,7 +249,7 @@
|
||||
<slot />
|
||||
<div>
|
||||
<p class="u-text">Choose a service</p>
|
||||
<div class="u-flex u-gap-8 u-margin-block-start-8">
|
||||
<div class="u-flex u-gap-8 u-margin-block-start-8 u-flex-wrap">
|
||||
{#each available.services as service}
|
||||
<Pill
|
||||
disabled={showInput}
|
||||
|
||||
@@ -1,22 +1,30 @@
|
||||
<script lang="ts">
|
||||
import { Button, InputNumber } from '$lib/elements/forms';
|
||||
import InputSelect from '$lib/elements/forms/inputSelect.svelte';
|
||||
import InputText from '$lib/elements/forms/inputText.svelte';
|
||||
import {
|
||||
Button,
|
||||
InputNumber,
|
||||
InputSelect,
|
||||
InputText,
|
||||
InputTags,
|
||||
FormList,
|
||||
InputSelectCheckbox
|
||||
} from '$lib/elements/forms';
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { tags, type Operator, queries } from './store';
|
||||
import { createEventDispatcher, onMount } from 'svelte';
|
||||
import { tags, type Operator, queries, type TagValue } from './store';
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import type { Writable } from 'svelte/store';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
|
||||
export let columns: Writable<Column[]>;
|
||||
export let columnId: string | null = null;
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
clear: void;
|
||||
apply: { applied: number };
|
||||
}>();
|
||||
|
||||
let columnId: string | null = null;
|
||||
$: column = $columns.find((c) => c.id === columnId) as Column;
|
||||
let arrayValues: string[] = [];
|
||||
|
||||
dispatch('apply', { applied: $tags.length });
|
||||
|
||||
@@ -36,7 +44,7 @@
|
||||
toTag: (attribute, input) => `**${attribute}** greater than **${input}**`,
|
||||
types: ['integer', 'double', 'datetime']
|
||||
},
|
||||
'greater than or equal to': {
|
||||
'greater than or equal': {
|
||||
toQuery: (attr, input) => Query.greaterThanEqual(attr, Number(input)),
|
||||
toTag: (attribute, input) => `**${attribute}** greater than or equal to **${input}**`,
|
||||
types: ['integer', 'double', 'datetime']
|
||||
@@ -46,7 +54,7 @@
|
||||
toTag: (attribute, input) => `**${attribute}** less than **${input}**`,
|
||||
types: ['integer', 'double', 'datetime']
|
||||
},
|
||||
'less than or equal to': {
|
||||
'less than or equal': {
|
||||
toQuery: Query.lessThanEqual,
|
||||
toTag: (attribute, input) => `**${attribute}** less than or equal to **${input}**`,
|
||||
types: ['integer', 'double', 'datetime']
|
||||
@@ -56,22 +64,36 @@
|
||||
toTag: (attribute, input) => `**${attribute}** equal to **${input}**`,
|
||||
types: ['string', 'integer', 'double', 'boolean']
|
||||
},
|
||||
'not equal to': {
|
||||
'not equal': {
|
||||
toQuery: Query.notEqual,
|
||||
toTag: (attribute, input) => `**${attribute}** not equal to **${input}**`,
|
||||
types: ['string', 'integer', 'double', 'boolean']
|
||||
},
|
||||
'not null': {
|
||||
'is not null': {
|
||||
toQuery: Query.isNotNull,
|
||||
toTag: (attribute) => `**${attribute}** is not null`,
|
||||
types: ['string', 'integer', 'double', 'boolean', 'datetime', 'relationship'],
|
||||
hideInput: true
|
||||
},
|
||||
null: {
|
||||
'is null': {
|
||||
toQuery: Query.isNull,
|
||||
toTag: (attribute) => `**${attribute}** is null`,
|
||||
types: ['string', 'integer', 'double', 'boolean', 'datetime', 'relationship'],
|
||||
hideInput: true
|
||||
},
|
||||
contains: {
|
||||
toQuery: Query.contains,
|
||||
toTag: (attribute, input) => {
|
||||
if (Array.isArray(input) && input.length > 2) {
|
||||
return {
|
||||
value: input,
|
||||
tag: `**${attribute}** contains **${formatArray(input)}** `
|
||||
};
|
||||
} else {
|
||||
return `**${attribute}** contains **${input}**`;
|
||||
}
|
||||
},
|
||||
types: ['string', 'integer', 'double', 'boolean', 'datetime', 'enum']
|
||||
}
|
||||
};
|
||||
|
||||
@@ -93,23 +115,48 @@
|
||||
/* eslint @typescript-eslint/no-explicit-any: 'off' */
|
||||
let value: any = null;
|
||||
|
||||
$: {
|
||||
columnId;
|
||||
value = null;
|
||||
}
|
||||
onMount(() => {
|
||||
value = column?.array ? [] : null;
|
||||
});
|
||||
|
||||
// This Map is keyed by tags, and has a query as the value
|
||||
function addFilter() {
|
||||
if (!column || !operator) return;
|
||||
|
||||
queries.addFilter({ column, operator, value: value ?? '' });
|
||||
value = null;
|
||||
if (column.array) {
|
||||
queries.addFilter({ column, operator, value: arrayValues });
|
||||
columnId = null;
|
||||
arrayValues = [];
|
||||
} else {
|
||||
queries.addFilter({ column, operator, value: value ?? '' });
|
||||
columnId = null;
|
||||
value = null;
|
||||
}
|
||||
}
|
||||
|
||||
function tagFormat(node: HTMLElement) {
|
||||
node.innerHTML = node.innerHTML.replace(/\*\*(.*?)\*\*/g, '<b>$1</b>');
|
||||
}
|
||||
|
||||
function formatArray(array: string[]) {
|
||||
if (!array?.length) return;
|
||||
if (array.length > 2) {
|
||||
return `${array[0]} or ${array.length - 1} others`;
|
||||
} else {
|
||||
return array.join(' or ');
|
||||
}
|
||||
}
|
||||
|
||||
function isTypeTagValue(obj: any): obj is TagValue {
|
||||
if (typeof obj === 'string') return false;
|
||||
return (
|
||||
obj &&
|
||||
typeof obj.tag === 'string' &&
|
||||
(typeof obj.value === 'string' ||
|
||||
typeof obj.value === 'number' ||
|
||||
Array.isArray(obj.value))
|
||||
);
|
||||
}
|
||||
|
||||
$: isDisabled = !operator;
|
||||
</script>
|
||||
|
||||
@@ -134,23 +181,55 @@
|
||||
bind:value={operatorKey} />
|
||||
</ul>
|
||||
{#if column && operator && !operator?.hideInput}
|
||||
<ul class="u-margin-block-start-8">
|
||||
{#if column.type === 'integer' || column.type === 'double'}
|
||||
<InputNumber id="value" bind:value placeholder="Enter value" />
|
||||
{:else if column.type === 'boolean'}
|
||||
<InputSelect
|
||||
id="value"
|
||||
placeholder="Select a value"
|
||||
required={true}
|
||||
options={[
|
||||
{ label: 'True', value: true },
|
||||
{ label: 'False', value: false }
|
||||
].filter(Boolean)}
|
||||
bind:value />
|
||||
{:else}
|
||||
<InputText id="value" bind:value placeholder="Enter value" />
|
||||
{/if}
|
||||
</ul>
|
||||
{#if column?.array}
|
||||
<FormList class="u-margin-block-start-8">
|
||||
{#if column.format === 'enum'}
|
||||
<InputSelectCheckbox
|
||||
name="value"
|
||||
bind:tags={arrayValues}
|
||||
placeholder="Select value"
|
||||
options={column?.elements?.map((value) => ({
|
||||
label: value,
|
||||
value,
|
||||
checked: arrayValues.includes(value)
|
||||
}))}>
|
||||
</InputSelectCheckbox>
|
||||
{:else}
|
||||
<InputTags
|
||||
label="values"
|
||||
showLabel={false}
|
||||
id="value"
|
||||
bind:tags={arrayValues}
|
||||
placeholder="Enter values" />
|
||||
{/if}
|
||||
</FormList>
|
||||
{:else}
|
||||
<ul class="u-margin-block-start-8">
|
||||
{#if column.format === 'enum'}
|
||||
<InputSelect
|
||||
id="value"
|
||||
bind:value
|
||||
placeholder="Select value"
|
||||
options={column?.elements?.map((value) => ({ label: value, value }))}
|
||||
label="Value"
|
||||
showLabel={false} />
|
||||
{:else if column.type === 'integer' || column.type === 'double'}
|
||||
<InputNumber id="value" bind:value placeholder="Enter value" />
|
||||
{:else if column.type === 'boolean'}
|
||||
<InputSelect
|
||||
id="value"
|
||||
placeholder="Select a value"
|
||||
required={true}
|
||||
options={[
|
||||
{ label: 'True', value: true },
|
||||
{ label: 'False', value: false }
|
||||
].filter(Boolean)}
|
||||
bind:value />
|
||||
{:else}
|
||||
<InputText id="value" bind:value placeholder="Enter value" />
|
||||
{/if}
|
||||
</ul>
|
||||
{/if}
|
||||
{/if}
|
||||
<Button text disabled={isDisabled} class="u-margin-block-start-4" submit>
|
||||
<i class="icon-plus" />
|
||||
@@ -160,16 +239,32 @@
|
||||
|
||||
<ul class="u-flex u-flex-wrap u-cross-center u-gap-8 u-margin-block-start-16 tags">
|
||||
{#each $tags as tag (tag)}
|
||||
<button
|
||||
class="tag"
|
||||
on:click={() => {
|
||||
queries.removeFilter(tag);
|
||||
}}>
|
||||
<span class="text" use:tagFormat>
|
||||
{tag}
|
||||
</span>
|
||||
<i class="icon-x" />
|
||||
</button>
|
||||
{#if isTypeTagValue(tag)}
|
||||
<button
|
||||
use:tooltip={{
|
||||
content: tag?.value?.toString()
|
||||
}}
|
||||
class="tag"
|
||||
on:click={() => {
|
||||
queries.removeFilter(tag);
|
||||
}}>
|
||||
<span class="text" use:tagFormat>
|
||||
{tag.tag}
|
||||
</span>
|
||||
<i class="icon-x" />
|
||||
</button>
|
||||
{:else}
|
||||
<button
|
||||
class="tag"
|
||||
on:click={() => {
|
||||
queries.removeFilter(tag);
|
||||
}}>
|
||||
<span class="text" use:tagFormat>
|
||||
{tag}
|
||||
</span>
|
||||
<i class="icon-x" />
|
||||
</button>
|
||||
{/if}
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
|
||||
export let query = '[]';
|
||||
export let columns: Writable<Column[]>;
|
||||
export let disabled = false;
|
||||
export let fullWidthMobile = false;
|
||||
|
||||
const parsedQueries = queryParamToMap(query);
|
||||
queries.set(parsedQueries);
|
||||
|
||||
let selectedColumn: string | null = null;
|
||||
// We need to separate them so we don't trigger Drop's handlers
|
||||
let showFiltersDesktop = false;
|
||||
let showFiltersMobile = false;
|
||||
@@ -25,11 +27,20 @@
|
||||
showFiltersDesktop = false;
|
||||
showFiltersMobile = false;
|
||||
});
|
||||
|
||||
function clearAll() {
|
||||
selectedColumn = null;
|
||||
queries.clearAll();
|
||||
}
|
||||
|
||||
$: if (!showFiltersDesktop && !showFiltersMobile) {
|
||||
selectedColumn = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="is-not-mobile">
|
||||
<Drop bind:show={showFiltersDesktop} noArrow>
|
||||
<Button secondary on:click={() => (showFiltersDesktop = !showFiltersDesktop)}>
|
||||
<Button secondary on:click={() => (showFiltersDesktop = !showFiltersDesktop)} {disabled}>
|
||||
<i class="icon-filter u-opacity-50" />
|
||||
Filters
|
||||
{#if applied > 0}
|
||||
@@ -42,12 +53,13 @@
|
||||
<div class="dropped card">
|
||||
<p>Apply filter rules to refine the table view</p>
|
||||
<Content
|
||||
bind:columnId={selectedColumn}
|
||||
{columns}
|
||||
on:apply={(e) => (applied = e.detail.applied)}
|
||||
on:clear={() => (applied = 0)} />
|
||||
<hr />
|
||||
<div class="u-flex u-margin-block-start-16 u-main-end u-gap-8">
|
||||
<Button text on:click={queries.clearAll}>Clear all</Button>
|
||||
<Button text on:click={clearAll}>Clear all</Button>
|
||||
<Button on:click={queries.apply} disabled={!$queriesAreDirty}>Apply</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -76,7 +88,7 @@
|
||||
on:apply={(e) => (applied = e.detail.applied)}
|
||||
on:clear={() => (applied = 0)} />
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={queries.clearAll}>Clear all</Button>
|
||||
<Button text on:click={clearAll}>Clear all</Button>
|
||||
<Button on:click={queries.apply} disabled={!$queriesAreDirty}>Apply</Button
|
||||
></svelte:fragment>
|
||||
</Modal>
|
||||
|
||||
@@ -5,14 +5,19 @@ import { page } from '$app/stores';
|
||||
import deepEqual from 'deep-equal';
|
||||
import type { Column, ColumnType } from '$lib/helpers/types';
|
||||
|
||||
export type TagValue = {
|
||||
tag: string;
|
||||
value: string | number | string[];
|
||||
};
|
||||
|
||||
export type Operator = {
|
||||
toTag: (attribute: string, input?: string | number) => string;
|
||||
toQuery: (attribute: string, input?: string | number) => string;
|
||||
toTag: (attribute: string, input?: string | number | string[]) => string | TagValue;
|
||||
toQuery: (attribute: string, input?: string | number | string[]) => string;
|
||||
types: ColumnType[];
|
||||
hideInput?: boolean;
|
||||
};
|
||||
|
||||
export function mapToQueryParams(map: Map<string, string>) {
|
||||
export function mapToQueryParams(map: Map<string | TagValue, string>) {
|
||||
return encodeURIComponent(JSON.stringify(Array.from(map.entries())));
|
||||
}
|
||||
|
||||
@@ -22,13 +27,13 @@ export function queryParamToMap(queryParam: string) {
|
||||
return new Map(queries);
|
||||
}
|
||||
|
||||
function initQueries(initialValue = new Map<string, string>()) {
|
||||
function initQueries(initialValue = new Map<string | TagValue, string>()) {
|
||||
const queries = writable(initialValue);
|
||||
|
||||
type AddFilterArgs = {
|
||||
operator: Operator;
|
||||
column: Column;
|
||||
value: string | number;
|
||||
value: string | number | string[];
|
||||
};
|
||||
|
||||
function addFilter({ column, operator, value }: AddFilterArgs) {
|
||||
@@ -38,7 +43,7 @@ function initQueries(initialValue = new Map<string, string>()) {
|
||||
});
|
||||
}
|
||||
|
||||
function removeFilter(tag: string) {
|
||||
function removeFilter(tag: string | TagValue) {
|
||||
queries.update((map) => {
|
||||
map.delete(tag);
|
||||
return map;
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
export let id: string = null;
|
||||
let classes = '';
|
||||
export { classes as class };
|
||||
export let style = '';
|
||||
</script>
|
||||
|
||||
<svelte:element
|
||||
this={tag}
|
||||
class={`heading-level-${size} u-min-width-0 ${classes}`}
|
||||
class:u-trim-1={trimmed}
|
||||
{style}
|
||||
{id}>
|
||||
<slot />
|
||||
</svelte:element>
|
||||
@@ -30,7 +30,7 @@
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<Button
|
||||
fullWidth
|
||||
href={$upgradeURL}
|
||||
@@ -63,6 +63,7 @@
|
||||
<div class="u-margin-block-start-8 u-width-full-line">
|
||||
{#key $app.themeInUse}
|
||||
<iframe
|
||||
style="color-scheme: none"
|
||||
title="Appwrite Status"
|
||||
src={`https://status.appwrite.online/badge?theme=${
|
||||
$app.themeInUse === 'dark' ? 'dark' : 'light'
|
||||
|
||||
@@ -343,11 +343,31 @@ export const eventServices: Array<EventService> = [
|
||||
{ name: 'update', attributes: ['email', 'name', 'password', 'status', 'prefs'] },
|
||||
{ name: 'delete' }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'providers',
|
||||
resources: [],
|
||||
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
|
||||
},
|
||||
{
|
||||
name: 'topics',
|
||||
resources: [
|
||||
{
|
||||
name: 'subscribers',
|
||||
actions: [{ name: 'create' }, { name: 'delete' }]
|
||||
}
|
||||
],
|
||||
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
|
||||
},
|
||||
{
|
||||
name: 'messages',
|
||||
resources: [],
|
||||
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
|
||||
}
|
||||
];
|
||||
|
||||
export enum BillingPlan {
|
||||
STARTER = 'tier-0',
|
||||
FREE = 'tier-0',
|
||||
PRO = 'tier-1',
|
||||
SCALE = 'tier-2'
|
||||
}
|
||||
@@ -367,7 +387,7 @@ export const feedbackDowngradeOptions = [
|
||||
},
|
||||
{
|
||||
value: 'starter',
|
||||
label: 'The Starter plan is enough for my projects'
|
||||
label: 'The Free plan is enough for my projects'
|
||||
},
|
||||
{
|
||||
value: 'budget',
|
||||
|
||||
@@ -31,4 +31,5 @@ export { default as InputDate } from './inputDate.svelte';
|
||||
export { default as InputDateRange } from './inputDateRange.svelte';
|
||||
export { default as InputTime } from './inputTime.svelte';
|
||||
export { default as InputDigits } from './inputDigits.svelte';
|
||||
export { default as InputSelectCheckbox } from './inputSelectCheckbox.svelte';
|
||||
export { default as InputFilePicker } from './inputFilePicker.svelte';
|
||||
@@ -6,14 +6,14 @@
|
||||
export let label: string | undefined = undefined;
|
||||
export let optionalText: string | undefined = undefined;
|
||||
export let showLabel = true;
|
||||
export let value: string | number | boolean;
|
||||
export let value: string | number | boolean | null;
|
||||
export let placeholder = '';
|
||||
export let required = false;
|
||||
export let hideRequired = false;
|
||||
export let disabled = false;
|
||||
export let wrapperTag: FormItemTag = 'li';
|
||||
export let options: {
|
||||
value: string | boolean | number;
|
||||
value: string | boolean | number | null;
|
||||
label: string;
|
||||
}[];
|
||||
export let isMultiple = false;
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<script lang="ts">
|
||||
import { DropList } from '$lib/components';
|
||||
import { SelectSearchCheckbox } from '..';
|
||||
|
||||
type Option = {
|
||||
value: string;
|
||||
label: string;
|
||||
checked: boolean;
|
||||
};
|
||||
|
||||
export let name: string;
|
||||
export let tags: string[] = [];
|
||||
export let placeholder: string;
|
||||
export let options: Option[] = [];
|
||||
|
||||
let search = '';
|
||||
let input: HTMLInputElement;
|
||||
let show = false;
|
||||
|
||||
function addValue(option: Option) {
|
||||
let tag = option.value.trim();
|
||||
if (tag.length === 0 || tags.includes(tag)) return;
|
||||
|
||||
tags = [...tags, tag];
|
||||
option.checked = true;
|
||||
clearSearch();
|
||||
}
|
||||
|
||||
function removeValue(option: Option) {
|
||||
tags = tags.filter((tag) => tag !== option.value);
|
||||
option.checked = false;
|
||||
}
|
||||
|
||||
function clearSearch() {
|
||||
search = '';
|
||||
input.value = '';
|
||||
}
|
||||
|
||||
$: filteredOptions = search
|
||||
? options.filter((option) => option.label.toLowerCase().includes(search.toLowerCase()))
|
||||
: options;
|
||||
|
||||
//TODO: Debounce search and open the droplist when the user starts typing
|
||||
</script>
|
||||
|
||||
<DropList bind:show noStyle noArrow scrollable placement="bottom-end" fixed noMaxWidthList>
|
||||
<button
|
||||
class="tags-input u-position-relative u-cursor-pointer"
|
||||
type="button"
|
||||
on:click={() => (show = !show)}>
|
||||
<div class="tags">
|
||||
<ul class="tags-list">
|
||||
{#each tags as tag}
|
||||
<li class="tags-item">
|
||||
<div class="input-tag">
|
||||
<span class="tag-text">{tag}</span>
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<input
|
||||
class="tags-input-text u-cursor-text"
|
||||
{placeholder}
|
||||
bind:value={search}
|
||||
bind:this={input} />
|
||||
<span
|
||||
class:icon-cheveron-up={show}
|
||||
class:icon-cheveron-down={!show}
|
||||
class="u-position-absolute u-inset-block-start-4 u-inset-inline-end-12"
|
||||
aria-hidden="true"></span>
|
||||
</button>
|
||||
|
||||
<svelte:fragment slot="list">
|
||||
{#each filteredOptions as option (option.value + option.checked)}
|
||||
<SelectSearchCheckbox
|
||||
on:click={() => (option?.checked ? removeValue(option) : addValue(option))}
|
||||
bind:value={option.checked}>
|
||||
{option.label}
|
||||
</SelectSearchCheckbox>
|
||||
{:else}
|
||||
<li class="drop-list-item">
|
||||
<span class="text">There are no {name} that match your search</span>
|
||||
</li>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
@@ -31,11 +31,11 @@
|
||||
/**
|
||||
* Allow form submit and tab input switch
|
||||
*/
|
||||
if (value === '' && ['Enter', 'Tab'].includes(e.key)) {
|
||||
if (value === '' && ['Enter', 'Tab', ','].includes(e.key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (['Enter', 'Tab', ' '].includes(e.key)) {
|
||||
if (['Enter', 'Tab', ' ', ','].includes(e.key)) {
|
||||
e.preventDefault();
|
||||
if (validityRegex && !validityRegex.test(value)) {
|
||||
error = validityMessage ? validityMessage : 'Invalid value';
|
||||
@@ -51,6 +51,10 @@
|
||||
};
|
||||
|
||||
const addValue = () => {
|
||||
if (validityRegex && !validityRegex.test(value) && !!value) {
|
||||
error = validityMessage ? validityMessage : 'Invalid value';
|
||||
return;
|
||||
}
|
||||
let tag = value.trim();
|
||||
if (tag.length === 0 || tags.includes(tag)) return;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export { default as Pill } from './pill.svelte';
|
||||
export { default as SelectSearchItem } from './selectSearchItem.svelte';
|
||||
export { default as Flag } from './flag.svelte';
|
||||
export { default as SelectSearchCheckbox } from './selectSearchCheckbox.svelte';
|
||||
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
// export let data: string[] = [];
|
||||
export let value = false;
|
||||
</script>
|
||||
|
||||
<li class="drop-list-item">
|
||||
<button
|
||||
class="drop-button u-flex u-cross-center u-gap-12"
|
||||
on:click|preventDefault
|
||||
type="button">
|
||||
<input type="checkbox" class="is-small" bind:checked={value} />
|
||||
<slot />
|
||||
</button>
|
||||
</li>
|
||||
@@ -7,6 +7,8 @@
|
||||
export let transparent = false;
|
||||
export let noStyles = false;
|
||||
export let dense = false;
|
||||
let classes: string = undefined;
|
||||
export { classes as class };
|
||||
|
||||
let isOverflowing = false;
|
||||
|
||||
@@ -43,7 +45,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="table-with-scroll" class:u-margin-block-start-32={!noMargin} data-private>
|
||||
<div class="table-with-scroll {classes}" class:u-margin-block-start-32={!noMargin} data-private>
|
||||
<div class="table-wrapper" use:hasOverflow={(v) => (isOverflowing = v)}>
|
||||
<table
|
||||
class="table"
|
||||
|
||||
@@ -13,7 +13,15 @@ export function isHTMLInputElement(el: unknown): el is HTMLInputElement {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export type Prettify<T> = T & {};
|
||||
|
||||
const columnTypes = ['string', 'integer', 'double', 'boolean', 'datetime', 'relationship'] as const;
|
||||
const columnTypes = [
|
||||
'string',
|
||||
'integer',
|
||||
'double',
|
||||
'boolean',
|
||||
'datetime',
|
||||
'relationship',
|
||||
'enum'
|
||||
] as const;
|
||||
export type ColumnType = (typeof columnTypes)[number];
|
||||
export type Column = {
|
||||
id: string;
|
||||
@@ -28,6 +36,9 @@ export type Column = {
|
||||
* Set to false to disable filtering for this column
|
||||
*/
|
||||
filter?: boolean;
|
||||
array?: boolean;
|
||||
format?: string;
|
||||
elements?: string[];
|
||||
};
|
||||
|
||||
export function isValueOfStringEnum<T extends Record<string, string>>(
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
Logs are retained in rolling {hoursToDays(limit)} intervals with the
|
||||
{tierToPlan($organization.billingPlan).name}
|
||||
plan.
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<Button link on:click={upgradeMethod}>Upgrade</Button> to increase your log
|
||||
retention for a longer period.
|
||||
{/if}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
export let title: string;
|
||||
export let tooltipContent =
|
||||
$organization.billingPlan === BillingPlan.STARTER
|
||||
$organization.billingPlan === BillingPlan.FREE
|
||||
? `Upgrade to add more ${title.toLocaleLowerCase()}`
|
||||
: `You've reached the ${title.toLocaleLowerCase()} limit for the ${
|
||||
tierToPlan($organization.billingPlan).name
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
$: tier = tierToPlan($organization?.billingPlan)?.name;
|
||||
$: hasProjectLimitation =
|
||||
checkForProjectLimitation(serviceId) && $organization?.billingPlan === BillingPlan.STARTER;
|
||||
checkForProjectLimitation(serviceId) && $organization?.billingPlan === BillingPlan.FREE;
|
||||
$: hasUsageFees = hasProjectLimitation
|
||||
? checkForUsageFees($organization?.billingPlan, serviceId)
|
||||
: false;
|
||||
@@ -88,7 +88,7 @@
|
||||
})
|
||||
.join(', ')}
|
||||
<slot name="alert" {limit} {tier} {title} {upgradeMethod} {hasUsageFees} {services}>
|
||||
{#if $organization?.billingPlan !== BillingPlan.STARTER && hasUsageFees}
|
||||
{#if $organization?.billingPlan !== BillingPlan.FREE && hasUsageFees}
|
||||
<Alert type="info" isStandalone>
|
||||
<span class="text">
|
||||
You've reached the {services} limit for the {tier} plan.
|
||||
@@ -135,7 +135,7 @@
|
||||
<p class="text">
|
||||
You are limited to {limit}
|
||||
{title.toLocaleLowerCase()} per project on the {tier} plan.
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}<Button
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}<Button
|
||||
link
|
||||
href={$upgradeURL}
|
||||
on:click={() =>
|
||||
@@ -158,7 +158,7 @@
|
||||
<p class="text">
|
||||
You are limited to {limit}
|
||||
{title.toLocaleLowerCase()} per organization on the {tier} plan.
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<Button link href={$upgradeURL}>Upgrade</Button>
|
||||
for additional {title.toLocaleLowerCase()}.
|
||||
{/if}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<footer class="main-footer u-cross-center">
|
||||
<div class="main-footer-start">
|
||||
<ul class="inline-links is-no-padding-first-and-last u-x-small">
|
||||
<ul class="inline-links is-no-padding-first-and-last u-x-small u-flex-wrap u-row-gap-16">
|
||||
<li class="inline-links-item" style="line-height: 1.02;">
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
{#if isCloud}
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
|
||||
<div class="main-header-end">
|
||||
<nav class="u-flex is-only-desktop u-cross-center">
|
||||
{#if isCloud && $organization?.billingPlan === BillingPlan.STARTER && !$page.url.pathname.startsWith('/console/account')}
|
||||
{#if isCloud && $organization?.billingPlan === BillingPlan.FREE && !$page.url.pathname.startsWith('/console/account')}
|
||||
<Button
|
||||
disabled={$organization?.markedForDeletion}
|
||||
href={$upgradeURL}
|
||||
|
||||
@@ -310,7 +310,7 @@
|
||||
<Alert>
|
||||
Logs are retained in rolling {hoursToDays(limit)} intervals
|
||||
with the {tier} plan.
|
||||
{#if $organization.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization.billingPlan === BillingPlan.FREE}
|
||||
<Button link href={$upgradeURL}>Upgrade</Button> to increase
|
||||
your log retention for a longer period.
|
||||
{/if}
|
||||
|
||||
@@ -1,22 +1,39 @@
|
||||
<script lang="ts">
|
||||
import { navigating } from '$app/stores';
|
||||
|
||||
let width: number;
|
||||
let updater: ReturnType<typeof setTimeout>;
|
||||
let completed = false;
|
||||
import { afterNavigate, beforeNavigate } from '$app/navigation';
|
||||
|
||||
const minimum = 0.08;
|
||||
const maximum = 0.994;
|
||||
const settleTime = 700;
|
||||
const intervalTime = 800;
|
||||
const intervalTime = 700;
|
||||
const displayThresholdMs = 150;
|
||||
const stepSizes = [0, 0.005, 0.01, 0.02];
|
||||
|
||||
function animate(): void {
|
||||
let running: boolean = false;
|
||||
let updater: ReturnType<typeof setInterval> | null = null;
|
||||
let completed = false;
|
||||
let width: number = 0;
|
||||
|
||||
function getIncrement(n: number) {
|
||||
if (n >= 0 && n < 0.2) return 0.1;
|
||||
else if (n >= 0.2 && n < 0.5) return 0.04;
|
||||
else if (n >= 0.5 && n < 0.8) return 0.02;
|
||||
else if (n >= 0.8 && n < 0.99) return 0.005;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
width = minimum;
|
||||
running = true;
|
||||
}
|
||||
|
||||
function animate() {
|
||||
if (updater) {
|
||||
// prevent multiple intervals by clearing before making
|
||||
clearInterval(updater);
|
||||
}
|
||||
running = true;
|
||||
updater = setInterval(() => {
|
||||
const randomStep = stepSizes[Math.floor(Math.random() * stepSizes.length)];
|
||||
const randomStep = stepSizes[Math.floor(Math.random() * stepSizes.length)] ?? 0;
|
||||
const step = getIncrement(width) + randomStep;
|
||||
if (width < maximum) {
|
||||
width = width + step;
|
||||
@@ -28,36 +45,57 @@
|
||||
}, intervalTime);
|
||||
}
|
||||
|
||||
function start(): void {
|
||||
width = minimum;
|
||||
function start() {
|
||||
reset();
|
||||
animate();
|
||||
}
|
||||
|
||||
function complete(): void {
|
||||
clearInterval(updater);
|
||||
function stop() {
|
||||
if (updater) {
|
||||
clearInterval(updater);
|
||||
}
|
||||
}
|
||||
|
||||
function complete() {
|
||||
if (updater) clearInterval(updater);
|
||||
if (!running) return;
|
||||
width = 1;
|
||||
running = false;
|
||||
setTimeout(() => {
|
||||
// complete the bar first
|
||||
completed = true;
|
||||
setTimeout(() => {
|
||||
// after some time (long enough to finish the hide animation) reset it back to 0
|
||||
completed = false;
|
||||
width = 0;
|
||||
}, settleTime);
|
||||
}, settleTime);
|
||||
}
|
||||
|
||||
function getIncrement(number: number): number {
|
||||
if (number >= 0 && number < 0.2) return 0.1;
|
||||
else if (number >= 0.2 && number < 0.5) return 0.04;
|
||||
else if (number >= 0.5 && number < 0.8) return 0.02;
|
||||
else if (number >= 0.8 && number < 0.99) return 0.005;
|
||||
return 0;
|
||||
}
|
||||
let progressBarStartTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
beforeNavigate((nav) => {
|
||||
if (progressBarStartTimeout) {
|
||||
clearTimeout(progressBarStartTimeout);
|
||||
progressBarStartTimeout = null;
|
||||
}
|
||||
|
||||
$: if ($navigating) {
|
||||
start();
|
||||
} else {
|
||||
if (nav.to?.route.id) {
|
||||
// Internal navigation.
|
||||
if (displayThresholdMs > 0) {
|
||||
// Schedule a display of the progress bar in `displayThresholdMs` milliseconds.
|
||||
// This is to avoid flickering/flashing when the navigation is fast.
|
||||
progressBarStartTimeout = setTimeout(() => start(), displayThresholdMs);
|
||||
} else start();
|
||||
}
|
||||
});
|
||||
|
||||
afterNavigate(() => {
|
||||
if (progressBarStartTimeout) {
|
||||
clearTimeout(progressBarStartTimeout);
|
||||
progressBarStartTimeout = null;
|
||||
}
|
||||
complete();
|
||||
}
|
||||
});
|
||||
|
||||
$: barStyle = (width && width * 100 && `width: ${width * 100}%;`) || '';
|
||||
</script>
|
||||
|
||||
@@ -1,20 +1,53 @@
|
||||
<script lang="ts">
|
||||
import { Heading } from '$lib/components';
|
||||
import AppwriteLogoDark from '$lib/images/appwrite-logo-dark.svg';
|
||||
import AppwriteLogoLight from '$lib/images/appwrite-logo-light.svg';
|
||||
import LoginDark from '$lib/images/login/login-dark-mode.png';
|
||||
import LoginLight from '$lib/images/login/login-light-mode.png';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { campaigns } from '$lib/stores/campaigns';
|
||||
import { user } from '$lib/stores/user';
|
||||
|
||||
export const imgLight = LoginLight;
|
||||
export const imgDark = LoginDark;
|
||||
|
||||
export let campaign: string = null;
|
||||
export let coupon: Coupon = null;
|
||||
|
||||
$: variation = coupon?.campaign ?? campaign ? 'card' : 'default';
|
||||
$: selectedCampaign = campaigns.get(coupon?.campaign ?? campaign);
|
||||
|
||||
function generateTitle() {
|
||||
if (coupon?.credits) {
|
||||
return selectedCampaign.title.replace('VALUE', coupon.credits.toString());
|
||||
} else {
|
||||
return selectedCampaign.title;
|
||||
}
|
||||
}
|
||||
|
||||
function generateDesc() {
|
||||
if (coupon?.credits) {
|
||||
return selectedCampaign.description.replace('VALUE', coupon.credits.toString());
|
||||
} else {
|
||||
return selectedCampaign.description;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<main class="grid-1-1 is-full-page" id="main">
|
||||
<section
|
||||
class="u-flex u-flex-vertical"
|
||||
style:--url={`url(${$app.themeInUse === 'dark' ? imgDark : imgLight})`}>
|
||||
<div class="logo u-flex u-gap-16 is-not-mobile">
|
||||
class={`u-flex u-flex-vertical ${variation === 'card' ? 'u-cross-center u-main-center u-height-100-percent u-width-full-line side-bg' : 'side-default'}`}
|
||||
style:--url={variation === 'card'
|
||||
? ''
|
||||
: `url(${$app.themeInUse === 'dark' ? imgDark : imgLight})`}>
|
||||
{#if variation === 'card'}
|
||||
<div class="side-bg-container" />
|
||||
{/if}
|
||||
<div
|
||||
class="logo u-flex u-gap-16"
|
||||
class:is-not-mobile={variation === 'default'}
|
||||
class:logo-variation={variation === 'card'}>
|
||||
<a href={user ? '/console' : '/'}>
|
||||
{#if $app.themeInUse === 'dark'}
|
||||
<img
|
||||
@@ -32,20 +65,58 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-stretch" />
|
||||
{#if variation === 'default'}
|
||||
<div class="u-flex u-stretch" />
|
||||
|
||||
<div class="tag-line is-not-mobile">
|
||||
<p>Build like a team of hundreds<span class="underscore">_</span></p>
|
||||
</div>
|
||||
<div class="tag-line is-not-mobile">
|
||||
<p>Build like a team of hundreds<span class="underscore">_</span></p>
|
||||
</div>
|
||||
{:else if variation === 'card'}
|
||||
<div
|
||||
class="u-flex u-flex-vertical u-main-center u-cross-center u-height-100-percent u-width-full-line">
|
||||
<img
|
||||
src={`/images/campaigns/${coupon?.campaign ?? campaign}/${$app.themeInUse}.png`}
|
||||
class="u-block u-image-object-fit-cover side-bg-img"
|
||||
alt="promo" />
|
||||
|
||||
<div class="u-text-center">
|
||||
<div class="is-only-mobile u-width-full-line">
|
||||
<Heading
|
||||
size="5"
|
||||
tag="h3"
|
||||
class="u-margin-block-start-16"
|
||||
trimmed={false}
|
||||
style="font-weight:normal">
|
||||
{generateTitle()}
|
||||
</Heading>
|
||||
</div>
|
||||
<div class="is-not-mobile u-width-full-line">
|
||||
<Heading
|
||||
size="4"
|
||||
tag="h3"
|
||||
class="u-margin-block-start-32"
|
||||
trimmed={false}
|
||||
style="font-weight:normal">
|
||||
{generateTitle()}
|
||||
</Heading>
|
||||
</div>
|
||||
<p class="u-margin-block-start-16 auth-container">
|
||||
{generateDesc()}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
<section class="grid-1-1-col-2 u-flex u-flex-vertical u-cross-center u-main-center">
|
||||
<slot name="top" />
|
||||
<div class="container u-flex u-flex-vertical u-cross-center u-main-center">
|
||||
<div class="form-container u-width-full-line">
|
||||
<div class="auth-container u-width-full-line">
|
||||
<h1 class="heading-level-4 u-margin-block-start-auto is-not-mobile">
|
||||
<slot name="title" />
|
||||
</h1>
|
||||
<h1 class="heading-level-5 u-margin-block-start-auto is-only-mobile">
|
||||
<h1
|
||||
class="heading-level-5 u-margin-block-start-auto is-only-mobile"
|
||||
class:u-padding-block-start-24={variation === 'card'}>
|
||||
<slot name="title" />
|
||||
</h1>
|
||||
<div class="u-margin-block-start-24">
|
||||
@@ -82,9 +153,86 @@
|
||||
|
||||
<style lang="scss">
|
||||
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
|
||||
@import '@appwrite.io/pink/src/abstract/variables/_common.scss';
|
||||
|
||||
.side-bg {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
z-index: 1;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
padding-block: 2rem;
|
||||
padding-inline: 1rem;
|
||||
background-color: #ededf0 !important;
|
||||
|
||||
&-container {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
block-size: 100%;
|
||||
inline-size: 100%;
|
||||
z-index: -1;
|
||||
&::before {
|
||||
position: absolute;
|
||||
inset-block-start: -200px;
|
||||
inset-inline-end: -50px;
|
||||
content: '';
|
||||
display: block;
|
||||
inline-size: 32%;
|
||||
block-size: 32%;
|
||||
background: radial-gradient(49.55% 43.54% at 47% 50.69%, #e7f8f7 0%, #85dbd8 100%);
|
||||
filter: blur(150px);
|
||||
@media #{$break1} {
|
||||
filter: blur(100px);
|
||||
}
|
||||
}
|
||||
&::after {
|
||||
position: absolute;
|
||||
inset-block-end: -50px;
|
||||
inset-inline-start: -50px;
|
||||
content: '';
|
||||
display: block;
|
||||
inline-size: 30%;
|
||||
block-size: 30%;
|
||||
background: radial-gradient(
|
||||
50% 46.73% at 50% 53.27%,
|
||||
#fe9567 28.17%,
|
||||
#fd366e 59.38%
|
||||
);
|
||||
filter: blur(200px);
|
||||
|
||||
@media #{$break1} {
|
||||
filter: blur(100px);
|
||||
}
|
||||
}
|
||||
}
|
||||
&-img {
|
||||
padding-inline: 6.25rem;
|
||||
max-width: 40rem;
|
||||
@media #{$break2} {
|
||||
max-width: 28rem;
|
||||
}
|
||||
@media #{$break1} {
|
||||
margin-block-start: 3rem;
|
||||
max-inline-size: 23rem;
|
||||
padding-inline: 4rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
:global(.theme-dark) .side-bg {
|
||||
background-color: #131315 !important;
|
||||
}
|
||||
|
||||
:global(.theme-dark) .side-bg-container::before {
|
||||
inline-size: 20%;
|
||||
block-size: 20%;
|
||||
filter: blur(180px);
|
||||
}
|
||||
:global(.theme-dark) .side-bg-container::after {
|
||||
filter: blur(250px);
|
||||
}
|
||||
|
||||
/* Default (including mobile) */
|
||||
#main section:first-child {
|
||||
.side-default {
|
||||
padding-block-start: 2.25rem;
|
||||
padding-block-end: 2rem;
|
||||
|
||||
@@ -109,7 +257,7 @@
|
||||
|
||||
/* for smaller screens */
|
||||
@media #{$break2open} {
|
||||
#main section:first-child {
|
||||
.side-default {
|
||||
background: var(--url);
|
||||
background-repeat: no-repeat;
|
||||
background-position: top;
|
||||
@@ -127,7 +275,7 @@
|
||||
|
||||
/* for larger screens */
|
||||
@media #{$break3open} {
|
||||
#main section:first-child {
|
||||
.side-default {
|
||||
div {
|
||||
padding-inline-start: 5.625rem;
|
||||
padding-inline-end: 5rem;
|
||||
@@ -152,7 +300,17 @@
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
.auth-container {
|
||||
max-inline-size: 27.5rem;
|
||||
}
|
||||
.logo-variation {
|
||||
padding-block-start: 2rem;
|
||||
|
||||
@media #{$break1} {
|
||||
padding-block-start: 0rem;
|
||||
& img {
|
||||
scale: 0.7;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -19,10 +19,10 @@
|
||||
onSubmit={handleSubmit}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
size="small"
|
||||
headerDivider={false}>
|
||||
<p>
|
||||
Are you sure you want to exit from <slot />? All data will be deleted. This action is
|
||||
irreversible.
|
||||
<p class="text">
|
||||
<slot />
|
||||
</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (show = false)}>Cancel</Button>
|
||||
|
||||
@@ -1,9 +1,33 @@
|
||||
<script lang="ts">
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import WizardExitModal from './wizardExitModal.svelte';
|
||||
|
||||
export let showExitModal = false;
|
||||
export let href = '';
|
||||
</script>
|
||||
|
||||
<section class="wizard-secondary c-wizard-position">
|
||||
<div class="wizard-secondary-container">
|
||||
<slot />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{#if showExitModal}
|
||||
<WizardExitModal
|
||||
{href}
|
||||
bind:show={showExitModal}
|
||||
on:exit={() => {
|
||||
trackEvent('wizard_exit', {
|
||||
from: 'prompt'
|
||||
});
|
||||
}}>
|
||||
<slot name="exit">
|
||||
Are you sure you want to exit from this process? All data will be deleted. This action
|
||||
is irreversible.
|
||||
</slot>
|
||||
</WizardExitModal>
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
.c-wizard-position {
|
||||
position: fixed;
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import { Heading } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import WizardExitModal from './wizardExitModal.svelte';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
let show = false;
|
||||
export let showExitModal = false;
|
||||
export let href: string;
|
||||
export let confirmExit = false;
|
||||
export let href = '';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
</script>
|
||||
|
||||
<header class="wizard-secondary-header">
|
||||
@@ -15,12 +16,11 @@
|
||||
<Button
|
||||
text
|
||||
round
|
||||
class="u-margin-block-start-8"
|
||||
ariaLabel="close modal"
|
||||
href={showExitModal ? null : href}
|
||||
href={confirmExit ? null : href}
|
||||
on:click={() => {
|
||||
if (showExitModal) {
|
||||
show = true;
|
||||
if (confirmExit) {
|
||||
dispatch('exit');
|
||||
} else {
|
||||
trackEvent('wizard_exit', {
|
||||
from: 'button'
|
||||
@@ -34,16 +34,3 @@
|
||||
<p class="body-text-2"><slot name="description" /></p>
|
||||
{/if}
|
||||
</header>
|
||||
|
||||
{#if show}
|
||||
<WizardExitModal
|
||||
{href}
|
||||
bind:show
|
||||
on:exit={() => {
|
||||
trackEvent('wizard_exit', {
|
||||
from: 'prompt'
|
||||
});
|
||||
}}>
|
||||
<slot name="exit">this process</slot>
|
||||
</WizardExitModal>
|
||||
{/if}
|
||||
@@ -29,6 +29,7 @@
|
||||
} catch (e) {
|
||||
error = true;
|
||||
trackError(e.message, Submit.DomainCreate);
|
||||
throw new Error(e.message);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -64,6 +64,7 @@ export type Coupon = {
|
||||
expiration: string;
|
||||
status: string; // 'active' | 'disabled' | 'expired'
|
||||
validity: number;
|
||||
campaign?: string;
|
||||
};
|
||||
|
||||
export type Credit = {
|
||||
|
||||
@@ -8,7 +8,9 @@ import type {
|
||||
Invoice,
|
||||
PaymentList,
|
||||
PlansMap,
|
||||
PaymentMethodData
|
||||
PaymentMethodData,
|
||||
OrganizationUsage,
|
||||
Plan
|
||||
} from '$lib/sdk/billing';
|
||||
import { isCloud } from '$lib/system';
|
||||
import { cachedStore } from '$lib/helpers/cache';
|
||||
@@ -25,6 +27,8 @@ import PaymentMandate from '$lib/components/billing/alerts/paymentMandate.svelte
|
||||
import MissingPaymentMethod from '$lib/components/billing/alerts/missingPaymentMethod.svelte';
|
||||
import LimitReached from '$lib/components/billing/alerts/limitReached.svelte';
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import { last } from '$lib/helpers/array';
|
||||
import { sizeToBytes, type Size } from '$lib/helpers/sizeConvertion';
|
||||
|
||||
export type Tier = 'tier-0' | 'tier-1' | 'tier-2';
|
||||
|
||||
@@ -36,7 +40,7 @@ export const readOnly = writable<boolean>(false);
|
||||
|
||||
export function tierToPlan(tier: Tier) {
|
||||
switch (tier) {
|
||||
case BillingPlan.STARTER:
|
||||
case BillingPlan.FREE:
|
||||
return tierFree;
|
||||
case BillingPlan.PRO:
|
||||
return tierPro;
|
||||
@@ -133,7 +137,7 @@ export type TierData = {
|
||||
};
|
||||
|
||||
export const tierFree: TierData = {
|
||||
name: 'Starter',
|
||||
name: 'Free',
|
||||
description: 'For personal hobby projects of small scale and students.'
|
||||
};
|
||||
|
||||
@@ -189,7 +193,7 @@ export function isServiceLimited(serviceId: PlanServices, plan: Tier, total: num
|
||||
}
|
||||
|
||||
export function calculateTrialDay(org: Organization) {
|
||||
if (org?.billingPlan === BillingPlan.STARTER) return false;
|
||||
if (org?.billingPlan === BillingPlan.FREE) return false;
|
||||
const endDate = new Date(org?.billingStartDate);
|
||||
const today = new Date();
|
||||
|
||||
@@ -203,7 +207,7 @@ export function calculateTrialDay(org: Organization) {
|
||||
}
|
||||
|
||||
export async function checkForUsageLimit(org: Organization) {
|
||||
if (org?.billingPlan !== BillingPlan.STARTER) {
|
||||
if (org?.billingPlan !== BillingPlan.FREE) {
|
||||
readOnly.set(false);
|
||||
return;
|
||||
}
|
||||
@@ -220,10 +224,9 @@ export async function checkForUsageLimit(org: Organization) {
|
||||
{ value: users, name: 'users' }
|
||||
];
|
||||
|
||||
const members = await sdk.forConsole.teams.listMemberships(org.$id);
|
||||
const members = org.total;
|
||||
const plan = get(plansInfo)?.get(org.billingPlan);
|
||||
const membersOverflow =
|
||||
members?.total > plan.members ? members.total - (plan.members || members.total) : 0;
|
||||
const membersOverflow = members > plan.members ? members - (plan.members || members) : 0;
|
||||
|
||||
if (resources.some((r) => r.value >= 100) || membersOverflow > 0) {
|
||||
readOnly.set(true);
|
||||
@@ -240,9 +243,9 @@ export async function checkForUsageLimit(org: Organization) {
|
||||
if (now - lastNotification < 1000 * 60 * 60 * 24) return;
|
||||
|
||||
localStorage.setItem('limitReachedNotification', now.toString());
|
||||
let message = `<b>${org.name}</b> has reached <b>75%</b> of the Starter plan's ${resources.find((r) => r.value >= 75).name} limit. Upgrade to ensure there are no service disruptions.`;
|
||||
let message = `<b>${org.name}</b> has reached <b>75%</b> of the ${tierToPlan(BillingPlan.FREE).name} plan's ${resources.find((r) => r.value >= 75).name} limit. Upgrade to ensure there are no service disruptions.`;
|
||||
if (resources.filter((r) => r.value >= 75)?.length > 1) {
|
||||
message = `Usage for <b>${org.name}</b> has reached 75% of the Starter plan limit. Upgrade to ensure there are no service disruptions.`;
|
||||
message = `Usage for <b>${org.name}</b> has reached 75% of the ${tierToPlan(BillingPlan.FREE).name} plan limit. Upgrade to ensure there are no service disruptions.`;
|
||||
}
|
||||
addNotification({
|
||||
type: 'warning',
|
||||
@@ -274,7 +277,7 @@ export async function checkForUsageLimit(org: Organization) {
|
||||
}
|
||||
|
||||
export async function checkPaymentAuthorizationRequired(org: Organization) {
|
||||
if (org.billingPlan === BillingPlan.STARTER) return;
|
||||
if (org.billingPlan === BillingPlan.FREE) return;
|
||||
|
||||
const invoices = await sdk.forConsole.billing.listInvoices(org.$id, [
|
||||
Query.equal('status', 'requires_authentication')
|
||||
@@ -370,7 +373,7 @@ export async function checkForMandate(org: Organization) {
|
||||
|
||||
export async function checkForMissingPaymentMethod() {
|
||||
const orgs = await sdk.forConsole.billing.listOrganization([
|
||||
Query.notEqual('billingPlan', BillingPlan.STARTER),
|
||||
Query.notEqual('billingPlan', BillingPlan.FREE),
|
||||
Query.isNull('paymentMethodId'),
|
||||
Query.isNull('backupPaymentMethodId')
|
||||
]);
|
||||
@@ -391,3 +394,20 @@ export const upgradeURL = derived(
|
||||
);
|
||||
|
||||
export const hideBillingHeaderRoutes = ['/console/create-organization', '/console/account'];
|
||||
|
||||
export function calculateExcess(usage: OrganizationUsage, plan: Plan, org: Organization) {
|
||||
const totBandwidth = usage?.bandwidth?.length > 0 ? last(usage.bandwidth).value : 0;
|
||||
return {
|
||||
bandwidth: calculateResourceSurplus(totBandwidth, plan.bandwidth),
|
||||
storage: calculateResourceSurplus(usage?.storageTotal, plan.storage, 'GB'),
|
||||
users: calculateResourceSurplus(usage?.usersTotal, plan.users),
|
||||
executions: calculateResourceSurplus(usage?.executionsTotal, plan.executions, 'GB'),
|
||||
members: calculateResourceSurplus(org.total, plan.members)
|
||||
};
|
||||
}
|
||||
|
||||
export function calculateResourceSurplus(total: number, limit: number, limitUnit: Size = null) {
|
||||
if (total === undefined || limit === undefined) return 0;
|
||||
const realLimit = (limitUnit ? sizeToBytes(limit, limitUnit) : limit) || Infinity;
|
||||
return total > realLimit ? total - realLimit : 0;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//campaign welcome and startup
|
||||
|
||||
type CampaignData = {
|
||||
title: string;
|
||||
description: string;
|
||||
};
|
||||
|
||||
export const campaigns: Map<string, CampaignData> = new Map();
|
||||
|
||||
campaigns
|
||||
.set('welcome', {
|
||||
title: "You've received $VALUE in credits",
|
||||
description:
|
||||
'Get $VALUE in credits when you upgrade or create an organization with a Pro plan.'
|
||||
})
|
||||
.set('startup', {
|
||||
title: 'Welcome to the Startups program!',
|
||||
description:
|
||||
"We're excited to have you on board. Add the coupon code to your Appwrite Pro account to join."
|
||||
})
|
||||
.set('RenderATL2024', {
|
||||
title: 'Claim your $100 RenderATL credits',
|
||||
description:
|
||||
'Get $100 in Cloud credits when you upgrade or create an organization with a Pro plan.'
|
||||
})
|
||||
.set('dealsfordevs', {
|
||||
title: 'Claim your $50 Deals For Devs credits',
|
||||
description:
|
||||
'Get $50 in Cloud credits when you upgrade or create an organization with a Pro plan.'
|
||||
});
|
||||
@@ -91,12 +91,11 @@ export const migrationFormToResources = (
|
||||
}
|
||||
if (formData.databases.root) {
|
||||
addResource('database');
|
||||
}
|
||||
if (formData.databases.documents) {
|
||||
addResource('collection');
|
||||
addResource('attribute');
|
||||
|
||||
addResource('index');
|
||||
}
|
||||
if (formData.databases.documents) {
|
||||
addResource('document');
|
||||
}
|
||||
if (formData.functions.root) {
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
import Loading from './loading.svelte';
|
||||
import { loading, requestedMigration } from './store';
|
||||
import { parseIfString } from '$lib/helpers/object';
|
||||
import Consent from '$lib/components/consent.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { campaigns } from '$lib/stores/campaigns';
|
||||
|
||||
onMount(async () => {
|
||||
// handle sources
|
||||
@@ -75,6 +75,32 @@
|
||||
const pathname = $page.url.pathname;
|
||||
const user = $page.data.account as Models.User<Record<string, string>>;
|
||||
|
||||
if ($page.url.searchParams.has('code')) {
|
||||
const code = $page.url.searchParams.get('code');
|
||||
try {
|
||||
const couponData = await sdk.forConsole.billing.getCoupon(code);
|
||||
if (couponData?.campaign && campaigns.has(couponData.campaign)) {
|
||||
if (user) {
|
||||
goto(`${base}/console/apply-credit?code=${code}`);
|
||||
loading.set(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if ($page.url.searchParams.has('campaign')) {
|
||||
const campaign = $page.url.searchParams.get('campaign');
|
||||
if (campaigns.has(campaign)) {
|
||||
if (user) {
|
||||
goto(`${base}/console/apply-credit?campaign=${campaign}`);
|
||||
loading.set(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldRedirect(pathname, authenticationRoutes)) {
|
||||
if (user?.$id) {
|
||||
if (shouldRedirect(pathname, acceptedAuthenticatedRoutes)) {
|
||||
@@ -122,9 +148,9 @@
|
||||
</script>
|
||||
|
||||
<Notifications />
|
||||
{#if isCloud}
|
||||
<!-- {#if isCloud}
|
||||
<Consent />
|
||||
{/if}
|
||||
{/if} -->
|
||||
|
||||
<slot />
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
import { project } from './project-[project]/store';
|
||||
import { feedback } from '$lib/stores/feedback';
|
||||
import { VARS, hasStripePublicKey, isCloud } from '$lib/system';
|
||||
import { loadStripe } from '@stripe/stripe-js';
|
||||
import { stripe } from '$lib/stores/stripe';
|
||||
import MobileSupportModal from './wizard/support/mobileSupportModal.svelte';
|
||||
import { showSupportModal } from './wizard/support/store';
|
||||
@@ -150,6 +149,7 @@
|
||||
await goto(`/console/project-${$project.$id}/auth/security#${heading}`);
|
||||
scrollBy({ top: -100 });
|
||||
},
|
||||
disabled: !$project?.$id,
|
||||
group: 'security',
|
||||
icon: 'pencil'
|
||||
}) as const
|
||||
@@ -162,7 +162,8 @@
|
||||
callback: () => {
|
||||
goto(`/console/project-${$project.$id}/settings`);
|
||||
},
|
||||
disabled: isOnSettingsLayout && $page.url.pathname.endsWith('settings'),
|
||||
disabled:
|
||||
!$project?.$id || (isOnSettingsLayout && $page.url.pathname.endsWith('settings')),
|
||||
group: isOnSettingsLayout ? 'navigation' : 'settings',
|
||||
rank: isOnSettingsLayout ? 40 : -1
|
||||
},
|
||||
@@ -173,7 +174,8 @@
|
||||
callback: () => {
|
||||
goto(`/console/project-${$project.$id}/settings/domains`);
|
||||
},
|
||||
disabled: isOnSettingsLayout && $page.url.pathname.includes('domains'),
|
||||
disabled:
|
||||
!$project?.$id || (isOnSettingsLayout && $page.url.pathname.includes('domains')),
|
||||
group: isOnSettingsLayout ? 'navigation' : 'settings',
|
||||
rank: isOnSettingsLayout ? 30 : -1
|
||||
},
|
||||
@@ -183,7 +185,8 @@
|
||||
callback: () => {
|
||||
goto(`/console/project-${$project.$id}/settings/webhooks`);
|
||||
},
|
||||
disabled: isOnSettingsLayout && $page.url.pathname.includes('webhooks'),
|
||||
disabled:
|
||||
!$project?.$id || (isOnSettingsLayout && $page.url.pathname.includes('webhooks')),
|
||||
group: isOnSettingsLayout ? 'navigation' : 'settings',
|
||||
|
||||
rank: isOnSettingsLayout ? 20 : -1
|
||||
@@ -194,7 +197,8 @@
|
||||
callback: () => {
|
||||
goto(`/console/project-${$project.$id}/settings/migrations`);
|
||||
},
|
||||
disabled: isOnSettingsLayout && $page.url.pathname.includes('migrations'),
|
||||
disabled:
|
||||
!$project?.$id || (isOnSettingsLayout && $page.url.pathname.includes('migrations')),
|
||||
group: isOnSettingsLayout ? 'navigation' : 'settings',
|
||||
|
||||
rank: isOnSettingsLayout ? 10 : -1
|
||||
@@ -203,9 +207,10 @@
|
||||
label: 'Go to SMTP settings',
|
||||
keys: isOnSettingsLayout ? ['g', 's'] : undefined,
|
||||
callback: () => {
|
||||
console.log('withing callback of go to smtp');
|
||||
goto(`/console/project-${$project.$id}/settings/smtp`);
|
||||
},
|
||||
disabled: isOnSettingsLayout && $page.url.pathname.includes('smtp'),
|
||||
disabled: !$project?.$id || (isOnSettingsLayout && $page.url.pathname.includes('smtp')),
|
||||
group: isOnSettingsLayout ? 'navigation' : 'settings',
|
||||
rank: -1
|
||||
},
|
||||
@@ -236,6 +241,8 @@
|
||||
}, INTERVAL);
|
||||
|
||||
if (isCloud && hasStripePublicKey) {
|
||||
const loadStripe = (await import('@stripe/stripe-js')).loadStripe;
|
||||
|
||||
$stripe = await loadStripe(VARS.STRIPE_PUBLIC_KEY);
|
||||
await checkForMissingPaymentMethod();
|
||||
}
|
||||
@@ -259,7 +266,7 @@
|
||||
if (isCloud) {
|
||||
await checkForUsageLimit(org);
|
||||
checkForMarkedForDeletion(org);
|
||||
if (org?.billingPlan !== BillingPlan.STARTER) {
|
||||
if (org?.billingPlan !== BillingPlan.FREE) {
|
||||
await paymentExpired(org);
|
||||
await checkPaymentAuthorizationRequired(org);
|
||||
await checkForMandate(org);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Table,
|
||||
TableScroll,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableCellHead,
|
||||
@@ -54,12 +54,12 @@
|
||||
</div>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Table noMargin noStyles>
|
||||
<TableScroll noMargin noStyles>
|
||||
<TableHeader>
|
||||
<TableCellHead width={100}>Provider</TableCellHead>
|
||||
<TableCellHead>Email</TableCellHead>
|
||||
<TableCellHead>Created At</TableCellHead>
|
||||
<TableCellHead>Expiry Date</TableCellHead>
|
||||
<TableCellHead width={140}>Email</TableCellHead>
|
||||
<TableCellHead width={140}>Created At</TableCellHead>
|
||||
<TableCellHead width={140}>Expiry Date</TableCellHead>
|
||||
<TableCellHead width={40} />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
@@ -95,7 +95,7 @@
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableScroll>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
@@ -71,7 +71,7 @@
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="status">
|
||||
{#if isCloudOrg(organization)}
|
||||
{#if organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if organization?.billingPlan === BillingPlan.FREE}
|
||||
<div
|
||||
class="u-flex u-cross-center"
|
||||
use:tooltip={{
|
||||
@@ -81,7 +81,7 @@
|
||||
<Pill>FREE</Pill>
|
||||
</div>
|
||||
{/if}
|
||||
{#if organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.STARTER && $plansInfo.get(organization.billingPlan)?.trialDays}
|
||||
{#if organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.FREE && $plansInfo.get(organization.billingPlan)?.trialDays}
|
||||
<div
|
||||
class="u-flex u-cross-center"
|
||||
use:tooltip={{
|
||||
|
||||
@@ -0,0 +1,357 @@
|
||||
<script lang="ts">
|
||||
import { afterNavigate, goto, invalidate } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import {
|
||||
CreditsApplied,
|
||||
EstimatedTotalBox,
|
||||
SelectPaymentMethod
|
||||
} from '$lib/components/billing';
|
||||
import { BillingPlan, Dependencies } from '$lib/constants';
|
||||
import { Button, Form, FormList, InputSelect, InputTags, InputText } from '$lib/elements/forms';
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import {
|
||||
WizardSecondaryContainer,
|
||||
WizardSecondaryContent,
|
||||
WizardSecondaryFooter,
|
||||
WizardSecondaryHeader
|
||||
} from '$lib/layout';
|
||||
import { type PaymentList } from '$lib/sdk/billing';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { campaigns } from '$lib/stores/campaigns';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { organizationList, type Organization } from '$lib/stores/organization';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { ID } from '@appwrite.io/console';
|
||||
import { onMount } from 'svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export let data;
|
||||
|
||||
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$/i;
|
||||
let previousPage: string = `${base}/console`;
|
||||
let showExitModal = false;
|
||||
|
||||
afterNavigate(({ from }) => {
|
||||
if (from?.url?.pathname) {
|
||||
if (from.url.pathname.includes('/login') || from.url.pathname.includes('/register')) {
|
||||
previousPage = `${base}/console`;
|
||||
} else {
|
||||
previousPage = from?.url?.pathname || previousPage;
|
||||
}
|
||||
} else {
|
||||
previousPage = `${base}/console`;
|
||||
}
|
||||
});
|
||||
|
||||
let selectedOrgId: string = null;
|
||||
let formComponent: Form;
|
||||
let isSubmitting = writable(false);
|
||||
let methods: PaymentList;
|
||||
let paymentMethodId: string;
|
||||
let collaborators: string[];
|
||||
let taxId: string;
|
||||
let billingBudget: number;
|
||||
let newOrgId = ID.unique();
|
||||
let options = [
|
||||
...($organizationList?.teams?.map((team) => ({
|
||||
value: team.$id,
|
||||
label: team.name
|
||||
})) ?? []),
|
||||
{
|
||||
value: newOrgId,
|
||||
label: 'Create new organization'
|
||||
}
|
||||
];
|
||||
let name: string;
|
||||
let coupon: string;
|
||||
let couponData = data?.couponData;
|
||||
|
||||
onMount(async () => {
|
||||
await loadPaymentMethods();
|
||||
if (!$organizationList?.total) {
|
||||
selectedOrgId = newOrgId;
|
||||
}
|
||||
});
|
||||
|
||||
async function loadPaymentMethods() {
|
||||
const methodList = await sdk.forConsole.billing.listPaymentMethods();
|
||||
const filteredMethods = methodList.paymentMethods.filter((method) => !!method?.last4);
|
||||
methods = { paymentMethods: filteredMethods, total: filteredMethods.length };
|
||||
paymentMethodId =
|
||||
selectedOrg?.paymentMethodId ??
|
||||
methods.paymentMethods.find((method) => !!method?.last4)?.$id ??
|
||||
null;
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
let org: Organization;
|
||||
// Create new org
|
||||
if (selectedOrgId === newOrgId) {
|
||||
org = await sdk.forConsole.billing.createOrganization(
|
||||
newOrgId,
|
||||
name,
|
||||
BillingPlan.PRO,
|
||||
paymentMethodId
|
||||
);
|
||||
}
|
||||
// Upgrade existing org
|
||||
else if (selectedOrg?.billingPlan !== BillingPlan.PRO) {
|
||||
org = await sdk.forConsole.billing.updatePlan(
|
||||
selectedOrg.$id,
|
||||
BillingPlan.PRO,
|
||||
paymentMethodId,
|
||||
null
|
||||
);
|
||||
}
|
||||
// Existing pro org
|
||||
else {
|
||||
org = selectedOrg;
|
||||
}
|
||||
|
||||
// Add coupon
|
||||
if (couponData?.code) {
|
||||
await sdk.forConsole.billing.addCredit(org.$id, couponData.code);
|
||||
}
|
||||
|
||||
// Add budget
|
||||
if (billingBudget) {
|
||||
await sdk.forConsole.billing.updateBudget(org.$id, billingBudget, [75]);
|
||||
}
|
||||
|
||||
// Add collaborators
|
||||
if (collaborators?.length) {
|
||||
collaborators.forEach(async (collaborator) => {
|
||||
await sdk.forConsole.teams.createMembership(
|
||||
org.$id,
|
||||
['owner'],
|
||||
collaborator,
|
||||
undefined,
|
||||
undefined,
|
||||
`${$page.url.origin}/console/organization-${org.$id}`
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Add tax ID
|
||||
if (taxId) {
|
||||
await sdk.forConsole.billing.updateTaxId(org.$id, taxId);
|
||||
}
|
||||
trackEvent(Submit.CreditRedeem, {
|
||||
coupon: couponData.code
|
||||
});
|
||||
await invalidate(Dependencies.ORGANIZATION);
|
||||
await goto(`/console/organization-${org.$id}`);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Credits applied successfully'
|
||||
});
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
} catch (e) {
|
||||
trackError(e, Submit.CreditRedeem);
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: e.message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function addCoupon() {
|
||||
try {
|
||||
const response = await sdk.forConsole.billing.getCoupon(coupon);
|
||||
couponData = response;
|
||||
coupon = null;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Credits applied successfully'
|
||||
});
|
||||
} catch (e) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: e.message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$: selectedOrg = $organizationList?.teams?.find(
|
||||
(team) => team.$id === selectedOrgId
|
||||
) as Organization;
|
||||
|
||||
$: isButtonDisabled =
|
||||
checkButtonDisabled(selectedOrgId, name, paymentMethodId) ||
|
||||
couponData?.status !== 'active';
|
||||
$: campaign = campaigns.get(data?.couponData?.campaign ?? data?.campaign);
|
||||
|
||||
function checkButtonDisabled(id: string | null, name: string | null, method: string | null) {
|
||||
if (id === newOrgId) {
|
||||
return !name || !method;
|
||||
} else if (id && selectedOrg?.billingPlan === BillingPlan.PRO) {
|
||||
return !selectedOrg?.paymentMethodId;
|
||||
} else if (id) {
|
||||
return !method;
|
||||
} else return true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Get started - Appwrite</title>
|
||||
</svelte:head>
|
||||
|
||||
<WizardSecondaryContainer href={previousPage} bind:showExitModal>
|
||||
<WizardSecondaryHeader confirmExit on:exit={() => (showExitModal = true)}>
|
||||
Get started
|
||||
</WizardSecondaryHeader>
|
||||
<WizardSecondaryContent>
|
||||
<Form bind:this={formComponent} onSubmit={handleSubmit} bind:isSubmitting>
|
||||
<FormList>
|
||||
{#if $organizationList?.total}
|
||||
<InputSelect
|
||||
bind:value={selectedOrgId}
|
||||
label="Select organization"
|
||||
{options}
|
||||
required
|
||||
placeholder="Select organization"
|
||||
id="organization" />
|
||||
{/if}
|
||||
{#if selectedOrgId && (selectedOrg?.billingPlan !== BillingPlan.PRO || !selectedOrg?.paymentMethodId)}
|
||||
{#if selectedOrgId === newOrgId}
|
||||
<InputText
|
||||
label="Organization name"
|
||||
placeholder="Enter organization name"
|
||||
id="name"
|
||||
required
|
||||
bind:value={name} />
|
||||
{/if}
|
||||
<InputTags
|
||||
bind:tags={collaborators}
|
||||
label="Invite members by email"
|
||||
tooltip="Invited members will have access to all services and payment data within your organization"
|
||||
placeholder="Enter email address(es)"
|
||||
validityRegex={emailRegex}
|
||||
validityMessage="Invalid email address"
|
||||
id="members" />
|
||||
<SelectPaymentMethod bind:methods bind:value={paymentMethodId} bind:taxId />
|
||||
{/if}
|
||||
</FormList>
|
||||
</Form>
|
||||
<Form onSubmit={addCoupon}>
|
||||
<FormList>
|
||||
{#if !data?.couponData?.code && selectedOrgId}
|
||||
<InputText
|
||||
disabled={!!couponData?.credits}
|
||||
bind:value={coupon}
|
||||
placeholder="Enter coupon code"
|
||||
id="code"
|
||||
label="Coupon code">
|
||||
<Button submit secondary disabled={!!couponData?.credits}>
|
||||
<span class="text">Apply</span>
|
||||
</Button>
|
||||
</InputText>
|
||||
{/if}
|
||||
</FormList>
|
||||
</Form>
|
||||
<svelte:fragment slot="aside">
|
||||
<div
|
||||
class="box card-container u-position-relative"
|
||||
style:--box-border-radius="var(--border-radius-small)">
|
||||
<div class="card-bg"></div>
|
||||
<div class="u-flex u-flex-vertical u-gap-24 u-cross-center u-position-relative">
|
||||
<img
|
||||
src={`/images/campaigns/${data?.couponData?.campaign ?? data?.campaign}/${$app.themeInUse}.png`}
|
||||
class="u-block u-image-object-fit-cover card-img"
|
||||
alt="promo" />
|
||||
<p class="text">
|
||||
{#if couponData?.credits}
|
||||
{campaign.title.replace('VALUE', couponData.credits.toString())}
|
||||
{:else}
|
||||
{campaign.title}
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{#if selectedOrg?.billingPlan === BillingPlan.PRO}
|
||||
<section
|
||||
class="card u-margin-block-start-24"
|
||||
style:--p-card-padding="1.5rem"
|
||||
style:--p-card-border-radius="var(--border-radius-small)">
|
||||
{#if couponData?.code && couponData?.status === 'active'}
|
||||
<CreditsApplied bind:couponData fixedCoupon={!!data?.couponData?.code} />
|
||||
<p class="text u-margin-block-start-12">
|
||||
Credits will automatically be applied to your next invoice on <b
|
||||
>{toLocaleDate(selectedOrg.billingNextInvoiceDate)}.</b>
|
||||
</p>
|
||||
{:else}
|
||||
<p class="text">Add a coupon code to apply credits to your organization.</p>
|
||||
{/if}
|
||||
</section>
|
||||
{:else if selectedOrgId}
|
||||
<EstimatedTotalBox
|
||||
fixedCoupon={!!data?.couponData?.code}
|
||||
billingPlan={BillingPlan.PRO}
|
||||
{collaborators}
|
||||
bind:couponData
|
||||
bind:billingBudget />
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</WizardSecondaryContent>
|
||||
|
||||
<WizardSecondaryFooter>
|
||||
<Button fullWidthMobile secondary on:click={() => (showExitModal = true)}>Cancel</Button>
|
||||
<Button
|
||||
fullWidthMobile
|
||||
on:click={() => formComponent.triggerSubmit()}
|
||||
disabled={$isSubmitting || isButtonDisabled}>
|
||||
{#if $isSubmitting}
|
||||
<span class="loader is-small is-transparent u-line-height-1-5" aria-hidden="true" />
|
||||
{/if}
|
||||
Create Organization
|
||||
</Button>
|
||||
</WizardSecondaryFooter>
|
||||
<svelte:fragment slot="exit">
|
||||
You can apply your credits to an organization at a later date. All other data entered will
|
||||
be lost.
|
||||
{#if couponData?.expiration}
|
||||
Credits expire {toLocaleDate(couponData.expiration)}.
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</WizardSecondaryContainer>
|
||||
|
||||
<style lang="scss">
|
||||
.card-container {
|
||||
overflow: hidden;
|
||||
}
|
||||
.card-bg {
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
inset: 0;
|
||||
}
|
||||
.card-bg::before {
|
||||
position: absolute;
|
||||
inset-block-start: -30px;
|
||||
inset-inline-end: -30px;
|
||||
content: '';
|
||||
display: block;
|
||||
inline-size: 30%;
|
||||
block-size: 30%;
|
||||
background: radial-gradient(49.55% 43.54% at 47% 50.69%, #e7f8f7 0%, #85dbd8 100%);
|
||||
filter: blur(70px);
|
||||
}
|
||||
.card-bg::after {
|
||||
position: absolute;
|
||||
inset-block-end: -30px;
|
||||
inset-inline-start: -30px;
|
||||
content: '';
|
||||
display: block;
|
||||
inline-size: 30%;
|
||||
block-size: 30%;
|
||||
background: radial-gradient(50% 46.73% at 50% 53.27%, #fe9567 28.17%, #fd366e 59.38%);
|
||||
filter: blur(70px);
|
||||
}
|
||||
.card-img {
|
||||
max-width: 12.5rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,41 @@
|
||||
import { base } from '$app/paths';
|
||||
import type { Coupon } from '$lib/sdk/billing.js';
|
||||
import { campaigns } from '$lib/stores/campaigns.js';
|
||||
import { sdk } from '$lib/stores/sdk.js';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export const load = async ({ url }) => {
|
||||
// Has promo code
|
||||
if (url.searchParams.has('code')) {
|
||||
let couponData: Coupon;
|
||||
const code = url.searchParams.get('code');
|
||||
try {
|
||||
couponData = await sdk.forConsole.billing.getCoupon(code);
|
||||
} catch (e) {
|
||||
redirect(303, `${base}/console`);
|
||||
}
|
||||
if (!couponData?.campaign || !campaigns.has(couponData.campaign)) {
|
||||
redirect(303, `${base}/console`);
|
||||
} else {
|
||||
return {
|
||||
couponData,
|
||||
campaign: couponData.campaign
|
||||
};
|
||||
}
|
||||
}
|
||||
// Has campaign
|
||||
else if (url.searchParams.has('campaign')) {
|
||||
const campaign = url.searchParams.get('campaign');
|
||||
if (campaigns.has(campaign)) {
|
||||
return {
|
||||
campaign
|
||||
};
|
||||
} else {
|
||||
redirect(303, `${base}/console`);
|
||||
}
|
||||
}
|
||||
// No campaign or promo code
|
||||
else {
|
||||
redirect(303, `${base}/console`);
|
||||
}
|
||||
};
|
||||
@@ -29,10 +29,11 @@
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
$: anyOrgFree = $organizationList.teams?.find(
|
||||
(org) => (org as Organization)?.billingPlan === BillingPlan.STARTER
|
||||
(org) => (org as Organization)?.billingPlan === BillingPlan.FREE
|
||||
);
|
||||
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$/i;
|
||||
let previousPage: string = `${base}/console`;
|
||||
let showExitModal = false;
|
||||
|
||||
afterNavigate(({ from }) => {
|
||||
previousPage = from?.url?.pathname || previousPage;
|
||||
@@ -43,7 +44,7 @@
|
||||
|
||||
let methods: PaymentList;
|
||||
let name: string;
|
||||
let billingPlan: BillingPlan = BillingPlan.STARTER;
|
||||
let billingPlan: BillingPlan = BillingPlan.FREE;
|
||||
let paymentMethodId: string;
|
||||
let collaborators: string[] = [];
|
||||
let couponData: Partial<Coupon> = {
|
||||
@@ -93,11 +94,11 @@
|
||||
try {
|
||||
let org: Organization;
|
||||
|
||||
if (billingPlan === BillingPlan.STARTER) {
|
||||
if (billingPlan === BillingPlan.FREE) {
|
||||
org = await sdk.forConsole.billing.createOrganization(
|
||||
ID.unique(),
|
||||
name,
|
||||
BillingPlan.STARTER,
|
||||
BillingPlan.FREE,
|
||||
null,
|
||||
null
|
||||
);
|
||||
@@ -107,7 +108,7 @@
|
||||
await sdk.forConsole.billing.createOrganization(
|
||||
ID.unique(),
|
||||
'Personal Projects',
|
||||
BillingPlan.STARTER,
|
||||
BillingPlan.FREE,
|
||||
null,
|
||||
null
|
||||
);
|
||||
@@ -174,7 +175,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: freePlan = $plansInfo.get(BillingPlan.STARTER);
|
||||
$: freePlan = $plansInfo.get(BillingPlan.FREE);
|
||||
$: proPlan = $plansInfo.get(BillingPlan.PRO);
|
||||
$: if (billingPlan === BillingPlan.PRO) {
|
||||
loadPaymentMethods();
|
||||
@@ -185,8 +186,8 @@
|
||||
<title>Create organization - Appwrite</title>
|
||||
</svelte:head>
|
||||
|
||||
<WizardSecondaryContainer>
|
||||
<WizardSecondaryHeader href={previousPage} showExitModal>
|
||||
<WizardSecondaryContainer bind:showExitModal href={previousPage}>
|
||||
<WizardSecondaryHeader confirmExit on:exit={() => (showExitModal = true)}>
|
||||
Create organization
|
||||
</WizardSecondaryHeader>
|
||||
<WizardSecondaryContent>
|
||||
@@ -194,8 +195,8 @@
|
||||
<FormList>
|
||||
<InputText
|
||||
bind:value={name}
|
||||
label="Name"
|
||||
placeholder="Enter name"
|
||||
label="Organization name"
|
||||
placeholder="Enter organization name"
|
||||
id="name"
|
||||
required />
|
||||
</FormList>
|
||||
@@ -274,7 +275,7 @@
|
||||
{/if}
|
||||
</Form>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if billingPlan !== BillingPlan.STARTER}
|
||||
{#if billingPlan !== BillingPlan.FREE}
|
||||
<EstimatedTotalBox
|
||||
{billingPlan}
|
||||
{collaborators}
|
||||
@@ -287,7 +288,7 @@
|
||||
</WizardSecondaryContent>
|
||||
|
||||
<WizardSecondaryFooter>
|
||||
<Button fullWidthMobile href={`${base}/console`} secondary>Cancel</Button>
|
||||
<Button fullWidthMobile secondary on:click={() => (showExitModal = true)}>Cancel</Button>
|
||||
<Button
|
||||
fullWidthMobile
|
||||
on:click={() => formComponent.triggerSubmit()}
|
||||
|
||||
@@ -49,9 +49,9 @@
|
||||
<Alert type="info">
|
||||
<svelte:fragment slot="title">Get ready for Appwrite Pro</svelte:fragment>
|
||||
We will soon introduce the much-anticipated Pro plan. Your account will continue to have
|
||||
access to <b>one free Starter organization</b>. If you manage more than one
|
||||
organization, you will need to either upgrade to the Pro plan, transfer your projects to
|
||||
a Pro organization, or migrate to self-hosting.
|
||||
access to <b>one free organization</b>. If you manage more than one organization, you
|
||||
will need to either upgrade to the Pro plan, transfer your projects to a Pro
|
||||
organization, or migrate to self-hosting.
|
||||
<svelte:fragment slot="buttons">
|
||||
<Button href="https://appwrite.io/pricing" external text>Learn more</Button>
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
const options = isCloud
|
||||
? [
|
||||
{
|
||||
value: BillingPlan.STARTER,
|
||||
label: `Starter - ${formatCurrency($plansInfo.get(BillingPlan.STARTER).price)}/month`
|
||||
value: BillingPlan.FREE,
|
||||
label: `${tierToPlan(BillingPlan.FREE).name} - ${formatCurrency($plansInfo.get(BillingPlan.FREE).price)}/month`
|
||||
},
|
||||
{
|
||||
value: BillingPlan.PRO,
|
||||
label: `Pro - ${formatCurrency($plansInfo.get(BillingPlan.PRO).price)}/month + add-ons`
|
||||
label: `${tierToPlan(BillingPlan.PRO).name} - ${formatCurrency($plansInfo.get(BillingPlan.PRO).price)}/month + add-ons`
|
||||
}
|
||||
]
|
||||
: [];
|
||||
@@ -50,7 +50,7 @@
|
||||
async function handleSubmit() {
|
||||
const orgName = name?.length ? name : 'Personal Projects';
|
||||
if (isCloud) {
|
||||
if (plan === BillingPlan.STARTER) {
|
||||
if (plan === BillingPlan.FREE) {
|
||||
try {
|
||||
const org = await sdk.forConsole.billing.createOrganization(
|
||||
id ?? ID.unique(),
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import PaymentHistory from './paymentHistory.svelte';
|
||||
import TaxId from './taxId.svelte';
|
||||
import { Alert, Heading } from '$lib/components';
|
||||
import { failedInvoice, paymentMethods, upgradeURL } from '$lib/stores/billing';
|
||||
import { failedInvoice, paymentMethods, tierToPlan, upgradeURL } from '$lib/stores/billing';
|
||||
import type { PaymentMethodData } from '$lib/sdk/billing';
|
||||
import { onMount } from 'svelte';
|
||||
import { page } from '$app/stores';
|
||||
@@ -111,8 +111,10 @@
|
||||
{/if}
|
||||
{#if $organization?.billingPlanDowngrade}
|
||||
<Alert type="info" class="common-section">
|
||||
Your organization will change to a Starter plan once your current billing cycle ends and
|
||||
your invoice is paid on {toLocaleDate($organization.billingNextInvoiceDate)}.
|
||||
Your organization will change to a {tierToPlan(BillingPlan.FREE).name} plan once your current
|
||||
billing cycle ends and your invoice is paid on {toLocaleDate(
|
||||
$organization.billingNextInvoiceDate
|
||||
)}.
|
||||
</Alert>
|
||||
{/if}
|
||||
<div class="common-section">
|
||||
@@ -121,10 +123,10 @@
|
||||
<PlanSummary />
|
||||
<PaymentHistory />
|
||||
<PaymentMethods />
|
||||
<BillingAddress billingAddress={data.billingAddress} />
|
||||
<BillingAddress billingAddress={data?.billingAddress} />
|
||||
<TaxId />
|
||||
<BudgetCap />
|
||||
{#if $organization?.billingPlan !== BillingPlan.STARTER && !!$organization?.billingBudget}
|
||||
{#if $organization?.billingPlan !== BillingPlan.FREE && !!$organization?.billingBudget}
|
||||
<BudgetAlert />
|
||||
{/if}
|
||||
<AvailableCredit />
|
||||
|
||||
@@ -15,10 +15,14 @@ export const load: PageLoad = async ({ parent, depends }) => {
|
||||
let billingAddress: Address = null;
|
||||
const billingAddressId = (organization as Organization)?.billingAddressId;
|
||||
if (billingAddressId) {
|
||||
billingAddress = await sdk.forConsole.billing.getOrganizationBillingAddress(
|
||||
organization.$id,
|
||||
billingAddressId
|
||||
);
|
||||
try {
|
||||
billingAddress = await sdk.forConsole.billing.getOrganizationBillingAddress(
|
||||
organization.$id,
|
||||
billingAddressId
|
||||
);
|
||||
} catch {
|
||||
billingAddress = null;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -67,12 +67,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<CardGrid hideFooter={$organization?.billingPlan !== BillingPlan.STARTER}>
|
||||
<CardGrid hideFooter={$organization?.billingPlan !== BillingPlan.FREE}>
|
||||
<Heading tag="h2" size="6">Available credit</Heading>
|
||||
|
||||
<p class="text">Appwrite credit will automatically be applied to your next invoice.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<Alert type="info">
|
||||
<svelte:fragment slot="title">Upgrade to Pro to add credits</svelte:fragment>
|
||||
Upgrade to a Pro plan to add credits to your organization. For more information on what
|
||||
@@ -129,7 +129,7 @@
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="actions">
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<Button
|
||||
secondary
|
||||
href={$upgradeURL}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
class="link">Learn more about usage rates.</button>
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<Alert type="info">
|
||||
<svelte:fragment slot="title">
|
||||
Budget caps are a Pro plan feature
|
||||
@@ -92,7 +92,7 @@
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<Button
|
||||
secondary
|
||||
href={$upgradeURL}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
{isTrial ? formatCurrency(0) : formatCurrency(currentPlan?.price)}
|
||||
</div>
|
||||
</CollapsibleItem>
|
||||
{#if $organization?.billingPlan !== BillingPlan.STARTER && extraUsage}
|
||||
{#if $organization?.billingPlan !== BillingPlan.FREE && extraUsage}
|
||||
<CollapsibleItem isInfo gap={8}>
|
||||
<svelte:fragment slot="beforetitle">
|
||||
<span class="body-text-2"><b>Add-ons</b></span><span class="inline-tag"
|
||||
@@ -147,7 +147,7 @@
|
||||
}}></span>
|
||||
</span>
|
||||
<div class="body-text-2 u-margin-inline-start-auto">
|
||||
{$organization?.billingPlan === BillingPlan.STARTER
|
||||
{$organization?.billingPlan === BillingPlan.FREE
|
||||
? formatCurrency(0)
|
||||
: formatCurrency(currentInvoice?.amount ?? 0)}
|
||||
</div>
|
||||
@@ -155,7 +155,7 @@
|
||||
</Collapsible>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="actions">
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<div class="u-flex u-gap-16 u-flex-wrap">
|
||||
<Button text href={`${base}/console/organization-${$organization?.$id}/usage`}>
|
||||
View estimated usage
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
PlanComparisonBox,
|
||||
SelectPaymentMethod
|
||||
} from '$lib/components/billing';
|
||||
import PlanExcess from '$lib/components/billing/planExcess.svelte';
|
||||
import ValidateCreditModal from '$lib/components/billing/validateCreditModal.svelte';
|
||||
import { BillingPlan, Dependencies, feedbackDowngradeOptions } from '$lib/constants';
|
||||
import {
|
||||
@@ -40,11 +41,11 @@
|
||||
export let data;
|
||||
|
||||
$: anyOrgFree = $organizationList.teams?.find(
|
||||
(org) => (org as Organization)?.billingPlan === BillingPlan.STARTER
|
||||
(org) => (org as Organization)?.billingPlan === BillingPlan.FREE
|
||||
);
|
||||
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$/i;
|
||||
let previousPage: string = `${base}/console`;
|
||||
|
||||
let showExitModal = false;
|
||||
afterNavigate(({ from }) => {
|
||||
previousPage = from?.url?.pathname || previousPage;
|
||||
});
|
||||
@@ -73,8 +74,8 @@
|
||||
let feedbackMessage: string;
|
||||
|
||||
onMount(async () => {
|
||||
if ($page.url.searchParams.has('coupon')) {
|
||||
const coupon = $page.url.searchParams.get('coupon');
|
||||
if ($page.url.searchParams.has('code')) {
|
||||
const coupon = $page.url.searchParams.get('code');
|
||||
try {
|
||||
const response = await sdk.forConsole.billing.getCoupon(coupon);
|
||||
couponData = response;
|
||||
@@ -105,7 +106,7 @@
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (billingPlan === BillingPlan.STARTER) {
|
||||
if (billingPlan === BillingPlan.FREE) {
|
||||
await downgrade();
|
||||
} else {
|
||||
await upgrade();
|
||||
@@ -235,7 +236,8 @@
|
||||
}
|
||||
|
||||
$: isUpgrade = billingPlan > $organization.billingPlan;
|
||||
$: freePlan = $plansInfo.get(BillingPlan.STARTER);
|
||||
$: isDowngrade = billingPlan < $organization.billingPlan;
|
||||
$: freePlan = $plansInfo.get(BillingPlan.FREE);
|
||||
$: proPlan = $plansInfo.get(BillingPlan.PRO);
|
||||
$: if (billingPlan === BillingPlan.PRO) {
|
||||
loadPaymentMethods();
|
||||
@@ -252,8 +254,9 @@
|
||||
<title>Change plan - Appwrite</title>
|
||||
</svelte:head>
|
||||
|
||||
<WizardSecondaryContainer>
|
||||
<WizardSecondaryHeader href={previousPage} showExitModal>Change plan</WizardSecondaryHeader>
|
||||
<WizardSecondaryContainer bind:showExitModal href={previousPage}>
|
||||
<WizardSecondaryHeader confirmExit on:exit={() => (showExitModal = true)}
|
||||
>Change plan</WizardSecondaryHeader>
|
||||
<WizardSecondaryContent>
|
||||
<Form bind:this={formComponent} onSubmit={handleSubmit} bind:isSubmitting>
|
||||
<Label class="label u-margin-block-start-16">Select plan</Label>
|
||||
@@ -263,8 +266,10 @@
|
||||
</p>
|
||||
{#if anyOrgFree && billingPlan === BillingPlan.PRO}
|
||||
<Alert type="warning" class="u-margin-block-16">
|
||||
You are limited to one Starter organization per account. Consider upgrading or
|
||||
deleting <Button link href={`${base}/console/organization-${anyOrgFree.$id}`}
|
||||
You are limited to one {tierToPlan(BillingPlan.FREE).name} organization per account.
|
||||
Consider upgrading or deleting <Button
|
||||
link
|
||||
href={`${base}/console/organization-${anyOrgFree.$id}`}
|
||||
>{anyOrgFree.name}</Button
|
||||
>.
|
||||
</Alert>
|
||||
@@ -276,8 +281,8 @@
|
||||
<LabelCard
|
||||
name="plan"
|
||||
bind:group={billingPlan}
|
||||
value="tier-0"
|
||||
disabled={!!anyOrgFree}
|
||||
value="tier-0"
|
||||
tooltipShow={!!anyOrgFree}
|
||||
tooltipText="You are limited to 1 Free organization per account.">
|
||||
<svelte:fragment slot="custom" let:disabled>
|
||||
@@ -286,7 +291,7 @@
|
||||
class:u-opacity-50={disabled}>
|
||||
<h4 class="body-text-2 u-bold">
|
||||
{tierFree.name}
|
||||
{#if $organization.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization.billingPlan === BillingPlan.FREE}
|
||||
<span class="inline-tag">Current plan</span>
|
||||
{/if}
|
||||
</h4>
|
||||
@@ -320,6 +325,9 @@
|
||||
</LabelCard>
|
||||
</li>
|
||||
</ul>
|
||||
{#if isDowngrade}
|
||||
<PlanExcess tier={BillingPlan.FREE} class="u-margin-block-start-24" />
|
||||
{/if}
|
||||
{#if billingPlan === BillingPlan.PRO && $organization.billingPlan !== BillingPlan.PRO}
|
||||
<FormList class="u-margin-block-start-16">
|
||||
<InputTags
|
||||
@@ -342,7 +350,7 @@
|
||||
</Button>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if !isUpgrade && billingPlan === BillingPlan.STARTER && $organization.billingPlan !== BillingPlan.STARTER}
|
||||
{#if !isUpgrade && billingPlan === BillingPlan.FREE && $organization.billingPlan !== BillingPlan.FREE}
|
||||
<FormList class="u-margin-block-start-16">
|
||||
<InputSelect
|
||||
id="reason"
|
||||
@@ -360,7 +368,7 @@
|
||||
{/if}
|
||||
</Form>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if billingPlan !== BillingPlan.STARTER && $organization.billingPlan !== BillingPlan.PRO}
|
||||
{#if billingPlan !== BillingPlan.FREE && $organization.billingPlan !== BillingPlan.PRO}
|
||||
<EstimatedTotalBox
|
||||
{billingPlan}
|
||||
{collaborators}
|
||||
@@ -373,7 +381,7 @@
|
||||
</WizardSecondaryContent>
|
||||
|
||||
<WizardSecondaryFooter>
|
||||
<Button fullWidthMobile href={`${base}/console`} secondary>Cancel</Button>
|
||||
<Button fullWidthMobile secondary on:click={() => (showExitModal = true)}>Cancel</Button>
|
||||
<Button
|
||||
fullWidthMobile
|
||||
on:click={() => formComponent.triggerSubmit()}
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { sizeToBytes } from '$lib/helpers/sizeConvertion';
|
||||
import { plansInfo, tierToPlan, upgradeURL } from '$lib/stores/billing';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { onMount } from 'svelte';
|
||||
import type { OrganizationUsage } from '$lib/sdk/billing';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { goto } from '$app/navigation';
|
||||
import { last } from '$lib/helpers/array';
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import PlanExcess from '$lib/components/billing/planExcess.svelte';
|
||||
|
||||
export let show = false;
|
||||
const plan = $plansInfo?.get($organization.billingPlan);
|
||||
let usage: OrganizationUsage = null;
|
||||
let members: Models.MembershipList = null;
|
||||
let excess: Record<string, number> = null;
|
||||
|
||||
onMount(async () => {
|
||||
usage = await sdk.forConsole.billing.listUsage(
|
||||
$organization.$id,
|
||||
$organization.billingCurrentInvoiceDate,
|
||||
new Date().toISOString()
|
||||
);
|
||||
members = await sdk.forConsole.teams.listMemberships($organization.$id);
|
||||
calculateExcess();
|
||||
});
|
||||
|
||||
function calculateExcess() {
|
||||
const totBandwidth = usage?.bandwidth?.length > 0 ? last(usage.bandwidth).value : 0;
|
||||
const totUsers = usage?.users?.length > 0 ? last(usage.users).value : 0;
|
||||
|
||||
excess = {
|
||||
bandwidth: totBandwidth > plan.bandwidth ? totBandwidth - plan.bandwidth : 0,
|
||||
storage:
|
||||
usage?.storageTotal > sizeToBytes(plan.storage, 'GB')
|
||||
? usage.storageTotal - sizeToBytes(plan.storage, 'GB')
|
||||
: 0,
|
||||
users: totUsers > (plan.users || Infinity) ? totUsers - plan.users : 0,
|
||||
executions:
|
||||
usage?.executionsTotal > sizeToBytes(plan.executions, 'GB')
|
||||
? usage.executionsTotal - sizeToBytes(plan.executions, 'GB')
|
||||
: 0,
|
||||
members:
|
||||
members?.total > (plan.members || Infinity)
|
||||
? members.total - (plan.members || Infinity)
|
||||
: 0
|
||||
};
|
||||
}
|
||||
|
||||
$: if (show) calculateExcess();
|
||||
</script>
|
||||
|
||||
<Modal bind:show title="Limit reached">
|
||||
<p class="text">
|
||||
Usage for <b>{$organization.name}</b> organization has reached the limits of the {tierToPlan(
|
||||
$organization.billingPlan
|
||||
).name} plan. Excess usage fees will apply.
|
||||
</p>
|
||||
|
||||
<PlanExcess {excess} currentTier={$organization.billingPlan} />
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<div class="u-flex u-main-space-between u-width-full-line">
|
||||
<Button text on:click={() => (show = false)}>Cancel</Button>
|
||||
<div class="u-flex u-main-end u-gap-16">
|
||||
<Button
|
||||
secondary
|
||||
on:click={() => {
|
||||
show = false;
|
||||
goto(`/console/organization-${$organization.$id}/usage`);
|
||||
}}>
|
||||
View usage
|
||||
</Button>
|
||||
<Button
|
||||
href={$upgradeURL}
|
||||
on:click={() => {
|
||||
show = false;
|
||||
trackEvent('click_organization_upgrade', {
|
||||
from: 'button',
|
||||
source: 'limit_reached_modal'
|
||||
});
|
||||
}}>
|
||||
Upgrade plan
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -107,10 +107,10 @@
|
||||
<span class="u-trim">
|
||||
{$organization.name}
|
||||
</span>
|
||||
{#if isCloud && $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if isCloud && $organization?.billingPlan === BillingPlan.FREE}
|
||||
<Pill>FREE</Pill>
|
||||
{/if}
|
||||
{#if isCloud && $organization?.billingTrialStartDate && $daysLeftInTrial > 0 && $organization.billingPlan !== BillingPlan.STARTER && $plansInfo.get($organization.billingPlan)?.trialDays}
|
||||
{#if isCloud && $organization?.billingTrialStartDate && $daysLeftInTrial > 0 && $organization.billingPlan !== BillingPlan.FREE && $plansInfo.get($organization.billingPlan)?.trialDays}
|
||||
<div
|
||||
class="u-flex u-cross-center"
|
||||
use:tooltip={{
|
||||
@@ -153,7 +153,7 @@
|
||||
<div
|
||||
use:tooltip={{
|
||||
content:
|
||||
$organization?.billingPlan === BillingPlan.STARTER
|
||||
$organization?.billingPlan === BillingPlan.FREE
|
||||
? `Upgrade to add more members`
|
||||
: `You've reached the members limit for the ${
|
||||
tierToPlan($organization?.billingPlan)?.name
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<div class="u-flex u-cross-center u-main-space-between">
|
||||
<Heading tag="h2" size="5">Usage</Heading>
|
||||
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<Button
|
||||
href={$upgradeURL}
|
||||
on:click={() => {
|
||||
@@ -76,7 +76,7 @@
|
||||
class="link"
|
||||
type="button">Learn more about plan usage limits.</button>
|
||||
</p>
|
||||
{:else if $organization.billingPlan === BillingPlan.STARTER}
|
||||
{:else if $organization.billingPlan === BillingPlan.FREE}
|
||||
<p class="text">
|
||||
If you exceed the limits of the {plan} plan, services for your organization's projects
|
||||
may be disrupted.
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
<p class="text">The number of members in your organization.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if $organization.billingPlan !== BillingPlan.STARTER}
|
||||
{#if $organization.billingPlan !== BillingPlan.FREE}
|
||||
<div class="u-flex u-flex-vertical">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<p>
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
import { Pill } from '$lib/elements';
|
||||
import { InputText, FormList } from '$lib/elements/forms';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { createProject } from './store';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { createProject, regions } from './store';
|
||||
|
||||
let showCustomId = false;
|
||||
|
||||
sdk.forConsole.billing.listRegions().then(regions.set);
|
||||
</script>
|
||||
|
||||
<WizardStep>
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { createProject } from './store';
|
||||
import type { Region, RegionList } from '$lib/sdk/billing';
|
||||
import { createProject, regions } from './store';
|
||||
import type { Region } from '$lib/sdk/billing';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
let regions: RegionList;
|
||||
let prefs: Models.Preferences;
|
||||
|
||||
onMount(async () => {
|
||||
regions = await sdk.forConsole.billing.listRegions();
|
||||
prefs = await sdk.forConsole.account.getPrefs();
|
||||
prefs = $page.data.account.prefs;
|
||||
});
|
||||
|
||||
async function notifyRegion(selectedRegion: Region) {
|
||||
@@ -66,11 +66,11 @@
|
||||
<svelte:fragment slot="subtitle">
|
||||
Choose a deployment region for your project. This region cannot be changed.
|
||||
</svelte:fragment>
|
||||
{#if regions?.total}
|
||||
{#if $regions}
|
||||
<ul
|
||||
class="grid-box u-margin-block-start-16"
|
||||
style="--p-grid-item-size:12em; --p-grid-item-size-small-screens:12rem; --grid-gap: 1rem;">
|
||||
{#each regions.regions.filter((r) => r.$id !== 'default') as region}
|
||||
{#each $regions.regions.filter((r) => r.$id !== 'default') as region}
|
||||
<li>
|
||||
<RegionCard
|
||||
name="region"
|
||||
@@ -115,7 +115,6 @@
|
||||
height={30}
|
||||
flag={region.flag}
|
||||
name={region.name} />
|
||||
|
||||
{region.name}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { RegionList } from '$lib/sdk/billing';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const createProject = writable<{
|
||||
@@ -9,3 +10,5 @@ export const createProject = writable<{
|
||||
name: null,
|
||||
region: 'fra'
|
||||
});
|
||||
|
||||
export const regions = writable<RegionList | undefined>(undefined);
|
||||
@@ -60,6 +60,7 @@
|
||||
EmailTemplateLocale
|
||||
} from '@appwrite.io/console';
|
||||
import Email2FaTemplate from './email2FATemplate.svelte';
|
||||
import { tierToPlan } from '$lib/stores/billing';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
|
||||
@@ -133,7 +134,7 @@
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
{#if $organization.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization.billingPlan === BillingPlan.FREE}
|
||||
<Alert
|
||||
buttons={[
|
||||
{
|
||||
@@ -141,8 +142,8 @@
|
||||
href: `${base}/console/organization-${$organization.$id}/billing`
|
||||
}
|
||||
]}>
|
||||
All emails sent using the Starter plan will include attribution to Appwrite in
|
||||
the signature. To send attribution-free emails, upgrade your plan.
|
||||
All emails sent using the {tierToPlan(BillingPlan.FREE).name} plan will include attribution
|
||||
to Appwrite in the signature. To send attribution-free emails, upgrade your plan.
|
||||
</Alert>
|
||||
{/if}
|
||||
<Collapsible>
|
||||
|
||||
@@ -28,7 +28,10 @@
|
||||
id: attribute.key,
|
||||
title: attribute.key,
|
||||
type: attribute.type as ColumnType,
|
||||
show: selected?.includes(attribute.key) ?? true
|
||||
show: selected?.includes(attribute.key) ?? true,
|
||||
array: attribute?.array,
|
||||
format: 'format' in attribute && attribute?.format === 'enum' ? attribute.format : null,
|
||||
elements: 'elements' in attribute ? attribute.elements : null
|
||||
}))
|
||||
);
|
||||
|
||||
@@ -54,7 +57,7 @@
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Filters query={data.query} {columns} />
|
||||
<Filters query={data.query} {columns} disabled={!(hasAttributes && hasValidAttributes)} />
|
||||
|
||||
<div class="u-flex u-main-end u-gap-16">
|
||||
<ViewSelector
|
||||
|
||||
@@ -91,7 +91,11 @@
|
||||
id: attribute.key,
|
||||
title: attribute.key,
|
||||
type: attribute.type as ColumnType,
|
||||
show: selected?.includes(attribute.key) ?? true
|
||||
show: selected?.includes(attribute.key) ?? true,
|
||||
array: attribute?.array,
|
||||
format:
|
||||
'format' in attribute && attribute?.format === 'enum' ? attribute.format : null,
|
||||
elements: 'elements' in attribute ? attribute.elements : null
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
`functions.${$page.params.function}.deployments.${$page.params.deployment}.update`
|
||||
)
|
||||
) {
|
||||
logs = message.payload.buildLogs;
|
||||
logs = message.payload['logs'];
|
||||
if (message.payload.status === 'ready') {
|
||||
invalidate(Dependencies.DEPLOYMENT);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
{hoursToDays(logs)} of logs
|
||||
</li>
|
||||
</ul>
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<p class="text">
|
||||
<button class="link" type="button" on:click|preventDefault={upgradeMethod}
|
||||
>Upgrade</button>
|
||||
|
||||
@@ -191,7 +191,10 @@
|
||||
background-position: top right;
|
||||
}
|
||||
}
|
||||
|
||||
.onboard-cover img {
|
||||
max-inline-size: none;
|
||||
max-block-size: none;
|
||||
}
|
||||
.onboard-cover > div {
|
||||
background-color: transparent;
|
||||
z-index: 1;
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
class="link">here</a>
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if $organization.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization.billingPlan === BillingPlan.FREE}
|
||||
<Alert type="info">
|
||||
Custom SMTP is a Pro plan feature. Upgrade to enable custom SMTP sever.
|
||||
<svelte:fragment slot="action">
|
||||
@@ -205,8 +205,7 @@
|
||||
<svelte:fragment slot="actions">
|
||||
<Button
|
||||
submit
|
||||
disabled={isButtonDisabled ||
|
||||
$organization.billingPlan === BillingPlan.STARTER}>
|
||||
disabled={isButtonDisabled || $organization.billingPlan === BillingPlan.FREE}>
|
||||
Update
|
||||
</Button>
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<div class="u-flex u-cross-center u-main-space-between">
|
||||
<Heading tag="h2" size="5">Usage</Heading>
|
||||
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<Button href={$upgradeURL}>
|
||||
<span class="text">Upgrade</span>
|
||||
</Button>
|
||||
@@ -71,7 +71,7 @@
|
||||
on:click={() => ($showUsageRatesModal = true)}
|
||||
link>Learn more about plan usage limits.</Button>
|
||||
</p>
|
||||
{:else if $organization.billingPlan === BillingPlan.STARTER}
|
||||
{:else if $organization.billingPlan === BillingPlan.FREE}
|
||||
<p class="text">
|
||||
If you exceed the limits of the {plan} plan, services for your projects may be disrupted.
|
||||
<a href={$upgradeURL} class="link">Upgrade for greater capacity</a>.
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
PaginationWithLimit,
|
||||
SearchQuery
|
||||
} from '$lib/components';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { BillingPlan, Dependencies } from '$lib/constants';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
@@ -45,7 +45,7 @@
|
||||
import { uploader } from '$lib/stores/uploader';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
import { getServiceLimit, showUsageRatesModal } from '$lib/stores/billing';
|
||||
import { getServiceLimit, showUsageRatesModal, tierToPlan } from '$lib/stores/billing';
|
||||
import { sdk } from '$lib/stores/sdk.js';
|
||||
import Create from './create-file/create.svelte';
|
||||
import DeleteFile from './deleteFile.svelte';
|
||||
@@ -112,7 +112,7 @@
|
||||
</SearchQuery>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="tooltip" let:limit let:tier let:upgradeMethod>
|
||||
{#if tier === 'Starter'}
|
||||
{#if tier === tierToPlan(BillingPlan.FREE).name}
|
||||
<p class="u-bold">The {tier} plan has limits</p>
|
||||
<ul>
|
||||
<li>{limit}GB total file storage</li>
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
The {plan.name} plan has a maximum upload file size limit of {Math.floor(
|
||||
parseInt(size.value)
|
||||
)}{size.unit}.
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
Upgrade to allow files of a larger size.
|
||||
{/if}
|
||||
</p>
|
||||
<svelte:fragment slot="action">
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<div class="alert-buttons u-flex">
|
||||
<Button text href={$upgradeURL}>Upgrade plan</Button>
|
||||
</div>
|
||||
|
||||
@@ -413,7 +413,7 @@
|
||||
label="Allowed extensions"
|
||||
placeholder="Allowed file extensions (mp4, jpg, pdf, etc.)"
|
||||
bind:tags={extensions} />
|
||||
<li class="u-flex u-gap-12 u-margin-block-start-8">
|
||||
<li class="u-flex u-gap-12 u-margin-block-start-8 with-scroll">
|
||||
{#each suggestedExtensions as ext}
|
||||
<Pill
|
||||
selected={extensions.includes(ext)}
|
||||
|
||||
@@ -41,12 +41,12 @@
|
||||
The {plan.name} plan has a maximum upload file size limit of {Math.floor(
|
||||
parseInt(size.value)
|
||||
)}{size.unit}.
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
Upgrade to allow files of a larger size.
|
||||
{/if}
|
||||
</p>
|
||||
<svelte:fragment slot="action">
|
||||
{#if $organization?.billingPlan === BillingPlan.STARTER}
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE}
|
||||
<div class="alert-buttons u-flex">
|
||||
<Button text href={$upgradeURL}>Upgrade plan</Button>
|
||||
</div>
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
let mail: string, pass: string, disabled: boolean;
|
||||
|
||||
export let data;
|
||||
|
||||
async function login() {
|
||||
try {
|
||||
disabled = true;
|
||||
@@ -39,6 +41,16 @@
|
||||
return;
|
||||
}
|
||||
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
if (data?.couponData?.code) {
|
||||
trackEvent(Submit.AccountCreate, { campaign_name: data?.couponData?.code });
|
||||
await goto(`${base}/console/apply-credit?code=${data?.couponData?.code}`);
|
||||
return;
|
||||
}
|
||||
if (data?.campaign) {
|
||||
await goto(`${base}/console/apply-credit?campaign=${data.campaign}`);
|
||||
return;
|
||||
}
|
||||
if ($page.url.searchParams) {
|
||||
const redirect = $page.url.searchParams.get('redirect');
|
||||
$page.url.searchParams.delete('redirect');
|
||||
@@ -85,7 +97,7 @@
|
||||
<title>Sign in - Appwrite</title>
|
||||
</svelte:head>
|
||||
|
||||
<Unauthenticated>
|
||||
<Unauthenticated coupon={data?.couponData} campaign={data?.campaign}>
|
||||
<svelte:fragment slot="title">Sign in</svelte:fragment>
|
||||
<svelte:fragment>
|
||||
<Form onSubmit={login}>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { base } from '$app/paths';
|
||||
import { campaigns } from '$lib/stores/campaigns';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export const load = async ({ url }) => {
|
||||
if (url.searchParams.has('code')) {
|
||||
const code = url.searchParams.get('code');
|
||||
try {
|
||||
const couponData = await sdk.forConsole.billing.getCoupon(code);
|
||||
if (couponData?.campaign && campaigns.has(couponData.campaign)) {
|
||||
return {
|
||||
couponData
|
||||
};
|
||||
} else redirect(303, `${base}/login`);
|
||||
} catch (e) {
|
||||
redirect(303, `${base}/login`);
|
||||
}
|
||||
}
|
||||
if (url.searchParams.has('campaign')) {
|
||||
const campaign = url.searchParams.get('campaign');
|
||||
if (campaigns.has(campaign)) {
|
||||
return {
|
||||
campaign
|
||||
};
|
||||
} else redirect(303, `${base}/login`);
|
||||
}
|
||||
return;
|
||||
};
|
||||
@@ -21,6 +21,8 @@
|
||||
import { page } from '$app/stores';
|
||||
import { redirectTo } from '$routes/store';
|
||||
|
||||
export let data;
|
||||
|
||||
let name: string, mail: string, pass: string, disabled: boolean;
|
||||
let terms = false;
|
||||
|
||||
@@ -36,7 +38,15 @@
|
||||
}
|
||||
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
|
||||
trackEvent(Submit.AccountCreate, { campaign_name: data?.couponData?.code });
|
||||
if (data?.couponData?.code) {
|
||||
await goto(`${base}/console/apply-credit?code=${data?.couponData?.code}`);
|
||||
return;
|
||||
}
|
||||
if (data?.campaign) {
|
||||
await goto(`${base}/console/apply-credit?campaign=${data.campaign}`);
|
||||
return;
|
||||
}
|
||||
if ($page.url.searchParams) {
|
||||
const redirect = $page.url.searchParams.get('redirect');
|
||||
$page.url.searchParams.delete('redirect');
|
||||
@@ -73,7 +83,7 @@
|
||||
<title>Sign up - Appwrite</title>
|
||||
</svelte:head>
|
||||
|
||||
<Unauthenticated>
|
||||
<Unauthenticated coupon={data?.couponData} campaign={data?.campaign}>
|
||||
<svelte:fragment slot="title">Sign up</svelte:fragment>
|
||||
<svelte:fragment>
|
||||
<Form onSubmit={register}>
|
||||
@@ -130,7 +140,9 @@
|
||||
<svelte:fragment slot="links">
|
||||
<li class="inline-links-item">
|
||||
<span class="text">
|
||||
Already got an account? <a class="link" href={`${base}/login`}>Sign in</a>
|
||||
Already got an account? <a
|
||||
class="link"
|
||||
href={`${base}/login${$page?.url?.search ?? ''}`}>Sign in</a>
|
||||
</span>
|
||||
</li>
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { base } from '$app/paths';
|
||||
import { campaigns } from '$lib/stores/campaigns.js';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export const load = async ({ url }) => {
|
||||
if (url.searchParams.has('code')) {
|
||||
const code = url.searchParams.get('code');
|
||||
try {
|
||||
const couponData = await sdk.forConsole.billing.getCoupon(code);
|
||||
if (couponData?.campaign && campaigns.has(couponData.campaign)) {
|
||||
return {
|
||||
couponData
|
||||
};
|
||||
} else redirect(303, `${base}/register`);
|
||||
} catch (e) {
|
||||
redirect(303, `${base}/register`);
|
||||
}
|
||||
}
|
||||
if (url.searchParams.has('campaign')) {
|
||||
const campaign = url.searchParams.get('campaign');
|
||||
if (campaigns.has(campaign)) {
|
||||
return {
|
||||
campaign
|
||||
};
|
||||
} else redirect(303, `${base}/login`);
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
After Width: | Height: | Size: 303 KiB |
|
After Width: | Height: | Size: 303 KiB |
|
After Width: | Height: | Size: 417 KiB |
|
After Width: | Height: | Size: 384 KiB |
|
After Width: | Height: | Size: 136 KiB |
|
After Width: | Height: | Size: 127 KiB |
|
After Width: | Height: | Size: 136 KiB |
|
After Width: | Height: | Size: 127 KiB |
@@ -10,7 +10,7 @@ export function registerUserStep(page: Page): Promise<Metadata> {
|
||||
return test.step('register user', async () => {
|
||||
const seed = crypto.randomUUID();
|
||||
await page.goto('/register');
|
||||
await page.getByRole('button', { name: 'only required' }).click();
|
||||
// await page.getByRole('button', { name: 'only required' }).click();
|
||||
const inputs = {
|
||||
name: page.locator('id=name'),
|
||||
email: page.locator('id=email'),
|
||||
|
||||