fixes(frontend): fixed small types/incorrect code
This commit is contained in:
parent
16cac7e111
commit
fac6df3882
5 changed files with 5 additions and 7 deletions
|
|
@ -14,7 +14,7 @@ export function getUser(): Readonly<User> | null {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isLogged(): boolean {
|
export function isLogged(): boolean {
|
||||||
return currentUser === null;
|
return currentUser !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setUser(newUser: User | null) {
|
export function setUser(newUser: User | null) {
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@ async function route(_url: string, _args: { [k: string]: string }): Promise<stri
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
addRoute('/', route)
|
addRoute('/about', route)
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,9 @@ function handleLogin(_url: string, _args: RouteHandlerParams): RouteHandlerRetur
|
||||||
const fLogin = document.querySelector<HTMLFormElement>('form#login-form');
|
const fLogin = document.querySelector<HTMLFormElement>('form#login-form');
|
||||||
if (fLogin === null)
|
if (fLogin === null)
|
||||||
return showError('Error while rendering the page: no form found');
|
return showError('Error while rendering the page: no form found');
|
||||||
showSuccess('got the form !')
|
|
||||||
fLogin.addEventListener('submit', async function(e: SubmitEvent) {
|
fLogin.addEventListener('submit', async function(e: SubmitEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let form = e.target as (HTMLFormElement | null)
|
let form = e.target as (HTMLFormElement | null);
|
||||||
if (form === null)
|
if (form === null)
|
||||||
return showError('Failed to send form...');
|
return showError('Failed to send form...');
|
||||||
let formData = Object.fromEntries((new FormData(form)).entries());
|
let formData = Object.fromEntries((new FormData(form)).entries());
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ export class RouteHandlerData {
|
||||||
if (part.startsWith(':')) {
|
if (part.startsWith(':')) {
|
||||||
let param_name = part.substring(1) // remove the :
|
let param_name = part.substring(1) // remove the :
|
||||||
// verifiy that the parameter name only contains character, underscores and numbers (not in fist char tho)
|
// 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`;
|
throw `route parameter ${idx} for url '${url}' contains illegal character`;
|
||||||
return { idx, param_name, part: null }
|
return { idx, param_name, part: null }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,7 @@ export default defineConfig({
|
||||||
hmr: {
|
hmr: {
|
||||||
protocol: 'ws',
|
protocol: 'ws',
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: '5137',
|
port: 5137,
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue