falta testear
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
let {getContrato, onConfirm, onCancel, onClose, men
|
||||
} : {
|
||||
getContrato:(idcontrato:number)=>void,
|
||||
onConfirm:()=>void,
|
||||
onCancel:()=>void,
|
||||
onConfirm:(idcontrato:number)=>void,
|
||||
onCancel:(idcontrato:number)=>void,
|
||||
onClose:()=>void,
|
||||
men: MensajeDto
|
||||
} = $props();
|
||||
@@ -21,13 +21,15 @@
|
||||
|
||||
function confirmar() {
|
||||
if (leiContrato) {
|
||||
onConfirm();
|
||||
let idcontrato = Number(men.mensaje.split(" ").reverse()[0]);
|
||||
onConfirm(idcontrato);
|
||||
}
|
||||
}
|
||||
|
||||
function rechazar() {
|
||||
if (leiContrato) {
|
||||
onCancel();
|
||||
let idcontrato = Number(men.mensaje.split(" ").reverse()[0]);
|
||||
onCancel(idcontrato);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import { self } from "svelte/legacy";
|
||||
import ModalVeryAceptarContrato from "../Componentes/ModalVeryAceptarContrato.svelte";
|
||||
import { getRequest } from "@sveltejs/kit/node";
|
||||
import { json } from "@sveltejs/kit";
|
||||
|
||||
const token = sessionStorage.getItem("token");
|
||||
let mensajes: MensajeDto[] = $state([]);
|
||||
@@ -320,7 +321,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
let blob = await Blob(responce.body());
|
||||
let blob = await responce.blob();
|
||||
const blobUrl = URL.createObjectURL(blob);
|
||||
window.open(blobUrl, '_blank');
|
||||
setTimeout(() => URL.revokeObjectURL(blobUrl), 100000);
|
||||
@@ -328,7 +329,75 @@
|
||||
modaldata = "Fallo al intentar conectarse al servidor";
|
||||
}
|
||||
}
|
||||
|
||||
async function handlerechazarcontrato(idcontrato:number) {
|
||||
if (idcontrato<=0){
|
||||
modaldata="La idcontrato da 0 o menos comunicate con el administrador";
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let rq = {
|
||||
idcontrato:idcontrato,
|
||||
fecha:Selmens.fecha,
|
||||
}
|
||||
const responce = await fetch($urlG+"/api/contratos/aceptarContrato", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
},
|
||||
body: JSON.stringify(rq),
|
||||
});
|
||||
if (responce.ok){
|
||||
let data = await responce.json();
|
||||
modaldata = data.message;
|
||||
if (mostrarleidos) {
|
||||
Leidos();
|
||||
} else {
|
||||
SinLeer();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let data = await responce.json();
|
||||
modaldata = data.message;
|
||||
return;
|
||||
} catch {
|
||||
modaldata = "Fallo la request";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAceptarContrato(idcontrato:number) {
|
||||
if (idcontrato<=0){
|
||||
modaldata="La idcontrato da 0 o menos comunicate con el administrador";
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const responce = await fetch($urlG+"/api/contratos/rechazarPreContrato?idcontrato="+idcontrato, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
}
|
||||
});
|
||||
if (responce.ok){
|
||||
let data = await responce.json();
|
||||
modaldata = data.message;
|
||||
if (mostrarleidos) {
|
||||
Leidos();
|
||||
} else {
|
||||
SinLeer();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let data = await responce.json();
|
||||
modaldata = data.message;
|
||||
return;
|
||||
} catch {
|
||||
modaldata = "Fallo la request";
|
||||
return;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -344,7 +413,7 @@
|
||||
{:else if Selmens.accion == "Check y Contrato"}
|
||||
<ModalCheckYContrato {garantes} men={Selmens} onCancel={handleCancelPrecontrato} onClose={() => (Selmens.accion = "")} onConfirm={handleEnviarmensaje4}/>
|
||||
{:else if Selmens.accion == "Aceptar Contrato"}
|
||||
<ModalVeryAceptarContrato onClose={() => (Selmens.accion = "")} onConfirm={()=> ""} onCancel={()=>""} getContrato={ObtenerContrato} men={Selmens}/>
|
||||
<ModalVeryAceptarContrato onClose={() => (Selmens.accion = "")} onConfirm={handleAceptarContrato} onCancel={handleCancelPrecontrato} getContrato={ObtenerContrato} men={Selmens}/>
|
||||
{/if}
|
||||
|
||||
<div class="container">
|
||||
|
||||
Reference in New Issue
Block a user