Skip to content

Commit

Permalink
chore: redo donation history page (#3666)
Browse files Browse the repository at this point in the history
Co-authored-by: Aditya Anand M C <aditya.anandmc@gmail.com>
  • Loading branch information
hussedev and thelostone-mc authored Oct 3, 2024
1 parent a158dbb commit 19d9999
Show file tree
Hide file tree
Showing 45 changed files with 1,192 additions and 1,152 deletions.
59 changes: 0 additions & 59 deletions packages/grant-explorer/src/features/api/round.ts
Original file line number Diff line number Diff line change
@@ -1,66 +1,7 @@
import { ApplicationStatus } from "./types";
import { useEffect, useState } from "react";
import { Address, getAddress } from "viem";
import { Contribution, useDataLayer } from "data-layer";
import { dateToEthereumTimestamp } from "common";

export type RoundProject = {
id: string;
status: ApplicationStatus;
payoutAddress: string;
};

export type ContributionHistoryState =
| { type: "loading" }
| {
type: "loaded";
data: { chainIds: number[]; data: Contribution[] };
}
| { type: "error"; error: string };

export const useContributionHistory = (
chainIds: number[],
rawAddress: string
) => {
const [state, setState] = useState<ContributionHistoryState>({
type: "loading",
});
const dataLayer = useDataLayer();

useEffect(() => {
const fetchContributions = async () => {
let address: Address = "0x";
try {
address = getAddress(rawAddress.toLowerCase());
} catch (e) {
return Promise.resolve({
chainIds,
error: "Invalid address",
data: [],
});
}

const contributions = await dataLayer.getDonationsByDonorAddress({
address,
chainIds,
});

setState({
type: "loaded",
data: {
chainIds: chainIds,
data: contributions.map((contribution) => ({
...contribution,
timestamp: dateToEthereumTimestamp(
new Date(contribution.timestamp)
).toString(),
})),
},
});
};

fetchContributions();
}, [chainIds, dataLayer, rawAddress]);

return state;
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ export default function CopyToClipboardButton(props: CopyToClipboardType) {
return (
<Button
type="button"
className={`inline-flex bg-[#FFD9CD] text-black w-30 justify-center font-mono ${
active && "animate-[peachTransition_20s_ease-in]"
} ${props.styles}`}
className={`inline-flex text-black w-30 justify-center text-sm font-semibold bg-white border border-grey-100 ${props.styles}`}
onClick={async () => {
setActive(true);
setTimeout(() => setActive(false), 1000);

await navigator.clipboard.writeText(props.textToCopy);
}}
>
<LinkIcon className={props.iconStyle} aria-hidden="true" />
{active ? "Link Copied" : "Share Profile"}
<LinkIcon className={`mt-1 ${props.iconStyle}`} aria-hidden="true" />
<span className="ml-1">
{active ? "Link Copied" : "Share Profile"}
</span>
</Button>
);
}
4 changes: 2 additions & 2 deletions packages/grant-explorer/src/features/common/StatCard.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export function StatCard(props: { title: string; value: string | undefined }) {
return (
<div className="rounded-2xl bg-[#F7F7F7] font-mono p-4">
<div className="rounded-2xl bg-[#F7F7F7] font-mono px-6 py-7">
<div className="text-grey-400 text-4xl">{props.value}</div>
<div className="font-bold text-md pb-4 mt-4">{props.title}</div>
<div className="font-bold text-md mt-6">{props.title}</div>
</div>
);
}

This file was deleted.

Loading

0 comments on commit 19d9999

Please sign in to comment.