feat(MemberPlayInterest): implement play interest management for members
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 38s

- Added new endpoints to get and set member play interests in the memberController.
- Integrated MemberPlayInterest model into the application, establishing relationships with Member and Club models.
- Updated memberRoutes to include routes for managing member play interests.
- Enhanced memberService to handle play interest retrieval and updates.
- Updated localization files to include new terms related to member play interests.
- Refactored server.js to include MemberPlayInterest in the synchronization process.
This commit is contained in:
Torsten Schulz (local)
2026-04-15 10:48:10 +02:00
parent 45c701b149
commit 2dff5221e3
15 changed files with 1226 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ import { checkAccess, getUserByToken, hasUserClubAccess } from "../utils/userUti
import Member from "../models/Member.js";
import MemberImage from "../models/MemberImage.js";
import MemberTtrHistory from "../models/MemberTtrHistory.js";
import MemberPlayInterest from "../models/MemberPlayInterest.js";
import Participant from "../models/Participant.js";
import DiaryDate from "../models/DiaryDates.js";
import { Op, fn, col } from 'sequelize';
@@ -14,6 +15,64 @@ import sharp from 'sharp';
import { devLog } from '../utils/logger.js';
import { standardizePhoneNumber } from '../utils/phoneUtils.js';
class MemberService {
async getMemberPlayInterests(userToken, clubId, seasonId, lineupHalf) {
await checkAccess(userToken, clubId);
if (!seasonId || !['first_half', 'second_half'].includes(String(lineupHalf || ''))) {
return {
status: 400,
response: { error: 'invalidplayinterestparams' }
};
}
const rows = await MemberPlayInterest.findAll({
where: {
clubId,
seasonId,
lineupHalf,
interested: true
},
attributes: ['memberId', 'seasonId', 'lineupHalf', 'interested']
});
return {
status: 200,
response: rows.map((row) => row.toJSON())
};
}
async setMemberPlayInterest(userToken, clubId, memberId, seasonId, lineupHalf, interested = true) {
await checkAccess(userToken, clubId);
if (!memberId || !seasonId || !['first_half', 'second_half'].includes(String(lineupHalf || ''))) {
return {
status: 400,
response: { error: 'invalidplayinterestparams' }
};
}
const member = await Member.findOne({ where: { id: memberId, clubId } });
if (!member) {
return {
status: 404,
response: { error: 'membernotfound' }
};
}
const [row] = await MemberPlayInterest.findOrCreate({
where: { clubId, memberId, seasonId, lineupHalf },
defaults: { interested: !!interested }
});
if (row.interested !== !!interested) {
row.interested = !!interested;
await row.save();
}
return {
status: 200,
response: { result: 'success' }
};
}
async getApprovalRequests(userToken, clubId) {
await checkAccess(userToken, clubId);
const user = await getUserByToken(userToken);