Avansamos mucho con el administracion propiedades
This commit is contained in:
86
Front/src/Componentes/AdminPanelBusqueda.svelte
Normal file
86
Front/src/Componentes/AdminPanelBusqueda.svelte
Normal file
@@ -0,0 +1,86 @@
|
||||
<script lang="ts">
|
||||
import "./css/dotted-line.css";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
import type { AdminParametrosBusqueda, PropiedadAdmin } from "../types";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
let canthabitaciones:number = $state(0);
|
||||
let servicios = ["Gas", "Internet", "Telefono", "Luz"];
|
||||
let serviciosSel:string[] = $state([]);
|
||||
let tipo: number = $state(0);
|
||||
|
||||
|
||||
|
||||
let { Params }: { Params: (a: AdminParametrosBusqueda) => void} = $props();
|
||||
|
||||
let token = sessionStorage.getItem("token");
|
||||
|
||||
async function formsubmit(e: Event){
|
||||
e.preventDefault();
|
||||
let params: AdminParametrosBusqueda = {
|
||||
cantidadhabitaciones: canthabitaciones||0,
|
||||
pag: 1,
|
||||
servicios: serviciosSel.join(","),
|
||||
tipopropiedad: tipo,
|
||||
};
|
||||
Params(params);
|
||||
}
|
||||
</script>
|
||||
|
||||
<form class="card p-3 border border-succes">
|
||||
|
||||
<div>Busqueda Filtrada
|
||||
<div class="dotted-line"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="number"
|
||||
id="canthabitaciones"
|
||||
class="form-control"
|
||||
bind:value={canthabitaciones}
|
||||
min="0"
|
||||
placeholder="Cantidad de Habitaciones"
|
||||
required
|
||||
/>
|
||||
<label for="canthabitaciones">Cantidad de Habitaciones</label>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<h6 class="form-floating form-label">Servicios</h6>
|
||||
{#each servicios as servicio}
|
||||
<div class="form-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="form-check-input"
|
||||
bind:group={serviciosSel}
|
||||
value={servicio}
|
||||
id={`servicio-${servicio}`}
|
||||
|
||||
/>
|
||||
<label class="form-check-label" for={`servicio-${servicio}`}>
|
||||
{servicio}
|
||||
</label>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<div class="form-floating mb-3">
|
||||
<select id="idtipo" class="form-select" bind:value={tipo} required>
|
||||
<option value="0">No Define</option>
|
||||
<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="idtipopropiedad">Tipo de propiedad</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary w-100 d-flex align-items-center justify-content-center" onclick={formsubmit}>
|
||||
Buscar
|
||||
<img src="/zoom.svg" alt="" class="ms-2" style="height: 1.2em;" />
|
||||
</button>
|
||||
</form>
|
||||
|
||||
59
Front/src/Componentes/AdminPropiedad.svelte
Normal file
59
Front/src/Componentes/AdminPropiedad.svelte
Normal file
@@ -0,0 +1,59 @@
|
||||
<script lang="ts">
|
||||
import type { PropiedadAdmin } from "../types";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
|
||||
let { prop, modal }: { prop: PropiedadAdmin, modal: (a:string) => void } = $props();
|
||||
|
||||
const token = sessionStorage.getItem("token");
|
||||
|
||||
async function cambioEstado() {
|
||||
try {
|
||||
const response = await fetch($urlG+"/api/admin/propiedad?id="+prop.id, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Auth": String(token)
|
||||
}
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
prop.estado = prop.estado=="Baja" ? "Disponible": "Baja";
|
||||
}
|
||||
|
||||
let data = await response.json();
|
||||
modal(String(data.message));
|
||||
|
||||
|
||||
} catch {
|
||||
modal("Fallo al intentar enviar la peticion para dar de baja");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="card text-center border shadow-sm">
|
||||
<div class="card-header bg-primary text-white">
|
||||
<h5 class="mb-0">{prop.tipo}</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-img-top mb-3">
|
||||
<i class="bi bi-building" style="font-size: 3rem;"></i>
|
||||
</div>
|
||||
<h6 class="card-title">{prop.ubicacion}</h6>
|
||||
<p class="card-text">
|
||||
<strong>Habitaciones:</strong> {prop.canthabitaciones}<br>
|
||||
<strong>Piso:</strong> {prop.piso || "N/A"}<br>
|
||||
<strong>Letra:</strong> {prop.letra || "N/A"}<br>
|
||||
<strong>Servicios:</strong> {prop.servicios || "Sin servicios especificados"}<br>
|
||||
<strong>Monto:</strong> ${prop.monto}<br>
|
||||
<strong>Estado:</strong> {prop.estado}<br>
|
||||
</p>
|
||||
{#if prop.estado == "Disponible"}
|
||||
<button class="btn btn-success" onclick={cambioEstado}>Baja</button>
|
||||
{:else}
|
||||
<button class="btn btn-danger" onclick={cambioEstado}>Alta</button>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="card-footer text-muted">
|
||||
ID Propiedad: {prop.id}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
35
Front/src/Componentes/PaginacionStepper.svelte
Normal file
35
Front/src/Componentes/PaginacionStepper.svelte
Normal file
@@ -0,0 +1,35 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
|
||||
let {currentPag,
|
||||
cantpag,
|
||||
queryPag
|
||||
}:{
|
||||
currentPag: number,
|
||||
cantpag: number,
|
||||
queryPag: (a:number) => void} = $props();
|
||||
|
||||
|
||||
const token = sessionStorage.getItem("token");
|
||||
|
||||
onMount(async () => {
|
||||
|
||||
});
|
||||
|
||||
let array = $derived.by(()=> Array.from({ length: cantpag }, (_, i) => i + 1));
|
||||
</script>
|
||||
|
||||
{#if cantpag>1}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination">
|
||||
{#each array as num }
|
||||
{#if currentPag !== num}
|
||||
<li class="page-item"><a class="page-link" href="#" onclick={()=>queryPag(num)}>{String(num)}</a></li>
|
||||
{:else}
|
||||
<li class="page-item"><a class="page-link active" href="#" onclick={()=>queryPag(num)}>{String(num)}</a></li>
|
||||
{/if}
|
||||
{/each}
|
||||
</ul>
|
||||
</nav>
|
||||
{/if}
|
||||
@@ -8,10 +8,11 @@
|
||||
let serviciosSel = $state([]);
|
||||
let tipo = $state(0);
|
||||
|
||||
async function formsubmit (e){
|
||||
async function formsubmit (e:Event){
|
||||
e.preventDefault();
|
||||
|
||||
const url = window.location.pathname;
|
||||
|
||||
const goto = url+"?cantidadHabitaciones="+canthabitaciones+"&tipoPropiedad="+tipo+"&servicios="+serviciosSel.join(",");
|
||||
window.location.replace(goto);
|
||||
}
|
||||
@@ -20,7 +21,7 @@
|
||||
<form class="card p-3 border border-succes">
|
||||
|
||||
<div>Busqueda Filtrada
|
||||
<div class="dotted-line">
|
||||
<div class="dotted-line"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-floating mb-3">
|
||||
|
||||
Reference in New Issue
Block a user