Parsing body number from autocod. Fixing error with null vin

This commit is contained in:
Selim Mustafaev 2021-10-22 23:08:19 +03:00
parent 3b77fdd528
commit 7d00a77f8b
2 changed files with 6 additions and 1 deletions

View File

@ -44,6 +44,7 @@ class Vehicle {
v.pts = report.fields.identifiers.vehicle.pts; v.pts = report.fields.identifiers.vehicle.pts;
v.sts = report.fields.identifiers.vehicle.sts; v.sts = report.fields.identifiers.vehicle.sts;
v.vin1 = report.fields.identifiers.vehicle.vin; v.vin1 = report.fields.identifiers.vehicle.vin;
v.vin2 = report.fields.identifiers.vehicle.body;
v.photos = report.fields.images.photos.items.map(p => { v.photos = report.fields.images.photos.items.map(p => {
return { return {
brand: p.vehicle.brand.name, brand: p.vehicle.brand.name,

View File

@ -64,7 +64,11 @@ router.post('/check', async (req, res) => {
} }
} else { } else {
vehicle = autocod.value; vehicle = autocod.value;
let vinMatch = vin01.value.vin1.match(RegExp(vehicle.vin1.replace(/\*/g, '.'))); let vinMatch = false;
if(vin01.value.vin1 && vehicle.vin1) {
vinMatch = vin01.value.vin1.match(RegExp(vehicle.vin1.replace(/\*/g, '.')));
}
if(vehicle.vin1 && vinMatch) { if(vehicle.vin1 && vinMatch) {
vehicle.vin1 = vin01.value.vin1; vehicle.vin1 = vin01.value.vin1;
vehicle.vin2 = vin01.value.vin2; vehicle.vin2 = vin01.value.vin2;