Skip to content

Commit

Permalink
f (#3719)
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc authored Nov 3, 2024
1 parent a3424aa commit 501834c
Show file tree
Hide file tree
Showing 10 changed files with 2,821 additions and 5,064 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,24 @@ export type CollectionCardProps = {
};

const CollectionCard = ({ collection, size }: CollectionCardProps) => {
const { cid, author, name, numberOfProjects } = collection;
const { cid, name, description } = collection;

return (
<BasicCard className="w-full">
<a
href={collectionPath(cid)}
href={collectionPath(cid!)}
data-track-event={`home-collections-card-${size}`}
>
<CardHeader>
<CollectionBanner />
</CardHeader>
<div className="p-4 space-y-1">
<div className="font-medium truncate text-xl">{name}</div>
<div className="flex justify-between items-center">
<div className="text-grey-400 text-sm">
{numberOfProjects} projects
</div>
<div className="text-sm flex gap-2 items-center truncate max-w-[20ch]">
by
<div className="truncate">
<Badge rounded="full">{author}</Badge>
</div>
</div>
<div className="font-medium truncate text-xl">
{name}
</div>
<p className="text-grey-400 text-sm">
{description}
</p>
</div>
</a>
</BasicCard>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,6 @@
export type CommunityCollection = {
cid: string;
author: string;
name: string;
numberOfProjects: number;
description: string;
cid: string | undefined;
name: string | undefined;
numberOfProjects: number | undefined;
description: string | undefined;
};

const collections: CommunityCollection[] = [
{
cid: "bafkreigolvgncxvmkqdbmaeyedbtikw7fweisya2xtilten2vmftpgzazu",
author: "Unknown",
name: "Womyn in GG21",
numberOfProjects: 19,
description: "This collection showcases Womyn in GG21",
},
{
cid: "bafkreia3o5nsbqrhf3qzlnhof2npna6ca3zbqvk2d74hzwcxpuzeris52a",
author: "Let's GROW Live Hosts & Contributors",
name: "Let's GROW Live Hosts & Contributors",
numberOfProjects: 40,
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!!!"
},
{
cid: "bafkreig3tpdwcwr2cfbwwocrfiyqlqk7sqewednjgxj2uyt2527fsngu7e",
author: "Philly Projects GG21 ",
name: "Philly Projects GG21 ",
numberOfProjects: 5,
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. "
},
{
cid: "bafkreibb6euk3ikgaahecpw3zfp6gj2wsarthxrn74lpeyiz3pneenm7kq",
author: "Waste Management/Incentives/Cleanups",
name: "Waste Management/Incentives/Cleanups",
numberOfProjects: 17,
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. "
},
{
cid: "bafkreig72mf33s23ss3q4en5thy7k7ixjujtivb6bulpe3hcepo5altoyy",
author: "The Token Jedi's GG21 OpenCivics Collection",
name: "The Token Jedi's GG21 OpenCivics Collection",
numberOfProjects: 11,
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!"
}
// {
// cid: "bafkreihkao32n3zjfffeuqm5bywgd67toztasrcpabyhrwjurfa7l35rse",
// author: "Wasabi",
// name: "Critical Infra + Scaling Web3",
// numberOfProjects: 45,
// description:
// "This is a curated collection about long-tail yet critical projects for a massive Web3 Scaling and secure Critical Infrastructure for the Future.",
// },
];

export default collections;
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,88 @@ import useSWR, { SWRResponse } from "swr";
import { CommunityCollection } from "../community";
import { CollectionV1, parseCollection } from "../collections";
import { getConfig } from "common/src/config";
import communityCollections from "../community";

const config = getConfig();

interface RawCollection {
Timestamp: string;
"Collection Name": string;
"Link to collection": string;
"Description": string;
"Review State": string;
}

export const useCollections = (): SWRResponse<CommunityCollection[]> => {
return useSWR(["collections"], async () => {
return communityCollections;
const collections = await fetchCommunityCollections();
console.log("Fetching community collections...", collections);
return collections;
});
};

const fetchCommunityCollections = async (): Promise<CommunityCollection[]> => {
try {
// Fetch the CSV file from the provided URL
const response = await fetch(
"https://docs.google.com/spreadsheets/d/e/2PACX-1vQndqhG0LcZ3omvRgUlp94Bzv_iGkFteXXcsl5wi6lArd2syVczbKXuGRZIn75B8rDQwcHd7ttpHVqG/pub?gid=653038372&single=true&output=csv"
);
const csvText = await response.text();

// Split the CSV text by lines
const lines = csvText.trim().split("\n");

// Get the headers from the first line
const headers = lines[0].split(",");

// Process the remaining lines as the data rows
const communityCollections = await Promise.all(
lines.slice(1).map(async (line) => {
// Split each line by commas
const values = line.split(",");

// Create a collection object by mapping headers to values
const collection: Partial<RawCollection> = headers.reduce(
(obj, header, index) => {
obj[header.trim() as keyof RawCollection] = values[index].trim();
return obj;
},
{} as Partial<RawCollection>
); // Use Partial to allow missing fields

const {
"Collection Name": name,
"Link to collection": link,
"Description":
description,
"Review State": reviewState,
} = collection;

// Filter out collections where Review State is not "Approved"
if (reviewState !== "Accepted") {
return null; // Return null for unapproved collections
}

// Extract the CID from the link (assuming it's the last part of the URL)
const cid = link?.split("/").pop();

// Return the structured object with a fixed project count
return {
cid,
name,
description,
numberOfProjects: 0, // note: keeping this as 0 as this querying from IPFS slows down
};
})
);

// Filter out null values from the results
return communityCollections.filter((collection) => collection !== null);
} catch (error) {
console.error("Error fetching community collections:", error);
throw error;
}
};

export const useIpfsCollection = (
cid: string | undefined
): SWRResponse<CollectionV1> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function CollectionBanner() {
const [gradient] = useState<string[]>(getRandomGradient());
return (
<div
className="h-[192px]"
className="h-[70px]"
style={{
background: `linear-gradient(180deg, #${gradient[0]} 0%, #${gradient[1]} 100%)`,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ const LandingPage = () => {
);
}, [roundsEndingSoon.data]);

// const collections = useCollections();
const collections = useCollections();

return (
<GradientLayout showWalletInteraction showAlloVersionBanner={false}>
<LandingHero />

{/* Note: This is being revisited for GG Rounds */}
{/* <LandingSection title="Community collections">
<LandingSection title="Community collections">
{collections.data !== undefined && (
<CollectionsGrid data={collections.data} />
)}
</LandingSection> */}
</LandingSection>

<LandingSection
title="Donate now"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ChevronDownIcon } from "@heroicons/react/24/outline";
import { ExpandableGrid } from "../../common/ExpandableGrid";
import { dateFromMs } from "../../api/utils";
import { FC } from "react";
import { IGapImpact, getGapProjectImpactUrl } from "../../api/gap";
import { IGapImpact } from "../../api/gap";
import { ShieldCheckIcon } from "@heroicons/react/24/solid";
import { useEnsName } from "wagmi";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useTokenPrice, TToken, stringToBlobUrl, getChainById } from "common";
import { formatUnits } from "viem";

type SummaryProps = {
totalDonation: number;
Expand Down Expand Up @@ -62,7 +61,7 @@ export function Summary({
className="rounded-md font-normal text-pink-500 flex justify-start items-center mt-2 mb-5 text-xs"
>
<span>
{`Insufficient funds in your wallet.`} <br/>
{`Insufficient funds in your wallet.`} <br />
{`Please bridge funds over to ${getChainById(chainId).prettyName}.`}
</span>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { groupBy, uniqBy } from "lodash-es";
import MRCProgressModal from "../../common/MRCProgressModal";
import { MRCProgressModalBody } from "./MRCProgressModalBody";
import { useCheckoutStore } from "../../../checkoutStore";
import { Address, formatUnits, parseUnits, zeroAddress } from "viem";
import { Address, parseUnits, zeroAddress } from "viem";
import { useConnectModal } from "@rainbow-me/rainbowkit";
import {
matchingEstimatesToText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
TransactionError,
} from "./utils/handleTransactionError";
import { Abi, PublicClient, WalletClient } from "viem";
import { legacyABI } from "./config";

/**
* Hook for the attestation mutation logic.
Expand Down
Loading

0 comments on commit 501834c

Please sign in to comment.