import express from 'express';
import {
  signUp,
  verifyEmail,
  verificationLink,
  signIn,
  getProfile,
  mobileForgotPassword,
  forgotPassword,
  resetPassword,
  changePassword,
  createNewUser,
  getUsers,
  editUser,
  getPermissions,
  createRole,
  getRoles,
  editRole,
  assignRole,
  deactivateOrActivateUser,
  createOrder,
  getOrders,
  editOrders,
  orderSystemCheck,
  getRouteReportChart,
  getDeliveryStatusChart,
  recommendRoute,
  skipOptRoute,
  saveRoute,
  getRoutes,
  createAdhoc,
  getAdhocs,
  editAdhoc,
  assignRoute,
  logOut,
  batchDeactivateOrActivateUser,
  getDashBoard,
  getReportStats,
  getReport,
  getDashBoardStats,
  getAssets,
  editAsset,
  createAsset,
  getNotifications,
  batchDeactivateOrActivateAsset,
  deactivateOrActivateAsset,
  downloadReport,
  saveDeviceToken,
  getUserDeviceTokens,
} from '../controllers';
import { authenticate, isCompany } from '../middlewares/authentication';

const router = express.Router();

router
  .post('/signup', signUp)
  .get('/verify-email', verifyEmail)
  .post('/request-email-verification', verificationLink)
  .post('/signin', signIn)
  .post('/signout', authenticate, logOut)
  .get('/current-user', authenticate, getProfile)
  .post('/forgot-password-mobile', mobileForgotPassword)
  .post('/forgot-password', forgotPassword)
  .patch('/reset-password', resetPassword)
  .patch('/change-password', authenticate, changePassword)
  .post('/users', authenticate, createNewUser)
  .get('/users/:userType', authenticate, getUsers)
  .patch('/users/:userID/:userType', authenticate, editUser)
  .patch(
    '/user-activation/:userID/:userType',
    authenticate,
    deactivateOrActivateUser,
  )
  .patch(
    '/batch-user-activation/:action',
    authenticate,
    isCompany,
    batchDeactivateOrActivateUser,
  )
  .patch(
    '/asset-activation/:assetID',
    authenticate,
    isCompany,
    deactivateOrActivateAsset,
  )
  .patch(
    '/batch-asset-activation/:action',
    authenticate,
    isCompany,
    batchDeactivateOrActivateAsset,
  )
  .get('/permissions', authenticate, getPermissions)
  .post('/roles', authenticate, createRole)
  .post('/assign-role', authenticate, assignRole)
  .get('/roles', authenticate, getRoles)
  .patch('/roles/:roleID', authenticate, editRole)
  .post('/orders', authenticate, createOrder)
  .get('/orders', authenticate, getOrders)
  .patch('/orders/:orderID', authenticate, editOrders)
  .post('/optimize-route', authenticate, recommendRoute)
  .post('/skip-optimize-route', authenticate, skipOptRoute)
  .post('/save-route', authenticate, saveRoute)
  .get('/get-route', authenticate, getRoutes)
  .post('/assign-route/:routeID/rider/:riderID', authenticate, assignRoute)
  .post('/adhocs', authenticate, createAdhoc)
  .patch('/adhocs/:adhocID', authenticate, editAdhoc)
  .get('/adhocs', authenticate, getAdhocs)
  .get('/notifications', authenticate, getNotifications)
  .get('/dashboard', authenticate, getDashBoard)
  .get('/dashboard-stats', authenticate, getDashBoardStats)
  .get('/routes-report', authenticate, getReport)
  .get('/routes-report/download', authenticate, downloadReport)
  .get('/routes-stats', authenticate, getReportStats)
  .get('/assets', authenticate, getAssets)
  .post('/assets', authenticate, createAsset)
  .patch('/assets/:assetID', authenticate, editAsset)
  .get('/orders-check', authenticate, orderSystemCheck)
  .get('/route-report-chart', authenticate, getRouteReportChart)
  .get('/delivery-status-chart', authenticate, getDeliveryStatusChart)
  .put('/device-token', authenticate, saveDeviceToken)
  .get('/users/:userID/device-tokens', authenticate, getUserDeviceTokens);

export = router;