fix(msg): show correct messages

This commit is contained in:
Maieul BOYER 2026-01-13 14:58:41 +01:00 committed by Maix0
parent aca2dbd070
commit a1a896daf2
4 changed files with 20 additions and 9 deletions

View file

@ -92,7 +92,7 @@ async function handleOtp(
});
navigateTo(returnTo ?? "/");
} else if (res.kind === "failed") {
showError(`Failed to authenticate: ${res.msg}`);
showError(`Failed to authenticate`);
}
}
}

View file

@ -221,7 +221,7 @@ async function route(url: string, _args: { [k: string]: string }) {
if (res.kind === "success") {
navigateTo(url);
} else {
showError(`failed to activate OTP: ${res.msg}`);
showError(`failed to activate OTP`);
}
};
@ -230,7 +230,7 @@ async function route(url: string, _args: { [k: string]: string }) {
if (res.kind === "success") {
navigateTo(url);
} else {
showError(`failed to deactivate OTP: ${res.msg}`);
showError(`failed to deactivate OTP`);
}
};
@ -252,7 +252,7 @@ async function route(url: string, _args: { [k: string]: string }) {
showSuccess("Successfully changed display name");
handleRoute();
} else {
showError(`Failed to update: ${req.msg}`);
showError(`Failed to update`);
}
};
passwordButton.onclick = async () => {
@ -265,7 +265,7 @@ async function route(url: string, _args: { [k: string]: string }) {
showSuccess("Successfully changed password");
handleRoute();
} else {
showError(`Failed to update: ${req.msg}`);
showError(`Failed to update`);
}
};
descButton.onclick = async () => {
@ -275,7 +275,7 @@ async function route(url: string, _args: { [k: string]: string }) {
handleRoute();
}
else {
showError(`Failed to update: ${req.msg}`);
showError(`Failed to update`);
}
};

View file

@ -8,6 +8,17 @@ import loggedInHtml from './alreadyLoggedin.html?raw';
import { isNullish } from "@app/utils";
import cuteCat from './cuteCat.png';
const MSG_KEY_TO_STRING = {
'signin.failed.username.existing': 'Username already exists',
'signin.failed.username.toolong': 'Username is too short',
'signin.failed.username.tooshort': 'Username is too long',
'signin.failed.username.invalid': 'Username is invalid',
'signin.failed.password.toolong': 'Password is too long',
'signin.failed.password.tooshort': 'Password is too short',
'signin.failed.password.invalid': 'Password is invalid',
'signin.failed.generic': 'Unknown Error',
};
async function handleSignin(_url: string, _args: RouteHandlerParams): Promise<RouteHandlerReturn> {
setTitle('Signin')
let user = await updateUser();
@ -72,7 +83,7 @@ async function handleSignin(_url: string, _args: RouteHandlerParams): Promise<Ro
break;
}
case 'failed': {
showError(`Failed to signin: ${res.msg}`);
showError(`Failed to signin: ${MSG_KEY_TO_STRING[res.msg]}`);
}
}
} catch (e) {

View file

@ -17,7 +17,7 @@ async function tourHistoryAll(_url: string, args: RouteHandlerParams): Promise<R
let data = await client.tournamentList();
if (data.kind !== 'success') {
showError(`Failed to fetch data: ${data.msg}`);
showError(`Failed to fetch data`);
return {
html: "", postInsert: async () => navigateTo('/')
}
@ -79,7 +79,7 @@ async function tourHistorySingle(_url: string, args: RouteHandlerParams): Promis
let data = await client.tournamentData({ id: args.tourid });
if (data.kind !== 'success') {
showError(`Failed to fetch data: ${data.msg}`);
showError(`Failed to fetch data`);
return {
html: "", postInsert: async () => navigateTo('/')
}