Compare commits

...

10 commits

Author SHA1 Message Date
ale
5a0cf73218 Crear pedido movido a vuex 2025-05-21 21:49:04 -03:00
ale
44bd8045b8 Cambios en obtener sesion 2025-05-21 21:31:46 -03:00
ale
8a32841f9d Agregadas rutas nuevas con session controller 2025-05-21 21:30:59 -03:00
ale
e0bb8127f4 Quitada ruta no usada 2025-05-21 21:30:38 -03:00
ale
1610acfbe7 formato 2025-05-21 21:30:10 -03:00
ale
fff9b5b65f Borradas cosas de admin ya no usadas 2025-05-21 20:48:06 -03:00
ale
d64659d653 template simplificada 2025-05-21 20:46:08 -03:00
ale
f92084d399 usando pedido definido 2025-05-21 20:45:50 -03:00
ale
f4560c0be5 arreglos en comparacion 2025-05-21 20:45:35 -03:00
ale
fe529c2242 esperar 2025-05-21 20:44:58 -03:00
10 changed files with 48 additions and 55 deletions

View 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
View file

@ -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')
},
});

View file

@ -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 });
}
},
};

View file

@ -20,7 +20,7 @@ export default {
}
},
methods: {
...mapActions('productos', ["init"]),
...mapActions('productos',["init"]),
},
async mounted() {
await this.init();

View file

@ -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>

View file

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

View file

@ -15,7 +15,6 @@ const mutations = {
},
setPedidos(state, pedidos) {
state.pedidos = pedidos;
console.log(state);
},
};

View file

@ -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

View file

@ -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')

View file

@ -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');