fixes(frontend): fixed small types/incorrect code

This commit is contained in:
Maieul BOYER 2025-11-10 19:16:15 +01:00 committed by Maix0
parent 16cac7e111
commit fac6df3882
5 changed files with 5 additions and 7 deletions

View file

@ -14,7 +14,7 @@ export function getUser(): Readonly<User> | null {
}
export function isLogged(): boolean {
return currentUser === null;
return currentUser !== null;
}
export function setUser(newUser: User | null) {

View file

@ -9,4 +9,4 @@ async function route(_url: string, _args: { [k: string]: string }): Promise<stri
addRoute('/', route)
addRoute('/about', route)

View file

@ -20,10 +20,9 @@ function handleLogin(_url: string, _args: RouteHandlerParams): RouteHandlerRetur
const fLogin = document.querySelector<HTMLFormElement>('form#login-form');
if (fLogin === null)
return showError('Error while rendering the page: no form found');
showSuccess('got the form !')
fLogin.addEventListener('submit', async function(e: SubmitEvent) {
e.preventDefault();
let form = e.target as (HTMLFormElement | null)
let form = e.target as (HTMLFormElement | null);
if (form === null)
return showError('Failed to send form...');
let formData = Object.fromEntries((new FormData(form)).entries());

View file

@ -61,7 +61,7 @@ export class RouteHandlerData {
if (part.startsWith(':')) {
let param_name = part.substring(1) // remove the :
// verifiy that the parameter name only contains character, underscores and numbers (not in fist char tho)
if (!param_name.match('^[a-zA-Z_][a-zA-Z_0-9]+$'))
if (!param_name.match('^[a-zA-Z_][a-zA-Z_0-9]*$'))
throw `route parameter ${idx} for url '${url}' contains illegal character`;
return { idx, param_name, part: null }
}

View file

@ -11,8 +11,7 @@ export default defineConfig({
hmr: {
protocol: 'ws',
host: 'localhost',
port: '5137',
port: 5137,
}
}
});