diff --git a/src/orgs/atoms/active-org-id-atom.ts b/src/orgs/atoms/active-org-id-atom.ts new file mode 100644 index 000000000..7d66979fc --- /dev/null +++ b/src/orgs/atoms/active-org-id-atom.ts @@ -0,0 +1,3 @@ +import { atom } from 'jotai'; + +export const activeOrgIdAtom = atom(null); diff --git a/src/orgs/components/org-card/create-org-card-tags.tsx b/src/orgs/components/org-card/create-org-card-tags.tsx new file mode 100644 index 000000000..b64052a2a --- /dev/null +++ b/src/orgs/components/org-card/create-org-card-tags.tsx @@ -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: , + link: `${baseRoute}/jobs`, + showExternalIcon: false, + }); + } + + if (projectCount > 0) { + tags.push({ + text: `${getPluralText('Project', projectCount)}: ${projectCount}`, + icon: , + link: `${baseRoute}/projects`, + showExternalIcon: false, + }); + } + + if (headcountEstimate) { + tags.push({ + text: `Employees ${headcountEstimate}`, + icon: , + }); + } + + if (lastFundingAmount) { + tags.push({ + text: `Last Funding: $${formatNumber(lastFundingAmount * 1_000_000)}`, + icon: , + }); + } + + if (lastFundingDate) { + tags.push({ + text: `Funding Date: ${shortTimestamp(lastFundingDate)}`, + icon: , + }); + } + + return tags; +}; diff --git a/src/orgs/components/org-card/index.tsx b/src/orgs/components/org-card/index.tsx new file mode 100644 index 000000000..9a90b178a --- /dev/null +++ b/src/orgs/components/org-card/index.tsx @@ -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 ( + + +
+ +
+

{name}

+

{location}

+
+
+

TODO

+
+ + {tags.length > 0 && } + + + +
+ ); +}; diff --git a/src/orgs/components/org-list.tsx b/src/orgs/components/org-list.tsx index 425de2e8c..5792c0988 100644 --- a/src/orgs/components/org-list.tsx +++ b/src/orgs/components/org-list.tsx @@ -6,6 +6,8 @@ import { VirtualWrapper } from '~/shared/components/virtual-wrapper'; import { useOrgList } from '~/orgs/hooks/use-org-list'; import { useFiltersContext } from '~/filters/providers/filters-provider/context'; +import { OrgCard } from './org-card'; + export const OrgList = () => { const { orgs, @@ -42,9 +44,10 @@ export const OrgList = () => { {(index) => (
0 })}> -
-
{JSON.stringify(orgs[index], undefined, '\t')}
-
+
)}
diff --git a/src/orgs/core/constants.ts b/src/orgs/core/constants.ts index 75b47b0ba..8a83ed645 100644 --- a/src/orgs/core/constants.ts +++ b/src/orgs/core/constants.ts @@ -30,3 +30,7 @@ export const ORG_REVIEW_TIMEZONES = [ 'GMT+13', 'GMT+14', ] as const; + +export const ORG_TEST_IDS = { + ORG_CARD: 'org-card', +} as const;