You've already forked isop-mirror
feat: implement login functionality and enhance alert styling in login page
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { FetchError } from 'ofetch';
|
import { FetchError } from 'ofetch';
|
||||||
|
const { login } = useSanctumAuth();
|
||||||
|
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
title: "Prihlásenie | ISOP",
|
title: "Prihlásenie | ISOP",
|
||||||
@@ -15,7 +16,7 @@ const rules = {
|
|||||||
|
|
||||||
const isValid = ref(false);
|
const isValid = ref(false);
|
||||||
const showPassword = ref(false);
|
const showPassword = ref(false);
|
||||||
const form = reactive({
|
const form = ref({
|
||||||
email: '',
|
email: '',
|
||||||
password: '',
|
password: '',
|
||||||
});
|
});
|
||||||
@@ -28,7 +29,7 @@ async function handleLogin() {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO: implement
|
await login(form.value);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof FetchError && e.response?.status === 422) {
|
if (e instanceof FetchError && e.response?.status === 422) {
|
||||||
error.value = e.response?._data.message;
|
error.value = e.response?._data.message;
|
||||||
@@ -46,11 +47,11 @@ async function handleLogin() {
|
|||||||
|
|
||||||
<!-- Chybová hláška -->
|
<!-- Chybová hláška -->
|
||||||
<v-alert v-if="error !== null" density="compact" :text="error" title="Chyba" type="error"
|
<v-alert v-if="error !== null" density="compact" :text="error" title="Chyba" type="error"
|
||||||
id="login-error-alert" class="mx-auto"></v-alert>
|
id="login-error-alert" class="mx-auto alert"></v-alert>
|
||||||
|
|
||||||
<!-- Čakajúca hláška -->
|
<!-- Čakajúca hláška -->
|
||||||
<v-alert v-if="loading" density="compact" text="Prosím čakajte..." title="Spracovávam" type="info"
|
<v-alert v-if="loading" density="compact" text="Prosím čakajte..." title="Spracovávam" type="info"
|
||||||
id="login-error-alert" class="mx-auto"></v-alert>
|
id="login-error-alert" class="mx-auto alert"></v-alert>
|
||||||
|
|
||||||
<v-form v-else v-model="isValid" @submit.prevent="handleLogin">
|
<v-form v-else v-model="isValid" @submit.prevent="handleLogin">
|
||||||
<v-text-field v-model="form.email" :rules="[rules.required, rules.email]" label="Email:"
|
<v-text-field v-model="form.email" :rules="[rules.required, rules.email]" label="Email:"
|
||||||
@@ -78,6 +79,10 @@ async function handleLogin() {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.alert {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.page-container {
|
.page-container {
|
||||||
max-width: 1120px;
|
max-width: 1120px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|||||||
Reference in New Issue
Block a user