"Updated backend and frontend code: added console logs, modified DiaryMemberController, DiaryTagController, DiaryService, and DiaryView, and made changes to CSS and vite.config.js"

This commit is contained in:
Torsten Schulz
2024-11-06 16:16:25 +01:00
parent 46efa9a9a4
commit 1efa4e588f
9 changed files with 110 additions and 41 deletions

View File

@@ -14,6 +14,7 @@ class DiaryMemberService {
async getNotesForMember(userToken, clubId, diaryDateId, memberId) {
await checkAccess(userToken, clubId);
console.log(clubId, diaryDateId, memberId);
return await DiaryMemberNote.findAll({ where: { diaryDateId, memberId }, order: [['createdAt', 'DESC']] });
}

View File

@@ -109,21 +109,33 @@ class DiaryService {
if (!diaryDate) {
throw new HttpError('DiaryDate not found', 404);
}
console.log('[DiaryService::addTagToDiaryDate] - Add tag to diary date');
const existingEntry = await DiaryDateTag.findOne({
where: { diaryDateId, tagId }
});
if (existingEntry) {
return;
}
console.log('[DiaryService::addTagToDiaryDate] - Tag not found, creating new entry');
const tag = await DiaryTag.findByPk(tagId);
if (!tag) {
throw new HttpError('Tag not found', 404);
}
console.log('[DiaryService::addTagToDiaryDate] - Add tag to diary date');
await DiaryDateTag.create({
diaryDateId,
tagId
})
return diaryDate.getDiaryTags();
});
console.log('[DiaryService::addTagToDiaryDate] - Get tags');
const tags = await DiaryDateTag.findAll({ where: {
diaryDateId: diaryDateId },
include: {
model: DiaryTag,
as: 'tag'
}
});
console.log(tags);
return tags.map(tag => tag.tag);
}
async getDiaryNotesForDateAndMember(diaryDateId, memberId) {