diff --git a/src/grants/components/grant-card/grant-card.tsx b/src/grants/components/grant-card/grant-card.tsx index 333aa3f..9c77738 100644 --- a/src/grants/components/grant-card/grant-card.tsx +++ b/src/grants/components/grant-card/grant-card.tsx @@ -9,5 +9,5 @@ interface Props { export const GrantCard = ({ grant }: Props) => { // TODO: JOB-678 - return } />; + return } />; }; diff --git a/src/grants/components/grant-item/content.tsx b/src/grants/components/grant-item/content.tsx new file mode 100644 index 0000000..5a86300 --- /dev/null +++ b/src/grants/components/grant-item/content.tsx @@ -0,0 +1,79 @@ +import { Avatar, AvatarGroup } from '@nextui-org/react'; + +import { formatNumber } from '@/shared/utils/format-number'; + +import { Grant } from '@/grants/core/types'; + +interface Props { + grant: Grant; + cta: React.ReactNode; +} + +export const GrantItemContent = ({ grant, cta }: Props) => { + const { + name, + grantees, + networks, + ecosystem, + totalFunds, + totalDisbursedFunds, + summary, + categories, + type, + reputations, + } = grant; + + return ( + <> +
+ {name} +
+ {`Grantees ${grantees}`} +
+ Networks + + {networks.map(({ name, logo }) => ( + + ))} + +
+ {`Ecosystem ${ecosystem}`} + {`Total Funds $${formatNumber(totalFunds)}`} + {`Total Disbursed Funds $${formatNumber(totalDisbursedFunds)}`} +
+ +
+ {summary} +
+ Categories + {categories.map((category) => ( + {category} + ))} +
+
+ Type + {type} +
+
+ +
+ Reputations + {reputations.map((reputation) => ( + {reputation} + ))} +
+
+ + {cta} + + ); +}; diff --git a/src/grants/components/grant-item/grant-item.tsx b/src/grants/components/grant-item/grant-item.tsx index c4469be..bb68eea 100644 --- a/src/grants/components/grant-item/grant-item.tsx +++ b/src/grants/components/grant-item/grant-item.tsx @@ -1,96 +1,54 @@ import Link from 'next/link'; -import { Avatar, AvatarGroup } from '@nextui-org/react'; - -import { formatNumber } from '@/shared/utils/format-number'; +import { cn } from '@/shared/utils/cn'; import { GRANT_TEST_IDS } from '@/grants/core/constants'; import { Grant } from '@/grants/core/types'; +import { GrantItemContent } from './content'; + +const WRAPPER_CLASSNAME = + 'flex items-center justify-between gap-6 rounded-lg p-6'; + +const CARD_CLASSNAME = 'bg-gradient-to-l from-[#0D0D0D] to-primary'; + +const LINK_CLASSNAME = + 'bg-white/5 transition-all duration-300 hover:bg-white/10'; + interface Props { - grant: Omit; + grant: Grant; cta: React.ReactNode; + isCard?: boolean; } -export const GrantItem = (props: Props) => { - const { - grant: { - id, - name, - grantees, - networks, - ecosystem, - totalFunds, - totalDisbursedFunds, - summary, - categories, - type, - reputations, - }, - cta, - } = props; +export const GrantItem = ({ isCard, grant, cta }: Props) => { + // TODO: Complete JOB-679 - const href = `/grants/${id}`; + const href = `/grants/${grant.id}`; - // TODO: JOB-679 + const className = cn( + WRAPPER_CLASSNAME, + isCard ? CARD_CLASSNAME : LINK_CLASSNAME, + ); - return ( - -
- {name} -
- {`Grantees ${grantees}`} -
- Networks - - {networks.map(({ name, logo }) => ( - - ))} - -
- {`Ecosystem ${ecosystem}`} - {`Total Funds $${formatNumber(totalFunds)}`} - {`Total Disbursed Funds $${formatNumber(totalDisbursedFunds)}`} -
+ const content = ; -
- {summary} -
- Categories - {categories.map((category) => ( - {category} - ))} -
-
- Type - {type} -
-
+ const testProps = { + 'data-uuid': grant.id, + 'data-testid': GRANT_TEST_IDS.GRANT_ITEM, + }; -
- Reputations - {reputations.map((reputation) => ( - {reputation} - ))} -
+ if (isCard) { + return ( +
+ {content}
+ ); + } - {cta} + return ( + + {content} ); }; diff --git a/src/grants/core/constants.ts b/src/grants/core/constants.ts index a125c25..074e7bc 100644 --- a/src/grants/core/constants.ts +++ b/src/grants/core/constants.ts @@ -1,4 +1,5 @@ export const GRANT_TEST_IDS = { GRANT_ITEM: 'grant-item', + GRANT_CARD: 'grant-card', GRANTEE_ITEM: 'grantee-item', } as const;