2021-06-07 17:41:25 +02:00
|
|
|
<template>
|
2021-06-25 19:28:41 +02:00
|
|
|
<div class="container">
|
2021-06-07 17:41:25 +02:00
|
|
|
<h1>Suche</h1>
|
|
|
|
<form @submit.prevent="submitSearch()">
|
2021-06-25 19:28:41 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="form-control"
|
|
|
|
id="searchText"
|
|
|
|
v-model="searchText"
|
|
|
|
required
|
|
|
|
/>
|
2021-06-07 17:41:25 +02:00
|
|
|
</div>
|
2021-06-25 19:28:41 +02:00
|
|
|
<div class="col">
|
|
|
|
<button type="submit" class="btn btn-primary mb-4">
|
|
|
|
Suche Starten
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-06-07 17:41:25 +02:00
|
|
|
</form>
|
2021-06-25 19:28:41 +02:00
|
|
|
<div
|
|
|
|
class="alert alert-danger mb-4 mt-4"
|
|
|
|
role="alert"
|
|
|
|
v-if="showErrorMessage"
|
|
|
|
>
|
|
|
|
Bei der Suche ist ein Fehler aufgetreten
|
2021-06-07 17:41:25 +02:00
|
|
|
</div>
|
2021-06-25 19:28:41 +02:00
|
|
|
</div>
|
2021-06-07 17:41:25 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
2021-06-25 19:28:41 +02:00
|
|
|
import axios from "axios";
|
2021-06-07 17:41:25 +02:00
|
|
|
|
|
|
|
export default {
|
2021-06-25 19:28:41 +02:00
|
|
|
name: "Search",
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showErrorMessage: false,
|
|
|
|
searchText: "",
|
|
|
|
};
|
2021-06-07 17:41:25 +02:00
|
|
|
},
|
|
|
|
methods: {
|
2021-06-25 19:28:41 +02:00
|
|
|
async submitSearch() {
|
|
|
|
this.showErrorMessage = false;
|
|
|
|
try {
|
|
|
|
const loginResult = await axios.post(
|
|
|
|
`${process.env.VUE_APP_API_URL}/search`,
|
|
|
|
// Beispiel Hafte Daten
|
|
|
|
{
|
|
|
|
searchText: this.searchText,
|
2021-06-07 17:41:25 +02:00
|
|
|
}
|
2021-06-25 19:28:41 +02:00
|
|
|
);
|
|
|
|
if (loginResult.status === 200) {
|
|
|
|
//success login
|
|
|
|
this.router.push({ path: "s/search" });
|
|
|
|
} else {
|
|
|
|
this.showErrorMessage = true;
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error();
|
|
|
|
this.showErrorMessage = true;
|
2021-06-07 17:41:25 +02:00
|
|
|
}
|
2021-06-25 19:28:41 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2021-06-07 17:41:25 +02:00
|
|
|
</script>
|