Skip to content

Commit 501834c

Browse files
f (#3719)
1 parent a3424aa commit 501834c

File tree

10 files changed

+2821
-5064
lines changed

10 files changed

+2821
-5064
lines changed

packages/grant-explorer/src/features/collections/CollectionCard.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,24 @@ export type CollectionCardProps = {
99
};
1010

1111
const CollectionCard = ({ collection, size }: CollectionCardProps) => {
12-
const { cid, author, name, numberOfProjects } = collection;
12+
const { cid, name, description } = collection;
1313

1414
return (
1515
<BasicCard className="w-full">
1616
<a
17-
href={collectionPath(cid)}
17+
href={collectionPath(cid!)}
1818
data-track-event={`home-collections-card-${size}`}
1919
>
2020
<CardHeader>
2121
<CollectionBanner />
2222
</CardHeader>
2323
<div className="p-4 space-y-1">
24-
<div className="font-medium truncate text-xl">{name}</div>
25-
<div className="flex justify-between items-center">
26-
<div className="text-grey-400 text-sm">
27-
{numberOfProjects} projects
28-
</div>
29-
<div className="text-sm flex gap-2 items-center truncate max-w-[20ch]">
30-
by
31-
<div className="truncate">
32-
<Badge rounded="full">{author}</Badge>
33-
</div>
34-
</div>
24+
<div className="font-medium truncate text-xl">
25+
{name}
3526
</div>
27+
<p className="text-grey-400 text-sm">
28+
{description}
29+
</p>
3630
</div>
3731
</a>
3832
</BasicCard>
Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,6 @@
11
export type CommunityCollection = {
2-
cid: string;
3-
author: string;
4-
name: string;
5-
numberOfProjects: number;
6-
description: string;
2+
cid: string | undefined;
3+
name: string | undefined;
4+
numberOfProjects: number | undefined;
5+
description: string | undefined;
76
};
8-
9-
const collections: CommunityCollection[] = [
10-
{
11-
cid: "bafkreigolvgncxvmkqdbmaeyedbtikw7fweisya2xtilten2vmftpgzazu",
12-
author: "Unknown",
13-
name: "Womyn in GG21",
14-
numberOfProjects: 19,
15-
description: "This collection showcases Womyn in GG21",
16-
},
17-
{
18-
cid: "bafkreia3o5nsbqrhf3qzlnhof2npna6ca3zbqvk2d74hzwcxpuzeris52a",
19-
author: "Let's GROW Live Hosts & Contributors",
20-
name: "Let's GROW Live Hosts & Contributors",
21-
numberOfProjects: 40,
22-
description: "People who consistently show up for the Gitcoin community & follow through with their commitment to host for 30 mins to 3+ hours single day throughout the rounds says a lot about these founders. It demonstrates dependability, reliability & tenacity. These predominantly Regen projects have also all signed the GROWfesto, which demonstrates they also have Regen values: https://letsgrow.network/manifesto\n\nLet's GROW!!!"
23-
},
24-
{
25-
cid: "bafkreig3tpdwcwr2cfbwwocrfiyqlqk7sqewednjgxj2uyt2527fsngu7e",
26-
author: "Philly Projects GG21 ",
27-
name: "Philly Projects GG21 ",
28-
numberOfProjects: 5,
29-
description: "We have 5 projects in our city in this round and regionally we have a lot of Gitcoiners. I think this collection would be of interest to many in the community. Our projects also exist across 4 different rounds on 2 different chains. Thank you for your consideration. "
30-
},
31-
{
32-
cid: "bafkreibb6euk3ikgaahecpw3zfp6gj2wsarthxrn74lpeyiz3pneenm7kq",
33-
author: "Waste Management/Incentives/Cleanups",
34-
name: "Waste Management/Incentives/Cleanups",
35-
numberOfProjects: 17,
36-
description: "Its urgently important to reward those who are building in proper waste management fields, cleanup and recycling, incentivizing users. We have a chance to create a new age plastic economy, but we all need support. And not only with funding, but with the exposure as well. "
37-
},
38-
{
39-
cid: "bafkreig72mf33s23ss3q4en5thy7k7ixjujtivb6bulpe3hcepo5altoyy",
40-
author: "The Token Jedi's GG21 OpenCivics Collection",
41-
name: "The Token Jedi's GG21 OpenCivics Collection",
42-
numberOfProjects: 11,
43-
description: "The Open Civics Round is full of incredible innovators working on critical resources for our movement's growth. Can't help but shill it forward and encourage everyone's generous grow-nations!"
44-
}
45-
// {
46-
// cid: "bafkreihkao32n3zjfffeuqm5bywgd67toztasrcpabyhrwjurfa7l35rse",
47-
// author: "Wasabi",
48-
// name: "Critical Infra + Scaling Web3",
49-
// numberOfProjects: 45,
50-
// description:
51-
// "This is a curated collection about long-tail yet critical projects for a massive Web3 Scaling and secure Critical Infrastructure for the Future.",
52-
// },
53-
];
54-
55-
export default collections;

packages/grant-explorer/src/features/collections/hooks/useCollections.ts

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,88 @@ import useSWR, { SWRResponse } from "swr";
22
import { CommunityCollection } from "../community";
33
import { CollectionV1, parseCollection } from "../collections";
44
import { getConfig } from "common/src/config";
5-
import communityCollections from "../community";
65

76
const config = getConfig();
87

8+
interface RawCollection {
9+
Timestamp: string;
10+
"Collection Name": string;
11+
"Link to collection": string;
12+
"Description": string;
13+
"Review State": string;
14+
}
15+
916
export const useCollections = (): SWRResponse<CommunityCollection[]> => {
1017
return useSWR(["collections"], async () => {
11-
return communityCollections;
18+
const collections = await fetchCommunityCollections();
19+
console.log("Fetching community collections...", collections);
20+
return collections;
1221
});
1322
};
1423

24+
const fetchCommunityCollections = async (): Promise<CommunityCollection[]> => {
25+
try {
26+
// Fetch the CSV file from the provided URL
27+
const response = await fetch(
28+
"https://docs.google.com/spreadsheets/d/e/2PACX-1vQndqhG0LcZ3omvRgUlp94Bzv_iGkFteXXcsl5wi6lArd2syVczbKXuGRZIn75B8rDQwcHd7ttpHVqG/pub?gid=653038372&single=true&output=csv"
29+
);
30+
const csvText = await response.text();
31+
32+
// Split the CSV text by lines
33+
const lines = csvText.trim().split("\n");
34+
35+
// Get the headers from the first line
36+
const headers = lines[0].split(",");
37+
38+
// Process the remaining lines as the data rows
39+
const communityCollections = await Promise.all(
40+
lines.slice(1).map(async (line) => {
41+
// Split each line by commas
42+
const values = line.split(",");
43+
44+
// Create a collection object by mapping headers to values
45+
const collection: Partial<RawCollection> = headers.reduce(
46+
(obj, header, index) => {
47+
obj[header.trim() as keyof RawCollection] = values[index].trim();
48+
return obj;
49+
},
50+
{} as Partial<RawCollection>
51+
); // Use Partial to allow missing fields
52+
53+
const {
54+
"Collection Name": name,
55+
"Link to collection": link,
56+
"Description":
57+
description,
58+
"Review State": reviewState,
59+
} = collection;
60+
61+
// Filter out collections where Review State is not "Approved"
62+
if (reviewState !== "Accepted") {
63+
return null; // Return null for unapproved collections
64+
}
65+
66+
// Extract the CID from the link (assuming it's the last part of the URL)
67+
const cid = link?.split("/").pop();
68+
69+
// Return the structured object with a fixed project count
70+
return {
71+
cid,
72+
name,
73+
description,
74+
numberOfProjects: 0, // note: keeping this as 0 as this querying from IPFS slows down
75+
};
76+
})
77+
);
78+
79+
// Filter out null values from the results
80+
return communityCollections.filter((collection) => collection !== null);
81+
} catch (error) {
82+
console.error("Error fetching community collections:", error);
83+
throw error;
84+
}
85+
};
86+
1587
export const useIpfsCollection = (
1688
cid: string | undefined
1789
): SWRResponse<CollectionV1> => {

packages/grant-explorer/src/features/discovery/CardBanner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function CollectionBanner() {
117117
const [gradient] = useState<string[]>(getRandomGradient());
118118
return (
119119
<div
120-
className="h-[192px]"
120+
className="h-[70px]"
121121
style={{
122122
background: `linear-gradient(180deg, #${gradient[0]} 0%, #${gradient[1]} 100%)`,
123123
}}

packages/grant-explorer/src/features/discovery/LandingPage.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,17 @@ const LandingPage = () => {
4040
);
4141
}, [roundsEndingSoon.data]);
4242

43-
// const collections = useCollections();
43+
const collections = useCollections();
4444

4545
return (
4646
<GradientLayout showWalletInteraction showAlloVersionBanner={false}>
4747
<LandingHero />
4848

49-
{/* Note: This is being revisited for GG Rounds */}
50-
{/* <LandingSection title="Community collections">
49+
<LandingSection title="Community collections">
5150
{collections.data !== undefined && (
5251
<CollectionsGrid data={collections.data} />
5352
)}
54-
</LandingSection> */}
53+
</LandingSection>
5554

5655
<LandingSection
5756
title="Donate now"

packages/grant-explorer/src/features/round/KarmaGrant/ImpactItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ChevronDownIcon } from "@heroicons/react/24/outline";
1212
import { ExpandableGrid } from "../../common/ExpandableGrid";
1313
import { dateFromMs } from "../../api/utils";
1414
import { FC } from "react";
15-
import { IGapImpact, getGapProjectImpactUrl } from "../../api/gap";
15+
import { IGapImpact } from "../../api/gap";
1616
import { ShieldCheckIcon } from "@heroicons/react/24/solid";
1717
import { useEnsName } from "wagmi";
1818

packages/grant-explorer/src/features/round/ViewCartPage/Summary.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useTokenPrice, TToken, stringToBlobUrl, getChainById } from "common";
2-
import { formatUnits } from "viem";
32

43
type SummaryProps = {
54
totalDonation: number;
@@ -62,7 +61,7 @@ export function Summary({
6261
className="rounded-md font-normal text-pink-500 flex justify-start items-center mt-2 mb-5 text-xs"
6362
>
6463
<span>
65-
{`Insufficient funds in your wallet.`} <br/>
64+
{`Insufficient funds in your wallet.`} <br />
6665
{`Please bridge funds over to ${getChainById(chainId).prettyName}.`}
6766
</span>
6867
</p>

packages/grant-explorer/src/features/round/ViewCartPage/SummaryContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { groupBy, uniqBy } from "lodash-es";
1818
import MRCProgressModal from "../../common/MRCProgressModal";
1919
import { MRCProgressModalBody } from "./MRCProgressModalBody";
2020
import { useCheckoutStore } from "../../../checkoutStore";
21-
import { Address, formatUnits, parseUnits, zeroAddress } from "viem";
21+
import { Address, parseUnits, zeroAddress } from "viem";
2222
import { useConnectModal } from "@rainbow-me/rainbowkit";
2323
import {
2424
matchingEstimatesToText,

packages/grant-explorer/src/hooks/attestations/useAttestMutation.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
TransactionError,
77
} from "./utils/handleTransactionError";
88
import { Abi, PublicClient, WalletClient } from "viem";
9-
import { legacyABI } from "./config";
109

1110
/**
1211
* Hook for the attestation mutation logic.

0 commit comments

Comments
 (0)