scale: Variable Global $urlG
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { writable } from "svelte/store";
|
import { writable } from "svelte/store";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
|
||||||
type Permiso = {
|
type Permiso = {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -21,7 +22,7 @@
|
|||||||
const match = path.match(/\/grupo\/(.+)/);
|
const match = path.match(/\/grupo\/(.+)/);
|
||||||
const grupo = match ? match[1] : null;
|
const grupo = match ? match[1] : null;
|
||||||
try {
|
try {
|
||||||
const response = await fetch("http://localhost:5007/api/acciones/grupo",{
|
const response = await fetch(String($urlG)+"/api/acciones/grupo",{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Auth' : String(token),
|
'Auth' : String(token),
|
||||||
|
|||||||
@@ -4,15 +4,18 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import './css/popup.css';
|
import './css/popup.css';
|
||||||
import type { Grupo } from "../types";
|
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 permisos = writable<Grupo[]>([]);
|
||||||
const email = localStorage.getItem('email');
|
const email = localStorage.getItem('email');
|
||||||
const token = sessionStorage.getItem('token');
|
const token = sessionStorage.getItem('token');
|
||||||
|
|
||||||
async function obtenerPermisos(){
|
async function obtenerPermisos(){
|
||||||
try {
|
try {
|
||||||
const response = await fetch("http://localhost:5007/api/acciones",{
|
const response = await fetch(String($urlG)+"/api/acciones",{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Auth' : String(token),
|
'Auth' : String(token),
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
let { id, ubicacion, tipo, letra, piso,canthabitaciones, servicios, btnbaja = "Baja" } = $props();
|
let { id, ubicacion, tipo, letra, piso,canthabitaciones, servicios, btnbaja = "Baja" } = $props();
|
||||||
|
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
|
||||||
let modal: boolean = $state(false);
|
let modal: boolean = $state(false);
|
||||||
let modalpayload: string = $state("");
|
let modalpayload: string = $state("");
|
||||||
|
|
||||||
@@ -17,7 +19,7 @@
|
|||||||
async function BajaPropiedad(){
|
async function BajaPropiedad(){
|
||||||
modal = false;
|
modal = false;
|
||||||
try {
|
try {
|
||||||
const responce = await fetch("http://localhost:5007/api/propiedad?id="+id, {
|
const responce = await fetch(String($urlG)+"/api/propiedad?id="+id, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers:{
|
headers:{
|
||||||
'Auth' : String(sessionStorage.getItem("token")),
|
'Auth' : String(sessionStorage.getItem("token")),
|
||||||
|
|||||||
@@ -1,54 +1,54 @@
|
|||||||
<script>
|
<script>
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { navigate } from 'svelte-routing';
|
import { navigate } from 'svelte-routing';
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
|
||||||
let { componente } = $props();
|
let { componente } = $props();
|
||||||
|
|
||||||
const isAuthenticated = writable(false);
|
const isAuthenticated = writable(false);
|
||||||
const isVerified = writable(false);
|
const isVerified = writable(false);
|
||||||
|
|
||||||
const redirect = window.location.pathname;
|
const redirect = window.location.pathname;
|
||||||
const email = localStorage.getItem('email');
|
const email = localStorage.getItem('email');
|
||||||
const token = sessionStorage.getItem('token');
|
const token = sessionStorage.getItem('token');
|
||||||
|
|
||||||
const handleAccess = async () => {
|
const handleAccess = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('http://127.0.0.1:5007/api/login/validar', {
|
const response = await fetch('http://127.0.0.1:5007/api/login/validar', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Auth': String(token),
|
'Auth': String(token),
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ email, redirect }),
|
body: JSON.stringify({ email, redirect }),
|
||||||
credentials: "include"
|
credentials: "include"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
isAuthenticated.set(true); // Actualiza el store
|
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
|
|
||||||
}
|
}
|
||||||
};
|
} catch (error) {
|
||||||
|
console.error('Error durante la autenticación:', error);
|
||||||
|
} finally {
|
||||||
|
isVerified.set(true); // Marca la verificación como completada
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
handleAccess();
|
handleAccess();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if !$isVerified}
|
{#if !$isVerified}
|
||||||
<div class="spinner-border position-absolute top-50 start-50 translate-middle" role="status">
|
<div class="spinner-border position-absolute top-50 start-50 translate-middle" role="status">
|
||||||
<span class="visually-hidden">Cargando</span>
|
<span class="visually-hidden">Cargando</span>
|
||||||
</div>
|
</div>
|
||||||
|
{:else}
|
||||||
|
{#if $isAuthenticated}
|
||||||
|
{@render componente()}
|
||||||
{:else}
|
{:else}
|
||||||
{#if $isAuthenticated}
|
{navigate('/')}
|
||||||
{@render componente()}
|
|
||||||
{:else}
|
|
||||||
{navigate('/')}
|
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { CardHeader, CardTitle, Button, Card, Input, Form, CardBody, FormGroup } from '@sveltestrap/sveltestrap';
|
import { CardHeader, CardTitle, Button, Card, Input, Form, CardBody, FormGroup } from '@sveltestrap/sveltestrap';
|
||||||
import { navigate } from 'svelte-routing';
|
import { navigate } from 'svelte-routing';
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
|
||||||
let email = $state("")
|
let email = $state("")
|
||||||
let contraseña = $state("")
|
let contraseña = $state("")
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
|
|
||||||
const data = {email, contraseña};
|
const data = {email, contraseña};
|
||||||
try{
|
try{
|
||||||
const response = await fetch("http://127.0.0.1:5007/api/login",{
|
const response = await fetch(String($urlG)+"/api/login",{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
||||||
import type { PropiedadDto } from "../types";
|
import type { PropiedadDto } from "../types";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
|
||||||
let propiedades = writable<PropiedadDto[]>([]);
|
let propiedades = writable<PropiedadDto[]>([]);
|
||||||
let email = localStorage.getItem("email");
|
let email = localStorage.getItem("email");
|
||||||
@@ -13,7 +14,7 @@
|
|||||||
|
|
||||||
onMount(async ()=> {
|
onMount(async ()=> {
|
||||||
try {
|
try {
|
||||||
const responce = await fetch("http://localhost:5007/api/propiedades/Propietario", {
|
const responce = await fetch(String($urlG)+"/api/propiedades/Propietario", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
'Auth': String(token),
|
'Auth': String(token),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
||||||
import type { PropiedadDto } from "../types";
|
import type { PropiedadDto } from "../types";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
|
||||||
let propiedades = writable<PropiedadDto[]>([]);
|
let propiedades = writable<PropiedadDto[]>([]);
|
||||||
let email = localStorage.getItem("email");
|
let email = localStorage.getItem("email");
|
||||||
@@ -13,7 +14,7 @@
|
|||||||
|
|
||||||
onMount(async ()=> {
|
onMount(async ()=> {
|
||||||
try {
|
try {
|
||||||
const responce = await fetch("http://localhost:5007/api/propiedades/Propietario/Bajas", {
|
const responce = await fetch(String($urlG)+"/api/propiedades/Propietario/Bajas", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
'Auth': String(token),
|
'Auth': String(token),
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { writable } from "svelte/store"; // Importar writable para los estados
|
|
||||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
import type { Propiedad } from "../types";
|
import type { Propiedad } from "../types";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
|
||||||
let propiedad: Propiedad = {
|
let propiedad: Propiedad = {
|
||||||
ubicacion: "",
|
ubicacion: "",
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
mostrarModal = false;
|
mostrarModal = false;
|
||||||
try {
|
try {
|
||||||
const response = await fetch("http://localhost:5007/api/propiedad", {
|
const response = await fetch(String($urlG)+"/api/propiedad", {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Auth': String(token),
|
'Auth': String(token),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<br>
|
<br>
|
||||||
<FormPostInq url="http://127.0.0.1:5007/api/inquilino"/>
|
<FormPostInq url={String($urlG)+"/api/inquilino"}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<NavBarAutocompletable/>
|
<NavBarAutocompletable/>
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<br>
|
<br>
|
||||||
<FormPostInq url="http://127.0.0.1:5007/api/propietario"/>
|
<FormPostInq url={String($urlG)+'/api/propietario'}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user