Formatting cleaning

This commit is contained in:
Florian Sylvain
2022-12-30 02:40:36 +01:00
parent 948243525e
commit 7107e4e867
+11 -9
View File
@@ -5,13 +5,13 @@ import { setCookie } from '@/utils/cookies';
import { ref, type Ref } from 'vue'; import { ref, type Ref } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
const isTokenOK: Ref<boolean|undefined> = ref(undefined) const isTokenOK: Ref<boolean | undefined> = ref(undefined)
const router = useRouter() const router = useRouter()
const authStore = useAuthStore() const authStore = useAuthStore()
const email = ref('') const email = ref('')
const password = ref('') const password = ref('')
const isFormEmpty: ()=>boolean = () => { const isFormEmpty: () => boolean = () => {
return email.value === '' || password.value === '' return email.value === '' || password.value === ''
} }
@@ -59,7 +59,7 @@ function login(email: string, password: string): void {
.then(response => response.json()) .then(response => response.json())
.then(result => { .then(result => {
jwtHandler(result) jwtHandler(result)
if (isTokenOK.value === true) { if (isTokenOK.value === true) {
router.push('/home') router.push('/home')
} }
}) })
@@ -70,7 +70,7 @@ function login(email: string, password: string): void {
<div class="login-page"> <div class="login-page">
<div class="login-form"> <div class="login-form">
<h2>Connexion à <span style="color:var(--brand-blue)">Go</span>hCMS</h2> <h2>Connexion à <span style="color:var(--brand-blue)">Go</span>hCMS</h2>
<form @submit.prevent="login(email, password)"> <form @submit.prevent="login(email, password)">
<div class="inputs-group"> <div class="inputs-group">
<div :class="`label-input${isTokenOK === false ? '-error' : ''}`"> <div :class="`label-input${isTokenOK === false ? '-error' : ''}`">
@@ -79,12 +79,14 @@ function login(email: string, password: string): void {
</div> </div>
<div :class="`label-input${isTokenOK === false ? '-error' : ''}`"> <div :class="`label-input${isTokenOK === false ? '-error' : ''}`">
<label for="password">Mot de passe</label> <label for="password">Mot de passe</label>
<input id="password" name="password" placeholder="Mot de passe" type="password" v-model="password"> <input id="password" name="password" placeholder="Mot de passe" type="password"
v-model="password">
<p v-if="isTokenOK === false"> E-mail et/ou mot de passe incorrect(s).</p> <p v-if="isTokenOK === false"> E-mail et/ou mot de passe incorrect(s).</p>
<p v-else-if="useErrorsStore().sessionExpired"> Votre session a expiré.</p> <p v-else-if="useErrorsStore().sessionExpired"> Votre session a expiré.</p>
</div> </div>
</div> </div>
<button :class="`button-${isFormEmpty() ? 'disabled' : 'primary'}`" type="submit" :disabled="isFormEmpty()"> <button :class="`button-${isFormEmpty() ? 'disabled' : 'primary'}`" type="submit"
:disabled="isFormEmpty()">
Se connecter Se connecter
</button> </button>
</form> </form>
@@ -93,11 +95,11 @@ function login(email: string, password: string): void {
</template> </template>
<style scoped> <style scoped>
h2 { h2 {
margin: 0 0 16px 0; margin: 0 0 16px 0;
} }
h2 span { h2 span {
font-family: inherit; font-family: inherit;
} }
@@ -112,7 +114,7 @@ h2 span {
.login-form { .login-form {
width: fit-content; width: fit-content;
max-width: 100%; max-width: 100%;
padding: 32px; padding: 32px;
} }