Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beds 538/validation notification settings #1026

Draft
wants to merge 2 commits into
base: staging
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions frontend/components/bc/input/BcInputCheckbox.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<script lang="ts" setup>
import { faInfoCircle } from '@fortawesome/pro-regular-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import type { BcInputError } from '~/components/bc/input/BcInputError.vue'

const props = defineProps<{
error?: BcInputError,
error?: string,
infoText?: string,
label?: string,
}>()
Expand Down
15 changes: 6 additions & 9 deletions frontend/components/bc/input/BcInputError.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<script lang="ts" setup>
const idError = useId()
/**
* Spacing of error message will be removed by explicitly passing `false`.
* This should encourage to always think about the error message.
*/
export type BcInputError = false | string
defineProps<{
error?: BcInputError,
}>()

withDefaults(defineProps<{
error?: string,
}>(), {
error: '',
})
</script>

<template>
Expand All @@ -17,7 +15,6 @@ defineProps<{
:aria-describedby="idError"
/>
<div
v-if="error !== false"
:id="idError"
class="bc-input-error"
>
Expand Down
4 changes: 1 addition & 3 deletions frontend/components/bc/input/BcInputText.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<script lang="ts" setup>
import type { BcInputError } from '~/components/bc/input/BcInputError.vue'

const idInput = useId()
const input = defineModel<string>()

const props = withDefaults(defineProps<{
error?: BcInputError,
error?: string,
inputWidth?: `${number}px`,
label: string,
labelPosition?: 'left' | 'right',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script lang="ts" setup>
import type { NotificationSettingsNetwork } from '~/types/api/notifications'

const { t: $t } = useTranslation()

const notificationsManagementStore = useNotificationsManagementStore()
Expand All @@ -13,12 +15,28 @@ const currentNetworkSettings = computed(() => currentNetwork.value?.settings)

const thresholdGasAbove = ref(formatWeiTo(currentNetworkSettings.value?.gas_above_threshold ?? '0', { unit: 'gwei' }))
const thresholdGasBelow = ref(formatWeiTo(currentNetworkSettings.value?.gas_below_threshold ?? '0', { unit: 'gwei' }))
const thresholdParticipationRate = ref(formatFraction(currentNetworkSettings.value?.participation_rate_threshold ?? 0))
// const thresholdParticipationRate = ref(formatFraction(currentNetworkSettings.value?.participation_rate_threshold ?? 0))
const hasGasAbove = ref(currentNetworkSettings.value?.is_gas_above_subscribed ?? false)
const hasGasBelow = ref(currentNetworkSettings.value?.is_gas_below_subscribed ?? false)
const hasParticipationRate = ref(currentNetworkSettings.value?.is_participation_rate_subscribed ?? false)
const hasNewRewardRound = ref(currentNetworkSettings.value?.is_new_reward_round_subscribed ?? false)

// const validationSchema = createSchemaObject({
// is_webhook_discord_enabled: validation.boolean(),
// webhook_url: validation.url($t('validation.url.invalid')),
// })

const {
errorMessage,
value: thresholdParticipationRate,
} = useField<NotificationSettingsNetwork['participation_rate_threshold']>(
'thresholdParticipationRate',
validation.numberRange({
max: 100,
min: 0,
}),
)

watchDebounced([
hasGasAbove,
hasGasBelow,
Expand Down Expand Up @@ -49,6 +67,9 @@ watchDebounced([

<template>
<div>
<pre>
{{ errorMessage }}
</pre>
<div v-if="!networks.length" class="error-container">
Upps something went wrong. Please try again.
</div>
Expand All @@ -75,29 +96,28 @@ watchDebounced([
<span>
{{ $t('notifications.network.settings.alert_if_gas_below') }}
</span>
<span class="">
<BcInputUnit
v-model="thresholdGasBelow"
:unit="$t('common.units.GWEI')"
/>
</span>
<BcInputUnit
v-model="thresholdGasBelow"
:unit="$t('common.units.GWEI')"
/>
<BcToggle
v-model="hasGasBelow"
class="toggle"
/>
<span>
{{ $t('notifications.network.settings.alert_if_gas_above') }}
</span>
<span class="">
<BcInputUnit
v-model="thresholdGasAbove"
:unit="$t('common.units.GWEI')"
/>
</span>
<BcInputUnit
v-model="thresholdGasAbove"
:unit="$t('common.units.GWEI')"
/>
<BcToggle
v-model="hasGasAbove"
class="toggle"
/>
<BcInputError
error="Invalid input"
/>
</BcListSection>
<BcListSection
class="grid-overwrite"
Expand All @@ -116,6 +136,9 @@ watchDebounced([
v-model="hasParticipationRate"
class="toggle"
/>
<BcInputError
:error="``"
/>
</BcListSection>
</div>
</BcTabPanel>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts" setup>
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { faPaperPlane } from '@fortawesome/pro-solid-svg-icons'
import { useForm } from 'vee-validate'
import { warn } from 'vue'
import { API_PATH } from '~/types/customFetch'
import type { NotificationSettingsValidatorDashboard } from '~/types/api/notifications'
Expand Down
1 change: 0 additions & 1 deletion frontend/components/user/settings/UserSettingsEmail.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts" setup>
import { object as yupObject } from 'yup'
import { useForm } from 'vee-validate'
import { API_PATH } from '~/types/customFetch'

const { t: $t } = useTranslation()
Expand Down
1 change: 0 additions & 1 deletion frontend/components/user/settings/UserSettingsPassword.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts" setup>
import { object as yupObject } from 'yup'
import { useForm } from 'vee-validate'
import { API_PATH } from '~/types/customFetch'

const { t: $t } = useTranslation()
Expand Down
9 changes: 6 additions & 3 deletions frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ export default defineNuxtConfig({
eslint: { config: { stylistic: true } },
i18n: { vueI18n: './i18n.config.ts' },
modules: [
'@nuxtjs/i18n',
'@nuxt/eslint',
'@nuxtjs/color-mode',
'@nuxtjs/i18n',
[
'@pinia/nuxt',
{ storesDirs: [ './stores/**' ] },
{
storesDirs: [ './stores/**' ],
},
],
'@primevue/nuxt-module',
'@nuxt/eslint',
'@vee-validate/nuxt',
'@vueuse/nuxt',
],
nitro: {
Expand Down
Loading