Bugs in settings fixed, profile added
This commit is contained in:
@@ -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' });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user