Usando store para grupo de compra id en lugar de prop
This commit is contained in:
parent
020d554019
commit
be24daf998
2 changed files with 10 additions and 7 deletions
|
@ -34,6 +34,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapActions, mapState } from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -42,6 +44,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState('barrio',["grupo_de_compra_id"]),
|
||||||
nombresDeSubpedidos: function () {
|
nombresDeSubpedidos: function () {
|
||||||
return this.subpedidosExistentes.map(a => a.nombre.toLowerCase())
|
return this.subpedidosExistentes.map(a => a.nombre.toLowerCase())
|
||||||
},
|
},
|
||||||
|
@ -49,11 +52,11 @@ export default {
|
||||||
return !this.subpedido || this.nombresDeSubpedidos.includes(this.subpedido.toLowerCase())
|
return !this.subpedido || this.nombresDeSubpedidos.includes(this.subpedido.toLowerCase())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: ["gdcid"],
|
async mounted() {
|
||||||
mounted() {
|
await this.getGrupoDeCompra();
|
||||||
console.log("ready");
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapActions('barrio',["getGrupoDeCompra"]),
|
||||||
onType() {
|
onType() {
|
||||||
if (!this.subpedido) {
|
if (!this.subpedido) {
|
||||||
this.subpedidosExistentes = [];
|
this.subpedidosExistentes = [];
|
||||||
|
@ -62,7 +65,7 @@ export default {
|
||||||
axios.get("/api/subpedidos", {
|
axios.get("/api/subpedidos", {
|
||||||
params: {
|
params: {
|
||||||
nombre: this.subpedido,
|
nombre: this.subpedido,
|
||||||
grupo_de_compra: this.gdcid
|
grupo_de_compra: this.grupo_de_compra_id
|
||||||
}
|
}
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
this.subpedidosExistentes = response.data
|
this.subpedidosExistentes = response.data
|
||||||
|
@ -71,7 +74,7 @@ export default {
|
||||||
submit() {
|
submit() {
|
||||||
axios.post("/api/subpedidos", {
|
axios.post("/api/subpedidos", {
|
||||||
nombre: this.subpedido,
|
nombre: this.subpedido,
|
||||||
grupo_de_compra_id: this.gdcid
|
grupo_de_compra_id: this.grupo_de_compra_id
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
//se creo el subpedido
|
//se creo el subpedido
|
||||||
this.elegirSubpedido(response.data);
|
this.elegirSubpedido(response.data);
|
||||||
|
@ -84,7 +87,7 @@ export default {
|
||||||
guardarSubpedidoEnSesion(subpedido) {
|
guardarSubpedidoEnSesion(subpedido) {
|
||||||
axios.post("/subpedidos/guardar_sesion", {
|
axios.post("/subpedidos/guardar_sesion", {
|
||||||
subpedido: subpedido,
|
subpedido: subpedido,
|
||||||
grupo_de_compra_id: this.gdcid
|
grupo_de_compra_id: this.grupo_de_compra_id
|
||||||
}).then(_ => {
|
}).then(_ => {
|
||||||
Event.$emit('obtener-sesion')
|
Event.$emit('obtener-sesion')
|
||||||
window.location.href = 'productos';
|
window.location.href = 'productos';
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<p class="subtitle">
|
<p class="subtitle">
|
||||||
Bienvenidx a la aplicación de pedidos del <strong>Mercado Popular de Subsistencia</strong>
|
Bienvenidx a la aplicación de pedidos del <strong>Mercado Popular de Subsistencia</strong>
|
||||||
</p>
|
</p>
|
||||||
<pedidos-subpedido-select gdcid="{{Auth::user()->grupoDeCompra->id}}"></pedidos-subpedido-select>
|
<pedidos-subpedido-select></pedidos-subpedido-select>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
Loading…
Add table
Reference in a new issue