import TimeAgo from "javascript-time-ago" ; import en from "javascript-time-ago/locale/en" ; import { IReviewUserCardItem } from "src/shared/constants/card" ; import { IJobDetails } from "../components/JobDetailsCard" ; import { GetJobDetails_job , GetJobDetails_job_reviews_items , } from "./types/GetJobDetails" ; TimeAgo . addLocale ( en ) ; const timeAgo = new TimeAgo ( "en-US" ) ; export const buildJobDetails = ( job ) : IJobDetails | undefined => job ? { name : job . name , companyName : job . company . name , companyId : job . company . id , companyLogoSrc : job . company . logo ?? "" , location : job . location ?? null , numRatings : job . reviews . count , avgRating : job . scoreAverages . overall , avgLearningMentorshipRating : job . scoreAverages . learningMentorship , avgMeaningfulWorkRating : job . scoreAverages . meaningfulWork , avgWorkLifeBalanceRating : job . scoreAverages . workLifeBalance , minHourlySalary : job . salaryMin . amount , maxHourlySalary : job . salaryMax . amount , hourlySalaryCurrency : job . salaryMin . currency , } : undefined ; export const buildJobReviewsCard = ( item ) : IReviewUserCardItem => ( { id : item . id , author : item . isLegacy ? "An InternCompass user" : "An intern+ user" , jobLocation : "" , relativeDate : item . isLegacy ? "A while ago" : timeAgo . format ( new Date ( item . createdAt ) ) , overallRating : item . score . overall , body : item . body , tags : item . tags , } ) ; export const buildJobReviewsCardList = ( data ? ) : IReviewUserCardItem [ ] => data ?. map ( buildJobReviewsCard ) ?? [ ] ;