@@ -2,14 +2,66 @@ import { StatsCard } from "./card";
22
33import  "./style.css" ; 
44
5- export  function  ExperienceStats ( )  { 
5+ export  function  ExperienceStats ( {  stats } )  { 
6+   const  findMonths  =  ( exp )  =>  { 
7+     const  {  start,  end,  professional }  =  exp ; 
8+     if  ( ! professional )  return  0 ; 
9+     
10+     const  startDate  =  new  Date ( start ) ; 
11+     const  endDate  =  end  ? new  Date ( end )  : new  Date ( ) ; 
12+ 
13+     const  months  =  ( 
14+       endDate . getFullYear ( )  -  startDate . getFullYear ( ) 
15+     )  *  12  +  ( endDate . getMonth ( )  -  startDate . getMonth ( ) )  +  1 ; 
16+     
17+     return  months ; 
18+   } 
19+ 
20+   const  experienceMonths  =  stats . reduce ( 
21+     ( acc ,  exp )  =>  findMonths ( exp )  +  acc ,  0 
22+   ) ; 
23+ 
24+   const  experienceDomains  =  new  Set ( stats . reduce ( 
25+     ( acc ,  exp )  =>  ( [ 
26+       ...exp . tags . domains , 
27+       ...acc , 
28+     ] ) ,  [ ] 
29+   ) ) . size ; 
30+ 
31+   const  experienceTools  =  new  Set ( stats . reduce ( 
32+     ( acc ,  exp )  =>  ( [ 
33+       ...exp . tags . tools , 
34+       ...acc , 
35+     ] ) ,  [ ] 
36+   ) ) . size ; 
37+ 
638  return  ( < > 
739    < div  className = "stats" > 
840      < div  className = "stats-rows" > 
9-         < StatsCard  stat = { 9 }  desc = { "months of experience" }  /> 
10-         < div  className = "stat-cols" > 
11-           < StatsCard  stat = { 9 }  desc = { "months of experience" }  /> 
12-           < StatsCard  stat = { 9 }  desc = { "months of experience" }  /> 
41+         < div  className = "stats-cols" > 
42+         < StatsCard 
43+           stat = { 
44+             experienceMonths  >  12 
45+             ? ( experienceMonths  /  12 ) . toFixed ( 1 ) 
46+             : experienceMonths 
47+           } 
48+           desc = { 
49+             experienceMonths  >  12 
50+             ? "years of experience" 
51+             : "months of experience" 
52+           } 
53+         /> 
54+         </ div > 
55+         < div  className = "stats-cols" > 
56+           < StatsCard 
57+             stat = { experienceDomains } 
58+             desc = { "domains worked in" } 
59+           /> 
60+           
61+           < StatsCard 
62+             stat = { experienceTools } 
63+             desc = { "tools used" } 
64+           /> 
1365        </ div > 
1466      </ div > 
1567    </ div > 
0 commit comments