From 3509b9348f4c873c28e2c2a33bffa29ed997e987 Mon Sep 17 00:00:00 2001 From: ale Date: Wed, 21 May 2025 19:28:41 -0300 Subject: [PATCH] =?UTF-8?q?Transici=C3=B3n=20a=20store?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/components/pedidos/SubpedidoSelect.vue | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/resources/js/components/pedidos/SubpedidoSelect.vue b/resources/js/components/pedidos/SubpedidoSelect.vue index f7b563a..eda680c 100644 --- a/resources/js/components/pedidos/SubpedidoSelect.vue +++ b/resources/js/components/pedidos/SubpedidoSelect.vue @@ -47,6 +47,7 @@ export default { }, computed: { ...mapState('barrio',["grupo_de_compra_id","pedidos"]), + ...mapState('pedido',["nombre","pedido_id"]), deshabilitado: function () { return !this.searchString?.trim() || this.pedidos.some(p => p.nombre.toLowerCase() === this.searchString.toLowerCase()) @@ -54,6 +55,7 @@ export default { }, methods: { ...mapActions('barrio',["getGrupoDeCompra","getPedidos"]), + ...mapActions('pedido',["crearPedido","getPedido"]), ...mapMutations('barrio',["setPedidos"]), onType() { if (!this.searchString) { @@ -63,17 +65,13 @@ export default { this.getPedidos(this.searchString); }, - submit() { - axios.post("/api/subpedidos", { - nombre: this.searchString, - grupo_de_compra_id: this.grupo_de_compra_id - }).then(response => { - //se creo el subpedido - this.elegirSubpedido(response.data); - }); + async submit() { + await this.crearPedido(this.searchString, this.grupo_de_compra_id); + this.guardarSubpedidoEnSesion({ id: this.pedido_id, nombre: this.nombre }); }, elegirSubpedido(subpedido) { //lo guardamos en sesion + this.getPedido(subpedido.id); this.guardarSubpedidoEnSesion(subpedido); }, guardarSubpedidoEnSesion(subpedido) {