import { FastifyInstanceType } from "../../utils/types";
import {
  editPresentation,
  editPrivacyPolicy,
  editTermsOfService,
  getPresentation,
  getPrivacyPolicy,
  getTermsOfService,
} from "./controller";
import {
  presenationSchema,
  privacyPolicySchema,
  termsOfServiceSchema,
} from "./schema";

export async function adminCcisRoutes(fastify: FastifyInstanceType) {
  //-------------------------------------------------------------------------------
  fastify.get(
    "presentation/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "CCIS"),
    },
    getPresentation
  );
  fastify.put(
    "presentation/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "CCIS"),
      schema: {
        body: presenationSchema,
      },
    },
    editPresentation
  );
  //-------------------------------------------------------------------------------
  fastify.get(
    "terms-of-service/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "CCIS"),
    },
    getTermsOfService
  );
  fastify.put(
    "terms-of-service/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "CCIS"),
      schema: {
        body: termsOfServiceSchema,
      },
    },
    editTermsOfService
  );
  //-------------------------------------------------------------------------------
  fastify.get(
    "privacy-policy/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "CCIS"),
    },
    getPrivacyPolicy
  );
  fastify.put(
    "privacy-policy/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "CCIS"),
      schema: {
        body: privacyPolicySchema,
      },
    },
    editPrivacyPolicy
  );
  //-------------------------------------------------------------------------------
  fastify.log.info("ccis routes registered");
}
