Skip to content

Commit

Permalink
Fix symbol validation for setup vote and advanced (#4284)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuveth authored Oct 16, 2023
1 parent c9834c9 commit c64625e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/components/SettingsStrategiesBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function handleSubmitStrategy(strategy) {
:error="validationErrors?.symbol"
:max-length="schemas.space.properties.symbol.maxLength"
:disabled="isViewOnly"
autofocus
/>
</ContainerParallelInput>

Expand Down
3 changes: 2 additions & 1 deletion src/components/SetupStrategyAdvanced.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const { validationErrors } = useFormSpaceSettings('setup');
const emit = defineEmits(['next']);
function nextStep() {
if (validationErrors.value.strategies) return;
if (validationErrors.value.strategies || validationErrors.value.symbol)
return;
emit('next');
}
</script>
Expand Down
31 changes: 18 additions & 13 deletions src/components/SetupStrategyVote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,30 @@ const votingItems = computed(() => {
}));
});
const isNotValidTicket = computed(
() =>
strategyName.value === 'ticket' &&
(validation.value.name === 'any' || validation.value.name === 'basic')
const isValidTicket = computed(
() => !(strategyName.value === 'ticket' && validation.value.name === 'any')
);
const isNotValidWhitelist = computed(
() => strategyName.value === 'whitelist' && whitelist.value.length === 0
const isValidWhitelist = computed(
() => !(strategyName.value === 'whitelist' && whitelist.value.length === 0)
);
const isValidSymbol = computed(() => symbol.value.length > 0);
const whitelistRef = ref();
const symbolRef = ref();
function forceShowError() {
whitelistRef?.value?.forceShowError();
symbolRef?.value?.forceShowError();
}
function nextStep() {
if (isNotValidWhitelist.value) {
if (!isValidWhitelist.value || !isValidSymbol.value) {
forceShowError();
return;
}
if (isNotValidTicket.value) {
if (!isValidTicket.value) {
showError.value = true;
return;
}
Expand Down Expand Up @@ -120,7 +122,12 @@ function nextStep() {
</span>
</template>
</TuneListbox>
<TuneInput v-model="symbol" label="Symbol" />
<TuneInput
ref="symbolRef"
v-model="symbol"
label="Symbol"
:error="!isValidSymbol ? 'Symbol is required' : ''"
/>
</div>
<template v-if="strategyName === 'ticket'" class="md:w-2/3">
<InputSelectVoteValidation
Expand All @@ -130,7 +137,7 @@ function nextStep() {
/>

<BaseMessageBlock
v-if="isNotValidTicket && showError"
v-if="!isValidTicket && showError"
level="warning-red"
class="mt-3"
>
Expand All @@ -155,9 +162,7 @@ function nextStep() {
v-model="whitelist"
label="Whitelisted addresses"
:placeholder="`0x8C28Cf33d9Fd3D0293f963b1cd27e3FF422B425c\n0xeF8305E140ac520225DAf050e2f71d5fBcC543e7`"
:error="
isNotValidWhitelist ? 'Please add at least one address' : ''
"
:error="!isValidWhitelist ? 'Please add at least one address' : ''"
/>
</template>
</div>
Expand Down

1 comment on commit c64625e

@vercel
Copy link

@vercel vercel bot commented on c64625e Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.