Skip to content

Commit

Permalink
Add loading to button on login and register
Browse files Browse the repository at this point in the history
  • Loading branch information
siard-y committed Aug 10, 2024
1 parent 1778f4f commit 3075bb2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/components/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
dense
type="password"
/>
<v-btn type="submit" color="primary" block class="mt-4">
<v-btn type="submit" color="primary" :loading="isLoading" block class="mt-4">
Inloggen
</v-btn>
</v-form>
Expand All @@ -29,10 +29,12 @@ const auth = useFirebaseAuth();
const username = ref('');
const password = ref('');
const isLoading = ref(false);
const emit = defineEmits(['login-success']);
const login = () => {
isLoading.value = true;
signInWithEmailAndPassword(auth, username.value, password.value)
.then((userCredential) => {
console.log('User logged-in as: ' + userCredential.user.email);
Expand Down Expand Up @@ -62,6 +64,9 @@ const login = () => {
console.error(`User login failed: ${code} - ${message}`);
break;
}
})
.finally(() => {
isLoading.value = false;
});
};
</script>
7 changes: 6 additions & 1 deletion src/components/RegisterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
dense
type="password"
/>
<v-btn type="submit" color="secondary" block class="mt-4">
<v-btn type="submit" color="secondary" :loading="isLoading" block class="mt-4">
Registreren
</v-btn>
</v-form>
Expand All @@ -39,10 +39,12 @@ import {useFirebaseAuth, useCurrentUser} from 'vuefire'
const auth = useFirebaseAuth();
const username = ref('');
const password = ref('');
const isLoading = ref(false);
const emit = defineEmits(['register-success']);
const register = () => {
isLoading.value = true;
createUserWithEmailAndPassword(auth, username.value, password.value)
.then((userCredential) => {
const currentUser = useCurrentUser();
Expand All @@ -64,6 +66,9 @@ const register = () => {
console.error(`User creation failed: ${code} - ${message}`);
break;
}
})
.finally(() => {
isLoading.value = false;
});
};
</script>
2 changes: 1 addition & 1 deletion src/components/ResetPasswordAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const verifyCode = () => {
const handleResetPassword = () => {
if (newPassword.value !== confirmPassword.value) {
emit('error', 'De ingevoerde wachtwoorden zijn niet hetzelfde.');
emit('error', 'De ingevoerde wachtwoorden komen niet overeen.');
return;
}
Expand Down

0 comments on commit 3075bb2

Please sign in to comment.