Enhance CarModifications component by integrating API calls for fetching modifications and customers, implementing a dialog for adding modifications to customers, and improving error and success message handling. Refactor state management and UI elements for better user experience.

This commit is contained in:
Alvin
2025-06-12 09:38:03 +02:00
parent 1ac852f2a1
commit f66670137b
11 changed files with 516 additions and 234 deletions

27
routes/modifications.js Normal file
View File

@@ -0,0 +1,27 @@
const express = require('express');
const router = express.Router();
const Modification = require('../models/Modification');
const auth = require('../middleware/auth');
// Get all modifications
router.get('/', async (req, res) => {
try {
const modifications = await Modification.find().sort({ name: 1 });
res.json(modifications);
} catch (err) {
res.status(500).json({ message: err.message });
}
});
// Add a new modification (admin only, or for seeding)
router.post('/', auth, async (req, res) => {
try {
const mod = new Modification(req.body);
await mod.save();
res.status(201).json(mod);
} catch (err) {
res.status(400).json({ message: err.message });
}
});
module.exports = router;