fix(msg): show correct messages
This commit is contained in:
parent
aca2dbd070
commit
a1a896daf2
4 changed files with 20 additions and 9 deletions
|
|
@ -92,7 +92,7 @@ async function handleOtp(
|
||||||
});
|
});
|
||||||
navigateTo(returnTo ?? "/");
|
navigateTo(returnTo ?? "/");
|
||||||
} else if (res.kind === "failed") {
|
} else if (res.kind === "failed") {
|
||||||
showError(`Failed to authenticate: ${res.msg}`);
|
showError(`Failed to authenticate`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,7 @@ async function route(url: string, _args: { [k: string]: string }) {
|
||||||
if (res.kind === "success") {
|
if (res.kind === "success") {
|
||||||
navigateTo(url);
|
navigateTo(url);
|
||||||
} else {
|
} 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") {
|
if (res.kind === "success") {
|
||||||
navigateTo(url);
|
navigateTo(url);
|
||||||
} else {
|
} 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");
|
showSuccess("Successfully changed display name");
|
||||||
handleRoute();
|
handleRoute();
|
||||||
} else {
|
} else {
|
||||||
showError(`Failed to update: ${req.msg}`);
|
showError(`Failed to update`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
passwordButton.onclick = async () => {
|
passwordButton.onclick = async () => {
|
||||||
|
|
@ -265,7 +265,7 @@ async function route(url: string, _args: { [k: string]: string }) {
|
||||||
showSuccess("Successfully changed password");
|
showSuccess("Successfully changed password");
|
||||||
handleRoute();
|
handleRoute();
|
||||||
} else {
|
} else {
|
||||||
showError(`Failed to update: ${req.msg}`);
|
showError(`Failed to update`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
descButton.onclick = async () => {
|
descButton.onclick = async () => {
|
||||||
|
|
@ -275,7 +275,7 @@ async function route(url: string, _args: { [k: string]: string }) {
|
||||||
handleRoute();
|
handleRoute();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
showError(`Failed to update: ${req.msg}`);
|
showError(`Failed to update`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,17 @@ import loggedInHtml from './alreadyLoggedin.html?raw';
|
||||||
import { isNullish } from "@app/utils";
|
import { isNullish } from "@app/utils";
|
||||||
import cuteCat from './cuteCat.png';
|
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> {
|
async function handleSignin(_url: string, _args: RouteHandlerParams): Promise<RouteHandlerReturn> {
|
||||||
setTitle('Signin')
|
setTitle('Signin')
|
||||||
let user = await updateUser();
|
let user = await updateUser();
|
||||||
|
|
@ -72,7 +83,7 @@ async function handleSignin(_url: string, _args: RouteHandlerParams): Promise<Ro
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'failed': {
|
case 'failed': {
|
||||||
showError(`Failed to signin: ${res.msg}`);
|
showError(`Failed to signin: ${MSG_KEY_TO_STRING[res.msg]}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ async function tourHistoryAll(_url: string, args: RouteHandlerParams): Promise<R
|
||||||
|
|
||||||
let data = await client.tournamentList();
|
let data = await client.tournamentList();
|
||||||
if (data.kind !== 'success') {
|
if (data.kind !== 'success') {
|
||||||
showError(`Failed to fetch data: ${data.msg}`);
|
showError(`Failed to fetch data`);
|
||||||
return {
|
return {
|
||||||
html: "", postInsert: async () => navigateTo('/')
|
html: "", postInsert: async () => navigateTo('/')
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +79,7 @@ async function tourHistorySingle(_url: string, args: RouteHandlerParams): Promis
|
||||||
|
|
||||||
let data = await client.tournamentData({ id: args.tourid });
|
let data = await client.tournamentData({ id: args.tourid });
|
||||||
if (data.kind !== 'success') {
|
if (data.kind !== 'success') {
|
||||||
showError(`Failed to fetch data: ${data.msg}`);
|
showError(`Failed to fetch data`);
|
||||||
return {
|
return {
|
||||||
html: "", postInsert: async () => navigateTo('/')
|
html: "", postInsert: async () => navigateTo('/')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue