mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Feat: check if a coupon is only for new orgs to show a friendly error to the user in the modal
This commit is contained in:
1 parent
e601937173
commit
007d5d8269
4 files changed
+21
-9
No files matched your search
@@ -7,6 +7,7 @@
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let show = false;
|
||||
export let isNewOrg = false;
|
||||
export let couponData: Partial<Coupon> = {
|
||||
code: null,
|
||||
status: null,
|
||||
@@ -20,13 +21,20 @@
|
||||
try {
|
||||
const response = await sdk.forConsole.billing.getCoupon(coupon);
|
||||
couponData = response;
|
||||
dispatch('validation', couponData);
|
||||
coupon = null;
|
||||
show = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Credits applied successfully'
|
||||
});
|
||||
if (response.onlyNewOrgs && !isNewOrg) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: 'Coupon only valid for new organizations'
|
||||
});
|
||||
} else {
|
||||
dispatch('validation', couponData);
|
||||
coupon = null;
|
||||
show = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Credits applied successfully'
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ export type Coupon = {
|
||||
status: string; // 'active' | 'disabled' | 'expired'
|
||||
validity: number;
|
||||
campaign?: string;
|
||||
onlyNewOrgs?: boolean;
|
||||
};
|
||||
|
||||
export type Credit = {
|
||||
|
||||
@@ -191,4 +191,4 @@
|
||||
</svelte:fragment>
|
||||
</Wizard>
|
||||
|
||||
<ValidateCreditModal bind:show={showCreditModal} bind:couponData={selectedCoupon} />
|
||||
<ValidateCreditModal bind:show={showCreditModal} bind:couponData={selectedCoupon} isNewOrg={true} />
|
||||
@@ -302,4 +302,7 @@
|
||||
</svelte:fragment>
|
||||
</Wizard>
|
||||
|
||||
<ValidateCreditModal bind:show={showCreditModal} bind:couponData={selectedCoupon} />
|
||||
<ValidateCreditModal
|
||||
bind:show={showCreditModal}
|
||||
bind:couponData={selectedCoupon}
|
||||
isNewOrg={false} />
|
||||
Reference in new issue
Block a user