Skip to content

Commit 56a9eb6

Browse files
authored
chore(vue): Replace callback props with event emitters in billing buttons (#6733)
1 parent f2f991e commit 56a9eb6

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

.changeset/cuddly-masks-beam.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@clerk/vue": minor
3+
---
4+
5+
Replaced callback props with event emitters in billing buttons:
6+
7+
props `onSubscriptionComplete` → emit `subscription-complete`
8+
props `onSubscriptionCancel` → emit `subscription-cancel`

packages/vue/src/components/CheckoutButton.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { useClerk } from '../composables/useClerk';
55
import { useAuth } from '../composables/useAuth';
66
import { assertSingleChild, normalizeWithDefaultValue } from '../utils';
77
8-
const props = defineProps<__experimental_CheckoutButtonProps>();
8+
type CheckoutButtonProps = Omit<__experimental_CheckoutButtonProps, 'onSubscriptionComplete'>;
9+
const props = defineProps<CheckoutButtonProps>();
910
1011
const clerk = useClerk();
1112
const { userId, orgId } = useAuth();
@@ -26,6 +27,8 @@ function getChildComponent() {
2627
return assertSingleChild(children, 'CheckoutButton');
2728
}
2829
30+
const emit = defineEmits<{ (e: 'subscription-complete'): void }>();
31+
2932
function clickHandler() {
3033
if (!clerk.value) {
3134
return;
@@ -35,9 +38,9 @@ function clickHandler() {
3538
planId: props.planId,
3639
planPeriod: props.planPeriod,
3740
for: props.for,
38-
onSubscriptionComplete: props.onSubscriptionComplete,
3941
newSubscriptionRedirectUrl: props.newSubscriptionRedirectUrl,
4042
...props.checkoutProps,
43+
onSubscriptionComplete: () => emit('subscription-complete'),
4144
});
4245
}
4346
</script>

packages/vue/src/components/SubscriptionDetailsButton.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { useClerk } from '../composables/useClerk';
55
import { useAuth } from '../composables/useAuth';
66
import { assertSingleChild, normalizeWithDefaultValue } from '../utils';
77
8-
const props = defineProps<__experimental_SubscriptionDetailsButtonProps>();
8+
type SubscriptionDetailsButtonProps = Omit<__experimental_SubscriptionDetailsButtonProps, 'onSubscriptionCancel'>;
9+
const props = defineProps<SubscriptionDetailsButtonProps>();
910
1011
const clerk = useClerk();
1112
const { userId, orgId } = useAuth();
@@ -26,15 +27,17 @@ function getChildComponent() {
2627
return assertSingleChild(children, 'SubscriptionDetailsButton');
2728
}
2829
30+
const emit = defineEmits<{ (e: 'subscription-cancel'): void }>();
31+
2932
function clickHandler() {
3033
if (!clerk.value) {
3134
return;
3235
}
3336
3437
return clerk.value.__internal_openSubscriptionDetails({
3538
for: props.for,
36-
onSubscriptionCancel: props.onSubscriptionCancel,
3739
...props.subscriptionDetailsProps,
40+
onSubscriptionCancel: () => emit('subscription-cancel'),
3841
});
3942
}
4043
</script>

0 commit comments

Comments
 (0)