import type { Request, Response } from 'express';
import CampusAttendanceService from '@/services/campus_attendance';

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

export async function upsertConfig(req: Request, res: Response): Promise<void> {
  const payload = await CampusAttendanceService.upsertConfig(
    req.params.campusKey,
    req.body.data,
    req.currentUser,
  );
  res.status(200).send(payload);
}

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

export async function upsertSummary(req: Request, res: Response): Promise<void> {
  const payload = await CampusAttendanceService.upsertSummary(
    req.params.campusKey,
    req.params.date,
    req.body.data,
    req.currentUser,
  );
  res.status(200).send(payload);
}
