const fastify = require("fastify");
const validationHandler = require("../handlers/friendRequestHandler");



module.exports = function (fastify, opts, next) {

    fastify.route({
        method: "POST",
        url: "/api/users/friend-request",
        schema: {
          tags: ["Friend-Request"],
          description: "This is for User Friend Request",
          summary: "This is for User Friend Request",
          body: {
            type: "object",
            //required: ["customerId"],
            properties: {
              customerId: { type: "string" },
              supplierId : { type : "string"}
            },
          },
          security: [
            {
              basicAuth: [],
            },
          ],
        },
        handler: validationHandler.friendRequest,
      });


      fastify.route({
        method: "PUT",
        url: "/api/friend-request/accept",
        schema: {
          tags: ["Friend-Request"],
          description: "This is for supplier accept the friend request",
          summary: "This is for supplier accept the friend request",
        body: {
          type: "object",
          properties: {
            supplierId: { type: "string" },
            customerId: { type: "string" }
            
          },
        },
          security: [
            { 
              basicAuth: [],
            },
          ],
        },
        handler: validationHandler.friendRequestAccept
      });
      fastify.route({
        method: "PUT",
        url: "/api/friend-request/reject",
        schema: {
          tags: ["Friend-Request"],
          description: "This is for supplier reject the friend request",
          summary: "This is for supplier reject the friend request",

        body: {
          type: "object",
          properties: {
            supplierId: { type: "string" },
            customerId: { type: "string" }
          },
        },
          security: [
            { 
              basicAuth: [],
            },
          ],
        },
        handler: validationHandler.friendRequestReject
      });
    
  next();
}

