mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #1931 from appwrite/fix-coupon-not-applying
Fix coupon not applying
This commit is contained in:
6 files changed
+14
-28
No files matched your search
@@ -38,14 +38,6 @@
|
||||
message: 'Credits applied successfully'
|
||||
});
|
||||
}
|
||||
couponData = response;
|
||||
dispatch('validation', couponData);
|
||||
coupon = null;
|
||||
show = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Credits applied successfully'
|
||||
});
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import { Button, Form, InputSelect, InputTags, InputText } from '$lib/elements/forms';
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import { Wizard } from '$lib/layout';
|
||||
import { type PaymentList, type Plan } from '$lib/sdk/billing';
|
||||
import type { PaymentList, Plan } from '$lib/sdk/billing';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import {
|
||||
organizationList,
|
||||
@@ -72,7 +72,7 @@
|
||||
let tempOrgId = null;
|
||||
let currentPlan: Plan;
|
||||
|
||||
$: onlyNewOrgs = (campaign && campaign.onlyNewOrgs) || (couponData && couponData.onlyNewOrgs);
|
||||
$: onlyNewOrgs = campaign?.onlyNewOrgs || couponData?.onlyNewOrgs;
|
||||
|
||||
$: selectedOrgId = tempOrgId;
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
'',
|
||||
clientSecret,
|
||||
paymentMethodId,
|
||||
'/console/apply-credit?' + params.toString()
|
||||
`/console/apply-credit?${params}`
|
||||
);
|
||||
org = await sdk.forConsole.billing.validateOrganization(org.teamId, collaborators);
|
||||
}
|
||||
@@ -205,7 +205,7 @@
|
||||
|
||||
async function addCoupon() {
|
||||
try {
|
||||
const response = await sdk.forConsole.billing.getCoupon(coupon);
|
||||
const response = await sdk.forConsole.billing.getCouponAccount(coupon);
|
||||
couponData = response;
|
||||
coupon = null;
|
||||
addNotification({
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import { isOrganization, tierToPlan } from '$lib/stores/billing';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { type OrganizationError, type Organization } from '$lib/stores/organization';
|
||||
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';
|
||||
@@ -35,11 +35,6 @@
|
||||
let billingPlan: BillingPlan = BillingPlan.FREE;
|
||||
let paymentMethodId: string;
|
||||
let collaborators: string[] = [];
|
||||
let couponData: Partial<Coupon> = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
};
|
||||
let taxId: string;
|
||||
|
||||
let billingBudget: number;
|
||||
@@ -54,9 +49,9 @@
|
||||
const coupon = page.url.searchParams.get('coupon');
|
||||
try {
|
||||
const response = await sdk.forConsole.billing.getCouponAccount(coupon);
|
||||
couponData = response;
|
||||
selectedCoupon = response;
|
||||
} catch (e) {
|
||||
couponData = {
|
||||
selectedCoupon = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
@@ -127,7 +122,7 @@
|
||||
selectedPlan,
|
||||
paymentMethodId,
|
||||
null,
|
||||
couponData.code ? couponData.code : null,
|
||||
selectedCoupon.code ? selectedCoupon.code : null,
|
||||
collaborators,
|
||||
billingBudget,
|
||||
taxId
|
||||
@@ -148,7 +143,7 @@
|
||||
'',
|
||||
clientSecret,
|
||||
paymentMethodId,
|
||||
'/console/create-organization?' + params.toString()
|
||||
`/console/create-organization?${params}`
|
||||
);
|
||||
await validate(org.teamId, collaborators);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ async function getCoupon(url: URL): Promise<Coupon | null> {
|
||||
if (url.searchParams.has('code')) {
|
||||
const coupon = url.searchParams.get('code');
|
||||
try {
|
||||
return sdk.forConsole.billing.getCoupon(coupon);
|
||||
return sdk.forConsole.billing.getCouponAccount(coupon);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
let showCreditModal = false;
|
||||
let feedbackDowngradeReason: string;
|
||||
let feedbackMessage: string;
|
||||
let couponData: Partial<Coupon> = data.coupon;
|
||||
|
||||
afterNavigate(({ from }) => {
|
||||
previousPage = from?.url?.pathname || previousPage;
|
||||
@@ -63,9 +62,9 @@
|
||||
if (page.url.searchParams.has('code')) {
|
||||
const coupon = page.url.searchParams.get('code');
|
||||
try {
|
||||
couponData = await sdk.forConsole.billing.getCouponAccount(coupon);
|
||||
selectedCoupon = await sdk.forConsole.billing.getCouponAccount(coupon);
|
||||
} catch (e) {
|
||||
couponData = {
|
||||
selectedCoupon = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
@@ -191,7 +190,7 @@
|
||||
selectedPlan,
|
||||
paymentMethodId,
|
||||
null,
|
||||
couponData?.code,
|
||||
selectedCoupon?.code,
|
||||
newCollaborators,
|
||||
billingBudget,
|
||||
taxId ? taxId : null
|
||||
|
||||
@@ -49,7 +49,7 @@ async function getCoupon(url: URL): Promise<Coupon | null> {
|
||||
if (url.searchParams.has('code')) {
|
||||
const coupon = url.searchParams.get('code');
|
||||
try {
|
||||
return sdk.forConsole.billing.getCoupon(coupon);
|
||||
return sdk.forConsole.billing.getCouponAccount(coupon);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user