Feat: commit antes de mostrar el codigo.
- Añadido alta propiedad - Arreglado alta inq/prop - Añadida pantalla de menu
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
<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";
|
||||
|
||||
type Propiedad = {
|
||||
ubicacion: string,
|
||||
canthabitaciones: number,
|
||||
@@ -7,26 +10,50 @@
|
||||
letra: string,
|
||||
email: string,
|
||||
idtipropiedad: number,
|
||||
}
|
||||
};
|
||||
|
||||
let propiedad: Propiedad = {
|
||||
ubicacion: "",
|
||||
canthabitaciones: 1,
|
||||
piso: 0,
|
||||
letra: "",
|
||||
email: "",
|
||||
email: localStorage.getItem("email") || "",
|
||||
idtipropiedad: 1,
|
||||
};
|
||||
|
||||
const submitForm = () => {
|
||||
console.log("Formulario enviado:", propiedad);
|
||||
};
|
||||
let token = sessionStorage.getItem("token");
|
||||
let mostrarModal = $state(false);
|
||||
let datosModal = $state("");
|
||||
|
||||
const submitForm = async (e: Event) => {
|
||||
e.preventDefault();
|
||||
try {
|
||||
const response = await fetch("http://localhost:5007/api/propiedad", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Auth': String(token),
|
||||
'Content-Type': "application/json"
|
||||
},
|
||||
body: JSON.stringify(propiedad),
|
||||
});
|
||||
|
||||
|
||||
const json = await response.json();
|
||||
datosModal = json.message;
|
||||
mostrarModal =true;
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
<NavBarAutocompletable />
|
||||
|
||||
|
||||
<div class="container mt-4">
|
||||
<h2>Registrar Propiedad</h2>
|
||||
<form on:submit|preventDefault={submitForm}>
|
||||
<form class="card card-body" onsubmit={submitForm}>
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="text"
|
||||
@@ -72,7 +99,6 @@
|
||||
/>
|
||||
<label for="letra">Letra</label>
|
||||
</div>
|
||||
|
||||
<div class="form-floating mb-3">
|
||||
<select
|
||||
id="idtipropiedad"
|
||||
@@ -81,11 +107,17 @@
|
||||
required
|
||||
>
|
||||
<option value="1">Casa</option>
|
||||
<option value="2">Departamento</option>
|
||||
<option value="3">Oficina</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>
|
||||
</div>
|
||||
{#if mostrarModal == true}
|
||||
<ModalEstatico payload={datosModal} />
|
||||
{/if}
|
||||
Reference in New Issue
Block a user