|
8 | 8 | Text, |
9 | 9 | View, |
10 | 10 | } from "@react-pdf/renderer"; |
11 | | -import type { LinkedInProfile } from "@/types/types"; |
| 11 | +import type { LinkedInProfile, Profile, SocialAccount } from "@/types/types"; |
12 | 12 | import { |
13 | 13 | getLinkedInProfileData, |
14 | 14 | getProfileData, |
@@ -142,7 +142,7 @@ const formatExperienceDuration = ( |
142 | 142 | end?: { |
143 | 143 | month?: number; |
144 | 144 | year?: number; |
145 | | - } | null, |
| 145 | + } | null |
146 | 146 | ) => { |
147 | 147 | const startMonth = start.month ? getMonthString(start.month) : ""; |
148 | 148 | const startYear = start.year; |
@@ -208,7 +208,7 @@ const ResumeDocument = ({ data }: { data: ResumeData }) => ( |
208 | 208 | <Text style={styles.text}> |
209 | 209 | {formatExperienceDuration( |
210 | 210 | experience.duration.start, |
211 | | - experience.duration.end, |
| 211 | + experience.duration.end |
212 | 212 | )} |
213 | 213 | </Text> |
214 | 214 | </View> |
@@ -313,10 +313,22 @@ const ResumeDocument = ({ data }: { data: ResumeData }) => ( |
313 | 313 | </Document> |
314 | 314 | ); |
315 | 315 |
|
| 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 | + |
316 | 327 | async function getResumeData(username: string): Promise<ResumeData> { |
317 | 328 | const userProfile = await getProfileData(username); |
318 | 329 | const userProjects = await getProjectData(username); |
319 | | - const userLinkedInProfile = await getLinkedInProfileData(username); |
| 330 | + const linkedInUsername = getLinkedInUsername(userProfile); |
| 331 | + const userLinkedInProfile = await getLinkedInProfileData(linkedInUsername); |
320 | 332 |
|
321 | 333 | const defaultLinkedInProfile: LinkedInProfile = { |
322 | 334 | experience: [], |
|
0 commit comments