import { groupSchema } from '../forms/schemas.js';
import { createGroup, listGroups } from '../models/groupModel.js';

export function index(req, res) {
  res.json(listGroups());
}

export function create(req, res) {
  const parsed = groupSchema.safeParse(req.body);
  if (!parsed.success) return res.status(400).json({ error: 'Invalid group payload' });
  res.status(201).json(createGroup(parsed.data));
}
