Update customer management functionality by adding modification support, enhancing the customer model to include modifications, and improving the UI for customer and modification forms. Refactor API routes for better error handling and streamline customer data management.

This commit is contained in:
Alvin
2025-06-10 11:38:27 +02:00
parent ec07b89dab
commit 1ac852f2a1
5 changed files with 329 additions and 145 deletions

View File

@@ -20,6 +20,7 @@ const customerSchema = new mongoose.Schema({
},
address: {
type: String,
required: true,
trim: true
},
carModel: {
@@ -28,10 +29,31 @@ const customerSchema = new mongoose.Schema({
trim: true
},
carYear: {
type: String,
required: true,
trim: true
type: Number,
required: true
},
modifications: [{
name: {
type: String,
required: true
},
description: {
type: String,
required: true
},
price: {
type: Number,
required: true
},
category: {
type: String,
required: true
},
dateAdded: {
type: Date,
default: Date.now
}
}],
createdAt: {
type: Date,
default: Date.now
@@ -48,4 +70,6 @@ customerSchema.pre('save', function(next) {
next();
});
module.exports = mongoose.model('Customer', customerSchema);
const Customer = mongoose.model('Customer', customerSchema);
module.exports = Customer;