feat(frontend): using api for admin valid code.
This commit is contained in:
		| @@ -17,22 +17,33 @@ | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
|   import { inject } from 'vue'; | ||||
|  | ||||
|   export default { | ||||
|     data() { | ||||
|       return { | ||||
|         api: inject('api'), | ||||
|         dialog: true, | ||||
|         code: '', | ||||
|       }; | ||||
|     }, | ||||
|     methods: { | ||||
|       verifyCode() { | ||||
|         if (this.code === 'sin seguridad') { | ||||
|           this.$emit('code-verified', true); | ||||
|           this.dialog = false; | ||||
|         } else { | ||||
|           alert('Código incorrecto'); | ||||
|           this.$emit('code-verified', false); | ||||
|         } | ||||
|         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); | ||||
|             }); | ||||
|       } | ||||
|     }, | ||||
|   } | ||||
|   | ||||
| @@ -23,6 +23,10 @@ class Api { | ||||
|     return this.apiImplementation.getPurchasesForReconciliation(); | ||||
|   } | ||||
|  | ||||
|   isValidAdminCode(code) { | ||||
|     return this.apiImplementation.isValidAdminCode(code); | ||||
|   } | ||||
|  | ||||
|   createPurchase(purchase) { | ||||
|     return this.apiImplementation.createPurchase(purchase); | ||||
|   } | ||||
|   | ||||
| @@ -24,6 +24,11 @@ class DjangoApi { | ||||
|     return this.getRequest(url); | ||||
|   } | ||||
|  | ||||
|   isValidAdminCode(code) { | ||||
|     const url = `/don_confiao/api/admin_code/validate/${code}` | ||||
|     return this.getRequest(url) | ||||
|     } | ||||
|  | ||||
|   createPurchase(purchase) { | ||||
|     const url = '/don_confiao/api/sales/'; | ||||
|     return this.postRequest(url, purchase); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user