From 44bd2028dd4cd97243eae3bdcfafc71bf0bbf203 Mon Sep 17 00:00:00 2001 From: John Ballesteros Date: Fri, 22 Nov 2024 17:51:43 +0800 Subject: [PATCH] fix: projects not showing org info Fixes JOB-854 --- .../org-details-card/funding-rounds.tsx | 90 ++++++++++--------- .../project-details-panel-header.tsx | 10 +-- src/projects/components/project-tabs.tsx | 24 ++--- src/projects/core/schemas.ts | 2 +- src/projects/pages/project-params-page.tsx | 44 ++++----- 5 files changed, 86 insertions(+), 84 deletions(-) diff --git a/src/orgs/components/org-details-card/funding-rounds.tsx b/src/orgs/components/org-details-card/funding-rounds.tsx index 7ed246b..0b8f204 100644 --- a/src/orgs/components/org-details-card/funding-rounds.tsx +++ b/src/orgs/components/org-details-card/funding-rounds.tsx @@ -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'; @@ -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: , - }); - } + if (roundName) { + tags.push({ + text: `Funding Round: ${roundName}`, + icon: , + }); + } - tags.push({ - text: `Funding Date: ${shortTimestamp(date)}`, - icon: , - }); + tags.push({ + text: `Funding Date: ${shortTimestamp(date)}`, + icon: , + }); - if (raisedAmount) { - tags.push({ - text: `Raised Amount: $${formatNumber(raisedAmount)}M`, - icon: , - }); - } + if (raisedAmount) { + tags.push({ + text: `Raised Amount: $${formatNumber(raisedAmount)}M`, + icon: , + }); + } - return tags; + return tags; }; const DashedLine = () => ( -
-
-
+
+
+
); 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 ( - <> - + return ( + <> + - + -
- {fundingRounds.map((fundingRound, i) => ( - <> -
- -
- {i !== count - 1 && } - - ))} -
- - ); +
+ {fundingRounds.map((fundingRound, i) => ( + +
+ +
+ {i !== count - 1 && } +
+ ))} +
+ + ); }; diff --git a/src/projects/components/project-details-panel-header.tsx b/src/projects/components/project-details-panel-header.tsx index 323484f..ed0db34 100644 --- a/src/projects/components/project-details-panel-header.tsx +++ b/src/projects/components/project-details-panel-header.tsx @@ -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 ; - if (!data.organization) return null; + if (!data) return ; + if (data.organizations.length === 0) return null; - return ; + return ; }; diff --git a/src/projects/components/project-tabs.tsx b/src/projects/components/project-tabs.tsx index c080056..3aa617f 100644 --- a/src/projects/components/project-tabs.tsx +++ b/src/projects/components/project-tabs.tsx @@ -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 ; + return ; }; diff --git a/src/projects/core/schemas.ts b/src/projects/core/schemas.ts index 19d0940..e80eb68 100644 --- a/src/projects/core/schemas.ts +++ b/src/projects/core/schemas.ts @@ -32,7 +32,7 @@ export type ProjectOrg = z.infer; export const projectDetailsSchema = z .object({ - organization: projectOrgSchema.nullable().optional(), + organizations: z.array(projectOrgSchema), }) .merge(projectAllInfoSchema); diff --git a/src/projects/pages/project-params-page.tsx b/src/projects/pages/project-params-page.tsx index a4b6a04..397aaba 100644 --- a/src/projects/pages/project-params-page.tsx +++ b/src/projects/pages/project-params-page.tsx @@ -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 ; - } + if (tab === ROUTE_TABS.SHARED.DETAILS) { + return ; + } - if (data.organization && tab === ROUTE_TABS.SHARED.ORG) { - return ( - - ); - } + if (data.organizations.length > 0 && tab === ROUTE_TABS.SHARED.ORG) { + return ( + + ); + } - return null; + return null; };