import express from "express";
import {
  listRecords,
  getRecordByPk,
  updateRecordByPk,
  deleteRecordByPk
} from "../controllers/genericCrudController.js";
import { createSubmission } from "../controllers/oracSubmissionsController.js";

const router = express.Router();
const tableName = "orac_submissions";
const primaryKeys = ["submission_id", "assessment_id", "submitter_id", "snap_id"];

router.get("/orac_submissions", listRecords(tableName));
router.get(
  `/orac_submissions/:${primaryKeys.join("/:")}`,
  getRecordByPk(tableName, primaryKeys)
);
router.post("/orac_submissions", createSubmission);
router.put(
  `/orac_submissions/:${primaryKeys.join("/:")}`,
  updateRecordByPk(tableName, primaryKeys)
);
router.delete(
  `/orac_submissions/:${primaryKeys.join("/:")}`,
  deleteRecordByPk(tableName, primaryKeys)
);

export default router;
