Skip to content

Commit

Permalink
Show spinner whilst attempting 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 79d3255 commit 359f399
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion resources/assets/js/prototype/screens/Login.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<script setup>
import axios from 'axios';
import { Loader2 } from 'lucide-vue';
import { getCurrentInstance, ref } from 'vue';
const router = getCurrentInstance().proxy.$router;
const isBusy = ref(false);
const email = ref('');
const password = ref('');
const logIn = () => {
isBusy.value = true;
axios
.post('/api/log-in', { email: email.value, password: password.value })
.then(response => {
Expand All @@ -24,10 +28,16 @@ const logIn = () => {
}
if (json.error) {
isBusy.value = false;
password.value = '';
alert('Unable to log in');
}
})
.catch(() => {
isBusy.value = false;
password.value = '';
alert('Unable to log in');
});
};
Expand All @@ -45,7 +55,12 @@ const logIn = () => {
<label class="block mb-2 text-sm dark:text-white">{{ $t('password') }}</label>
<input class="w-full px-3.5 py-2.5 text-sm dark:text-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-lg" type="password" v-model="password" @keyup.enter="logIn" />
</div>
<button class="w-full py-3 text-sm text-white bg-gray-900 dark:bg-gray-950 rounded-lg" @click="logIn">{{ $t('logIn') }}</button>
<button class="w-full py-3 text-sm text-white bg-gray-900 dark:bg-gray-950 rounded-lg" @click="logIn">
<span v-if="!isBusy">{{ $t('logIn') }}</span>
<div v-if="isBusy" class="flex justify-center h-5">
<Loader2 class="animate-spin" :size="18" :strokeWidth="2.4" />
</div>
</button>
</div>
<div class="mt-5 text-sm text-center dark:text-white">{{ versionNumber }}</div>
</div>
Expand Down

0 comments on commit 359f399

Please sign in to comment.