Bugs in settings fixed, profile added

This commit is contained in:
Torsten Schulz
2024-09-21 00:25:42 +02:00
parent c5a72d57d8
commit e494fe41db
65 changed files with 3121 additions and 7478 deletions

View File

@@ -1,4 +1,5 @@
import AdminService from '../services/adminService.js';
import Joi from 'joi';
export const getOpenInterests = async (req, res) => {
try {
@@ -51,4 +52,28 @@ export const getOpenContacts = async (req, res) => {
} catch (error) {
res.status(403).json({ error: error.message });
}
}
}
export const answerContact = async (req, res) => {
try {
const schema = Joi.object({
id: Joi.number().integer().required(),
answer: Joi.string().min(1).required()
});
const { error, value } = schema.validate(req.body);
if (error) {
return res.status(400).json({ error: error.details[0].message });
}
const { id, answer } = value;
await AdminService.answerContact(id, answer);
res.status(200).json({ status: 'ok' });
} catch (error) {
console.error('Error in answerContact:', error);
res.status(error.status || 500).json({ error: error.message || 'Internal Server Error' });
}
};