2021-06-07 17:41:25 +02:00
|
|
|
<template>
|
2021-06-14 15:02:53 +02:00
|
|
|
<div class="container">
|
|
|
|
<h1>Profil Ändern</h1>
|
|
|
|
<form @submit.prevent="submitForm()">
|
2021-07-12 19:12:51 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col">
|
2021-07-26 16:12:23 +02:00
|
|
|
<input type="radio" id="false" :value="false" v-model="profile.visible" class="mr-2"/>
|
|
|
|
<label for="false" class="m-2 fw-bold"> Nicht Öffentlich</label>
|
2021-07-12 19:12:51 +02:00
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<input type="radio" id="true" :value="true" v-model="profile.visible" />
|
2021-07-26 16:12:23 +02:00
|
|
|
<label for="true" class="m-2 fw-bold"> Öffentlich</label>
|
2021-07-12 19:12:51 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-26 16:12:23 +02:00
|
|
|
<div id="visibilityHelp" class="form-text">
|
|
|
|
Erst wenn du dein Profil Öffentlich stellst, können andere Genoss:innen darauf zugreifen oder es in der Suche finden.
|
|
|
|
</div>
|
2021-06-14 15:02:53 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-6 col-xs-12">
|
2021-07-26 16:12:23 +02:00
|
|
|
<label for="nickname" class="form-label fw-bold">Nickname:</label>
|
2021-06-14 15:02:53 +02:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="form-control"
|
|
|
|
id="nickname"
|
2021-06-25 19:28:41 +02:00
|
|
|
v-model="profile.nickname"
|
2021-06-14 15:02:53 +02:00
|
|
|
required
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="col-6 col-xs-12">
|
2021-07-26 16:12:23 +02:00
|
|
|
<label for="pronouns" class="form-label fw-bold">Pronomen:</label>
|
2021-06-14 15:02:53 +02:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="form-control"
|
|
|
|
id="pronouns"
|
2021-06-25 19:28:41 +02:00
|
|
|
v-model="profile.pronouns"
|
2021-06-14 15:02:53 +02:00
|
|
|
/>
|
2021-07-26 16:12:23 +02:00
|
|
|
<div for="pronouns" class="form-text">
|
2021-06-24 00:40:27 +02:00
|
|
|
Z.B.: Er/Ihn, Sie/Ihr, Es etc..
|
|
|
|
</div>
|
2021-06-14 15:02:53 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-12 col-xs-12">
|
2021-07-26 16:12:23 +02:00
|
|
|
<label for="freetext" class="form-label fw-bold">Freitext Vorstellung:</label>
|
2021-06-24 00:40:27 +02:00
|
|
|
<textarea
|
|
|
|
class="form-control"
|
|
|
|
id="freetext"
|
|
|
|
rows="3"
|
2021-06-25 19:28:41 +02:00
|
|
|
v-model="profile.freetext"
|
2021-06-24 00:40:27 +02:00
|
|
|
></textarea>
|
2021-06-14 15:02:53 +02:00
|
|
|
</div>
|
|
|
|
<div class="col-12 col-xs-12">
|
2021-07-26 16:12:23 +02:00
|
|
|
<label for="volunteerwork" class="form-label fw-bold"
|
2021-06-24 00:40:27 +02:00
|
|
|
>Ehrentamtliche Arbeit:</label
|
|
|
|
>
|
|
|
|
<textarea
|
|
|
|
class="form-control"
|
|
|
|
id="volunteerwork"
|
|
|
|
rows="3"
|
2021-06-25 19:28:41 +02:00
|
|
|
v-model="profile.volunteerwork"
|
2021-06-24 00:40:27 +02:00
|
|
|
></textarea>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-12 18:32:17 +02:00
|
|
|
<auto-complete
|
|
|
|
type="skill"
|
|
|
|
label="Deine Fähigkeiten (Autocomplete)"
|
|
|
|
:values="profile.skills"
|
|
|
|
@update-values="profile.skills = $event"
|
|
|
|
></auto-complete>
|
|
|
|
<auto-complete
|
|
|
|
type="language"
|
|
|
|
label="Deine Sprachen (Autocomplete)"
|
|
|
|
:values="profile.languages"
|
|
|
|
@update-values="profile.languages = $event"
|
|
|
|
></auto-complete>
|
|
|
|
<auto-complete
|
|
|
|
type="skill"
|
|
|
|
label="Ich Suche"
|
|
|
|
:values="profile.searchtopics"
|
|
|
|
@update-values="profile.searchtopics = $event"
|
|
|
|
></auto-complete>
|
|
|
|
|
2021-07-12 19:12:51 +02:00
|
|
|
<div class="col-12 col-xs-12">
|
2021-07-26 16:12:23 +02:00
|
|
|
<label for="availability" class="form-label fw-bold"
|
2021-07-12 19:12:51 +02:00
|
|
|
>Ich bin für Anfragen verfügbar:</label
|
|
|
|
>
|
|
|
|
<textarea
|
|
|
|
class="form-control"
|
|
|
|
id="availability"
|
|
|
|
rows="3"
|
|
|
|
v-model="profile.availability"
|
|
|
|
></textarea>
|
|
|
|
</div>
|
|
|
|
|
2021-07-12 18:32:17 +02:00
|
|
|
<auto-complete
|
|
|
|
type="contacttype"
|
|
|
|
label="Kontaktmöglichkeiten"
|
|
|
|
:values="profile.contacts"
|
|
|
|
@update-values="profile.contacts = $event"
|
|
|
|
></auto-complete>
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col">
|
2021-07-26 17:10:28 +02:00
|
|
|
<label for="pzl" class="form-label fw-bold">PLZ</label>
|
2021-07-12 18:32:17 +02:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="form-control"
|
|
|
|
id="pzl"
|
|
|
|
v-model="profile.address.postcode"
|
|
|
|
/>
|
2021-06-14 15:02:53 +02:00
|
|
|
</div>
|
2021-07-12 18:32:17 +02:00
|
|
|
<div class="col">
|
2021-07-26 16:12:23 +02:00
|
|
|
<label for="city" class="form-label fw-bold">Stadt</label>
|
2021-07-12 18:32:17 +02:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="form-control"
|
2021-07-26 16:12:23 +02:00
|
|
|
id="city"
|
2021-07-12 18:32:17 +02:00
|
|
|
v-model="profile.address.city"
|
|
|
|
/>
|
2021-06-25 19:28:41 +02:00
|
|
|
</div>
|
2021-07-12 18:32:17 +02:00
|
|
|
<div class="col">
|
2021-07-26 16:12:23 +02:00
|
|
|
<label for="country" class="form-label fw-bold">Land</label>
|
2021-07-12 18:32:17 +02:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="form-control"
|
2021-07-26 16:12:23 +02:00
|
|
|
id="country"
|
2021-07-12 18:32:17 +02:00
|
|
|
v-model="profile.address.country"
|
|
|
|
/>
|
2021-06-25 19:28:41 +02:00
|
|
|
</div>
|
2021-07-28 21:52:12 +02:00
|
|
|
</div>
|
2021-06-14 15:02:53 +02:00
|
|
|
|
2021-07-26 16:12:23 +02:00
|
|
|
<button type="submit" class="btn btn-outline-success mb-4 mt-4 col-12">Speichern</button>
|
2021-06-14 15:02:53 +02:00
|
|
|
<div
|
|
|
|
class="alert alert-danger mb-4 mt-4"
|
|
|
|
role="alert"
|
|
|
|
v-if="showErrorMessage"
|
|
|
|
>
|
|
|
|
Es ist Fehler aufgetreten
|
|
|
|
</div>
|
2021-07-26 16:12:23 +02:00
|
|
|
<div
|
|
|
|
class="alert alert-success mb-4 mt-4"
|
|
|
|
role="alert"
|
|
|
|
v-if="showSuccessMessage"
|
|
|
|
>
|
|
|
|
Deine Änderungen wurden erfolgreich gespeichert
|
|
|
|
</div>
|
2021-06-14 15:02:53 +02:00
|
|
|
</form>
|
|
|
|
</div>
|
2021-06-07 17:41:25 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
2021-06-24 00:40:27 +02:00
|
|
|
import axios from "axios";
|
2021-07-12 18:32:17 +02:00
|
|
|
import AutoComplete from "@/components/AutoComplete";
|
2021-07-26 17:10:28 +02:00
|
|
|
|
2021-06-07 17:41:25 +02:00
|
|
|
export default {
|
2021-06-14 15:02:53 +02:00
|
|
|
name: "profileEdit",
|
2021-07-12 18:32:17 +02:00
|
|
|
components: {
|
|
|
|
AutoComplete,
|
|
|
|
},
|
2021-06-14 15:02:53 +02:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showErrorMessage: false,
|
2021-07-26 16:12:23 +02:00
|
|
|
showSuccessMessage: false,
|
2021-06-25 19:28:41 +02:00
|
|
|
profile: {
|
2021-07-12 19:12:51 +02:00
|
|
|
visible: false,
|
2021-06-25 19:28:41 +02:00
|
|
|
nickname: "",
|
|
|
|
pronouns: "",
|
|
|
|
volunteerwork: "",
|
|
|
|
freetext: "",
|
2021-07-12 19:12:51 +02:00
|
|
|
availability: "",
|
2021-06-25 19:28:41 +02:00
|
|
|
address: {
|
|
|
|
postcode: "",
|
|
|
|
city: "",
|
|
|
|
country: "",
|
|
|
|
},
|
|
|
|
skills: [],
|
|
|
|
languages: [],
|
2021-07-12 18:32:17 +02:00
|
|
|
searchtopics: [],
|
|
|
|
contacts: [],
|
2021-06-25 19:28:41 +02:00
|
|
|
},
|
2021-06-14 15:02:53 +02:00
|
|
|
};
|
|
|
|
},
|
2021-06-25 19:28:41 +02:00
|
|
|
async created() {
|
|
|
|
try {
|
|
|
|
const userProfile = await axios.get(
|
2021-07-28 21:52:12 +02:00
|
|
|
`${this.apiUrl}/users/${localStorage.getItem(
|
2021-06-25 19:28:41 +02:00
|
|
|
"user_id"
|
|
|
|
)}/profile`,
|
|
|
|
{
|
|
|
|
headers: { Authorization: `Bearer ${localStorage.getItem("token")}` },
|
|
|
|
}
|
|
|
|
);
|
2021-07-12 19:12:51 +02:00
|
|
|
this.profile = userProfile.data.profile;
|
2021-06-25 19:28:41 +02:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
},
|
2021-06-14 15:02:53 +02:00
|
|
|
methods: {
|
2021-06-25 19:28:41 +02:00
|
|
|
async submitForm() {
|
|
|
|
try {
|
|
|
|
const formSubmitResult = await axios.post(
|
2021-07-28 21:52:12 +02:00
|
|
|
`${this.apiUrl}/users/${localStorage.getItem(
|
2021-06-25 19:28:41 +02:00
|
|
|
"user_id"
|
|
|
|
)}/profile`,
|
2021-07-12 18:32:17 +02:00
|
|
|
this.profile,
|
2021-06-25 19:28:41 +02:00
|
|
|
{
|
|
|
|
headers: {
|
|
|
|
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
if (formSubmitResult.status === 200) {
|
|
|
|
// success
|
2021-07-26 16:12:23 +02:00
|
|
|
this.showSuccessMessage = true;
|
2021-06-25 19:28:41 +02:00
|
|
|
} else {
|
|
|
|
// failure
|
2021-07-26 16:12:23 +02:00
|
|
|
this.showErrorMessage = true;
|
2021-06-25 19:28:41 +02:00
|
|
|
}
|
|
|
|
} catch (error) {
|
2021-07-26 16:12:23 +02:00
|
|
|
console.error(error);
|
2021-06-25 19:28:41 +02:00
|
|
|
this.showErrorMessage = true;
|
|
|
|
}
|
2021-07-12 18:32:17 +02:00
|
|
|
}
|
2021-06-14 15:02:53 +02:00
|
|
|
},
|
|
|
|
};
|
2021-07-28 21:52:12 +02:00
|
|
|
</script>
|