import type { Request, Response } from 'express';
import CommunicationsService from '@/services/communications';

export async function listParentMessages(
  req: Request,
  res: Response,
): Promise<void> {
  const payload = await CommunicationsService.listParentMessages(
    req.query,
    req.currentUser,
  );
  res.status(200).send(payload);
}

export async function createParentMessage(
  req: Request,
  res: Response,
): Promise<void> {
  const payload = await CommunicationsService.createParentMessage(
    req.body.data,
    req.currentUser,
  );
  res.status(201).send(payload);
}

export async function listEvents(req: Request, res: Response): Promise<void> {
  const payload = await CommunicationsService.listEvents(
    req.query,
    req.currentUser,
  );
  res.status(200).send(payload);
}

export async function createEvent(req: Request, res: Response): Promise<void> {
  const payload = await CommunicationsService.createEvent(
    req.body.data,
    req.currentUser,
  );
  res.status(201).send(payload);
}
