Arreglado error de ts

This commit is contained in:
2025-12-01 22:37:24 -03:00
parent 476c1308d0
commit c2c8bd58a8
2 changed files with 18 additions and 13 deletions

View File

@@ -7,20 +7,19 @@
import { register } from '@/hooks/register';
import Loader2Icon from '@lucide/svelte/icons/loader-2';
let {showAlert = $bindable() } = $props();
let { showAlert = $bindable() } = $props();
let cargando = $state(false);
let cargando = $state(false);
const setAlert = () => showAlert = true;
const setAlert = () => (showAlert = true);
let dto: RegisterDto = $state({ password: '', username: '', email: '', displayName: '' });
let dto: RegisterDto = $state({password: "", username: "", email:"", displayName: ""});
const handleSubmit = async (e: Event) => {
cargando = true;
await register(e, dto, setAlert);
cargando = false;
}
const handleSubmit = async (e: SubmitEvent) => {
cargando = true;
await register(e, dto, setAlert);
cargando = false;
};
</script>
<Card.Root>
@@ -29,7 +28,7 @@ const handleSubmit = async (e: Event) => {
<hr />
</Card.Header>
<Card.Content>
<form onsubmit={handleSubmit}>
<form onsubmit={handleSubmit}>
<Field.Group>
<Field.Field>
<Field.Label for="name">Nombre de Usuario</Field.Label>
@@ -43,7 +42,13 @@ const handleSubmit = async (e: Event) => {
<Field.Field>
<Field.Label for="email">Email</Field.Label>
<Input id="email" type="email" bind:value={dto.email} placeholder="m@ejemplo.com" required />
<Input
id="email"
type="email"
bind:value={dto.email}
placeholder="m@ejemplo.com"
required
/>
</Field.Field>
<Field.Field>
<Field.Label for="password">Contraseña</Field.Label>

View File

@@ -2,7 +2,7 @@ import { apiBase } from "@/stores/url";
import { goto } from "$app/navigation";
import type { RegisterDto } from "../../types";
export async function register(e:FormDataEvent,dto: RegisterDto, callbackfn:()=>void){
export async function register(e: SubmitEvent, dto: RegisterDto, callbackfn:()=>void){
e.preventDefault();
if (dto.password == "" || dto.username == "" ||
!dto.email?.includes("@") || dto.displayName=="") return;