Skip to content

Commit 7576993

Browse files
committed
fix: payment methods not updated after adding it.
1 parent 223ef63 commit 7576993

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/lib/components/billing/paymentModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
try {
2222
const card = await submitStripeCard(name, page?.params?.organization ?? null);
2323
modal.closeModal();
24-
invalidate(Dependencies.PAYMENT_METHODS);
24+
await invalidate(Dependencies.PAYMENT_METHODS);
2525
dispatch('submit', card);
2626
addNotification({
2727
type: 'success',

src/lib/components/billing/selectPaymentMethod.svelte

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,19 @@
2020
2121
async function cardSaved(event: CustomEvent<PaymentMethodData>) {
2222
value = event.detail.$id;
23-
invalidate(Dependencies.UPGRADE_PLAN);
24-
invalidate(Dependencies.CREATE_ORGANIZATION);
23+
24+
if (value) {
25+
methods = {
26+
...methods,
27+
total: methods.total + 1,
28+
paymentMethods: [...methods.paymentMethods, event.detail]
29+
};
30+
}
31+
32+
await Promise.all([
33+
invalidate(Dependencies.UPGRADE_PLAN),
34+
invalidate(Dependencies.CREATE_ORGANIZATION)
35+
]);
2536
}
2637
2738
onMount(() => {

src/routes/(console)/organization-[organization]/change-plan/+page.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,12 @@
338338
</Layout.Stack>
339339
</Layout.Stack>
340340
</Fieldset>
341-
{:then paymentMethods}
341+
{:then _}
342342
<Fieldset legend="Payment">
343343
<SelectPaymentMethod
344-
methods={paymentMethods}
344+
bind:taxId
345345
bind:value={paymentMethodId}
346-
bind:taxId>
346+
bind:methods={paymentMethods}>
347347
<svelte:fragment slot="actions">
348348
{#if !selectedCoupon?.code}
349349
{#if paymentMethodId}

0 commit comments

Comments
 (0)