Skip to content

Commit

Permalink
refactor: org details card (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshift authored Apr 2, 2024
1 parent 7dabec8 commit fe4d3ac
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 38 deletions.
31 changes: 0 additions & 31 deletions src/jobs/components/job-org-card/index.tsx

This file was deleted.

7 changes: 4 additions & 3 deletions src/jobs/pages/job-params-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const JobParamsPage = ({ params: { id, tab } }: Props) => {

const getPageContent = (job: JobDetails, tab: string) => {
if (tab === ROUTE_TABS.SHARED.DETAILS) return <JobDetailsCard job={job} />;
if (tab === ROUTE_TABS.SHARED.ORG) return <JobOrgCard job={job} />;
if (tab === ROUTE_TABS.SHARED.ORG)
return <OrgDetailsCard withActions org={job.organization} />;
if (tab === ROUTE_TABS.JOBS.PROJECTS) return <JobProjectCards job={job} />;

if (tab === ROUTE_TABS.JOBS.COMPETITORS) {
Expand All @@ -43,8 +44,8 @@ const JobDetailsCard = dynamic(() =>
import('~/jobs/components/job-details-card').then((m) => m.JobDetailsCard),
);

const JobOrgCard = dynamic(() =>
import('~/jobs/components/job-org-card').then((m) => m.JobOrgCard),
const OrgDetailsCard = dynamic(() =>
import('~/orgs/components/org-details-card').then((m) => m.OrgDetailsCard),
);

const JobProjectCards = dynamic(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DetailsPanelActionsWrapper } from '~/shared/components/details-panel/ac
import { DetailsPanelCTA } from '~/shared/components/details-panel/cta';
import { Divider } from '~/shared/components/divider';

export const JobOrgCardActions = () => {
export const Actions = () => {
return (
<>
<Divider />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Props {
fundingRounds: FundingRound[];
}

export const JobOrgCardFundingRounds = ({ fundingRounds }: Props) => {
export const FundingRounds = ({ fundingRounds }: Props) => {
const count = fundingRounds.length;

if (!count) return null;
Expand Down
35 changes: 35 additions & 0 deletions src/orgs/components/org-details-card/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { FundingRound, Investor } from '~/shared/core/schemas';
import { DetailsPanelCardWrapper } from '~/shared/components/details-panel/card-wrapper';
import { Divider } from '~/shared/components/divider';
import { Heading } from '~/shared/components/heading';
import { Text } from '~/shared/components/text';

import { Actions } from './actions';
import { FundingRounds } from './funding-rounds';
import { Investors } from './investors';

interface Props {
org: {
name: string;
description: string;
fundingRounds: FundingRound[];
investors: Investor[];
};
withActions?: boolean;
}

export const OrgDetailsCard = ({
org: { name, description, fundingRounds, investors },
withActions,
}: Props) => {
return (
<DetailsPanelCardWrapper>
<Heading text={name} />
<Divider />
<Text text={description} />
<FundingRounds fundingRounds={fundingRounds} />
<Investors investors={investors} />
{withActions && <Actions />}
</DetailsPanelCardWrapper>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Props {
investors: Investor[];
}

export const JobOrgCardInvestors = ({ investors }: Props) => {
export const Investors = ({ investors }: Props) => {
const count = investors.length;

if (!count) return null;
Expand Down
3 changes: 2 additions & 1 deletion src/orgs/pages/org-params-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { ROUTE_TABS } from '~/shared/core/constants';

import { useOrgDetails } from '~/orgs/hooks/use-org-details';
import { OrgDetailsCard } from '~/orgs/components/org-details-card';

interface Props {
params: {
Expand All @@ -16,7 +17,7 @@ export const OrgParamsPage = ({ params: { id, tab } }: Props) => {

if (!data) return null;

if (tab === ROUTE_TABS.SHARED.DETAILS) return <p>OrgDetailsCard</p>;
if (tab === ROUTE_TABS.SHARED.DETAILS) return <OrgDetailsCard org={data} />;
if (tab === ROUTE_TABS.ORGS.PROJECTS) return <p>OrgProjectsCard</p>;
if (tab === ROUTE_TABS.ORGS.JOBS) return <p>OrgJobsCard</p>;
if (tab === ROUTE_TABS.ORGS.REVIEWS) return <p>OrgReviewsCard</p>;
Expand Down

0 comments on commit fe4d3ac

Please sign in to comment.