lang: register view

This commit is contained in:
AdrienLSH 2024-02-01 16:31:25 +01:00
parent 1bd3f1cb20
commit 3179c3c056
4 changed files with 29 additions and 13 deletions

View File

@ -19,5 +19,13 @@
"loginFormButton": "Login", "loginFormButton": "Login",
"loginNoAccount": "No account yet?", "loginNoAccount": "No account yet?",
"loginRegister": "Register", "loginRegister": "Register",
"errorEmptyField": "This field may not be blank." "errorEmptyField": "This field may not be blank.",
"logoutWindowTitle": "Logout",
"registerWindowTitle": "Register",
"registerFormTitle": "Register",
"registerFormUsername": "Username",
"registerFormPassword": "Password",
"registerFormButton": "Register",
"registerAlreadyAccount": "Already have an account?",
"registerLogin": "Login"
} }

View File

@ -19,5 +19,13 @@
"loginFormButton": "Connexion", "loginFormButton": "Connexion",
"loginNoAccount": "Pas de compte?", "loginNoAccount": "Pas de compte?",
"loginRegister": "S'inscrire", "loginRegister": "S'inscrire",
"errorEmptyField": "Ce champ ne peut être vide." "errorEmptyField": "Ce champ ne peut être vide.",
"logoutWindowTitle": "Déconnexion",
"registerWindowTitle": "S'inscrire",
"registerFormTitle": "S'inscrire",
"registerFormUsername": "Nom d'utilisateur",
"registerFormPassword": "Mot de passe",
"registerFormButton": "S'inscrire",
"registerAlreadyAccount": "Déjà un compte?",
"registerLogin": "Connexion"
} }

View File

@ -1,10 +1,10 @@
import { client, navigateTo } from "../../index.js"; import { client, lang, navigateTo } from "../../index.js";
import AbstractAuthentifiedView from "../abstracts/AbstractAuthentifiedView.js"; import AbstractAuthentifiedView from "../abstracts/AbstractAuthentifiedView.js";
export default class extends AbstractAuthentifiedView export default class extends AbstractAuthentifiedView
{ {
constructor(params, lastPageUrl = '/login') { constructor(params, lastPageUrl = '/login') {
super(params, "Logout"); super(params, lang.get('logoutWindowTitle', 'Logout'));
this.lastPageUrl = lastPageUrl; this.lastPageUrl = lastPageUrl;
} }

View File

@ -1,4 +1,4 @@
import { client, navigateTo } from "../../index.js"; import { client, lang, navigateTo } from "../../index.js";
import { clear, fill_errors } from "../../utils/formUtils.js"; import { clear, fill_errors } from "../../utils/formUtils.js";
import AbstractNonAuthentifiedView from "../abstracts/AbstractNonAuthentified.js"; import AbstractNonAuthentifiedView from "../abstracts/AbstractNonAuthentified.js";
@ -10,9 +10,9 @@ async function register(redirectTo = '/home')
if (username === '' || password === '') { if (username === '' || password === '') {
clear("innerHTML", ["username", "password"]); clear("innerHTML", ["username", "password"]);
if (username === '') if (username === '')
document.getElementById('username').innerHTML = 'This field may not be blank.'; document.getElementById('username').innerHTML = lang.get('errorEmptyField', 'This field may not be blank.');
if (password === '') if (password === '')
document.getElementById('password').innerHTML = 'This field may not be blank.'; document.getElementById('password').innerHTML = lang.get('errorEmptyField', 'This field may not be blank.');
return; return;
} }
@ -30,7 +30,7 @@ async function register(redirectTo = '/home')
export default class extends AbstractNonAuthentifiedView { export default class extends AbstractNonAuthentifiedView {
constructor(params, lastUrlBeforeLogin = '/home') { constructor(params, lastUrlBeforeLogin = '/home') {
super(params, "Register", lastUrlBeforeLogin); super(params, lang.get('registerWindowTitle', 'Register'), lastUrlBeforeLogin);
this.redirectTo = lastUrlBeforeLogin; this.redirectTo = lastUrlBeforeLogin;
} }
@ -54,21 +54,21 @@ export default class extends AbstractNonAuthentifiedView {
return ` return `
<div class='container-fluid'> <div class='container-fluid'>
<form class='border border-2 rounded bg-light-subtle mx-auto p-2 col-md-7 col-lg-4'> <form class='border border-2 rounded bg-light-subtle mx-auto p-2 col-md-7 col-lg-4'>
<h4 class='text-center fw-semibold mb-4'>Register</h4> <h4 class='text-center fw-semibold mb-4'>${lang.get('registerFormTitle', 'Register')}</h4>
<div class='form-floating mb-2'> <div class='form-floating mb-2'>
<input type='text' class='form-control' id='usernameInput' placeholder='Username'> <input type='text' class='form-control' id='usernameInput' placeholder='Username'>
<label for='usernameInput'>Username</label> <label for='usernameInput'>${lang.get('registerFormUsername', 'Username')}</label>
<span class='text-danger' id='username'></span> <span class='text-danger' id='username'></span>
</div> </div>
<div class='form-floating'> <div class='form-floating'>
<input type='password' class='form-control' id='passwordInput' placeholder='Password'> <input type='password' class='form-control' id='passwordInput' placeholder='Password'>
<label for='passwordInput'>Password</label> <label for='passwordInput'>${lang.get('registerFormPassword', 'Password')}</label>
<span class='text-danger' id='password'></span> <span class='text-danger' id='password'></span>
</div> </div>
<div class='d-flex'> <div class='d-flex'>
<button type='button' class='btn btn-primary mt-3 mb-2' id='registerButton'>Register</button> <button type='button' class='btn btn-primary mt-3 mb-2' id='registerButton'>${lang.get('registerFormButton', 'Register')}</button>
<span class='text-danger my-auto mx-2' id='register'></span> <span class='text-danger my-auto mx-2' id='register'></span>
<p class='ms-auto mt-auto'>Already have an account? <a href='/login' data-link>Login</a></p> <p class='ms-auto mt-auto'>${lang.get('registerAlreadyAccount', 'Already have an account?')} <a href='/login' data-link>${lang.get('registerLogin', 'Login')}</a></p>
</div> </div>
</form> </form>
</div> </div>