|  |  |  | @ -1079,14 +1079,22 @@ exports.createquotationforSensor = async (req, reply) => { | 
			
		
	
		
			
				
					|  |  |  |  |     const { installationId } = req.params; | 
			
		
	
		
			
				
					|  |  |  |  |     const { customerId, masters, slaves, motor_switches, electricals } = req.body; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     // Validate electricals field to ensure it's an array of objects
 | 
			
		
	
		
			
				
					|  |  |  |  |     if (!Array.isArray(electricals) || electricals.some(e => typeof e !== 'object')) { | 
			
		
	
		
			
				
					|  |  |  |  |       return reply.code(400).send({ | 
			
		
	
		
			
				
					|  |  |  |  |         success: false, | 
			
		
	
		
			
				
					|  |  |  |  |         message: 'Invalid data format for electricals. It should be an array of objects with "name" and "type".' | 
			
		
	
		
			
				
					|  |  |  |  |       }); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     // Create a new SensorQuotation document
 | 
			
		
	
		
			
				
					|  |  |  |  |     const newQuotation = new SensorQuotation({ | 
			
		
	
		
			
				
					|  |  |  |  |       customerIdId: customerId, | 
			
		
	
		
			
				
					|  |  |  |  |       installationId: installationId,  // Assuming installationId is being used as InstallerId
 | 
			
		
	
		
			
				
					|  |  |  |  |       customerId: customerId, | 
			
		
	
		
			
				
					|  |  |  |  |       installationId: installationId,  // Using installationId for the field
 | 
			
		
	
		
			
				
					|  |  |  |  |       masters, | 
			
		
	
		
			
				
					|  |  |  |  |       slaves, | 
			
		
	
		
			
				
					|  |  |  |  |       motor_switches, | 
			
		
	
		
			
				
					|  |  |  |  |       electricals,  // This will store the array of electrical items
 | 
			
		
	
		
			
				
					|  |  |  |  |       electricals,  // This will store the array of electrical items (objects)
 | 
			
		
	
		
			
				
					|  |  |  |  |     }); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     // Save the document to the database
 | 
			
		
	
	
		
			
				
					|  |  |  | 
 |