Private
Public Access
fix+feat: añadido crear usuario y separado en componentes los modals
This commit is contained in:
1 parent
eff116fab0
commit
62ec25b768
14 files changed
+387
-131
No files matched your search
@@ -0,0 +1,51 @@
|
||||
<script lang="ts">
|
||||
import { Button, Modal, PasswordInput } from 'carbon-components-svelte';
|
||||
import { cambiarContraseña } from '$lib/hooks/cambiarContraseña.js';
|
||||
|
||||
let {
|
||||
show = $bindable(),
|
||||
onclose,
|
||||
usuario
|
||||
}: { show?: boolean; onclose: () => void; usuario: { id: number } } = $props();
|
||||
|
||||
let password = $state('');
|
||||
let error = $state('');
|
||||
|
||||
async function handleSubmit(e: Event) {
|
||||
e.preventDefault();
|
||||
error = '';
|
||||
const result = await cambiarContraseña({
|
||||
old_password: 'adminoverride',
|
||||
new_password: password,
|
||||
user_id: usuario.id
|
||||
});
|
||||
if (result !== 'Ok') {
|
||||
error = result;
|
||||
return;
|
||||
}
|
||||
password = '';
|
||||
onclose();
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
password = '';
|
||||
error = '';
|
||||
onclose();
|
||||
}
|
||||
</script>
|
||||
|
||||
<form id="cambiarForm" onsubmit={handleSubmit}>
|
||||
<Modal
|
||||
formId="cambiarForm"
|
||||
bind:open={show}
|
||||
modalHeading="Cambiar Contraseña"
|
||||
primaryButtonText="Aceptar"
|
||||
secondaryButtonText="Cerrar"
|
||||
on:click:button--secondary={handleClose}
|
||||
>
|
||||
{#if error}
|
||||
<div class="text-red-500">{error}</div>
|
||||
{/if}
|
||||
<PasswordInput labelText="Nueva Contraseña: " minlength={8} bind:value={password} />
|
||||
</Modal>
|
||||
</form>
|
||||
Reference in new issue
Block a user