-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add org aggregate-ratings-card component
- Loading branch information
Showing
6 changed files
with
139 additions
and
40 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/orgs/components/org-reviews/aggregate-ratings-card.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { DetailsPanelCardWrapper } from '~/shared/components/details-panel/card-wrapper'; | ||
import { Heading } from '~/shared/components/heading'; | ||
|
||
import { ORG_RATING_LABELS } from '~/orgs/core/constants'; | ||
import { OrgDetails } from '~/orgs/core/schemas'; | ||
|
||
interface Props { | ||
showInfos: boolean; | ||
infoTexts: React.ReactNode; | ||
actions: React.ReactNode; | ||
aggregateRatings: OrgDetails['aggregateRatings']; | ||
} | ||
|
||
export const AggregateRatingsCard = ({ | ||
showInfos, | ||
infoTexts, | ||
actions, | ||
aggregateRatings, | ||
}: Props) => { | ||
const ratings = Object.entries(aggregateRatings).filter( | ||
([, rating]) => rating !== null, | ||
) as [string, number][]; | ||
|
||
// const ratings = Object.entries({ | ||
// benefits: null, | ||
// careerGrowth: 4.5, | ||
// diversityInclusion: 3.9, | ||
// management: 3.4, | ||
// product: 3.3, | ||
// compensation: 4.9, | ||
// onboarding: 4.6, | ||
// workLifeBalance: null, | ||
// }).filter(([, rating]) => rating !== null) as [string, number][]; | ||
|
||
return ( | ||
<DetailsPanelCardWrapper> | ||
<Heading text={HEADING_TEXT} /> | ||
|
||
{showInfos && <>{infoTexts}</>} | ||
|
||
<div className="grid-cold-1 2xl:grid-cols-3 grid gap-3 sm:grid-cols-2"> | ||
{ratings.map(([label, rating]) => ( | ||
<div | ||
key={label} | ||
className="flex shrink-0 flex-wrap items-center justify-start gap-2" | ||
> | ||
<p>{rating.toFixed(1)}</p> | ||
{/* <Rating | ||
count={1} | ||
fractions={5} | ||
value={(rating ?? 0) / 5} | ||
color="gold" | ||
/> */} | ||
<p className="shrink-0"> | ||
{ORG_RATING_LABELS[label as keyof typeof ORG_RATING_LABELS]} | ||
</p> | ||
</div> | ||
))} | ||
</div> | ||
|
||
{showInfos && <>{actions}</>} | ||
</DetailsPanelCardWrapper> | ||
); | ||
}; | ||
|
||
const HEADING_TEXT = 'Aggregate Ratings'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
|
||
import { DetailsPanelCardWrapper } from '~/shared/components/details-panel/card-wrapper'; | ||
import { Heading } from '~/shared/components/heading'; | ||
|
||
interface Props { | ||
actions: React.ReactNode; | ||
infoTexts: React.ReactNode; | ||
} | ||
|
||
export const AnonReview = ({ actions, infoTexts }: Props) => { | ||
return ( | ||
<DetailsPanelCardWrapper> | ||
<Heading text={HEADING_TEXT} /> | ||
|
||
{infoTexts} | ||
|
||
{actions} | ||
</DetailsPanelCardWrapper> | ||
); | ||
}; | ||
|
||
const HEADING_TEXT = 'Leave a Review'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Text } from '~/shared/components/text'; | ||
|
||
export const InfoTexts = () => { | ||
return ( | ||
<> | ||
{INFO_TEXTS.map((text, i) => ( | ||
<Text key={i} text={text} /> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
const INFO_TEXTS = [ | ||
'Only devs associated with the org can review it.', | ||
"If you know anyone who works or worked here here, please invite them to review this organization. It's easy: Share the link above with them!", | ||
]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters