Skip to content

Commit

Permalink
Show error upon failed attempt to log in
Browse files Browse the repository at this point in the history
  • Loading branch information
range-of-motion committed Aug 31, 2024
1 parent 4aa1530 commit 729e0fb
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions resources/assets/js/prototype/screens/Login.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<script setup>
import axios from 'axios';
import { Loader2 } from 'lucide-vue';
import { getCurrentInstance, ref } from 'vue';
import { XCircle, Loader2 } from 'lucide-vue';
import { getCurrentInstance, ref, watch } from 'vue';
const router = getCurrentInstance().proxy.$router;
const isBusy = ref(false);
const showError = ref(false);
const email = ref('');
const password = ref('');
Expand All @@ -29,18 +30,24 @@ const logIn = () => {
if (json.error) {
isBusy.value = false;
showError.value = true;
password.value = '';
alert('Unable to log in');
}
})
.catch(() => {
isBusy.value = false;
showError.value = true;
password.value = '';
alert('Unable to log in');
});
};
watch(showError, value => {
if (value === true) {
setTimeout(() => {
showError.value = false;
}, 5000);
}
});
</script>

<template>
Expand All @@ -64,5 +71,11 @@ const logIn = () => {
</div>
<div class="mt-5 text-sm text-center dark:text-white">{{ versionNumber }}</div>
</div>
<div v-if="showError" class="absolute top-0 left-0 right-0 flex">
<div class="mt-10 mx-auto py-3 px-5 flex bg-white border border-gray-200 rounded-lg shadow-sm">
<XCircle class="text-red-600" :size="20" />
<div class="ml-3 text-sm">Unable to log in</div>
</div>
</div>
</div>
</template>

0 comments on commit 729e0fb

Please sign in to comment.