From 248b346f78a1fe42f5274a65776a0096176c4ffd Mon Sep 17 00:00:00 2001 From: ale <ale.tasistro@gmail.com> Date: Wed, 21 May 2025 19:10:47 -0300 Subject: [PATCH] Usando store para pedidos --- .../js/components/pedidos/SubpedidoSelect.vue | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/resources/js/components/pedidos/SubpedidoSelect.vue b/resources/js/components/pedidos/SubpedidoSelect.vue index 11bdf8b..f7b563a 100644 --- a/resources/js/components/pedidos/SubpedidoSelect.vue +++ b/resources/js/components/pedidos/SubpedidoSelect.vue @@ -34,7 +34,7 @@ </template> <script> -import { mapActions, mapState } from "vuex"; +import { mapActions, mapMutations, mapState } from "vuex"; export default { async mounted() { @@ -42,32 +42,26 @@ export default { }, data() { return { - searchString: null, - pedidos: [] + searchString: null } }, computed: { - ...mapState('barrio',["grupo_de_compra_id"]), + ...mapState('barrio',["grupo_de_compra_id","pedidos"]), deshabilitado: function () { return !this.searchString?.trim() || this.pedidos.some(p => p.nombre.toLowerCase() === this.searchString.toLowerCase()) } }, methods: { - ...mapActions('barrio',["getGrupoDeCompra"]), + ...mapActions('barrio',["getGrupoDeCompra","getPedidos"]), + ...mapMutations('barrio',["setPedidos"]), onType() { if (!this.searchString) { - this.pedidos = []; + this.setPedidos([]); return; } - axios.get("/api/subpedidos", { - params: { - nombre: this.searchString, - grupo_de_compra: this.grupo_de_compra_id - } - }).then(response => { - this.pedidos = response.data - }); + + this.getPedidos(this.searchString); }, submit() { axios.post("/api/subpedidos", {