creo que estoy con esto
This commit is contained in:
56
Front/src/Componentes/ModalNotificacion.svelte
Normal file
56
Front/src/Componentes/ModalNotificacion.svelte
Normal file
@@ -0,0 +1,56 @@
|
||||
<script lang="ts">
|
||||
let {onCancel, onConfirm}: {onCancel:()=>void, onConfirm:(message:string)=>void} = $props();
|
||||
|
||||
let message:string = $state("");
|
||||
const maxLength = $state(100);
|
||||
|
||||
function handleConfirm(e:Event) {
|
||||
e.preventDefault();
|
||||
if (message.length <= maxLength) {
|
||||
onConfirm(message);
|
||||
onCancel();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<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">Confirmar acción</h5>
|
||||
<button type="button" class="btn-close" aria-label="Close" onclick={onCancel}></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form onsubmit={(e)=>handleConfirm(e)}>
|
||||
<div class="mb-3">
|
||||
<label for="message" class="form-label">Mensaje</label>
|
||||
<input
|
||||
type="text"
|
||||
id="message"
|
||||
class="form-control"
|
||||
bind:value={message}
|
||||
maxlength={maxLength}
|
||||
required
|
||||
/>
|
||||
<div class="form-text">
|
||||
Caracteres restantes: {maxLength - message.length}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer d-flex justify-content-between">
|
||||
<button type="button" class="btn btn-secondary" onclick={onCancel}>
|
||||
Cancelar
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" onclick={(e)=>handleConfirm(e)}>
|
||||
Confirmar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -6,6 +6,7 @@
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, GaranteDto2 } from "../types";
|
||||
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
||||
import ModalNotificacion from "../Componentes/ModalNotificacion.svelte";
|
||||
|
||||
|
||||
let token:string = sessionStorage.getItem("token")||"";
|
||||
@@ -13,6 +14,9 @@
|
||||
let interes:number = $state(0);
|
||||
let selMod:any =$state();
|
||||
let showmodal:boolean = $state(false);
|
||||
let shownotif:boolean = $state(false);
|
||||
|
||||
let max:number=$state(0);
|
||||
|
||||
let canons:CanonDto[] = $state([]);
|
||||
let garantes: GaranteDto2[] = $state([]);
|
||||
@@ -33,10 +37,11 @@
|
||||
|
||||
let modaldata:string = $state("");
|
||||
let contratoid:string = $state("");
|
||||
|
||||
onMount(()=>{
|
||||
|
||||
onMount(async ()=>{
|
||||
getparams();
|
||||
obtenerDatosACargar();
|
||||
await obtenerDatosACargar();
|
||||
max = canons.at(-1).mesNum||0;
|
||||
});
|
||||
|
||||
async function obtenerDatosACargar() {
|
||||
@@ -78,12 +83,14 @@
|
||||
contratoid = par.get("id")||"";
|
||||
}
|
||||
|
||||
async function submitnuevosCanones() {
|
||||
async function submitnuevosCanones(e: Event) {
|
||||
e.preventDefault();
|
||||
try {
|
||||
const ret = await fetch($urlG+"/api/contratos/crearcanons",{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth" : String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({idcontrato: contratoid, aumento: interes})
|
||||
});
|
||||
@@ -169,7 +176,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function generarTiket(mod) {
|
||||
function generarTiket(mod:any) {
|
||||
selMod = mod;
|
||||
showmodal =true;
|
||||
}
|
||||
@@ -198,6 +205,34 @@
|
||||
modaldata = "Fallo al intentar hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function EscribirNotificacion(message:string) {
|
||||
if (message =="") {
|
||||
modaldata = "no se puede enviar un mensaje vacio";
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/notificarInquilino", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
mensaje: message,
|
||||
idpropiedad: prop.id
|
||||
})
|
||||
});
|
||||
let data = await r.json();
|
||||
modaldata = data.message;
|
||||
} catch {
|
||||
modaldata ="No se pudo enviar el mensaje";
|
||||
}
|
||||
}
|
||||
|
||||
function abrirModalNotif() {
|
||||
shownotif = true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -210,6 +245,10 @@
|
||||
<ModalPedirDoc onClose={()=>showmodal=false} onSubmit={pedirdocumento} />
|
||||
{/if}
|
||||
|
||||
{#if shownotif}
|
||||
<ModalNotificacion onCancel={()=>shownotif = false} onConfirm={EscribirNotificacion}/>
|
||||
{/if}
|
||||
|
||||
<div class="container-fluid mt-4 d-flex">
|
||||
<div class="col-md-4 me-4">
|
||||
<div class="card">
|
||||
@@ -224,9 +263,14 @@
|
||||
<p><b>Letra:</b> {prop.letra}</p>
|
||||
<p><b>Fecha Inicio:</b> {String(prop.fechainicio).split("T")[0]}</p>
|
||||
<p><b>Estado:</b> {prop.estado}</p>
|
||||
<button class="btn btn-secondary" onclick={verContrato}>
|
||||
Ver Contrato
|
||||
</button>
|
||||
<div class="d-flex justify-content-between">
|
||||
<button class="btn btn-secondary" onclick={verContrato}>
|
||||
Ver Contrato
|
||||
</button>
|
||||
<button class="btn btn-warning" onclick={abrirModalNotif}>
|
||||
Enviar Notificacion
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer text-center">
|
||||
IdContrato: {prop.id}
|
||||
@@ -327,6 +371,8 @@
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{#if max < prop.mesesDuracion}
|
||||
{$inspect(max)}
|
||||
<div class="card">
|
||||
<div class="card-header text-center">
|
||||
Definir el interés para los siguientes Canones
|
||||
@@ -335,25 +381,26 @@
|
||||
<form>
|
||||
<div class="input-group">
|
||||
<input
|
||||
class="form-control"
|
||||
type="number"
|
||||
id="interes"
|
||||
bind:value={interes}
|
||||
min="0"
|
||||
class="form-control"
|
||||
type="number"
|
||||
id="interes"
|
||||
bind:value={interes}
|
||||
min="0"
|
||||
/>
|
||||
<span class="input-group-text" id="basic-addon2">%</span>
|
||||
</div>
|
||||
<br />
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
type="submit"
|
||||
onclick={() => submitnuevosCanones()}
|
||||
class="btn btn-primary"
|
||||
type="submit"
|
||||
onclick={(e) => submitnuevosCanones(e)}
|
||||
>
|
||||
Enviar
|
||||
Enviar
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -130,6 +130,11 @@
|
||||
Selmens = {...mensaje};
|
||||
return;
|
||||
}
|
||||
|
||||
if (mensaje.accion === "Notificacion Inquilino") {
|
||||
Selmens = {...mensaje};
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function obtenerListaGarantes(idcontrato: number) {
|
||||
@@ -422,6 +427,8 @@
|
||||
<ModalCheckYContrato {garantes} men={Selmens} onCancel={handleCancelPrecontrato} onClose={() => (Selmens.accion = "")} onConfirm={handleEnviarmensaje4}/>
|
||||
{:else if Selmens.accion == "Aceptar Contrato"}
|
||||
<ModalVeryAceptarContrato onClose={() => (Selmens.accion = "")} onConfirm={handleAceptarContrato} onCancel={handlerechazarcontrato} getContrato={ObtenerContrato} men={Selmens}/>
|
||||
{:else if Selmens.accion == "Notificacion Inquilino"}
|
||||
<ModalEstatico payload={Selmens.mensaje} close={()=> !!(Selmens.accion = "") }/>
|
||||
{/if}
|
||||
|
||||
<div class="container">
|
||||
@@ -483,9 +490,10 @@
|
||||
</button>
|
||||
{/if}
|
||||
{#if (men.accion === "ContratoCancelado" || men.accion === "Rechazo Contrato" ||
|
||||
men.accion === "Aceptado Contrato") && mostrarleidos == false}
|
||||
men.accion === "Aceptado Contrato" || men.accion === "Notificacion Inquilino"
|
||||
) && mostrarleidos == false}
|
||||
<button
|
||||
class="btn btn-outline-danger"
|
||||
class="btn btn-outline-danger btn-sm"
|
||||
onclick={() => marcarleido(men.fecha, localStorage.getItem("email")|| "", men)}>
|
||||
Marcar Leido
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user