Skip to content

Commit

Permalink
refactor: add project-details tab card components (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshift authored Apr 7, 2024
1 parent 3d40563 commit 72c3907
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/projects/components/project-details-cards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const ProjectDetailsCards = ({ projects }: Props) => {
return (
<div className="flex flex-col gap-6">
{projects.map((project) => (
<ProjectDetailsCard key={project.id} project={project} />
<ProjectDetailsCard key={project.id} withActions project={project} />
))}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import { ProjectDetailsCardLinks } from './links';

interface Props {
project: ProjectAllInfo;
withActions?: boolean;
}

export const ProjectDetailsCard = ({ project }: Props) => {
export const ProjectDetailsCard = ({ project, withActions }: Props) => {
const { name, website, logo, description, chains } = project;

const src = getLogoUrl(website, logo);
Expand Down Expand Up @@ -62,11 +63,15 @@ export const ProjectDetailsCard = ({ project }: Props) => {

<ChainsInfoTag chains={chains} />

<Divider />
{withActions && (
<>
<Divider />

<DetailsPanelActionsWrapper>
<DetailsPanelCTA text={CTA_TEXT} />
</DetailsPanelActionsWrapper>
<DetailsPanelActionsWrapper>
<DetailsPanelCTA text={CTA_TEXT} />
</DetailsPanelActionsWrapper>
</>
)}
</DetailsPanelCardWrapper>
);
};
Expand Down
21 changes: 19 additions & 2 deletions src/projects/pages/project-params-page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use client';

import dynamic from 'next/dynamic';

import { ROUTE_TABS } from '~/shared/core/constants';

import { useProjectDetails } from '~/projects/hooks/use-project-details';
Expand All @@ -16,8 +18,23 @@ export const ProjectParamsPage = ({ params: { id, tab } }: Props) => {

if (!data) return null;

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

if (tab === ROUTE_TABS.SHARED.ORG) {
return <OrgDetailsCard withActions org={data.organization} />;
}

return null;
};

const ProjectDetailsCard = dynamic(() =>
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),
);

0 comments on commit 72c3907

Please sign in to comment.