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