at main 1.5 kB view raw
1import { Heading } from '@/components/Heading/Heading'; 2import { Paragraph } from '@/components/Paragraph/Paragraph'; 3import React from 'react'; 4import * as styles from './CardRole.styles'; 5import { CardRoleProps } from './CardRole.types'; 6 7/** 8 * Format date string to readable format 9 */ 10function formatDate(dateString: string): string { 11 const date = new Date(dateString); 12 if (isNaN(date.getTime())) return dateString; 13 14 return date.toLocaleDateString('en-US', { 15 year: 'numeric', 16 month: 'short', 17 }); 18} 19 20export const CardRole: React.FC<CardRoleProps> = ({ role }) => { 21 const startDate = formatDate(role.startDate); 22 const endDate = role.endDate ? formatDate(role.endDate) : 'Present'; 23 const dateRange = `${startDate}${endDate}`; 24 25 return ( 26 <div className={styles.cardWrapper}> 27 {/* Content */} 28 <div className={styles.contentContainer}> 29 {/* Company Name (left) and Date (right) */} 30 <div className={styles.metaContainer}> 31 <span className={styles.companyName}>{role.company}</span> 32 <span className={styles.date}>{dateRange}</span> 33 </div> 34 <div className={styles.detailContainer}> 35 {/* Position Title */} 36 <Heading level={3} size="md"> 37 {role.position} 38 </Heading> 39 40 {/* Description */} 41 {role.description && <Paragraph size="base">{role.description}</Paragraph>} 42 </div> 43 </div> 44 </div> 45 ); 46};