Usando store para grupo de compra id en lugar de prop

This commit is contained in:
Alejandro Tasistro 2025-05-21 18:50:32 -03:00
parent 020d554019
commit be24daf998
2 changed files with 10 additions and 7 deletions

View file

@ -34,6 +34,8 @@
</template>
<script>
import { mapActions, mapState } from "vuex";
export default {
data() {
return {
@ -42,6 +44,7 @@ export default {
}
},
computed: {
...mapState('barrio',["grupo_de_compra_id"]),
nombresDeSubpedidos: function () {
return this.subpedidosExistentes.map(a => a.nombre.toLowerCase())
},
@ -49,11 +52,11 @@ export default {
return !this.subpedido || this.nombresDeSubpedidos.includes(this.subpedido.toLowerCase())
}
},
props: ["gdcid"],
mounted() {
console.log("ready");
async mounted() {
await this.getGrupoDeCompra();
},
methods: {
...mapActions('barrio',["getGrupoDeCompra"]),
onType() {
if (!this.subpedido) {
this.subpedidosExistentes = [];
@ -62,7 +65,7 @@ export default {
axios.get("/api/subpedidos", {
params: {
nombre: this.subpedido,
grupo_de_compra: this.gdcid
grupo_de_compra: this.grupo_de_compra_id
}
}).then(response => {
this.subpedidosExistentes = response.data
@ -71,7 +74,7 @@ export default {
submit() {
axios.post("/api/subpedidos", {
nombre: this.subpedido,
grupo_de_compra_id: this.gdcid
grupo_de_compra_id: this.grupo_de_compra_id
}).then(response => {
//se creo el subpedido
this.elegirSubpedido(response.data);
@ -84,7 +87,7 @@ export default {
guardarSubpedidoEnSesion(subpedido) {
axios.post("/subpedidos/guardar_sesion", {
subpedido: subpedido,
grupo_de_compra_id: this.gdcid
grupo_de_compra_id: this.grupo_de_compra_id
}).then(_ => {
Event.$emit('obtener-sesion')
window.location.href = 'productos';

View file

@ -9,7 +9,7 @@
<p class="subtitle">
Bienvenidx a la aplicación de pedidos del <strong>Mercado Popular de Subsistencia</strong>
</p>
<pedidos-subpedido-select gdcid="{{Auth::user()->grupoDeCompra->id}}"></pedidos-subpedido-select>
<pedidos-subpedido-select></pedidos-subpedido-select>
</div>
</section>
@endsection