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) {