mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 14:25:17 +00:00
Removed forEach for normal for statements
This commit is contained in:
@@ -61,20 +61,29 @@ exports.pass = functions.https.onRequest(async (request, response) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
request.body.header.forEach((field, index) => {
|
for (let i = 0; i < request.body.header.length; i++) {
|
||||||
if (field.label !== "" || field.value !== "") {
|
const field = request.body.header[i];
|
||||||
|
|
||||||
|
if (!(field.label && field.value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
newPass.headerFields.push({
|
newPass.headerFields.push({
|
||||||
key: `header${index}`,
|
key: `header${i}`,
|
||||||
label: field.label,
|
label: field.label,
|
||||||
value: field.value,
|
value: field.value,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
request.body.primary.forEach((field, index) => {
|
for (let i = 0; i < request.body.primary.length; i++) {
|
||||||
if (field.label !== "" || field.value !== "") {
|
const field = request.body.primary[i];
|
||||||
|
|
||||||
|
if (!(field.label && field.value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
newPass.primaryFields.push({
|
newPass.primaryFields.push({
|
||||||
key: `primary${index}`,
|
key: `primary${i}`,
|
||||||
label: field.label,
|
label: field.label,
|
||||||
value:
|
value:
|
||||||
currentPassType == "boardingPass"
|
currentPassType == "boardingPass"
|
||||||
@@ -82,37 +91,48 @@ exports.pass = functions.https.onRequest(async (request, response) => {
|
|||||||
: field.value,
|
: field.value,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
request.body.secondary.forEach((field, index) => {
|
for (let i = 0; i < request.body.secondary.length; i++) {
|
||||||
if (field.label !== "" || field.value !== "") {
|
const field = request.body.secondary[i];
|
||||||
|
|
||||||
|
if (!(field.label && field.value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isElementInLastTwoPositions =
|
||||||
|
index === request.body.secondary.length - 2 ||
|
||||||
|
index === request.body.secondary.length - 1;
|
||||||
|
|
||||||
newPass.secondaryFields.push({
|
newPass.secondaryFields.push({
|
||||||
key: `secondary${index}`,
|
key: `secondary${i}`,
|
||||||
label: field.label,
|
label: field.label,
|
||||||
value: field.value,
|
value: field.value,
|
||||||
textAlignment:
|
textAlignment: isElementInLastTwoPositions
|
||||||
index === request.body.secondary.length - 2 ||
|
|
||||||
index === request.body.secondary.length - 1
|
|
||||||
? "PKTextAlignmentRight"
|
? "PKTextAlignmentRight"
|
||||||
: "PKTextAlignmentLeft",
|
: "PKTextAlignmentLeft",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
request.body.auxiliary.forEach((field, index) => {
|
for (let i = 0; i < request.body.auxiliary.length; i++) {
|
||||||
if (field.label !== "" || field.value !== "") {
|
const field = request.body.auxiliary[i];
|
||||||
|
|
||||||
|
if (!(field.label && field.value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isElementInLastTwoPositions =
|
||||||
|
index === request.body.auxiliary.length - 2 ||
|
||||||
|
index === request.body.auxiliary.length - 1;
|
||||||
|
|
||||||
newPass.auxiliaryFields.push({
|
newPass.auxiliaryFields.push({
|
||||||
key: `auxiliary${index}`,
|
key: `auxiliary${i}`,
|
||||||
label: field.label,
|
label: field.label,
|
||||||
value: field.value,
|
value: field.value,
|
||||||
textAlignment:
|
textAlignment: isElementInLastTwoPositions
|
||||||
index === request.body.secondary.length - 2 ||
|
|
||||||
index === request.body.secondary.length - 1
|
|
||||||
? "PKTextAlignmentRight"
|
? "PKTextAlignmentRight"
|
||||||
: "PKTextAlignmentLeft",
|
: "PKTextAlignmentLeft",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (!request.body.codeAlt || request.body.codeAlt.trim() === "") {
|
if (!request.body.codeAlt || request.body.codeAlt.trim() === "") {
|
||||||
newPass.setBarcodes({
|
newPass.setBarcodes({
|
||||||
|
|||||||
Reference in New Issue
Block a user