import type { Request, Response } from 'express';
import service from '@/services/schools';
import { createCrudController } from '@/api/controllers/shared/crud-controller';

/** Custom: atomically create a school + its first campus. */
export async function createWithFirstCampus(
  req: Request,
  res: Response,
): Promise<void> {
  const payload = await service.createWithFirstCampus(
    req.body.data,
    req.body.firstCampus,
    req.currentUser,
  );
  res.status(200).send(payload);
}

export default createCrudController(service, {
  csvFields: ['id', 'name', 'code', 'address', 'phone', 'email'],
});
