Skip to content

Commit

Permalink
fix: projects not showing org info
Browse files Browse the repository at this point in the history
Fixes JOB-854
  • Loading branch information
johnshift committed Nov 22, 2024
1 parent 71f5fc7 commit 44bd202
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 84 deletions.
90 changes: 46 additions & 44 deletions src/orgs/components/org-details-card/funding-rounds.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Fragment } from 'react';

import { FundingRound } from '@/shared/core/schemas';
import { InfoTagProps } from '@/shared/core/types';
import { formatNumber } from '@/shared/utils/format-number';
Expand All @@ -11,66 +13,66 @@ import { InfoTags } from '@/shared/components/info-tags';
const HEADING_TEXT = 'Funding Rounds';

const createFundingRoundTags = (fundingRound: FundingRound) => {
const { roundName, date, raisedAmount } = fundingRound;
const { roundName, date, raisedAmount } = fundingRound;

const tags: InfoTagProps[] = [];
const tags: InfoTagProps[] = [];

if (roundName) {
tags.push({
text: `Funding Round: ${roundName}`,
icon: <PaperbillIcon />,
});
}
if (roundName) {
tags.push({
text: `Funding Round: ${roundName}`,
icon: <PaperbillIcon />,
});
}

tags.push({
text: `Funding Date: ${shortTimestamp(date)}`,
icon: <BankIcon />,
});
tags.push({
text: `Funding Date: ${shortTimestamp(date)}`,
icon: <BankIcon />,
});

if (raisedAmount) {
tags.push({
text: `Raised Amount: $${formatNumber(raisedAmount)}M`,
icon: <PaperbillIcon />,
});
}
if (raisedAmount) {
tags.push({
text: `Raised Amount: $${formatNumber(raisedAmount)}M`,
icon: <PaperbillIcon />,
});
}

return tags;
return tags;
};

const DashedLine = () => (
<div className="h-1 pt-0.5">
<hr className="border-t border-dashed border-white/20" />
</div>
<div className="h-1 pt-0.5">
<hr className="border-t border-dashed border-white/20" />
</div>
);

interface Props {
fundingRounds: FundingRound[];
fundingRounds: FundingRound[];
}

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

if (!count) return null;
if (!count) return null;

return (
<>
<Divider />
return (
<>
<Divider />

<Heading text={HEADING_TEXT} className="text-lg font-semibold" />
<Heading text={HEADING_TEXT} className="text-lg font-semibold" />

<div className="flex flex-col justify-center gap-2">
{fundingRounds.map((fundingRound, i) => (
<>
<div key={fundingRound.id} className="flex flex-wrap">
<InfoTags
tags={createFundingRoundTags(fundingRound)}
classNames={{ wrapper: 'gap-y-0' }}
/>
</div>
{i !== count - 1 && <DashedLine />}
</>
))}
</div>
</>
);
<div className="flex flex-col justify-center gap-2">
{fundingRounds.map((fundingRound, i) => (
<Fragment key={fundingRound.id}>
<div className="flex flex-wrap">
<InfoTags
tags={createFundingRoundTags(fundingRound)}
classNames={{ wrapper: 'gap-y-0' }}
/>
</div>
{i !== count - 1 && <DashedLine />}
</Fragment>
))}
</div>
</>
);
};
10 changes: 5 additions & 5 deletions src/projects/components/project-details-panel-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { DetailsPanelHeader } from '@/shared/components/details-panel/header';
import { useProjectDetails } from '@/projects/hooks/use-project-details';

interface Props {
slug: string;
slug: string;
}

export const ProjectDetailsPanelHeader = ({ slug }: Props) => {
const { data } = useProjectDetails(slug);
const { data } = useProjectDetails(slug);

if (!data) return <Spinner size="sm" color="white" />;
if (!data.organization) return null;
if (!data) return <Spinner size="sm" color="white" />;
if (data.organizations.length === 0) return null;

return <DetailsPanelHeader org={data.organization} />;
return <DetailsPanelHeader org={data.organizations[0]} />;
};
24 changes: 12 additions & 12 deletions src/projects/components/project-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import { DetailsPanelTabs } from '@/shared/components/details-panel/tabs';
import { useProjectDetails } from '@/projects/hooks/use-project-details';

const projectTabs = [
{ text: `Project Details`, href: `/${ROUTE_TABS.SHARED.DETAILS}` },
{ text: `Organization`, href: `/${ROUTE_TABS.SHARED.ORG}` },
{ text: `Project Details`, href: `/${ROUTE_TABS.SHARED.DETAILS}` },
{ text: `Organization`, href: `/${ROUTE_TABS.SHARED.ORG}` },
];

interface Props {
slug: string;
slug: string;
}

export const ProjectTabs = ({ slug }: Props) => {
const { data } = useProjectDetails(slug);
const { data } = useProjectDetails(slug);

if (!data) return null;
if (!data.organization) return null;
if (!data) return null;
if (data.organizations.length === 0) return null;

const prefix = `${HREFS.PROJECTS_PAGE}/${slug}`;
const tabs = projectTabs.map((tab) => ({
...tab,
href: `${prefix}${tab.href}`,
}));
const prefix = `${HREFS.PROJECTS_PAGE}/${slug}`;
const tabs = projectTabs.map((tab) => ({
...tab,
href: `${prefix}${tab.href}`,
}));

return <DetailsPanelTabs tabs={tabs} />;
return <DetailsPanelTabs tabs={tabs} />;
};
2 changes: 1 addition & 1 deletion src/projects/core/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type ProjectOrg = z.infer<typeof projectOrgSchema>;

export const projectDetailsSchema = z
.object({
organization: projectOrgSchema.nullable().optional(),
organizations: z.array(projectOrgSchema),
})
.merge(projectAllInfoSchema);

Expand Down
44 changes: 22 additions & 22 deletions src/projects/pages/project-params-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@ import { FRONTEND_URL } from '@/shared/core/envs';
import { useProjectDetails } from '@/projects/hooks/use-project-details';

const ProjectDetailsCard = dynamic(() =>
import(
'@/projects/components/project-details-cards/project-details-card'
).then((m) => m.ProjectDetailsCard),
import(
'@/projects/components/project-details-cards/project-details-card'
).then((m) => m.ProjectDetailsCard),
);

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

interface Props {
params: {
slug: string;
tab: string;
};
params: {
slug: string;
tab: string;
};
}

export const ProjectParamsPage = ({ params: { slug, tab } }: Props) => {
const { data } = useProjectDetails(slug);
const { data } = useProjectDetails(slug);

if (!data) return null;
if (!data) return null;

if (tab === ROUTE_TABS.SHARED.DETAILS) {
return <ProjectDetailsCard project={data} />;
}
if (tab === ROUTE_TABS.SHARED.DETAILS) {
return <ProjectDetailsCard project={data} />;
}

if (data.organization && tab === ROUTE_TABS.SHARED.ORG) {
return (
<OrgDetailsCard
org={data.organization}
actionHref={`${FRONTEND_URL}/organizations/${data.organization.normalizedName}/details`}
/>
);
}
if (data.organizations.length > 0 && tab === ROUTE_TABS.SHARED.ORG) {
return (
<OrgDetailsCard
org={data.organizations[0]}
actionHref={`${FRONTEND_URL}/organizations/${data.organizations[0].normalizedName}/details`}
/>
);
}

return null;
return null;
};

0 comments on commit 44bd202

Please sign in to comment.