Skip to content

Commit 9526af5

Browse files
authored
Merge pull request #103 from NayanUnni95/resume/fix
[Fix] resolve Invalid redirect URL for Linkedin link on resume
2 parents acb5c76 + 1601181 commit 9526af5

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

www/lib/resume.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Text,
99
View,
1010
} from "@react-pdf/renderer";
11-
import type { LinkedInProfile } from "@/types/types";
11+
import type { LinkedInProfile, Profile, SocialAccount } from "@/types/types";
1212
import {
1313
getLinkedInProfileData,
1414
getProfileData,
@@ -142,7 +142,7 @@ const formatExperienceDuration = (
142142
end?: {
143143
month?: number;
144144
year?: number;
145-
} | null,
145+
} | null
146146
) => {
147147
const startMonth = start.month ? getMonthString(start.month) : "";
148148
const startYear = start.year;
@@ -208,7 +208,7 @@ const ResumeDocument = ({ data }: { data: ResumeData }) => (
208208
<Text style={styles.text}>
209209
{formatExperienceDuration(
210210
experience.duration.start,
211-
experience.duration.end,
211+
experience.duration.end
212212
)}
213213
</Text>
214214
</View>
@@ -313,10 +313,22 @@ const ResumeDocument = ({ data }: { data: ResumeData }) => (
313313
</Document>
314314
);
315315

316+
const getLinkedInUsername = (userProfile: Profile | any) => {
317+
if (!userProfile) return null;
318+
const linkedInAccount = userProfile?.social_accounts?.find(
319+
(account: SocialAccount) => account.provider === "linkedin"
320+
);
321+
const username =
322+
linkedInAccount?.url?.split("in/").pop()?.replace("/", "") || "";
323+
324+
return username || null;
325+
};
326+
316327
async function getResumeData(username: string): Promise<ResumeData> {
317328
const userProfile = await getProfileData(username);
318329
const userProjects = await getProjectData(username);
319-
const userLinkedInProfile = await getLinkedInProfileData(username);
330+
const linkedInUsername = getLinkedInUsername(userProfile);
331+
const userLinkedInProfile = await getLinkedInProfileData(linkedInUsername);
320332

321333
const defaultLinkedInProfile: LinkedInProfile = {
322334
experience: [],

0 commit comments

Comments
 (0)