51 lines
1.2 KiB
Vue
51 lines
1.2 KiB
Vue
<template>
|
|
<v-dialog v-model="dialog" persistent>
|
|
<v-card>
|
|
<v-card-title>
|
|
Ingrese el código
|
|
</v-card-title>
|
|
<v-card-text>
|
|
<v-form id="code-form" @submit.prevent="verifyCode">
|
|
<v-text-field v-model="code" label="Código" type="password" autocomplete="off" />
|
|
</v-form>
|
|
</v-card-text>
|
|
<v-card-actions>
|
|
<v-btn type="submit" form="code-form">Aceptar</v-btn>
|
|
</v-card-actions>
|
|
</v-card>
|
|
</v-dialog>
|
|
</template>
|
|
|
|
<script>
|
|
import { inject } from 'vue';
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
api: inject('api'),
|
|
dialog: true,
|
|
code: '',
|
|
};
|
|
},
|
|
methods: {
|
|
verifyCode() {
|
|
this.api.isValidAdminCode(this.code)
|
|
.then(data => {
|
|
if (data['validCode']) {
|
|
this.$emit('code-verified', true);
|
|
this.dialog = false;
|
|
} else {
|
|
alert('Código incorrecto');
|
|
this.$emit('code-verified', false);
|
|
}
|
|
})
|
|
.catch(error => {
|
|
alert('Error al validar el código');
|
|
this.$emit('code-verified', false);
|
|
console.error(error);
|
|
});
|
|
}
|
|
},
|
|
}
|
|
</script>
|