diff --git a/backend/models/Group.js b/backend/models/Group.js new file mode 100644 index 0000000..f7257a5 --- /dev/null +++ b/backend/models/Group.js @@ -0,0 +1,29 @@ +import { DataTypes } from 'sequelize'; +import sequelize from '../database.js'; +import DiaryDate from './DiaryDates.js'; + +const Group = sequelize.define('Group', { + diaryDate: { + type: DataTypes.INTEGER, + allowNull: false, + references: { + model: DiaryDate, + key: 'id', + }, + onDelete: 'CASCADE', + }, + name: { + type: DataTypes.STRING, + allowNull: false, + }, + lead: { + type: DataTypes.STRING, + allowNull: true, + } +}, { + tableName: 'group', + underscored: true, + timestamps: true, +}); + +export default Group; diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 11f162b..acb0d7d 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -48,7 +48,7 @@ export default { data() { return { selectedClub: null, - isMenuOpen: false, // Für das mobile Design zum Öffnen/Schließen des Menüs + isMenuOpen: false, }; }, computed: { diff --git a/frontend/src/store.js b/frontend/src/store.js index e127371..232ed57 100644 --- a/frontend/src/store.js +++ b/frontend/src/store.js @@ -1,4 +1,6 @@ import { createStore } from 'vuex'; +import router from './router.js'; +import apiClient from './apiClient.js'; const store = createStore({ state: { @@ -31,12 +33,12 @@ const store = createStore({ }, setClubsMutation(state, clubs) { state.clubs = clubs; - localStorage.setItem('clubs', JSON.stringify(clubs)); + localStorage.setItem('clubs', JSON.stringify(clubs)); }, clearToken(state) { state.token = null; localStorage.removeItem('token'); - router.push("/"); + localStorage.removeItem('currentClub'); // Auch den aktuellen Club entfernen }, clearUsername(state) { state.username = ''; @@ -53,7 +55,8 @@ const store = createStore({ logout({ commit }) { commit('clearToken'); commit('clearUsername'); - router.push("/"); + router.push("/"); + window.location.reload(); }, setCurrentClub({ commit }, club) { commit('setClub', club); diff --git a/frontend/src/views/DiaryView.vue b/frontend/src/views/DiaryView.vue index 934c1d4..355e433 100644 --- a/frontend/src/views/DiaryView.vue +++ b/frontend/src/views/DiaryView.vue @@ -246,7 +246,7 @@ export default { id: tag.id, name: tag.name })); - this.previousActivityTags = [...this.selectedActivityTags]; // Hier setzen + this.previousActivityTags = [...this.selectedActivityTags]; await this.loadMembers(); await this.loadParticipants(dateId); @@ -277,12 +277,13 @@ export default { trainingStart: this.trainingStart || null, trainingEnd: this.trainingEnd || null, }); + console.log(response); this.dates.push({ id: response.data.id, date: response.data.date }); this.date = { id: response.data.id, date: response.data.date }; this.showForm = false; this.newDate = ''; - this.trainingStart = ''; - this.trainingEnd = ''; + this.trainingStart = response.data.trainingStart; + this.trainingEnd = response.data.trainingEnd; } catch (error) { alert('Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.'); } @@ -623,6 +624,7 @@ export default { await apiClient.put(`/diary-date-activities/${this.currentClub}/${movedItem.id}/order`, { orderId: evt.newIndex }); + this.recalculateTimes(); } catch (error) { console.error('Fehler beim Aktualisieren der Reihenfolge:', error); alert('Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.'); @@ -673,6 +675,13 @@ export default { this.imageUrl = null; } }, + recalculateTimes() { + let currentTime = this.trainingStart; // Die Startzeit des Trainings + this.trainingPlan.forEach((item, index) => { + item.startTime = currentTime; + currentTime = this.addDurationToTime(currentTime, item.duration); + }); + }, }, async mounted() { await this.init();