Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Jun 3, 2024
1 parent 603c689 commit f1d0e58
Show file tree
Hide file tree
Showing 2 changed files with 16,871 additions and 11,971 deletions.
43 changes: 22 additions & 21 deletions packages/builder/src/components/grants/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useDataLayer } from "data-layer";
import { Badge, Image } from "@chakra-ui/react";
import { useEffect } from "react";
import { useEffect, useState } from "react";
import { shallowEqual, useDispatch, useSelector } from "react-redux";
import { Link } from "react-router-dom";
import { getChainById, renderToPlainText, stringToBlobUrl } from "common";
import { getChainById, renderToPlainText, stringToBlobUrl, TChain } from "common";

Check failure on line 6 in packages/builder/src/components/grants/Card.tsx

View workflow job for this annotation

GitHub Actions / lint-test-typecheck

Replace `·getChainById,·renderToPlainText,·stringToBlobUrl,·TChain·` with `⏎··getChainById,⏎··renderToPlainText,⏎··stringToBlobUrl,⏎··TChain,⏎`
import { fetchGrantData } from "../../actions/grantsMetadata";
import { DefaultProjectBanner, DefaultProjectLogo } from "../../assets";
import { RootState } from "../../reducers";
Expand All @@ -15,6 +15,9 @@ import LoadingCard from "./LoadingCard";
function Card({ projectId }: { projectId: string }) {
const dataLayer = useDataLayer();
const dispatch = useDispatch();

const [chain, setChain] = useState<TChain | undefined>(undefined);

const props = useSelector((state: RootState) => {
const grantMetadata = state.grantsMetadata[projectId];
const chainId = grantMetadata?.metadata?.chainId!;
Expand All @@ -26,17 +29,11 @@ function Card({ projectId }: { projectId: string }) {
const bannerImg = getProjectImage(loading, ImgTypes.bannerImg, project);
const logoImg = getProjectImage(loading, ImgTypes.logoImg, project);

const chain = getChainById(chainId);
const projectChainName = chain.prettyName;
const projectChainIconUri = stringToBlobUrl(chain.icon);

return {
id: projectId,
chainId,
loading,
currentProject: project,
projectChainName,
projectChainIconUri,
bannerImg,
logoImg,
status,
Expand All @@ -46,6 +43,8 @@ function Card({ projectId }: { projectId: string }) {
useEffect(() => {
if (projectId !== undefined && props.status === Status.Undefined) {
dispatch(fetchGrantData(projectId, dataLayer));
} else {
setChain(getChainById(props.chainId));
}
}, [dispatch, projectId, props.currentProject, props.status]);

Expand Down Expand Up @@ -100,19 +99,21 @@ function Card({ projectId }: { projectId: string }) {
</div>
</Link>

<div className="flex justify-end w-fit mt-auto">
<Badge
className="flex flex-row bg-gitcoin-grey-50 ml-6 mb-4 px-3 py-1 shadow-lg"
borderRadius="full"
>
<Image
src={props.projectChainIconUri}
alt="chain icon"
className="flex flex-row h-4 mr-1 mt-[1px] rounded-full"
/>
{props.projectChainName}
</Badge>
</div>
{ chain &&

Check failure on line 102 in packages/builder/src/components/grants/Card.tsx

View workflow job for this annotation

GitHub Actions / lint-test-typecheck

Replace `·chain·&&` with `chain·&&·(`
<div className="flex justify-end w-fit mt-auto">
<Badge
className="flex flex-row bg-gitcoin-grey-50 ml-6 mb-4 px-3 py-1 shadow-lg"
borderRadius="full"
>
<Image
src={stringToBlobUrl(chain.icon)}
alt="chain icon"
className="flex flex-row h-4 mr-1 mt-[1px] rounded-full"
/>
{chain.prettyName}
</Badge>
</div>
}

Check failure on line 116 in packages/builder/src/components/grants/Card.tsx

View workflow job for this annotation

GitHub Actions / lint-test-typecheck

Insert `)`
</>
)}
</div>
Expand Down
Loading

0 comments on commit f1d0e58

Please sign in to comment.