const { Router } = require('express')
const router = Router()
const transactionController = require('../controllers/transactionController')
const pieceController = require('../controllers/pieceController')
const pieceRequestController = require('../controllers/pieceRequestController')
const oldPieceRequestController = require('../controllers/oldPieceRequestController')
const bufferRequestController = require('../controllers/bufferRequestController')

const guaranteeReportController = require('../controllers/guaranteeReportController')

/// // inbox
router.get('/inbox', transactionController.get_all_transactions_for_agent)
router.get('/inbox/:id', transactionController.get_one_transaction_for_agent)
router.put('/changeTStatus/:id', transactionController.change_transaction_status_by_agent)

/// ///////////// pieces
router.get('/pieces', pieceController.get_all_pieces)

/// // piece request
router.post('/pr', pieceRequestController.add_piece_request)
router.post('/sendPr/:id', pieceRequestController.change_pr_status_to_sent_by_agent)
router.put('/prDescription/:id', pieceRequestController.update_pr_description)
router.put('/addPrItems/:prId', pieceRequestController.add_pieces_to_pr)
router.delete('/removePrItems/:pieceItemId', pieceRequestController.remove_piece_from_pr)
router.delete('/pr/:id', pieceRequestController.delete_pr)
router.get('/prList', pieceRequestController.get_all_pr_for_agent)
router.get('/pr/:id', pieceRequestController.get_one_pr_for_agent)

/// // oldPiece request
router.post('/opr', oldPieceRequestController.add_oldPiece_request)
router.post('/sendOpr/:id', oldPieceRequestController.change_opr_status_to_sent_by_agent)
router.put('/oprDescription/:id', oldPieceRequestController.update_opr_description)
router.put('/addOprItems/:oprId', oldPieceRequestController.add_oldPieces_to_opr)
router.delete('/removeOprItems/:oldPieceItemId', oldPieceRequestController.remove_oldPiece_from_opr)
router.delete('/opr/:id', oldPieceRequestController.delete_opr)
router.get('/oprList', oldPieceRequestController.get_all_opr_for_agent)
router.get('/opr/:id', oldPieceRequestController.get_one_opr_for_agent)

/// // buffer request
router.post('/br', bufferRequestController.add_buffer_request)
router.post('/sendBr/:id', bufferRequestController.change_br_status_to_sent_by_agent)
router.put('/brDescription/:id', bufferRequestController.update_br_description)
router.put('/addBrItems/:brId', bufferRequestController.add_buffer_to_br)
router.delete('/removeBrItems/:bufferItemId', bufferRequestController.remove_buffer_from_br)
router.delete('/br/:id', bufferRequestController.delete_br)
router.get('/brList', bufferRequestController.get_all_br_for_agent)
router.get('/br/:id', bufferRequestController.get_one_br_for_agent)

/// // guarantee report
router.post('/gr', guaranteeReportController.add_guaranteeReport)
router.post('/sendGr/:id', guaranteeReportController.change_gr_status_to_sent_by_agent)
router.put('/grDescription/:id', guaranteeReportController.update_gr_description)
router.put('/addGrItems/:grId', guaranteeReportController.add_report_to_gr)
router.delete('/removeGrItems/:reportItemId', guaranteeReportController.remove_report_from_gr)
router.delete('/gr/:id', guaranteeReportController.delete_gr)
router.get('/grList', guaranteeReportController.get_all_gr_for_agent)
router.get('/gr/:id', guaranteeReportController.get_one_gr_for_agent)

module.exports = router
