Private
Public Access
feat: hecho formulario de alta usuario
Signed-off-by: fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
1 parent
405eaca25c
commit
1948f1f426
1 file changed
+65
@@ -0,0 +1,65 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { InlineNotification, Modal } from 'carbon-components-svelte';
|
||||||
|
import { altaMiembro } from '$lib/hooks/tenant';
|
||||||
|
import type { Miembro } from '../../types';
|
||||||
|
|
||||||
|
let {
|
||||||
|
show = $bindable(),
|
||||||
|
onclose,
|
||||||
|
usuario,
|
||||||
|
onalta
|
||||||
|
}: {
|
||||||
|
show?: boolean;
|
||||||
|
onclose: () => void;
|
||||||
|
usuario: Partial<Miembro> & { id: number };
|
||||||
|
onalta?: () => void;
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let error = $state('');
|
||||||
|
let guardando = $state(false);
|
||||||
|
|
||||||
|
async function handleSubmit(e: Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
error = '';
|
||||||
|
if (!usuario.id) {
|
||||||
|
error = 'No se pudo obtener el usuario. Recargá la página.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
guardando = true;
|
||||||
|
try {
|
||||||
|
await altaMiembro(usuario.id);
|
||||||
|
onalta?.();
|
||||||
|
onclose();
|
||||||
|
} catch (e) {
|
||||||
|
error = e instanceof Error ? e.message : 'No se pudo reactivar el miembro';
|
||||||
|
} finally {
|
||||||
|
guardando = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClose() {
|
||||||
|
error = '';
|
||||||
|
onclose();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<form id="altaUsuarioForm" onsubmit={handleSubmit}>
|
||||||
|
<Modal
|
||||||
|
formId="altaUsuarioForm"
|
||||||
|
bind:open={show}
|
||||||
|
modalHeading="Reactivar miembro"
|
||||||
|
primaryButtonText={guardando ? 'Reactivando...' : 'Reactivar'}
|
||||||
|
secondaryButtonText="Cancelar"
|
||||||
|
on:click:button--secondary={handleClose}
|
||||||
|
>
|
||||||
|
{#if error}
|
||||||
|
<div class="mb-4">
|
||||||
|
<InlineNotification kind="error" title="Error" subtitle={error} hideCloseButton />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
<p>
|
||||||
|
¿Querés reactivar a <strong>{usuario.email}</strong> en la empresa? Volverá a tener acceso con su
|
||||||
|
rol anterior. Los grupos que tenía asignados deberán configurarse nuevamente.
|
||||||
|
</p>
|
||||||
|
</Modal>
|
||||||
|
</form>
|
||||||
Reference in new issue
Block a user