Transición a store

This commit is contained in:
Alejandro Tasistro 2025-05-21 19:28:41 -03:00
parent 83027245e8
commit 3509b9348f

View file

@ -47,6 +47,7 @@ export default {
}, },
computed: { computed: {
...mapState('barrio',["grupo_de_compra_id","pedidos"]), ...mapState('barrio',["grupo_de_compra_id","pedidos"]),
...mapState('pedido',["nombre","pedido_id"]),
deshabilitado: function () { deshabilitado: function () {
return !this.searchString?.trim() return !this.searchString?.trim()
|| this.pedidos.some(p => p.nombre.toLowerCase() === this.searchString.toLowerCase()) || this.pedidos.some(p => p.nombre.toLowerCase() === this.searchString.toLowerCase())
@ -54,6 +55,7 @@ export default {
}, },
methods: { methods: {
...mapActions('barrio',["getGrupoDeCompra","getPedidos"]), ...mapActions('barrio',["getGrupoDeCompra","getPedidos"]),
...mapActions('pedido',["crearPedido","getPedido"]),
...mapMutations('barrio',["setPedidos"]), ...mapMutations('barrio',["setPedidos"]),
onType() { onType() {
if (!this.searchString) { if (!this.searchString) {
@ -63,17 +65,13 @@ export default {
this.getPedidos(this.searchString); this.getPedidos(this.searchString);
}, },
submit() { async submit() {
axios.post("/api/subpedidos", { await this.crearPedido(this.searchString, this.grupo_de_compra_id);
nombre: this.searchString, this.guardarSubpedidoEnSesion({ id: this.pedido_id, nombre: this.nombre });
grupo_de_compra_id: this.grupo_de_compra_id
}).then(response => {
//se creo el subpedido
this.elegirSubpedido(response.data);
});
}, },
elegirSubpedido(subpedido) { elegirSubpedido(subpedido) {
//lo guardamos en sesion //lo guardamos en sesion
this.getPedido(subpedido.id);
this.guardarSubpedidoEnSesion(subpedido); this.guardarSubpedidoEnSesion(subpedido);
}, },
guardarSubpedidoEnSesion(subpedido) { guardarSubpedidoEnSesion(subpedido) {