-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: redo donation history page (#3666)
Co-authored-by: Aditya Anand M C <[email protected]>
- Loading branch information
1 parent
a158dbb
commit 19d9999
Showing
45 changed files
with
1,192 additions
and
1,152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
146 changes: 0 additions & 146 deletions
146
packages/grant-explorer/src/features/contributors/DirectDonationsTable.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.