feat: Improve login event handling and form data validation in dees-simple-login component

This commit is contained in:
2025-06-19 11:50:24 +00:00
parent 1789807f90
commit d697958536
2 changed files with 43 additions and 8 deletions

View File

@@ -19,7 +19,13 @@ export const demoFunc = () => html`
name="My Application"
@login=${(e: CustomEvent) => {
console.log('Login event received:', e.detail);
alert(`Login attempted with:\nUsername: ${e.detail.formData.username}\nPassword: ${e.detail.formData.password}`);
const loginData = e.detail?.data || e.detail;
if (loginData?.username && loginData?.password) {
alert(`Login attempted with:\nUsername: ${loginData.username}\nPassword: ${loginData.password}`);
// Here you would typically validate credentials and show the slotted content
} else {
console.error('Invalid login data structure:', e.detail);
}
}}
>
<div style="padding: 40px; text-align: center;">