From 7d4625bb975a97679ecf7e6c5338b9d423398c37 Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Tue, 2 Jul 2024 22:25:17 +0530 Subject: [PATCH] fix: Default value for number winners (#4804) * fix: Default value for number winners * fix * lint * fixes --- src/views/SpaceBoost.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/views/SpaceBoost.vue b/src/views/SpaceBoost.vue index e2a469f4..754c607a 100644 --- a/src/views/SpaceBoost.vue +++ b/src/views/SpaceBoost.vue @@ -84,7 +84,7 @@ const form = ref
({ weightedLimit: '', hasLotteryLimit: false, lotteryLimit: '', - numWinners: '' + numWinners: '1' }, network: '1', token: undefined, @@ -225,6 +225,11 @@ const strategy = computed(() => { eligibilityType = 'bribe'; } + const numWinners = + form.value.distribution.type === 'lottery' + ? Number(form.value.distribution.numWinners) + : undefined; + return { name: 'Boost', description: 'Snapshot.org proposal boost', @@ -242,7 +247,7 @@ const strategy = computed(() => { distribution: { type: form.value.distribution.type, limit: strategyDistributionLimit.value, - numWinners: form.value.distribution.numWinners || undefined + numWinners } } }; @@ -484,7 +489,7 @@ watchEffect(async () => { }); watch( - () => form.value.distribution, + [() => form.value.distribution.type], () => { if (!form.value.distribution.hasWeightedLimit) { form.value.distribution.weightedLimit = ''; @@ -495,11 +500,12 @@ watch( if (form.value.distribution.type === 'lottery') { form.value.distribution.hasWeightedLimit = false; form.value.distribution.weightedLimit = ''; + form.value.distribution.numWinners ??= '1'; } if (form.value.distribution.type === 'weighted') { form.value.distribution.hasLotteryLimit = false; form.value.distribution.lotteryLimit = ''; - form.value.distribution.numWinners = ''; + form.value.distribution.numWinners = undefined; } }, { deep: true }