mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
remove: Coupon type!
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { Button, InputText } from '$lib/elements/forms';
|
||||
import { formatCurrency } from '$lib/helpers/numbers';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Layout } from '@appwrite.io/pink-svelte';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { Layout } from '@appwrite.io/pink-svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { formatCurrency } from '$lib/helpers/numbers';
|
||||
import { Button, InputText } from '$lib/elements/forms';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let required = false;
|
||||
export let coupon: string = '';
|
||||
export let couponData: Partial<Coupon> = {
|
||||
export let couponData: Partial<Models.Coupon> = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
async function addCoupon() {
|
||||
try {
|
||||
const response = await sdk.forConsole.billing.getCouponAccount(coupon);
|
||||
couponData = response;
|
||||
couponData = await sdk.forConsole.billing.getCouponAccount(coupon);
|
||||
dispatch('validation', couponData);
|
||||
coupon = null;
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { formatCurrency } from '$lib/helpers/numbers';
|
||||
import { IconTag, IconX } from '@appwrite.io/pink-icons-svelte';
|
||||
import { Badge, Icon, Layout, Tooltip, Typography } from '@appwrite.io/pink-svelte';
|
||||
|
||||
export let couponData: Partial<Coupon> = {
|
||||
export let couponData: Partial<Models.Coupon> = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<script lang="ts">
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { formatCurrency } from '$lib/helpers/numbers';
|
||||
import { IconTag } from '@appwrite.io/pink-icons-svelte';
|
||||
import { Badge, Icon, Layout, Typography } from '@appwrite.io/pink-svelte';
|
||||
|
||||
export let label: string;
|
||||
export let value: number;
|
||||
export let couponData: Partial<Coupon> = {
|
||||
export let couponData: Partial<Models.Coupon> = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { InputChoice, InputNumber } from '$lib/elements/forms';
|
||||
import { formatCurrency } from '$lib/helpers/numbers';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import { Card, Divider, Layout, Typography } from '@appwrite.io/pink-svelte';
|
||||
import { CreditsApplied } from '.';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
@@ -10,7 +9,7 @@
|
||||
|
||||
export let billingPlan: string;
|
||||
export let collaborators: string[];
|
||||
export let couponData: Partial<Coupon>;
|
||||
export let couponData: Partial<Models.Coupon>;
|
||||
export let billingBudget: number;
|
||||
export let fixedCoupon = false; // If true, the coupon cannot be removed
|
||||
export let isDowngrade = false;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button, InputText } from '$lib/elements/forms';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export let show = false;
|
||||
export let isNewOrg = false;
|
||||
export let couponData: Partial<Coupon> = {
|
||||
export let couponData: Partial<Models.Coupon> = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
|
||||
@@ -5,18 +5,18 @@
|
||||
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 type { Campaign } from '$lib/stores/campaigns';
|
||||
import { Typography, Layout, Avatar } from '@appwrite.io/pink-svelte';
|
||||
import { getCampaignImageUrl } from '$routes/(public)/card/helpers';
|
||||
import { isSmallViewport } from '$lib/stores/viewport';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export const imgLight = LoginLight;
|
||||
export const imgDark = LoginDark;
|
||||
|
||||
export let campaign: Campaign = null;
|
||||
export let coupon: Coupon = null;
|
||||
export let coupon: Models.Coupon = null;
|
||||
export let align: 'start' | 'center' | 'end' = 'start';
|
||||
|
||||
$: variation = ((coupon?.campaign ?? campaign) ? campaign?.template : 'default') as
|
||||
|
||||
+2
-13
@@ -3,17 +3,6 @@ import type { Client, Models } from '@appwrite.io/console';
|
||||
import type { PaymentMethod as StripePaymentMethod } from '@stripe/stripe-js';
|
||||
import type { Organization, OrganizationError, OrganizationList } from '../stores/organization';
|
||||
|
||||
export type Coupon = {
|
||||
$id: string;
|
||||
code: string;
|
||||
credits: number;
|
||||
expiration: string;
|
||||
status: string; // 'active' | 'disabled' | 'expired'
|
||||
validity: number;
|
||||
campaign?: string;
|
||||
onlyNewOrgs?: boolean;
|
||||
};
|
||||
|
||||
export type AggregationTeam = {
|
||||
$id: string;
|
||||
/**
|
||||
@@ -829,7 +818,7 @@ export class Billing {
|
||||
}
|
||||
}
|
||||
|
||||
async getCouponAccount(couponId: string): Promise<Coupon> {
|
||||
async getCouponAccount(couponId: string): Promise<Models.Coupon> {
|
||||
const path = `/account/coupons/${couponId}`;
|
||||
const params = {
|
||||
couponId
|
||||
@@ -845,7 +834,7 @@ export class Billing {
|
||||
);
|
||||
}
|
||||
|
||||
async getCoupon(couponId: string): Promise<Coupon> {
|
||||
async getCoupon(couponId: string): Promise<Models.Coupon> {
|
||||
const path = `/console/coupons/${couponId}`;
|
||||
const params = {
|
||||
couponId
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { base } from '$app/paths';
|
||||
import type { Coupon } from '$lib/sdk/billing.js';
|
||||
import type { Campaign } from '$lib/stores/campaigns.js';
|
||||
import { resolve } from '$app/paths';
|
||||
import { sdk } from '$lib/stores/sdk.js';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export const load = async ({ url }) => {
|
||||
// Has promo code
|
||||
if (url.searchParams.has('code')) {
|
||||
let couponData: Coupon;
|
||||
let campaign: Campaign;
|
||||
let couponData: Models.Coupon;
|
||||
let campaign: Models.Campaign;
|
||||
const code = url.searchParams.get('code');
|
||||
try {
|
||||
couponData = await sdk.forConsole.billing.getCouponAccount(code);
|
||||
@@ -17,22 +16,22 @@ export const load = async ({ url }) => {
|
||||
}
|
||||
return { couponData, campaign };
|
||||
} catch (e) {
|
||||
redirect(303, base);
|
||||
redirect(303, resolve('/'));
|
||||
}
|
||||
}
|
||||
// Has campaign
|
||||
else if (url.searchParams.has('campaign')) {
|
||||
const campaignId = url.searchParams.get('campaign');
|
||||
let campaign: Campaign;
|
||||
let campaign: Models.Campaign;
|
||||
try {
|
||||
campaign = await sdk.forConsole.billing.getCampaign(campaignId);
|
||||
return { campaign };
|
||||
} catch (e) {
|
||||
redirect(303, base);
|
||||
redirect(303, resolve('/'));
|
||||
}
|
||||
}
|
||||
// No campaign or promo code
|
||||
else {
|
||||
redirect(303, base);
|
||||
redirect(303, resolve('/'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,13 +8,12 @@
|
||||
import { BillingPlan, Dependencies } from '$lib/constants';
|
||||
import { Button, Form, InputTags, InputText } from '$lib/elements/forms';
|
||||
import { Wizard } from '$lib/layout';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import { isOrganization, billingIdToPlan } from '$lib/stores/billing';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import type { OrganizationError, Organization } from '$lib/stores/organization';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { confirmPayment } from '$lib/stores/stripe';
|
||||
import { ID } from '@appwrite.io/console';
|
||||
import { ID, type Models } from '@appwrite.io/console';
|
||||
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
|
||||
import { Divider, Fieldset, Icon, Layout, Link, Typography } from '@appwrite.io/pink-svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
@@ -27,7 +26,7 @@
|
||||
let showExitModal = $state(false);
|
||||
let previousPage: string = $state(resolve('/(console)'));
|
||||
let selectedPlan: BillingPlan = $state(data.plan as BillingPlan);
|
||||
let selectedCoupon: Partial<Coupon> | null = $state(data.coupon);
|
||||
let selectedCoupon: Partial<Models.Coupon> | null = $state(data.coupon);
|
||||
|
||||
let isSubmitting = $state(writable(false));
|
||||
let formComponent: Form | null = $state(null);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { BillingPlan, Dependencies } from '$lib/constants';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { Organization } from '$lib/stores/organization';
|
||||
import { BillingPlan, Dependencies } from '$lib/constants';
|
||||
|
||||
export const load: PageLoad = async ({ url, parent, depends }) => {
|
||||
const { organizations } = await parent();
|
||||
@@ -41,7 +41,7 @@ function getPlanFromUrl(url: URL): BillingPlan | null {
|
||||
return BillingPlan.FREE;
|
||||
}
|
||||
|
||||
async function getCoupon(url: URL): Promise<Coupon | null> {
|
||||
async function getCoupon(url: URL): Promise<Models.Coupon | null> {
|
||||
if (url.searchParams.has('code')) {
|
||||
const coupon = url.searchParams.get('code');
|
||||
try {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { CouponInput } from '$lib/components/billing';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { onMount } from 'svelte';
|
||||
import { addCreditWizardStore } from '../store';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
let coupon: string;
|
||||
export let couponData: Partial<Coupon> = {
|
||||
export let couponData: Partial<Models.Coupon> = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
import { Button, Form, InputSelect, InputTags, InputTextarea } from '$lib/elements/forms';
|
||||
import { formatCurrency } from '$lib/helpers/numbers.js';
|
||||
import { Wizard } from '$lib/layout';
|
||||
import { type Coupon } from '$lib/sdk/billing';
|
||||
import { isOrganization, plansInfo, billingIdToPlan } from '$lib/stores/billing';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { currentPlan, organization } from '$lib/stores/organization';
|
||||
@@ -39,7 +38,7 @@
|
||||
|
||||
export let data;
|
||||
|
||||
let selectedCoupon: Partial<Coupon> = null;
|
||||
let selectedCoupon: Partial<Models.Coupon> = null;
|
||||
|
||||
let selectedPlan: BillingPlan = data.plan as BillingPlan;
|
||||
let previousPage: string = base;
|
||||
|
||||
Reference in New Issue
Block a user