Private
Public Access
feat: hecha interfaz y hooks para clientes
Signed-off-by: fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
1 parent
1948f1f426
commit
d9b76701e9
10 files changed
+557
No files matched your search
@@ -0,0 +1,58 @@
|
||||
<script lang="ts">
|
||||
import { InlineNotification, Modal } from 'carbon-components-svelte';
|
||||
import { altaCliente } from '$lib/hooks/clientes/altaCliente';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import type { Cliente } from '../../types';
|
||||
|
||||
let {
|
||||
open = $bindable(),
|
||||
onClose,
|
||||
cliente
|
||||
}: {
|
||||
open?: boolean;
|
||||
onClose?: () => void;
|
||||
cliente?: Cliente | null;
|
||||
} = $props();
|
||||
|
||||
let error = $state('');
|
||||
|
||||
async function handleSubmit(e: Event) {
|
||||
e.preventDefault();
|
||||
error = '';
|
||||
if (!cliente?.ID) {
|
||||
error = 'No se pudo obtener el cliente. Recargá la página.';
|
||||
return;
|
||||
}
|
||||
const result = await altaCliente(cliente.ID);
|
||||
if (result !== 'Ok') {
|
||||
error = result;
|
||||
return;
|
||||
}
|
||||
await invalidate('clientes:load');
|
||||
handleClose();
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
error = '';
|
||||
onClose?.();
|
||||
}
|
||||
</script>
|
||||
|
||||
<form id="altaClienteForm" onsubmit={handleSubmit}>
|
||||
<Modal
|
||||
formId="altaClienteForm"
|
||||
bind:open
|
||||
size="lg"
|
||||
modalHeading="Reactivar cliente"
|
||||
primaryButtonText="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>¿Está seguro de que desea reactivar este cliente?</p>
|
||||
</Modal>
|
||||
</form>
|
||||
Reference in new issue
Block a user