{
// Do nothing when already logging in
if ( this.isLoggingIn ) {
return;
}
// Reset the error
this.error = undefined;
if (this.valueIsNotEmpty(this.login) === false || this.valueIsNotEmpty(this.password) === false) {
this.error = "Login and password are required.";
this.requestUpdate();
return;
}
if (this.client === undefined) {
this.error = "Client is undefined.";
}
this.isLoggingIn = true;
const request = this.client!.routes.post.login(
this.login ?? '',
this.password ?? ''
);
const result = await request?.execute();
this.isLoggingIn = false;
if (result?.success === false) {
this.error = result.message;
this.requestUpdate();
return;
}
}
public static styles?: CSSResultGroup | undefined = css`
.login-form {
display: flex;
flex-direction: column;
gap: calc( var( --thermal-gap ) * .5 );
width: 100%;
input {
background: var( --thermal-background );
color: var( --thermal-foreground );
border: 1px solid var( --thermal-slate );
border-radius: var( --thermal-radius );
box-sizing: border-box;
padding: .5em;
text-align: center;
}
}
.login-error {
color: red;
text-align: center;
font-size: calc( var( --thermal-fs ) * .8 );
}
thermal-button::part(btn) {
width: 100%;
}
`;
protected render(): unknown {
return html`
`;
}
}