scale: Variable Global $urlG
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { writable } from "svelte/store";
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
type Permiso = {
|
||||
id: number;
|
||||
@@ -21,7 +22,7 @@
|
||||
const match = path.match(/\/grupo\/(.+)/);
|
||||
const grupo = match ? match[1] : null;
|
||||
try {
|
||||
const response = await fetch("http://localhost:5007/api/acciones/grupo",{
|
||||
const response = await fetch(String($urlG)+"/api/acciones/grupo",{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Auth' : String(token),
|
||||
|
||||
@@ -4,15 +4,18 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import './css/popup.css';
|
||||
import type { Grupo } from "../types";
|
||||
let isOpen: boolean = $state(false);
|
||||
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
let isOpen: boolean = $state(false);
|
||||
|
||||
const permisos = writable<Grupo[]>([]);
|
||||
const email = localStorage.getItem('email');
|
||||
const token = sessionStorage.getItem('token');
|
||||
|
||||
async function obtenerPermisos(){
|
||||
try {
|
||||
const response = await fetch("http://localhost:5007/api/acciones",{
|
||||
const response = await fetch(String($urlG)+"/api/acciones",{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Auth' : String(token),
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
let { id, ubicacion, tipo, letra, piso,canthabitaciones, servicios, btnbaja = "Baja" } = $props();
|
||||
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
let modal: boolean = $state(false);
|
||||
let modalpayload: string = $state("");
|
||||
|
||||
@@ -17,7 +19,7 @@
|
||||
async function BajaPropiedad(){
|
||||
modal = false;
|
||||
try {
|
||||
const responce = await fetch("http://localhost:5007/api/propiedad?id="+id, {
|
||||
const responce = await fetch(String($urlG)+"/api/propiedad?id="+id, {
|
||||
method: "DELETE",
|
||||
headers:{
|
||||
'Auth' : String(sessionStorage.getItem("token")),
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { navigate } from 'svelte-routing';
|
||||
import { writable } from 'svelte/store';
|
||||
import { onMount } from 'svelte';
|
||||
import { navigate } from 'svelte-routing';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
let { componente } = $props();
|
||||
let { componente } = $props();
|
||||
|
||||
const isAuthenticated = writable(false);
|
||||
const isVerified = writable(false);
|
||||
const isAuthenticated = writable(false);
|
||||
const isVerified = writable(false);
|
||||
|
||||
const redirect = window.location.pathname;
|
||||
const email = localStorage.getItem('email');
|
||||
const token = sessionStorage.getItem('token');
|
||||
const redirect = window.location.pathname;
|
||||
const email = localStorage.getItem('email');
|
||||
const token = sessionStorage.getItem('token');
|
||||
|
||||
const handleAccess = async () => {
|
||||
try {
|
||||
const response = await fetch('http://127.0.0.1:5007/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
|
||||
const handleAccess = async () => {
|
||||
try {
|
||||
const response = await fetch('http://127.0.0.1:5007/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>
|
||||
onMount(() => {
|
||||
handleAccess();
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if !$isVerified}
|
||||
<div class="spinner-border position-absolute top-50 start-50 translate-middle" role="status">
|
||||
<span class="visually-hidden">Cargando</span>
|
||||
</div>
|
||||
{#if !$isVerified}
|
||||
<div class="spinner-border position-absolute top-50 start-50 translate-middle" role="status">
|
||||
<span class="visually-hidden">Cargando</span>
|
||||
</div>
|
||||
{:else}
|
||||
{#if $isAuthenticated}
|
||||
{@render componente()}
|
||||
{:else}
|
||||
{#if $isAuthenticated}
|
||||
{@render componente()}
|
||||
{:else}
|
||||
{navigate('/')}
|
||||
{/if}
|
||||
{navigate('/')}
|
||||
{/if}
|
||||
|
||||
{/if}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script>
|
||||
import { CardHeader, CardTitle, Button, Card, Input, Form, CardBody, FormGroup } from '@sveltestrap/sveltestrap';
|
||||
import { navigate } from 'svelte-routing';
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
let email = $state("")
|
||||
let contraseña = $state("")
|
||||
@@ -12,7 +13,7 @@
|
||||
|
||||
const data = {email, contraseña};
|
||||
try{
|
||||
const response = await fetch("http://127.0.0.1:5007/api/login",{
|
||||
const response = await fetch(String($urlG)+"/api/login",{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
Reference in New Issue
Block a user