Better error handling and more lenient on the imported values

This commit is contained in:
Zsombor Gegesy
2024-02-24 12:47:41 +01:00
parent 550e15228e
commit 5a2c222d61
2 changed files with 7 additions and 4 deletions

View File

@ -186,7 +186,7 @@ export const ImportDialog = () => {
toast({
variant: "error",
title: t`Oops, the server returned an error.`,
description: importError?.message,
description: error?.message,
});
}
};

View File

@ -55,6 +55,9 @@ export class LinkedInParser implements Parser<JSZip, LinkedIn> {
convert(data: LinkedIn) {
const result = JSON.parse(JSON.stringify(defaultResumeData)) as ResumeData;
function avoidToShort(name, len) {
if (!name || name.length<len) { return "Unknown" } else { return name; }
};
// Profile
if (data.Profile && data.Profile.length > 0) {
@ -109,9 +112,9 @@ export class LinkedInParser implements Parser<JSZip, LinkedIn> {
result.sections.education.items.push({
...defaultEducation,
id: createId(),
institution: education["School Name"],
studyType: education["Degree Name"],
summary: education.Notes ?? "",
institution: avoidToShort(education["School Name"], 2),
studyType: avoidToShort(education["Degree Name"], 2),
summary: avoidToShort(education.Notes ?? "", 2),
date: `${education["Start Date"]} - ${education["End Date"] ?? "Present"}`,
});
}