1. Update first controller:
- Add new method `CaminarContraAdmin` for changing contrasection
- Include HTTP PATCH handler
- Use camelCase for class names
2. Update second controller:
- Update method name from `caminarContraseña` to `caminarContraAdmin`
- Fix message "contraseña" to be more precise ("contraseña correcta")
3. Update modal component:
- Change `handleSubmit` event from `submit` (JS) to `POST` (Svelte)
- Ensure form validation in JavaScript
4. Update page admin/users to use CardLink for links
This commit is contained in:
@@ -4,6 +4,13 @@
|
||||
submit,
|
||||
}: { close: () => void; submit: (e: Event, pass: string) => void } =
|
||||
$props();
|
||||
|
||||
let password: string = $state("");
|
||||
|
||||
function handleSubmit(e: Event) {
|
||||
e.preventDefault();
|
||||
submit(e, password);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
@@ -23,27 +30,26 @@
|
||||
></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form onsubmit={submit}>
|
||||
<!--
|
||||
|
||||
<form onsubmit={handleSubmit}>
|
||||
<div class="mb-3">
|
||||
<label for="nombre" class="form-label">Nombre</label>
|
||||
<input type="text" id="nombre" class="form-control" bind:value={cli.nombre} required />
|
||||
<label for="password" class="form-label"
|
||||
>Contraseña</label
|
||||
>
|
||||
<input
|
||||
type="password"
|
||||
id="password"
|
||||
class="form-control"
|
||||
minlength="8"
|
||||
required
|
||||
bind:value={password}
|
||||
/>
|
||||
<div class="form-text">
|
||||
La contraseña debe tener al menos 8 caracteres.
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="apellido" class="form-label">Apellido</label>
|
||||
<input type="text" id="apellido" class="form-control" bind:value={cli.apellido} required />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="domicilio" class="form-label">Domicilio</label>
|
||||
<input type="text" id="domicilio" class="form-control" bind:value={cli.domicilio} required />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="celular" class="form-label">Celular</label>
|
||||
<input type="tel" id="celular" class="form-control" bind:value={cli.celular} required />
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary" onclick={(e)=>handleConfirm(e)}>Guardar</button>
|
||||
-->
|
||||
<button type="submit" class="btn btn-primary"
|
||||
>Guardar</button
|
||||
>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||
import { fade, fly } from "svelte/transition";
|
||||
import ModalModificarPropietarios from "../Componentes/ModalModificarPropietarios.svelte";
|
||||
import { CardLink } from "@sveltestrap/sveltestrap";
|
||||
import { CardLink, Modal } from "@sveltestrap/sveltestrap";
|
||||
import ModalRestablecerContra from "../Componentes/ModalRestablecerContra.svelte";
|
||||
|
||||
let Clientes: Cliente[] = $state([]);
|
||||
@@ -248,20 +248,21 @@
|
||||
async function handleRestablecerContraseña(e: Event, pass: string) {
|
||||
e.preventDefault();
|
||||
try {
|
||||
const req = await fetch($urlG + "", {
|
||||
method: "POST",
|
||||
const req = await fetch($urlG + "/api/admin/contraseña", {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
Auth: token || "",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
Dni: restablecercontracli?.dni,
|
||||
Pass: pass,
|
||||
contraseña: pass,
|
||||
}),
|
||||
});
|
||||
//WIP
|
||||
if (req.ok) {
|
||||
}
|
||||
const js = await req.json();
|
||||
showmodalrestablecercontra = false;
|
||||
restablecercontracli = null;
|
||||
modaldata = js.message;
|
||||
} catch {
|
||||
modaldata = "Falla la conexion al servidor";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user