avance: estado pre implementacion de notificaciones
This commit is contained in:
36
Front/src/Componentes/ModalConfirm.svelte
Normal file
36
Front/src/Componentes/ModalConfirm.svelte
Normal file
@@ -0,0 +1,36 @@
|
||||
<script lang="ts">
|
||||
let {show = false, title = "Confirmación",
|
||||
message = "¿Está seguro?",
|
||||
onConfirm , onCancel
|
||||
}:{
|
||||
show:boolean, title: string, message: string, onConfirm:()=>void, onCancel:()=>void } = $props();
|
||||
|
||||
function handleConfirm() {
|
||||
onConfirm();
|
||||
}
|
||||
|
||||
function handleCancel() {
|
||||
onCancel();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{#if show}
|
||||
<div class="modal fade show d-block" tabindex="-1" style="background-color: rgba(0,0,0,0.5);">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{title}</h5>
|
||||
<button type="button" class="btn-close" aria-label="Close" onclick={handleCancel}></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>{message}</p>
|
||||
<div class="d-flex justify-content-between">
|
||||
<button class="btn btn-secondary" onclick={handleCancel}>Cancelar</button>
|
||||
<button class="btn btn-primary" onclick={handleConfirm}>Aceptar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -1,8 +1,46 @@
|
||||
<script lang="ts">
|
||||
import type { PropiedadDto } from "../types";
|
||||
import ModalConfirm from "./ModalConfirm.svelte";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
|
||||
let { prop }: { prop: PropiedadDto } = $props();
|
||||
|
||||
let show: boolean = $state(false);
|
||||
let token = sessionStorage.getItem("token");
|
||||
let remitente = localStorage.getItem("email");
|
||||
|
||||
const message: string = "Queres consultar con el propietario por el alquiler? (esto le envia una notificacion y email al propietario)";
|
||||
const accion = "Consulta Nuevo Alquiler";
|
||||
|
||||
function Consultar() {
|
||||
show = true;
|
||||
}
|
||||
|
||||
async function onConfirm() {
|
||||
const propiedad = prop.id;
|
||||
try {
|
||||
const responce = await fetch($urlG+"/api/notificaciones", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth": String(token)
|
||||
},
|
||||
body : JSON.stringify({remitente, accion, propiedad})
|
||||
});
|
||||
|
||||
} catch {
|
||||
|
||||
}
|
||||
|
||||
show=!show;
|
||||
}
|
||||
|
||||
function onCancel() {
|
||||
show=!show;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<ModalConfirm {show} {message} title="Consulta" {onConfirm} {onCancel}/>
|
||||
<div class="card text-center border shadow-sm">
|
||||
<div class="card-header bg-primary text-white">
|
||||
<h5 class="mb-0">{prop.tipo}</h5>
|
||||
@@ -19,7 +57,7 @@
|
||||
<strong>Servicios:</strong> {prop.servicios || "Sin servicios especificados"}<br>
|
||||
<strong>Monto:</strong> ${prop.monto}<br>
|
||||
</p>
|
||||
<button class="btn btn-primary">Consultar</button>
|
||||
<button class="btn btn-primary" onclick={Consultar}>Alquilar</button>
|
||||
</div>
|
||||
<div class="card-footer text-muted">
|
||||
ID Propiedad: {prop.id}
|
||||
|
||||
Reference in New Issue
Block a user