feat: hecha la parte de gestion de propiedades en venta
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
<script lang="ts">
|
||||
import type { PatchPropiedad, setVenta } from "../types";
|
||||
|
||||
let {onClose, onConfirm}: {onClose:()=>void, onConfirm:()=>void} = $props();
|
||||
let {onClose, onConfirm, title = "Publicar para venta", btntext = "Publicar a la venta"
|
||||
} : {
|
||||
onClose:()=>void, onConfirm:(data:setVenta)=>void, title:string, btntext:string
|
||||
} = $props();
|
||||
|
||||
let data:setVenta = $state({iddivisa:0, idpropiedad:0, monto:0});
|
||||
let monto:number = $state(0);
|
||||
|
||||
|
||||
function handleSubmit(e: Event) {
|
||||
e.preventDefault();
|
||||
onConfirm();onClose();
|
||||
onConfirm(data);onClose();
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -14,7 +19,7 @@
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Contrato</h5>
|
||||
<h5 class="modal-title">{title}</h5>
|
||||
<button type="button" class="btn-close" onclick={onClose} aria-label="Cerrar"></button>
|
||||
</div>
|
||||
|
||||
@@ -25,17 +30,23 @@
|
||||
type="number"
|
||||
id="monto"
|
||||
class="form-control"
|
||||
bind:value={monto}
|
||||
bind:value={data.monto}
|
||||
placeholder="0"
|
||||
required
|
||||
/>
|
||||
<label for="monto">Monto</label>
|
||||
</div>
|
||||
|
||||
<label for="divisa">divisa</label>
|
||||
<select id="divisa" class="form-select">
|
||||
<option value="0" selected>AR$</option>
|
||||
<option value="1">US$</option>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" onclick={(e)=> handleSubmit(e)}>Publicar a la venta</button>
|
||||
<button class="btn btn-primary" onclick={(e)=> handleSubmit(e)}>{btntext}</button>
|
||||
|
||||
<button class="btn btn-secondary ms-auto" onclick={onClose}>Cerrar</button>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { Navbar, NavbarBrand, NavbarToggler, NavItem, Nav, NavLink, Collapse } from "@sveltestrap/sveltestrap";
|
||||
|
||||
let isOpen:boolean = false;
|
||||
let isOpen:boolean =$state(false);
|
||||
let theme = $state(localStorage.getItem("theme") ?? "light");
|
||||
const toggleTheme = () => {
|
||||
theme = theme === "light" ? "dark" : "light";
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import { urlG } from "../stores/urlStore";
|
||||
import ModalPublicarPropiedadParaVenta from "./ModalPublicarPropiedadParaVenta.svelte";
|
||||
import type { setVenta } from "../types";
|
||||
|
||||
let modal: boolean = $state(false);
|
||||
let modalpayload: string = $state("");
|
||||
@@ -41,8 +42,27 @@
|
||||
function setventa() {
|
||||
showPublicarVenta = true;
|
||||
}
|
||||
async function sendMod() {
|
||||
|
||||
async function sendMod(data:setVenta) {
|
||||
data.idpropiedad = id;
|
||||
try {
|
||||
const responce = await fetch(String($urlG)+"/api/propiedad/setPropiedadAVenta", {
|
||||
method: "PUT",
|
||||
headers:{
|
||||
'Auth' : String(sessionStorage.getItem("token")),
|
||||
'Content-Type': "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if(responce.ok){
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
const json = await responce.json();
|
||||
modalpayload = json.message;
|
||||
modal = true;
|
||||
}catch (e){
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user