@@ -1,13 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Button, Modal } from '@sveltestrap/sveltestrap';
|
import { Modal } from '@sveltestrap/sveltestrap';
|
||||||
|
|
||||||
let {payload} = $props();
|
|
||||||
let open = $state(true);
|
|
||||||
const toggle = () => (open = !open);
|
const toggle = () => (open = !open);
|
||||||
|
let {payload, close = toggle, iscomponent = false } = $props();
|
||||||
|
let open = $state(true);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Modal body isOpen={open} {toggle}>
|
<Modal body isOpen={open} toggle={close}>
|
||||||
|
{#if iscomponent == false}
|
||||||
{payload}
|
{payload}
|
||||||
|
{:else}
|
||||||
|
{@render payload()}
|
||||||
|
{/if}
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { fade } from "svelte/transition";
|
||||||
import type {PropiedadDto} from "../types"
|
import type {PropiedadDto} from "../types"
|
||||||
import ModalEstatico from "./ModalEstatico.svelte";
|
import ModalEstatico from "./ModalEstatico.svelte";
|
||||||
let { id, ubicacion, tipo, letra, piso }: PropiedadDto = $props();
|
import ModificarPropiedadForm from "./modificarPropiedadForm.svelte";
|
||||||
|
let { id, ubicacion, tipo, letra, piso,canthabitaciones }: PropiedadDto = $props();
|
||||||
|
|
||||||
let modal: boolean = $state(false)
|
let modal: boolean = $state(false);
|
||||||
let modalpayload: string = $state("")
|
let modalpayload: string = $state("");
|
||||||
|
|
||||||
|
let modificar: boolean = $state(false);
|
||||||
|
|
||||||
|
function setmod(){
|
||||||
|
modificar = !modificar;
|
||||||
|
}
|
||||||
|
|
||||||
async function BajaPropiedad(){
|
async function BajaPropiedad(){
|
||||||
modal = false;
|
modal = false;
|
||||||
@@ -15,7 +23,7 @@
|
|||||||
'Auth' : String(sessionStorage.getItem("token")),
|
'Auth' : String(sessionStorage.getItem("token")),
|
||||||
'Email' : String(localStorage.getItem("email"))
|
'Email' : String(localStorage.getItem("email"))
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (responce.ok){
|
if (responce.ok){
|
||||||
const json = await responce.json();
|
const json = await responce.json();
|
||||||
@@ -34,17 +42,20 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr>
|
<tr in:fade>
|
||||||
<td>{id}</td>
|
<td>{id}</td>
|
||||||
<td>{ubicacion}</td>
|
<td>{ubicacion}</td>
|
||||||
|
<td>{canthabitaciones}</td>
|
||||||
<td>{letra}</td>
|
<td>{letra}</td>
|
||||||
<td>{piso}</td>
|
<td>{piso}</td>
|
||||||
<td>{tipo}</td>
|
<td>{tipo}</td>
|
||||||
<td class="text-end">
|
<td class="text-end">
|
||||||
<button class="btn btn-outline-secondary">Modificar</button>
|
<button class="btn btn-outline-secondary" onclick={() => setmod()}>Modificar</button>
|
||||||
<button class="btn btn-outline-danger" onclick={()=> BajaPropiedad()}>Baja</button>
|
<button class="btn btn-outline-danger" onclick={()=> BajaPropiedad()}>Baja</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{#if modal}
|
{#if modal}
|
||||||
<ModalEstatico payload={modalpayload}/>
|
<ModalEstatico payload={modalpayload}/>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if modificar}
|
||||||
|
{/if}
|
||||||
|
|||||||
77
Front/src/Componentes/modificarPropiedadForm.svelte
Normal file
77
Front/src/Componentes/modificarPropiedadForm.svelte
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import type { PropiedadDto } from "../types";
|
||||||
|
|
||||||
|
let propi: PropiedadDto = $props();
|
||||||
|
|
||||||
|
function submitForm(e: Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<form onsubmit={submitForm} class="card card-body">
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="ubicacion"
|
||||||
|
class="form-control"
|
||||||
|
bind:value={propi.ubicacion}
|
||||||
|
placeholder="Ubicación"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<label for="ubicacion">Ubicación</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="canthabitaciones"
|
||||||
|
class="form-control"
|
||||||
|
bind:value={propi.canthabitaciones}
|
||||||
|
min="1"
|
||||||
|
placeholder="Cantidad de Habitaciones"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<label for="canthabitaciones">Cantidad de Habitaciones</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="piso"
|
||||||
|
class="form-control"
|
||||||
|
bind:value={propi.piso}
|
||||||
|
min="0"
|
||||||
|
placeholder="Piso"
|
||||||
|
/>
|
||||||
|
<label for="piso">Piso</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="letra"
|
||||||
|
class="form-control"
|
||||||
|
bind:value={propi.letra}
|
||||||
|
maxlength="1"
|
||||||
|
placeholder="Letra"
|
||||||
|
/>
|
||||||
|
<label for="letra">Letra</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<select
|
||||||
|
id="idtipropiedad"
|
||||||
|
class="form-select"
|
||||||
|
bind:value={propi.tipo}
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<option value="1">Casa</option>
|
||||||
|
<option value="2">Piso</option>
|
||||||
|
<option value="3">Departamento</option>
|
||||||
|
<option value="4">Galpon</option>
|
||||||
|
<option value="5">LocalComercial</option>
|
||||||
|
<option value="6">Oficina</option>
|
||||||
|
</select>
|
||||||
|
<label for="idtipropiedad">Tipo de Propiedad</label>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Enviar</button>
|
||||||
|
</form>
|
||||||
@@ -44,6 +44,7 @@ onMount(async ()=> {
|
|||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>ubicacion</th>
|
<th>ubicacion</th>
|
||||||
|
<th>Habitaciones</th>
|
||||||
<th>Letra</th>
|
<th>Letra</th>
|
||||||
<th>Piso</th>
|
<th>Piso</th>
|
||||||
<th>Tipo</th>
|
<th>Tipo</th>
|
||||||
@@ -51,7 +52,8 @@ onMount(async ()=> {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each $propiedades as propiedad}
|
{#each $propiedades as propiedad}
|
||||||
<RowPropiedad id={propiedad.id} ubicacion={propiedad.ubicacion} letra={propiedad.letra} piso={propiedad.piso} tipo={propiedad.tipo}/>
|
<RowPropiedad id={propiedad.id} ubicacion={propiedad.ubicacion} letra={propiedad.letra} piso={propiedad.piso} tipo={propiedad.tipo} canthabitaciones={propiedad.canthabitaciones}/>
|
||||||
|
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -3,15 +3,7 @@
|
|||||||
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";
|
||||||
type Propiedad = {
|
|
||||||
ubicacion: string,
|
|
||||||
canthabitaciones: number,
|
|
||||||
piso: number,
|
|
||||||
letra: string,
|
|
||||||
email: string,
|
|
||||||
idtipropiedad: number,
|
|
||||||
};
|
|
||||||
|
|
||||||
let propiedad: Propiedad = {
|
let propiedad: Propiedad = {
|
||||||
ubicacion: "",
|
ubicacion: "",
|
||||||
@@ -28,6 +20,7 @@
|
|||||||
|
|
||||||
const submitForm = async (e: Event) => {
|
const submitForm = async (e: Event) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
mostrarModal = false;
|
||||||
try {
|
try {
|
||||||
const response = await fetch("http://localhost:5007/api/propiedad", {
|
const response = await fetch("http://localhost:5007/api/propiedad", {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
10
Front/src/types.d.ts
vendored
10
Front/src/types.d.ts
vendored
@@ -4,6 +4,7 @@ export type PropiedadDto = {
|
|||||||
tipo: string,
|
tipo: string,
|
||||||
piso: string | null,
|
piso: string | null,
|
||||||
letra: string | null,
|
letra: string | null,
|
||||||
|
canthabitaciones: number,
|
||||||
}
|
}
|
||||||
export type Permiso = {
|
export type Permiso = {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -15,3 +16,12 @@ export type Grupo = {
|
|||||||
nombre: string;
|
nombre: string;
|
||||||
idpermisos: Permiso[];
|
idpermisos: Permiso[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type Propiedad = {
|
||||||
|
ubicacion: string,
|
||||||
|
canthabitaciones: number,
|
||||||
|
piso: number,
|
||||||
|
letra: string,
|
||||||
|
email: string,
|
||||||
|
idtipropiedad: number,
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user