import type { Request, Response } from 'express';
import GuardianStudentsService from '@/services/guardian_students';

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

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

export async function unlink(req: Request, res: Response): Promise<void> {
  const id = String(req.params.id);
  await GuardianStudentsService.unlink(id, req.currentUser);
  res.status(200).send({ id });
}
