fix: credit reload

This commit is contained in:
Arman committed 2023-12-06 18:09:15 +01:00
1 parent 3a65123912
commit 2b105cb28b
3 files changed
+14 -2

No files matched your search

@@ -7,7 +7,9 @@
import { addNotification } from '$lib/stores/notifications';
import { organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
export let show = false;
let coupon: string = null;
@@ -25,6 +27,7 @@
coupon
});
coupon = null;
dispatch('success');
} catch (error) {
addNotification({
type: 'error',
@@ -13,7 +13,7 @@
import PaymentDetails from './wizard/paymentDetails.svelte';
async function onFinish() {
await invalidate(Dependencies.FUNCTIONS);
await invalidate(Dependencies.CREDIT);
}
async function create() {
@@ -25,6 +25,7 @@
total: 0
};
let show = false;
let reloadOnWizardClose = false;
onMount(async () => {
request();
@@ -37,6 +38,7 @@
show = true;
} else {
wizard.start(AddCreditWizard);
reloadOnWizardClose = true;
}
}
@@ -56,6 +58,13 @@
(acc: number, curr: Credit) => acc + curr.creditsRemaining,
0
);
$: {
if (reloadOnWizardClose && !$wizard.show) {
request();
reloadOnWizardClose = false;
}
}
</script>
<CardGrid>
@@ -107,4 +116,4 @@
</svelte:fragment>
</CardGrid>
<AddCreditModal bind:show />
<AddCreditModal bind:show on:success={request} />