-
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.
- Loading branch information
Showing
5 changed files
with
139 additions
and
3 deletions.
There are no files selected for viewing
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,3 @@ | ||
import { atom } from 'jotai'; | ||
|
||
export const activeOrgIdAtom = atom<string | null>(null); |
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,67 @@ | ||
import { InfoTagProps } from '~/shared/core/types'; | ||
import { formatNumber } from '~/shared/utils/format-number'; | ||
import { getPluralText } from '~/shared/utils/get-plural-text'; | ||
import { shortTimestamp } from '~/shared/utils/short-timestamp'; | ||
import { BankIcon } from '~/shared/components/icons/bank-icon'; | ||
import { CodeIcon } from '~/shared/components/icons/code-icon'; | ||
import { PaperBillIcon } from '~/shared/components/icons/paper-bill-icon'; | ||
import { SuitCaseIcon } from '~/shared/components/icons/suit-case-icon'; | ||
import { UsersThreeIcon } from '~/shared/components/icons/users-three-icon'; | ||
|
||
import { OrgListItem } from '~/orgs/core/schemas'; | ||
|
||
export const createOrgCardTags = (orgListItem: OrgListItem): InfoTagProps[] => { | ||
const { | ||
orgId, | ||
headcountEstimate, | ||
jobCount, | ||
projectCount, | ||
lastFundingAmount, | ||
lastFundingDate, | ||
} = orgListItem; | ||
|
||
const tags: InfoTagProps[] = []; | ||
|
||
const baseRoute = `/organizations/${orgId}`; | ||
|
||
if (jobCount > 0) { | ||
tags.push({ | ||
text: `${getPluralText('Job', jobCount)}: ${jobCount}`, | ||
icon: <SuitCaseIcon />, | ||
link: `${baseRoute}/jobs`, | ||
showExternalIcon: false, | ||
}); | ||
} | ||
|
||
if (projectCount > 0) { | ||
tags.push({ | ||
text: `${getPluralText('Project', projectCount)}: ${projectCount}`, | ||
icon: <CodeIcon />, | ||
link: `${baseRoute}/projects`, | ||
showExternalIcon: false, | ||
}); | ||
} | ||
|
||
if (headcountEstimate) { | ||
tags.push({ | ||
text: `Employees ${headcountEstimate}`, | ||
icon: <UsersThreeIcon />, | ||
}); | ||
} | ||
|
||
if (lastFundingAmount) { | ||
tags.push({ | ||
text: `Last Funding: $${formatNumber(lastFundingAmount * 1_000_000)}`, | ||
icon: <PaperBillIcon />, | ||
}); | ||
} | ||
|
||
if (lastFundingDate) { | ||
tags.push({ | ||
text: `Funding Date: ${shortTimestamp(lastFundingDate)}`, | ||
icon: <BankIcon />, | ||
}); | ||
} | ||
|
||
return tags; | ||
}; |
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,59 @@ | ||
import Link from 'next/link'; | ||
|
||
import { HREFS } from '~/shared/core/constants'; | ||
import { getLogoUrl } from '~/shared/utils/get-logo-url'; | ||
import { CardWrapper } from '~/shared/components/card-wrapper'; | ||
import { Divider } from '~/shared/components/divider'; | ||
import { InfoTags } from '~/shared/components/info-tags'; | ||
import { LogoTitle } from '~/shared/components/logo-title'; | ||
|
||
import { ORG_TEST_IDS } from '~/orgs/core/constants'; | ||
import { OrgListItem } from '~/orgs/core/schemas'; | ||
import { activeOrgIdAtom } from '~/orgs/atoms/active-org-id-atom'; | ||
|
||
import { createOrgCardTags } from './create-org-card-tags'; | ||
|
||
interface Props { | ||
orgItem: OrgListItem; | ||
isInit?: boolean; | ||
filterParamsString?: string; | ||
} | ||
|
||
export const OrgCard = ({ | ||
orgItem, | ||
isInit, | ||
filterParamsString = '', | ||
}: Props) => { | ||
const { orgId, url, logoUrl, name, location } = orgItem; | ||
|
||
const src = getLogoUrl(url, logoUrl); | ||
const tags = createOrgCardTags(orgItem); | ||
|
||
return ( | ||
<CardWrapper id={orgId} idAtom={activeOrgIdAtom}> | ||
<Link | ||
href={`${HREFS.ORGS_PAGE}/${orgId}/details${filterParamsString}`} | ||
scroll={false} | ||
data-testid={ORG_TEST_IDS.ORG_CARD} | ||
data-uuid={orgId} | ||
data-is-init={isInit ?? undefined} | ||
prefetch={true} | ||
className="flex flex-col gap-3 p-6" | ||
> | ||
<div className="flex items-center justify-between"> | ||
<LogoTitle src={src}> | ||
<div className="flex flex-col "> | ||
<h3 className={`font-lato text-lg font-bold`}>{name}</h3> | ||
<h4 className={`font-lato text-sm text-white/60`}>{location}</h4> | ||
</div> | ||
</LogoTitle> | ||
<p>TODO</p> | ||
</div> | ||
|
||
{tags.length > 0 && <Divider />} | ||
|
||
<InfoTags compact tags={tags} /> | ||
</Link> | ||
</CardWrapper> | ||
); | ||
}; |
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