feat: terminado tema desabilitacion cliente
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
<strong>Piso:</strong> {prop.piso || "N/A"}<br>
|
||||
<strong>Letra:</strong> {prop.letra || "N/A"}<br>
|
||||
<strong>Servicios:</strong> {prop.servicios || "Sin servicios especificados"}
|
||||
<strong>Monto:</strong> {prop.monto}<br>
|
||||
</p>
|
||||
<button class="btn btn-primary">Consultar</button>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import ModalEstatico from "./ModalEstatico.svelte";
|
||||
import ModificarPropiedadForm from "./modificarPropiedadForm.svelte";
|
||||
|
||||
let { id, ubicacion, tipo, letra, piso,canthabitaciones, servicios, btnbaja = "Baja" } = $props();
|
||||
let { id, ubicacion, tipo, letra, piso,canthabitaciones, servicios, btnbaja = "Baja", monto } = $props();
|
||||
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
<td>{piso}</td>
|
||||
<td>{tipo}</td>
|
||||
<td>{servicios}</td>
|
||||
<td>{monto}</td>
|
||||
<td class="text-end">
|
||||
<button class="btn btn-outline-secondary" onclick={()=> setmod()}>Modificar</button>
|
||||
<button class="btn btn-outline-danger" onclick={() => BajaPropiedad()}>{btnbaja}</button>
|
||||
@@ -56,7 +57,7 @@
|
||||
{#if modificar}
|
||||
<tr transition:fade={{duration:100}}>
|
||||
<td colspan="8">
|
||||
<ModificarPropiedadForm {id} {ubicacion} {canthabitaciones} {letra} {piso} {tipo} {servicios}/>
|
||||
<ModificarPropiedadForm {id} {ubicacion} {canthabitaciones} {letra} {piso} {tipo} {servicios} {monto}/>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { urlG } from "../stores/urlStore";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
let { canthabitaciones, id, letra, piso, tipo, ubicacion, servicios } = $props();
|
||||
let { canthabitaciones, id, letra, piso, tipo, ubicacion, servicios, monto } = $props();
|
||||
let serviciosSeleccionados: string[] = $state([]);
|
||||
const serviciosDisponibles = ["Gas", "Internet", "Telefono", "Luz"];
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
ubicacion,
|
||||
email,
|
||||
servicios: serviciosSeleccionados,
|
||||
monto
|
||||
}),
|
||||
});
|
||||
if (response.ok) {
|
||||
@@ -116,6 +117,17 @@
|
||||
/>
|
||||
<label for="piso">Piso</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="number"
|
||||
id="monto"
|
||||
class="form-control"
|
||||
bind:value={monto}
|
||||
min="1"
|
||||
placeholder={monto}
|
||||
/>
|
||||
<label for="monto">Monto</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="text"
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
let Grupos:any[] = $state([]);
|
||||
let modaldata = $state();
|
||||
let token = sessionStorage.getItem("token");
|
||||
let showAddmenu: boolean = $state(false)
|
||||
let showAddmenu: boolean = $state(false);
|
||||
|
||||
let grupo:string;
|
||||
let SelCliente: Cliente = $state();
|
||||
|
||||
onMount(async () => {
|
||||
try{
|
||||
@@ -33,9 +36,9 @@
|
||||
|
||||
});
|
||||
|
||||
async function cargaGrupos(dni: number){
|
||||
async function cargaGrupos(cli: Cliente){
|
||||
try {
|
||||
const response = await fetch($urlG+"/api/admin/clientes/grupo?Dni="+dni, {
|
||||
const response = await fetch($urlG+"/api/admin/clientes/grupo?Dni="+cli.dni, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
@@ -45,6 +48,7 @@
|
||||
let data = await response.json();
|
||||
Grupos = data;
|
||||
showAddmenu = true;
|
||||
SelCliente = cli;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,6 +78,67 @@
|
||||
}
|
||||
|
||||
}
|
||||
async function añadirGrupo(e:Event, cli: Cliente, grupo:string){
|
||||
e.preventDefault();
|
||||
if (cli.dni == 0 || cli.email == "" || grupo == ""){
|
||||
modaldata = "No se selecciono un cliente o Grupo";
|
||||
return;
|
||||
}
|
||||
const email = cli.email;
|
||||
try {
|
||||
const response = await fetch($urlG+"/api/admin/cliente/addGrupo", {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
'Content-Type' : 'application/json',
|
||||
},
|
||||
body: JSON.stringify({email, grupo})
|
||||
});
|
||||
|
||||
if (response.ok){
|
||||
let data = await response.json();
|
||||
modaldata = data.message;
|
||||
cargaGrupos(cli);
|
||||
return;
|
||||
}
|
||||
let data = await response.json();
|
||||
modaldata = data.message;
|
||||
} catch {
|
||||
modaldata = "Falla la conexion al servidor";
|
||||
}
|
||||
}
|
||||
async function BajaGrupo(e:Event, cli: Cliente, grupo:string){
|
||||
e.preventDefault();
|
||||
if (cli.dni == 0 || cli.email == "" || grupo == ""){
|
||||
modaldata = "No se selecciono un cliente o Grupo";
|
||||
return;
|
||||
}
|
||||
const email = cli.email;
|
||||
if (grupo === "Propietario"){
|
||||
if (confirm("Sos propietario si te desactivas de ese rol tus propiedades se van a dar de baja, Estas seguro?") == false) return;
|
||||
}
|
||||
try {
|
||||
const response = await fetch($urlG+"/api/admin/cliente/rmGrupo", {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
'Content-Type' : 'application/json',
|
||||
},
|
||||
body: JSON.stringify({email, grupo})
|
||||
});
|
||||
|
||||
if (response.ok){
|
||||
let data = await response.json();
|
||||
modaldata = data.message;
|
||||
cargaGrupos(cli);
|
||||
return;
|
||||
}
|
||||
let data = await response.json();
|
||||
modaldata = data.message;
|
||||
} catch {
|
||||
modaldata = "Falla la conexion al servidor";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -99,7 +164,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each Clientes as cli}
|
||||
<tr onclick={() => cargaGrupos(cli.dni)} in:fade>
|
||||
<tr onclick={() => cargaGrupos(cli)} in:fade>
|
||||
<td>{cli.dni}</td>
|
||||
<td>{cli.nombre}</td>
|
||||
<td>{cli.email}</td>
|
||||
@@ -131,13 +196,24 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#if Grupos.length>0}
|
||||
|
||||
{#each Grupos as g}
|
||||
<tr in:fade>
|
||||
<td>{g.id}</td>
|
||||
<td>{g.descripcion}</td>
|
||||
<td><button class="btn btn-outline-danger" onclick={()=>modaldata = "Hi babe"}>Baja</button></td>
|
||||
<td><button class="btn btn-outline-danger" onclick={(e)=>BajaGrupo(e, SelCliente, g.descripcion)}>Baja</button></td>
|
||||
</tr>
|
||||
{/each}
|
||||
{:else if SelCliente != null}
|
||||
<tr>
|
||||
<td colspan="2">Este Cliente no tiene Grupos</td>
|
||||
</tr>
|
||||
{:else}
|
||||
<tr>
|
||||
<td colspan="2">Seleccione un cliente para ver sus grupos</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -145,14 +221,14 @@
|
||||
<div in:fade>
|
||||
|
||||
<BarraHorizontalConTexto text="Añadir Grupos al Usuario"/>
|
||||
<form class="card card-body">
|
||||
<form class="card card-body" onsubmit={(e) => añadirGrupo(e,SelCliente, grupo)}>
|
||||
<div class="mb-3">
|
||||
<label for="userRole" class="form-label">Seleccionar Grupo</label>
|
||||
<select id="userRole" class="form-select">
|
||||
<option value="1">Propietario</option>
|
||||
<option value="2">Inquilino</option>
|
||||
<option value="3">Admin</option>
|
||||
<option value="4">Informes</option>
|
||||
<select id="userRole" class="form-select" bind:value={grupo}>
|
||||
<option value="Propietario">Propietario</option>
|
||||
<option value="Inquilino">Inquilino</option>
|
||||
<option value="Admin">Admin</option>
|
||||
<option value="Informes">Informes</option>
|
||||
</select>
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit">Añadir</button>
|
||||
|
||||
@@ -52,12 +52,13 @@
|
||||
<th>Piso</th>
|
||||
<th>Tipo</th>
|
||||
<th>Servicios</th>
|
||||
<th>Monto</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each $propiedades as propiedad}
|
||||
<RowPropiedad id={propiedad.id} ubicacion={propiedad.ubicacion} letra={propiedad.letra} piso={propiedad.piso} tipo={propiedad.tipo} canthabitaciones={propiedad.canthabitaciones} servicios={propiedad.servicios} />
|
||||
<RowPropiedad id={propiedad.id} ubicacion={propiedad.ubicacion} letra={propiedad.letra} piso={propiedad.piso} tipo={propiedad.tipo} canthabitaciones={propiedad.canthabitaciones} servicios={propiedad.servicios} monto={propiedad.monto} />
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -53,12 +53,13 @@
|
||||
<th>Piso</th>
|
||||
<th>Tipo</th>
|
||||
<th>Servicios</th>
|
||||
<th>Monto</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each $propiedades as propiedad}
|
||||
<RowPropiedad id={propiedad.id} ubicacion={propiedad.ubicacion} letra={propiedad.letra} piso={propiedad.piso} tipo={propiedad.tipo} canthabitaciones={propiedad.canthabitaciones} servicios={propiedad.servicios} btnbaja={"Alta"}/>
|
||||
<RowPropiedad id={propiedad.id} ubicacion={propiedad.ubicacion} letra={propiedad.letra} piso={propiedad.piso} tipo={propiedad.tipo} canthabitaciones={propiedad.canthabitaciones} servicios={propiedad.servicios} btnbaja={"Alta"} monto={propiedad.monto}/>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
letra: "",
|
||||
email: localStorage.getItem("email") || "",
|
||||
idtipropiedad: 1,
|
||||
monto: 1,
|
||||
};
|
||||
|
||||
let token = sessionStorage.getItem("token");
|
||||
@@ -93,6 +94,17 @@
|
||||
/>
|
||||
<label for="piso">Piso</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="number"
|
||||
id="monto"
|
||||
class="form-control"
|
||||
bind:value={propiedad.monto}
|
||||
min="1"
|
||||
placeholder="1"
|
||||
/>
|
||||
<label for="monto">Monto</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input
|
||||
type="text"
|
||||
|
||||
4
Front/src/types.d.ts
vendored
4
Front/src/types.d.ts
vendored
@@ -5,7 +5,8 @@ export type PropiedadDto = {
|
||||
piso: string | null,
|
||||
letra: string | null,
|
||||
canthabitaciones: number,
|
||||
servicios: string
|
||||
servicios: string,
|
||||
monto: number
|
||||
}
|
||||
export type Permiso = {
|
||||
id: number;
|
||||
@@ -32,4 +33,5 @@ export type Propiedad = {
|
||||
letra: string,
|
||||
email: string,
|
||||
idtipropiedad: number,
|
||||
monto: number
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user