@@ -586,8 +586,44 @@ console.log("Filtered Users:", filteredUsers);
586586 }
587587 </td>
588588 <td>${ user . education ?. [ 0 ] ?. graduation_date || "N/A" } </td>
589+ <td>${ user . about ?. dob ? calculateAge ( user . about . dob ) + " years" : "N/A" } </td>
589590 <td>${ user . skills ?. join ( ", " ) || "N/A" } </td>
590- ` ;
591+ <td>
592+ ${ user . social ?. github ? `<a href="${ user . social . github } " target="_blank">GitHub</a><br>` : "" }
593+ ${ user . social ?. instagram ? `<a href="${ user . social . instagram } " target="_blank">Instagram</a><br>` : "" }
594+ ${ user . social ?. leetcode ? `<a href="${ user . social . leetcode } " target="_blank">LeetCode</a><br>` : "" }
595+ ${ user . social ?. linkedin ? `<a href="${ user . social . linkedin } " target="_blank">LinkedIn</a>` : "" }
596+ </td>
597+ <td>
598+ ${ user . experience ?. map ( exp => {
599+ const duration = calculateExperience ( exp . startDate , exp . endDate ) ;
600+ return `<div><strong>${ exp . companyName } </strong>: ${ duration } </div>` ;
601+ } ) . join ( "" ) || "N/A" }
602+ </td>
603+ <td>
604+ <strong>Present:</strong><br>
605+ ${ user . address ?. present ?. address || "" } ${ user . address ?. present ?. city || "" } ${ user . address ?. present ?. state || "" } ${ user . address ?. present ?. zip || "" } <br><br>
606+ <strong>Permanent:</strong><br>
607+ ${ user . address ?. permanent ?. address || "" } ${ user . address ?. permanent ?. city || "" } ${ user . address ?. permanent ?. state || "" } ${ user . address ?. permanent ?. zip || "" }
608+ </td>
609+
610+ ` ;
611+
612+ // calculating experience
613+ function calculateExperience ( start , end ) {
614+ const startDate = new Date ( start ) ;
615+ const endDate = new Date ( end ) ;
616+ if ( isNaN ( startDate ) || isNaN ( endDate ) ) return "Invalid dates" ;
617+
618+ const months =
619+ ( endDate . getFullYear ( ) - startDate . getFullYear ( ) ) * 12 +
620+ ( endDate . getMonth ( ) - startDate . getMonth ( ) ) ;
621+
622+ if ( months < 12 ) return `${ months } months` ;
623+ const years = Math . floor ( months / 12 ) ;
624+ const remMonths = months % 12 ;
625+ return `${ years } year${ years > 1 ? "s" : "" } ${ remMonths ? ` ${ remMonths } months` : "" } ` ;
626+ }
591627
592628 // Rating Dropdown
593629 const ratingCell = document . createElement ( "td" ) ;
@@ -710,6 +746,20 @@ console.log("Filtered Users:", filteredUsers);
710746 }
711747}
712748
749+ // calculating age from dob
750+ function calculateAge ( dob ) {
751+ if ( ! dob ) return "N/A" ;
752+ const birthDate = new Date ( dob ) ;
753+ const today = new Date ( ) ;
754+ let age = today . getFullYear ( ) - birthDate . getFullYear ( ) ;
755+ const monthDiff = today . getMonth ( ) - birthDate . getMonth ( ) ;
756+
757+ if ( monthDiff < 0 || ( monthDiff === 0 && today . getDate ( ) < birthDate . getDate ( ) ) ) {
758+ age -- ;
759+ }
760+ return age ;
761+ }
762+
713763// Function to update user rating in Firestore
714764async function updateUserRating ( email , rating ) {
715765 try {
0 commit comments