import { idParamsSchema } from "../../utils/schema";
import { FastifyInstanceType } from "../../utils/types";
import {
  deleteBusinessPlan,
  deleteMarketResearch,
  deleteNetworking,
  deleteProspecting,
  deleteSourcing,
  getBusinessPlan,
  getMarketResearch,
  getNetworking,
  getProspecting,
  getSourcing,
} from "./controller";

export async function adminServicesRoutes(fastify: FastifyInstanceType) {
  //-------------------------------------------------------------------------------
  fastify.get(
    "business-plan/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "Services"),
    },
    getBusinessPlan
  );
  //-------------------------------------------------------------------------------
  fastify.delete(
    "business-plan/:id/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "Services"),
      schema: {
        params: idParamsSchema,
      },
    },
    deleteBusinessPlan
  );
  //-------------------------------------------------------------------------------
  fastify.get(
    "market-research/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "Services"),
    },
    getMarketResearch
  );
  //-------------------------------------------------------------------------------
  fastify.delete(
    "market-research/:id/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "Services"),
      schema: {
        params: idParamsSchema,
      },
    },
    deleteMarketResearch
  );
  //-------------------------------------------------------------------------------
  fastify.get(
    "networking/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "Services"),
    },
    getNetworking
  );
  //-------------------------------------------------------------------------------
  fastify.delete(
    "networking/:id/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "Services"),
      schema: {
        params: idParamsSchema,
      },
    },
    deleteNetworking
  );
  //-------------------------------------------------------------------------------
  fastify.get(
    "sourcing/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "Services"),
    },
    getSourcing
  );
  //-------------------------------------------------------------------------------
  fastify.delete(
    "sourcing/:id/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "Services"),
      schema: {
        params: idParamsSchema,
      },
    },
    deleteSourcing
  );
  //-------------------------------------------------------------------------------
  fastify.get(
    "prospecting/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "Services"),
    },
    getProspecting
  );
  //-------------------------------------------------------------------------------
  fastify.delete(
    "prospecting/:id/",
    {
      preHandler: (req, reply) => fastify.adminAuth(req, reply, "Services"),
      schema: {
        params: idParamsSchema,
      },
    },
    deleteProspecting
  );
  //-------------------------------------------------------------------------------
  fastify.log.info("services routes registered");
}
