dev #48
@@ -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'
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
||||
import type { PropiedadDto } from "../types";
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
let propiedades = writable<PropiedadDto[]>([]);
|
||||
let email = localStorage.getItem("email");
|
||||
@@ -13,7 +14,7 @@
|
||||
|
||||
onMount(async ()=> {
|
||||
try {
|
||||
const responce = await fetch("http://localhost:5007/api/propiedades/Propietario", {
|
||||
const responce = await fetch(String($urlG)+"/api/propiedades/Propietario", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Auth': String(token),
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import RowPropiedad from "../Componentes/RowPropiedad.svelte";
|
||||
import type { PropiedadDto } from "../types";
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
let propiedades = writable<PropiedadDto[]>([]);
|
||||
let email = localStorage.getItem("email");
|
||||
@@ -13,7 +14,7 @@
|
||||
|
||||
onMount(async ()=> {
|
||||
try {
|
||||
const responce = await fetch("http://localhost:5007/api/propiedades/Propietario/Bajas", {
|
||||
const responce = await fetch(String($urlG)+"/api/propiedades/Propietario/Bajas", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Auth': String(token),
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { writable } from "svelte/store"; // Importar writable para los estados
|
||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||
import type { Propiedad } from "../types";
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
let propiedad: Propiedad = {
|
||||
ubicacion: "",
|
||||
@@ -22,7 +22,7 @@
|
||||
e.preventDefault();
|
||||
mostrarModal = false;
|
||||
try {
|
||||
const response = await fetch("http://localhost:5007/api/propiedad", {
|
||||
const response = await fetch(String($urlG)+"/api/propiedad", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Auth': String(token),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
import { urlG } from "../stores/urlStore";
|
||||
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||
</script>
|
||||
|
||||
@@ -29,7 +30,7 @@
|
||||
</div>
|
||||
<div class="col">
|
||||
<br>
|
||||
<FormPostInq url="http://127.0.0.1:5007/api/inquilino"/>
|
||||
<FormPostInq url={String($urlG)+"/api/inquilino"}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import FormPostInq from "../Componentes/FormPostCli.svelte";
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
import TextBar from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||
import { urlG } from "../stores/urlStore";
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -28,7 +29,7 @@
|
||||
</div>
|
||||
<div class="col">
|
||||
<br>
|
||||
<FormPostInq url="http://127.0.0.1:5007/api/propietario"/>
|
||||
<FormPostInq url={String($urlG)+'/api/propietario'}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user