Compare commits
10 commits
3509b9348f
...
5a0cf73218
Author | SHA1 | Date | |
---|---|---|---|
5a0cf73218 | |||
44bd8045b8 | |||
8a32841f9d | |||
e0bb8127f4 | |||
1610acfbe7 | |||
fff9b5b65f | |||
d64659d653 | |||
f92084d399 | |||
f4560c0be5 | |||
fe529c2242 |
10 changed files with 48 additions and 55 deletions
26
app/Http/Controllers/SessionController.php
Normal file
26
app/Http/Controllers/SessionController.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Subpedido;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class SessionController extends Controller
|
||||
{
|
||||
public function store(Request $request) {
|
||||
$grupo_de_compra_id = Auth::user()->grupo_de_compra_id;
|
||||
$validated = $request->validate([
|
||||
'id' => 'required',
|
||||
Rule::in(Subpedido::where('grupo_de_compra_id', $grupo_de_compra_id)->pluck('id')),
|
||||
]);
|
||||
session()->put('pedido_id', $validated["id"]);
|
||||
return response()->noContent();
|
||||
}
|
||||
|
||||
public function fetch() {
|
||||
return session('pedido_id');
|
||||
}
|
||||
}
|
29
resources/js/app.js
vendored
29
resources/js/app.js
vendored
|
@ -19,16 +19,6 @@ window.bulmaToast = require('bulma-toast');
|
|||
*/
|
||||
import './components';
|
||||
import store from "./store";
|
||||
import {mapState} from "vuex";
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
Vue.prototype.$rootMiga = {
|
||||
nombre: "Categorías",
|
||||
href: "/productos"
|
||||
}
|
||||
|
||||
/**
|
||||
* Global methods
|
||||
*/
|
||||
|
@ -82,16 +72,11 @@ const app = new Vue({
|
|||
},
|
||||
mounted() {
|
||||
Event.$on('obtener-sesion', () => {
|
||||
if (window.location.pathname.startsWith('/admin')) {
|
||||
axios.get('/admin/obtener_sesion')
|
||||
.then(response => {
|
||||
this.gdc = response.data.gdc
|
||||
});
|
||||
} else {
|
||||
if (!window.location.pathname.startsWith('/admin')) {
|
||||
axios.get('/subpedidos/obtener_sesion')
|
||||
.then(response => {
|
||||
this.gdc = response.data.gdc;
|
||||
this.settearDevoluciones();
|
||||
// this.settearDevoluciones();
|
||||
this.pedido = response.data.subpedido.id;
|
||||
axios.get('/api/subpedidos/' + this.pedido)
|
||||
.then(response => {
|
||||
|
@ -132,15 +117,7 @@ const app = new Vue({
|
|||
Event.$emit("pedido-actualizado");
|
||||
});
|
||||
});
|
||||
|
||||
Event.$on('aprobacion-subpedido', (subpedidoId, aprobado) => {
|
||||
axios.post("/api/admin/subpedidos/" + subpedidoId + "/aprobacion", {
|
||||
aprobacion: aprobado
|
||||
}).then((response) => {
|
||||
Event.$emit('sync-aprobacion', response.data.data);
|
||||
this.$toast('Pedido ' + (aprobado ? 'aprobado' : 'desaprobado') + ' exitosamente')
|
||||
})
|
||||
})
|
||||
if (window.location.pathname.startsWith('/productos'))
|
||||
Event.$emit('obtener-sesion')
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,15 +4,12 @@
|
|||
<a class="navbar-item" href="https://mps.org.uy">
|
||||
<img src="/assets/logoMPS.png" height="28">
|
||||
</a>
|
||||
<!-- Styles nombre del barrio-->
|
||||
<p class="navbar-item hide-below-1024">
|
||||
<slot name="gdc"></slot>
|
||||
</p>
|
||||
<p class="navbar-item">
|
||||
<slot name="subpedido"></slot>
|
||||
</p>
|
||||
<chismosa-dropdown
|
||||
v-if="this.$root.pedido != null"
|
||||
v-if="pedidoDefinido"
|
||||
class="hide-above-1023"
|
||||
id="mobile">
|
||||
</chismosa-dropdown>
|
||||
|
@ -25,7 +22,7 @@
|
|||
</div>
|
||||
<div class="navbar-menu" :class="{'is-active':burgerActiva}">
|
||||
<div class="navbar-end">
|
||||
<div v-if="this.$root.pedido != null" class="navbar-item field has-addons mt-2 mr-3">
|
||||
<div v-if="pedidoDefinido" class="navbar-item field has-addons mt-2 mr-3">
|
||||
<a class="button is-small has-text-dark-grey" @click.capture="buscar">
|
||||
<span class="icon">
|
||||
<i class="fas fa-search"></i>
|
||||
|
@ -35,7 +32,7 @@
|
|||
@keyup.enter="buscar">
|
||||
</div>
|
||||
<chismosa-dropdown
|
||||
v-if="this.$root.pedido != null"
|
||||
v-if="pedidoDefinido"
|
||||
class="hide-below-1024"
|
||||
id="wide">
|
||||
</chismosa-dropdown>
|
||||
|
@ -53,7 +50,7 @@
|
|||
|
||||
<script>
|
||||
import ChismosaDropdown from '../pedidos/ChismosaDropdown.vue';
|
||||
import { mapActions } from "vuex";
|
||||
import { mapActions, mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
components: { ChismosaDropdown },
|
||||
|
@ -63,6 +60,9 @@ export default {
|
|||
searchString: "",
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('pedido',["pedidoDefinido"]),
|
||||
},
|
||||
methods: {
|
||||
...mapActions('productos', ["filtrarProductos"]),
|
||||
toggleBurger() {
|
||||
|
@ -73,7 +73,6 @@ export default {
|
|||
this.toggleBurger();
|
||||
this.filtrarProductos({ filtro: "nombre", valor: this.searchString });
|
||||
Event.$emit('migas-agregar', { nombre: this.searchString });
|
||||
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
<nav v-if="pedidoDefinido" class="breadcrumb is-centered has-background-danger-light is-fixed-top"
|
||||
aria-label="breadcrumbs" v-show="visible">
|
||||
<ul class="mt-4">
|
||||
<li v-for="(miga, i) in migas" :key="i" :class="{'is-active': i == migaActiva}">
|
||||
<li v-for="(miga, i) in migas" :key="i" :class="{'is-active': i === migaActiva}">
|
||||
<a :href="miga.href" v-text="miga.nombre"
|
||||
:class="{'has-text-danger': i != migaActiva}"></a>
|
||||
:class="{'has-text-danger': i !== migaActiva}"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -55,7 +55,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
...mapActions('barrio',["getGrupoDeCompra","getPedidos"]),
|
||||
...mapActions('pedido',["crearPedido","getPedido"]),
|
||||
...mapActions('pedido',["crearPedido"]),
|
||||
...mapMutations('barrio',["setPedidos"]),
|
||||
onType() {
|
||||
if (!this.searchString) {
|
||||
|
@ -66,12 +66,11 @@ export default {
|
|||
this.getPedidos(this.searchString);
|
||||
},
|
||||
async submit() {
|
||||
await this.crearPedido(this.searchString, this.grupo_de_compra_id);
|
||||
await this.crearPedido({ nombre: this.searchString, grupo_de_compra_id: 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) {
|
||||
|
|
1
resources/js/store/modules/barrio.js
vendored
1
resources/js/store/modules/barrio.js
vendored
|
@ -15,7 +15,6 @@ const mutations = {
|
|||
},
|
||||
setPedidos(state, pedidos) {
|
||||
state.pedidos = pedidos;
|
||||
console.log(state);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
2
resources/js/store/modules/pedido.js
vendored
2
resources/js/store/modules/pedido.js
vendored
|
@ -29,7 +29,7 @@ const mutations = {
|
|||
};
|
||||
|
||||
const actions = {
|
||||
async crearPedido({ commit }, nombre, grupo_de_compra_id) {
|
||||
async crearPedido({ commit }, { nombre, grupo_de_compra_id }) {
|
||||
const response = await axios.post("/api/subpedidos", {
|
||||
nombre: nombre,
|
||||
grupo_de_compra_id: grupo_de_compra_id
|
||||
|
|
|
@ -14,22 +14,17 @@
|
|||
<script src="https://kit.fontawesome.com/9235d1c676.js" crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
|
||||
@yield('stylesheets')
|
||||
|
||||
|
||||
</head>
|
||||
<body class="has-navbar-fixed-top">
|
||||
<div id="root">
|
||||
<comunes-nav-bar>
|
||||
<template slot="subpedido">{{ session('subpedido_nombre') ? 'Pedido de '. session('subpedido_nombre') : Auth::user()->name }}</template>
|
||||
<template slot="gdc">{{ session('subpedido_nombre') ? Auth::user()->name : "" }}</template>
|
||||
<template slot="logout-form">
|
||||
<template #logout-form>
|
||||
<form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
|
||||
@csrf
|
||||
</form>
|
||||
</template>
|
||||
</comunes-nav-bar>
|
||||
<pedidos-nav-migas></pedidos-nav-migas>
|
||||
|
||||
<main id="main" class="py-4 has-top-padding">
|
||||
<pedidos-cartel-pedido-aprobado></pedidos-cartel-pedido-aprobado>
|
||||
@yield('content')
|
||||
|
|
|
@ -59,17 +59,15 @@ Route::middleware(['auth', 'role:barrio'])->group( function() {
|
|||
'gdc' => session("gdc")
|
||||
];
|
||||
})->name('obtenerSesion');
|
||||
|
||||
Route::post('sesion', 'SessionController@store');
|
||||
|
||||
Route::get('sesion', 'SessionController@fetch');
|
||||
});
|
||||
});
|
||||
|
||||
Route::get('/admin/login', 'AdminController@show')->name('admin.login');
|
||||
|
||||
Route::get('/admin/obtener_sesion', function() {
|
||||
return [
|
||||
'gdc' => session("admin_gdc")
|
||||
];
|
||||
})->name('admin_obtener_sesion');
|
||||
|
||||
Route::middleware(['auth', 'role:admin_barrio'])->group( function () {
|
||||
Route::get('/admin', 'AdminController@index')->name('admin.pedidos');
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue