Skip to content

Commit

Permalink
resolves RED-95
Browse files Browse the repository at this point in the history
  • Loading branch information
sombriks committed Jul 21, 2024
1 parent af7d0e1 commit fa68aa1
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
12 changes: 6 additions & 6 deletions web-app-vue/src/pages/configuracao/card-configuracoes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
color="green"
variant="outlined"
@click="(e) => (wantImport = true)"
>Importar
>Importar
</v-btn>
<v-form
v-if="wantImport"
Expand All @@ -19,7 +19,7 @@
<p class="item">Veja o <a href="dados.csv">arquivo de exemplo</a></p>
<v-file-input
v-model="csvFile"
:rules="[requiredRule('Arquivo obrigatório'), lengthRule(1)]"
:rules="[requiredRule('Arquivo obrigatório'), lengthRule(1,'Ao menos um arquivo deve ser selecionado')]"
accept="text/plain, text/csv"
class="item"
label="Selecionar CSV"
Expand Down Expand Up @@ -51,7 +51,7 @@
color="blue"
variant="outlined"
@click="wantExport = true"
>Exportar
>Exportar
</v-btn>
<v-form
v-if="wantExport"
Expand Down Expand Up @@ -91,7 +91,7 @@
</div>
</v-form>
<v-btn v-if="csvDownload" class="item" color="blue" variant="outlined" :href="csvDownload"
>Baixar arquivo
>Baixar arquivo
</v-btn>
<v-btn class="item" color="white" variant="outlined" @click="linkPerfil()">Editar perfil</v-btn>
<v-btn class="item" color="orange" variant="outlined" @click="logout()">Desconectar</v-btn>
Expand All @@ -101,7 +101,7 @@
color="red"
variant="outlined"
@click="wantDelete = true"
>Excluir conta
>Excluir conta
</v-btn>
<v-form
v-if="wantDelete"
Expand Down Expand Up @@ -219,7 +219,7 @@ const closeExport = () => {
}
const linkPerfil = async () => {
alert("um email com o link de solicitação de alteração de dados foi enviado!")
alert('um email com o link de solicitação de alteração de dados foi enviado!')
// XXX remover depois que tiver o serviço de email configurado
await router.push('/user-details/1234')
}
Expand Down
6 changes: 3 additions & 3 deletions web-app-vue/src/pages/conta/detalhe-conta.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@
></v-text-field>
<v-text-field
v-if="contaEdit.tipo_conta_id == 3"
:rules="[dayOfMonthRule]"
:rules="[dayOfMonthRule('Dia inválido')]"
v-model="contaEdit.dia_fechamento"
label="Fechamento"
prepend-inner-icon="mdi-calendar-check"
></v-text-field>
<v-text-field
v-if="contaEdit.tipo_conta_id == 3"
:rules="[dayOfMonthRule]"
:rules="[dayOfMonthRule('Dia inválido')]"
v-model="contaEdit.dia_vencimento"
label="Vencimento"
prepend-inner-icon="mdi-calendar-alert"
></v-text-field>
<v-text-field
v-if="contaEdit.tipo_conta_id == 3 || contaEdit.tipo_conta_id == 2"
:rules="[numberRule]"
:rules="[numberRule('Inorme um valor numérico')]"
type="number"
v-model="contaEdit.limite"
:label="contaEdit.tipo_conta_id == 2 ? 'Cheque especial' : 'Limite'"
Expand Down
2 changes: 1 addition & 1 deletion web-app-vue/src/pages/movimentacao/editar-movimentacao.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<!-- valor -->
<v-text-field
class="item"
:rules="[requiredRule('Valor obrigatório'), numberRule]"
:rules="[requiredRule('Valor obrigatório'), numberRule('Informe um valor numérico')]"
type="number"
v-model="movForm.valor"
label="Valor"
Expand Down
2 changes: 1 addition & 1 deletion web-app-vue/src/pages/pagamento/transferencia-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/>
<v-text-field
class="item"
:rules="[requiredRule('Valor obrigatório'), numberRule]"
:rules="[requiredRule('Valor obrigatório'), numberRule('Informe um valor numérico')]"
type="number"
v-model="formTransferencia.valor"
label="Valor"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<v-row align="center">
<v-text-field
class="item"
:rules="[requiredRule('Valor obrigatório'), numberRule]"
:rules="[requiredRule('Valor obrigatório'), numberRule('Informe um valor numérico')]"
type="number"
v-model="plan.limite"
label="Valor"
Expand Down
2 changes: 1 addition & 1 deletion web-app-vue/src/pages/usuario/card-login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
type="email"
></v-text-field>
<v-text-field
:rules="[requiredRule('Senha obrigatória'), minSizeRule(6)]"
:rules="[requiredRule('Senha obrigatória'), minSizeRule(6, 'Senha deve conter no mínimo 6 caracteres')]"
v-model="senha"
label="Senha"
required
Expand Down
2 changes: 1 addition & 1 deletion web-app-vue/src/pages/usuario/user-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
type="email"
></v-text-field>
<v-text-field
:rules="[requiredRule('Senha obrigatória'), minSizeRule(6)]"
:rules="[requiredRule('Senha obrigatória'), minSizeRule(6, 'Senha deve ter no mínimo 6 caracteres')]"
v-model="userUpdate.senha"
label="Senha"
required
Expand Down
20 changes: 10 additions & 10 deletions web-app-vue/src/services/basic-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ export const requiredRule = (message = 'Required field') => (value) => {
return !!value || message
}

export const lengthRule = (n, msg = `Minimum ${n} required`) => (value) => {
return value.length >= n || msg
export const lengthRule = (n, message = `Minimum ${n} required`) => (value) => {
return value.length >= n || message
}

const dayOfMonth = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31
]

export const dayOfMonthRule = (value) => {
return dayOfMonth.includes(parseInt(value)) || 'Must provide a valid day'
export const dayOfMonthRule = (message = 'Must provide a valid day') => (value) => {
return dayOfMonth.includes(parseInt(value)) || message
}

export const numberRule = (value) => {
return !isNaN(value) || "Provide a valid number"
export const numberRule = (message = 'Provide a valid number') => (value) => {
return !isNaN(value) || message
}

export const minValueRule = min => value => {
return parseInt(value) >= parseInt(min) || `Value smaller than ${min}`
export const minValueRule = (min, message = `Value smaller than ${min}`) => value => {
return parseInt(value) >= parseInt(min) || message
}

export const minSizeRule = min => value => {
return parseInt(value.length) >= parseInt(min) || `Must have size of at least ${min}`
export const minSizeRule = (min, message = `Must have size of at least ${min}`) => value => {
return parseInt(value.length) >= parseInt(min) || message
}

0 comments on commit fa68aa1

Please sign in to comment.