import express from 'express'
import serviceController from '../controller/serviceController.js'
import authMiddleware from '../middleware/authMiddleware.js'

const router = express.Router()

// Create - Add new service
router.post('/add',authMiddleware, serviceController.addService)

// Read - Get all services
router.get('/all', serviceController.getAllServices)

// Read - Get service statistics
router.get('/stats', serviceController.getServiceStats)

// Read - Get services by userId
router.get('/user/:userId', serviceController.getServiceByUserId)

// Read - Get services by vehicle number
router.get('/vehicle/:vehicleNumber', serviceController.getServiceByVehicleNumber)

// Read - Get service by ID
router.get('/:id', serviceController.getServiceById)

// Update - Update service details
router.put('/:id',authMiddleware, serviceController.updateService)

// Update - Update service status
router.patch('/:id/status', serviceController.updateServiceStatus)

// Delete - Delete service
router.delete('/:id', serviceController.deleteService)

router.post('/invoice',authMiddleware,serviceController.addInvoice)
router.get('/invoice/:id',authMiddleware,serviceController.getServiceInvoice)

export default router
