const multer = require("fastify-multer");

var storage = multer.diskStorage({
  destination: "build/uploads/products/",
  filename: function (request, file, cb) {
    cb(null, Date.now() + file.originalname);
  }
});
const upload = multer({ storage });
const {
  clientInvite,
  clientSignup,
  clientEdit,
  clientDelete,
  clientLinkRedirect,
  getAllClients,
  getDataForAddClient,
  addClient,
  fetchClientById,
  updateClient,
  removeClient,
  addInternalNotes,
  sendMessage,
  viewMessage,
  viewClientDetails,
  manageWorkflows,
  updateProfilePic,
  updateCoverImage,
  getAllCustomersFromQuickbook,
  getAllVendorsFromQuickbook,
  saveClientVendorOrder,
  getAllStatesController,
  uploadClients,
  getAllPartnerQb
} = require("../controllers/client");
const { submitReview } = require("../controllers/clientChat");


const clientRoutes = [
  {
    method: "POST",
    url: "/client/invite",
    handler: clientInvite,
  },
  {
    method: "POST",
    url: "/client/signup",
    handler: clientSignup,
  },
  {
    method: "POST",
    url: "/client/edit",
    handler: clientEdit,
  },
  {
    method: "POST",
    url: "/client/delete",
    handler: clientDelete,
  },
  {
    method: "GET",
    url: "/user/signup",
    handler: clientLinkRedirect,
  },
  {
    method: 'POST',
    url: '/webservice/clients/getAllClients',
    preHandler: upload.any(),
    handler: getAllClients,
  },
  {
    method: 'POST',
    url: '/webservice/clients/getDataForAddClients',
    preHandler: upload.any(),
    handler: getDataForAddClient,
  },
  {
    method: 'POST',
    url: '/webservice/clients/addClient',
    preHandler: upload.any(),
    handler: addClient,
  },
  {
    method: 'POST',
    url: '/webservice/clients/fetch-client-by-id',
    preHandler: upload.any(),
    handler: fetchClientById,
  },
  {
   method:'POST',
   url:'/webservice/clients/view-client-profile',
   preHandler: upload.any(),
   handler: viewClientDetails,
  },
  {
    method: 'POST',
    url: '/webservice/clients/update-client',
    preHandler: upload.any(),
    handler: updateClient,
  },
  {
    method: 'POST',
    url: '/webservice/clients/remove-client',
    preHandler: upload.any(),
    handler: removeClient,
  },
  {
    method: 'POST',
    url: '/webservice/clients/add-internal-note',
    preHandler: upload.any(),
    handler: addInternalNotes,
  },
  {
    method : "POST",
    url: "/webservice/clients/send-message",
    handler:sendMessage
},
{
    method : "POST",
    url: "/webservice/clients/view-message",
    handler:viewMessage
},
{
  method : "POST",
  url: "/webservice/clients/add-review",
  handler:submitReview
},
{
  method : "POST",
  url: "/webservice/clients/manage-workflow",
  handler:manageWorkflows
},
{
  method : "POST",
  url: "/webservice/clients/update-pic",
  handler:updateProfilePic
},
{
  method : "POST",
  url: "/webservice/clients/update-coverimage",
  handler:updateCoverImage
},
{
  method : "POST",
  url: "/webservice/clients/get-customers-quickbook-sandbox",
  handler:getAllCustomersFromQuickbook
},
{
  method : "POST",
  url: "/webservice/vendor/get-vendors-quickbook-sandbox",
  handler:getAllVendorsFromQuickbook
},
{
  method : "POST",
  url: "/webservice/client-vendor/save-card-order",
  handler:saveClientVendorOrder
},
{
  method : "POST",
  url: "/webservice/clients/get-all-states",
  handler:getAllStatesController
},
{
  method: 'POST',
  url: '/webservice/clients/upload-clients',
  preHandler: upload.any(),
  handler: uploadClients,
},
{
  method : "POST",
  url: "/webservice/clients/get-all-partner-qb",
  handler:getAllPartnerQb
},
];

module.exports = clientRoutes;
