const express = require('express');
const router = express.Router();
const customerController = require('../controllers/customerController');
const multer = require('multer');
const upload = multer({ dest: 'uploads/' });

router.post('/', customerController.createCustomer);
router.get('/', customerController.getAllCustomers);
router.get('/:id', customerController.getCustomerById);
router.put('/:id', customerController.updateCustomer);
router.delete('/:id', customerController.deleteCustomer);
router.get('/withpayment/:id', customerController.getCustomerDetails);
router.get('/:id/payment-history', customerController.getCustomerPaymentHistory);
router.post('/bulk-upload', upload.single('file'), customerController.bulkUploadCustomers);

// Manual trigger to update totals
router.put('/:id/update-totals', customerController.updateCustomerTotals);

module.exports = router;
