"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.adminSettingRoutes = adminSettingRoutes;
const schema_1 = require("../../utils/schema");
const controller_1 = require("./controller");
const schema_2 = require("./schema");
function adminSettingRoutes(fastify) {
    return __awaiter(this, void 0, void 0, function* () {
        //-------------------------------------------------------------------------------
        fastify.get("cities/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.cities);
        fastify.post("cities/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.citySchema,
            },
        }, controller_1.addCity);
        fastify.put("cities/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.citySchema,
            },
        }, controller_1.editCity);
        fastify.delete("cities/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteCity);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("activities-families/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.activitiesFamilies);
        fastify.post("activities-families/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.activityFamiliySchema,
            },
        }, controller_1.addActivityFamily);
        fastify.put("activities-families/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.activityFamiliySchema,
            },
        }, controller_1.editActivityFamily);
        fastify.delete("activities-families/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteActivityFamily);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("activities/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.activities);
        fastify.post("activities/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.activitySchema,
            },
        }, controller_1.addActivity);
        fastify.put("activities/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.activitySchema,
            },
        }, controller_1.editActivity);
        fastify.delete("activities/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteActivity);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("turnovers/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.turnovers);
        fastify.post("turnovers/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.turnoverSchema,
            },
        }, controller_1.addTurnover);
        fastify.put("turnovers/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.turnoverSchema,
            },
        }, controller_1.editTurnover);
        fastify.delete("turnovers/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteTurnover);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("positions/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.positions);
        fastify.post("positions/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.positionSchema,
            },
        }, controller_1.addPosition);
        fastify.put("positions/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.positionSchema,
            },
        }, controller_1.editPosition);
        fastify.delete("positions/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deletePosition);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("n-employees/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.nEmployees);
        fastify.post("n-employees/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.nEmployeesSchema,
            },
        }, controller_1.addNEmployees);
        fastify.put("n-employees/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.nEmployeesSchema,
            },
        }, controller_1.editNEmployees);
        fastify.delete("n-employees/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteNEmployees);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("expertise-areas/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.expertiseAreas);
        fastify.post("expertise-areas/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.expertiseAreaSchema,
            },
        }, controller_1.addExpertiseArea);
        fastify.put("expertise-areas/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.expertiseAreaSchema,
            },
        }, controller_1.editExpertiseArea);
        fastify.delete("expertise-areas/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteExpertiseArea);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("interest-areas/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.interestAreas);
        fastify.post("interest-areas/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.interestAreaSchema,
            },
        }, controller_1.addInterestArea);
        fastify.put("interest-areas/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.interestAreaSchema,
            },
        }, controller_1.editInterestArea);
        fastify.delete("interest-areas/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteInterestArea);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("provinces/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.provinces);
        fastify.post("provinces/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.provinceSchema,
            },
        }, controller_1.addProvince);
        fastify.put("provinces/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.provinceSchema,
            },
        }, controller_1.editProvince);
        fastify.delete("provinces/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteProvince);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("categories/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.categories);
        fastify.post("categories/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.categorySchema,
            },
        }, controller_1.addCategory);
        fastify.put("categories/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.categorySchema,
            },
        }, controller_1.editCategory);
        fastify.delete("categories/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteCategory);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("commissions/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.commissions);
        fastify.post("commissions/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.commissionSchema,
            },
        }, controller_1.addCommission);
        fastify.put("commissions/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.commissionSchema,
            },
        }, controller_1.editCommission);
        fastify.delete("commissions/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteCommission);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("mandates/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.mandates);
        fastify.post("mandates/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.mandateSchema,
            },
        }, controller_1.addMandate);
        fastify.put("mandates/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.mandateSchema,
            },
        }, controller_1.editMandate);
        fastify.delete("mandates/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteMandate);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.get("colleges/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
        }, controller_1.colleges);
        fastify.post("colleges/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                body: schema_2.collegeSchema,
            },
        }, controller_1.addCollege);
        fastify.put("colleges/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
                body: schema_2.collegeSchema,
            },
        }, controller_1.editCollege);
        fastify.delete("colleges/:id/", {
            preHandler: (req, reply) => fastify.adminAuth(req, reply, "Settings"),
            schema: {
                params: schema_1.idParamsSchema,
            },
        }, controller_1.deleteCollege);
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        fastify.log.info("settings routes registered");
    });
}
