54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
import AdminService from '../services/adminService.js';
|
|
|
|
export const getOpenInterests = async (req, res) => {
|
|
try {
|
|
const { userid: userId} = req.headers;
|
|
const openInterests = await AdminService.getOpenInterests(userId);
|
|
res.status(200).json(openInterests);
|
|
} catch (error) {
|
|
res.status(403).json({error: error.message });
|
|
}
|
|
}
|
|
|
|
export const changeInterest = async (req, res) => {
|
|
try {
|
|
const { userid: userId } = req.headers;
|
|
const { id: interestId, active, adult: adultOnly} = req.body;
|
|
AdminService.changeInterest(userId, interestId, active, adultOnly);
|
|
res.status(200).json(AdminService.getOpenInterests(userId));
|
|
} catch (error) {
|
|
res.status(403).json({ error: error.message });
|
|
}
|
|
}
|
|
|
|
export const deleteInterest = async (req, res) => {
|
|
try {
|
|
const { userid: userId } = req.headers;
|
|
const { id: interestId } = req.params;
|
|
AdminService.deleteInterest(userId, interestId);
|
|
res.status(200).json(AdminService.getOpenInterests(userId));
|
|
} catch (error) {
|
|
res.status(403).json({ error: error.message });
|
|
}
|
|
}
|
|
|
|
export const changeTranslation = async (req, res) => {
|
|
try {
|
|
const { userid: userId } = req.headers;
|
|
const { id: interestId, translations } = req.body;
|
|
AdminService.changeTranslation(userId, interestId, translations);
|
|
res.status(200).json(AdminService.getOpenInterests(userId))
|
|
} catch(error) {
|
|
res.status(403).json({ error: error.message });
|
|
}
|
|
}
|
|
|
|
export const getOpenContacts = async (req, res) => {
|
|
try {
|
|
const { userid: userId } = req.headers;
|
|
const openContacts = await AdminService.getOpenContacts(userId);
|
|
res.status(200).json(openContacts);
|
|
} catch (error) {
|
|
res.status(403).json({ error: error.message });
|
|
}
|
|
} |