Some falukant fixes, added undeground ui - no save right now, changed menu (and verification)

This commit is contained in:
Torsten Schulz
2025-07-17 14:28:52 +02:00
parent fceea5b7fb
commit 89cf12a7a8
33 changed files with 1010 additions and 423 deletions

View File

@@ -53,6 +53,8 @@ import Candidate from '../models/falukant/data/candidate.js';
import Vote from '../models/falukant/data/vote.js';
import PoliticalOfficePrerequisite from '../models/falukant/predefine/political_office_prerequisite.js';
import PoliticalOfficeHistory from '../models/falukant/log/political_office_history.js';
import UndergroundType from '../models/falukant/type/underground.js';
import Notification from '../models/falukant/log/notification.js';
function calcAge(birthdate) {
const b = new Date(birthdate); b.setHours(0, 0);
@@ -1063,8 +1065,8 @@ class FalukantService extends BaseService {
]
});
if (regionUserDirectorProposals.length > 0) {
for (const proposal of regionUserDirectorProposals) {
await DirectorProposal.destroy();
for (const p of regionUserDirectorProposals) {
await p.destroy();
}
}
notifyUser(hashedUserId, 'directorchanged');
@@ -1772,7 +1774,7 @@ class FalukantService extends BaseService {
}
const housePrice = this.housePrice(house);
const oldHouse = await UserHouse.findOne({ where: { userId: falukantUser.id } });
if (falukantUser.money < housePrice) {
if (Number(falukantUser.money) < Number(housePrice)) {
throw new Error('notenoughmoney.');
}
if (oldHouse) {
@@ -2779,6 +2781,20 @@ class FalukantService extends BaseService {
return { cost: totalCost };
}
async getUndergroundTypes(hashedUserId) {
const user = await getFalukantUserOrFail(hashedUserId);
const undergroundTypes = await UndergroundType.findAll();
return undergroundTypes;
}
async getNotifications(hashedUserId) {
const user = await getFalukantUserOrFail(hashedUserId);
const notifications = await Notification.findAll({
where: { userId: user.id, shown: false },
order: [['createdAt', 'DESC']]
});
return user.notifications;
}
}
export default new FalukantService();