fix: validate earned inspection resources
This commit is contained in:
1 parent
aa49634d93
commit
d025f51733
5 files changed
+23
-3
No files matched your search
+5
-1
@@ -384,7 +384,11 @@
|
||||
} else if (activity === 'inspection') {
|
||||
data.place = document.querySelector('#pointsInspection [name="place"]').value;
|
||||
data.inspections = Number(document.querySelector('#pointsInspection [name="inspections"]').value);
|
||||
data.resources = [...document.querySelector('#pointsInspection [name="resources"]').value.matchAll(/^\+\s*(\d+)\s+(.+)$/gm)].map(match => [match[2].trim(), Number(match[1])]);
|
||||
data.resources = document.querySelector('#pointsInspection [name="resources"]').value.split('\n').map(line => line.trim()).filter(Boolean).map(line => {
|
||||
const match = line.match(/^\+\s*(\d+)\s+(.+)$/);
|
||||
if (!match) throw new Error('Ресурс укажите так: +2 вьюнок.');
|
||||
return [match[2].trim(), Number(match[1])];
|
||||
});
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user