Merge pull request #1790 from gzsombor/import-fixes

Better error handling and more lenient on the imported values
This commit is contained in:
Amruth Pillai
2024-03-10 10:23:58 +01:00
committed by GitHub
2 changed files with 12 additions and 5 deletions

View File

@ -182,11 +182,11 @@ export const ImportDialog = () => {
}
close();
} catch (error) {
} catch (error: any) {
toast({
variant: "error",
title: t`Oops, the server returned an error.`,
description: importError?.message,
description: error["message"],
});
}
};

View File

@ -55,6 +55,13 @@ export class LinkedInParser implements Parser<JSZip, LinkedIn> {
convert(data: LinkedIn) {
const result = JSON.parse(JSON.stringify(defaultResumeData)) as ResumeData;
function avoidTooShort(name: string, len: number) {
if (!name || name.length<len) {
return "Unknown";
} else {
return name;
}
};
// Profile
if (data.Profile && data.Profile.length > 0) {
@ -109,9 +116,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: avoidTooShort(education["School Name"], 2),
studyType: avoidTooShort(education["Degree Name"], 2),
summary: avoidTooShort(education.Notes ?? "", 2),
date: `${education["Start Date"]} - ${education["End Date"] ?? "Present"}`,
});
}