feat: listar propiedades y baja propiedad
Signed-off-by: fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
@@ -1,21 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { Navbar, NavbarBrand, NavbarToggler, NavItem, Nav, NavLink, Collapse } from "@sveltestrap/sveltestrap";
|
||||
import { Navbar, NavbarBrand, NavbarToggler, Nav, Collapse } from "@sveltestrap/sveltestrap";
|
||||
import { onMount } from "svelte";
|
||||
import { writable } from 'svelte/store';
|
||||
import './css/popup.css';
|
||||
import type { Grupo } from "../types";
|
||||
let isOpen: boolean = $state(false);
|
||||
|
||||
type Permiso = {
|
||||
id: number;
|
||||
descripcion: string;
|
||||
};
|
||||
|
||||
type Grupo = {
|
||||
id: number;
|
||||
nombre: string;
|
||||
idpermisos: Permiso[];
|
||||
};
|
||||
|
||||
const permisos = writable<Grupo[]>([]);
|
||||
const email = localStorage.getItem('email');
|
||||
const token = sessionStorage.getItem('token');
|
||||
|
||||
50
Front/src/Componentes/RowPropiedad.svelte
Normal file
50
Front/src/Componentes/RowPropiedad.svelte
Normal file
@@ -0,0 +1,50 @@
|
||||
<script lang="ts">
|
||||
import type {PropiedadDto} from "../types"
|
||||
import ModalEstatico from "./ModalEstatico.svelte";
|
||||
let { id, ubicacion, tipo, letra, piso }: PropiedadDto = $props();
|
||||
|
||||
let modal: boolean = $state(false)
|
||||
let modalpayload: string = $state("")
|
||||
|
||||
async function BajaPropiedad(){
|
||||
modal = false;
|
||||
try {
|
||||
const responce = await fetch("http://localhost:5007/api/propiedad?id="+id, {
|
||||
method: "DELETE",
|
||||
headers:{
|
||||
'Auth' : String(sessionStorage.getItem("token")),
|
||||
'Email' : String(localStorage.getItem("email"))
|
||||
},
|
||||
});
|
||||
|
||||
if (responce.ok){
|
||||
const json = await responce.json();
|
||||
modalpayload = json.message;
|
||||
modal = true;
|
||||
}
|
||||
|
||||
if (!responce.ok) {
|
||||
const json = await responce.json();
|
||||
modalpayload = json.message;
|
||||
modal = true;
|
||||
}
|
||||
}catch (e){
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<tr>
|
||||
<td>{id}</td>
|
||||
<td>{ubicacion}</td>
|
||||
<td>{letra}</td>
|
||||
<td>{piso}</td>
|
||||
<td>{tipo}</td>
|
||||
<td class="text-end">
|
||||
<button class="btn btn-outline-secondary">Modificar</button>
|
||||
<button class="btn btn-outline-danger" onclick={()=> BajaPropiedad()}>Baja</button>
|
||||
</td>
|
||||
</tr>
|
||||
{#if modal}
|
||||
<ModalEstatico payload={modalpayload}/>
|
||||
{/if}
|
||||
@@ -5,7 +5,6 @@
|
||||
let email = $state("")
|
||||
let contraseña = $state("")
|
||||
let errorMessage = $state("")
|
||||
let showAlert = false;
|
||||
|
||||
// @ts-ignore
|
||||
async function submitForm(event) {
|
||||
@@ -25,7 +24,6 @@
|
||||
if (!response.ok){
|
||||
const errorData = await response.json()
|
||||
errorMessage = errorData.message;
|
||||
showAlert = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user