import express from "express";
import {
  getRecordByPk,
  createRecord,
  updateRecordByPk,
  deleteRecordByPk
} from "../controllers/genericCrudController.js";
import { listOracParticipantsWithNames } from "../controllers/oracParticipantsController.js";

const router = express.Router();

const tableName = "orac_participants";
const primaryKeys = ["assessment_id", "participant_user_id"];
const pkPath = primaryKeys.map((k) => `:${k}`).join("/");

router.get("/orac_participants", listOracParticipantsWithNames);
router.get(
  `/orac_participants/${pkPath}`,
  getRecordByPk(tableName, primaryKeys)
);
router.post("/orac_participants", createRecord(tableName));
router.put(
  `/orac_participants/${pkPath}`,
  updateRecordByPk(tableName, primaryKeys)
);
router.delete(
  `/orac_participants/${pkPath}`,
  deleteRecordByPk(tableName, primaryKeys)
);

export default router;

