skeleton para pagina grupo creado por usuario
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
import BuscarVentas from "./paginas/BuscarVentas.svelte";
|
||||
import MisPropiedadesEnVenta from "./paginas/MisPropiedadesEnVenta.svelte";
|
||||
import AdminGrupos from "./paginas/AdminGrupos.svelte";
|
||||
import OtroG from "./paginas/grupos/OtroG.svelte";
|
||||
</script>
|
||||
|
||||
<Router>
|
||||
@@ -151,6 +152,9 @@
|
||||
<Route path="/grupo/Informes">
|
||||
<ProteRoute componente={FrontInformes} />
|
||||
</Route>
|
||||
<Route path="/grupo/:id" let:params>
|
||||
<ProteRoute componente={{ OtroG, params }} />
|
||||
</Route>
|
||||
|
||||
<!--Notificaciones-->
|
||||
<Route path="/notificaciones">
|
||||
|
||||
@@ -1,55 +1,59 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
import { onMount } from "svelte";
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
import { urlG } from "../stores/urlStore";
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
let { componente } = $props();
|
||||
|
||||
const isAuthenticated = writable(false);
|
||||
const isVerified = writable(false);
|
||||
|
||||
const redirect = window.location.pathname;
|
||||
const email = localStorage.getItem('email');
|
||||
const token = sessionStorage.getItem('token');
|
||||
|
||||
const handleAccess = async () => {
|
||||
try {
|
||||
const response = await fetch($urlG+"/api/login/validar", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Auth': String(token),
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ email, redirect }),
|
||||
credentials: "include"
|
||||
});
|
||||
let { componente } = $props();
|
||||
|
||||
if (response.ok) {
|
||||
isAuthenticated.set(true); // Actualiza el store
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error durante la autenticación:', error);
|
||||
} finally {
|
||||
isVerified.set(true); // Marca la verificación como completada
|
||||
}
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
handleAccess();
|
||||
});
|
||||
const isAuthenticated = writable(false);
|
||||
const isVerified = writable(false);
|
||||
|
||||
const redirect = window.location.pathname;
|
||||
const email = localStorage.getItem("email");
|
||||
const token = sessionStorage.getItem("token");
|
||||
|
||||
const handleAccess = async () => {
|
||||
try {
|
||||
const response = await fetch($urlG + "/api/login/validar", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Auth: String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ email, redirect }),
|
||||
credentials: "include",
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
isAuthenticated.set(true); // Actualiza el store
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error durante la autenticación:", error);
|
||||
} finally {
|
||||
isVerified.set(true); // Marca la verificación como completada
|
||||
}
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
handleAccess();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
{#if !$isVerified}
|
||||
<div class="d-flex justify-content-center position-absolute top-50 start-50">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="d-flex justify-content-center position-absolute top-50 start-50"
|
||||
>
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
{:else if $isAuthenticated}
|
||||
{#if typeof componente === "object" && componente !== null}
|
||||
{@render componente.OtroG(componente.params)}
|
||||
{:else}
|
||||
{@render componente()}
|
||||
{/if}
|
||||
{:else}
|
||||
{#if $isAuthenticated}
|
||||
{@render componente()}
|
||||
{:else}
|
||||
{window.location.replace('/')}
|
||||
{/if}
|
||||
{/if}
|
||||
{window.location.replace("/")}
|
||||
{/if}
|
||||
|
||||
13
Front/src/paginas/grupos/OtroG.svelte
Normal file
13
Front/src/paginas/grupos/OtroG.svelte
Normal file
@@ -0,0 +1,13 @@
|
||||
<script lang="ts">
|
||||
import ListaAcciones from "../../Componentes/ListaAcciones.svelte";
|
||||
import NavBarAutocompletable from "../../Componentes/NavBarAutocompletable.svelte";
|
||||
let { id }: { id: string } = $props();
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable />
|
||||
<div class="container mt-5">
|
||||
<div class="text-center mb-4">
|
||||
<h1>Menu grupo: {id}</h1>
|
||||
</div>
|
||||
<ListaAcciones />
|
||||
</div>
|
||||
Reference in New Issue
Block a user