[FE][Certs] Fixes #16: Reject cert generation if a custom label is missing

This commit is contained in:
Araozu 2023-12-16 09:40:43 -05:00
parent a97690c518
commit 1feeb70af8

View File

@ -177,9 +177,17 @@ export function generateCert(person: Person, register: Register, coursesMap: {[c
const personFullName = `${person.person_names} ${person.person_paternal_surname} ${person.person_maternal_surname}`; const personFullName = `${person.person_names} ${person.person_paternal_surname} ${person.person_maternal_surname}`;
// Manage custom label // Manage custom label
const certCustomLabel = register.register_custom_label === 1 let certCustomLabel = "";
? "" if (register.register_custom_label === 1) {
: customLabelsMap()[register.register_custom_label]?.custom_label_value ?? ""; certCustomLabel = "";
} else {
const customLabel = customLabelsMap()[register.register_custom_label];
if (customLabel === undefined) {
alert(`Error. No se encontró la denominación con id ${register.register_custom_label}`);
return;
}
certCustomLabel = customLabel.custom_label_value;
}
const certCode = register.register_is_preview ? "0000" : register.register_code.toString().padStart(4, "0"); const certCode = register.register_is_preview ? "0000" : register.register_code.toString().padStart(4, "0");