Skip to content

Commit b2a68ca

Browse files
committed
wip
1 parent e75d6b3 commit b2a68ca

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

packages/grant-explorer/src/features/projects/ViewProject.tsx

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
getChainById,
55
renderToHTML,
66
stringToBlobUrl,
7+
TToken,
78
useParams,
89
useValidateCredential,
910
} from "common";
@@ -35,6 +36,10 @@ import { useProject, useProjectApplications } from "./hooks/useProject";
3536
import NotFoundPage from "../common/NotFoundPage";
3637
import { useCartStorage } from "../../store";
3738
import { CartProject } from "../api/types";
39+
import InfoModal from "../common/InfoModal";
40+
import { Input } from "common/src/styles";
41+
import { PayoutTokenDropdown } from "../round/ViewCartPage/PayoutTokenDropdown";
42+
import { useAccount } from "wagmi";
3843

3944
const CalendarIcon = (props: React.SVGProps<SVGSVGElement>) => {
4045
return (
@@ -58,6 +63,8 @@ const CalendarIcon = (props: React.SVGProps<SVGSVGElement>) => {
5863

5964
export default function ViewProject() {
6065
const [selectedTab, setSelectedTab] = useState(0);
66+
const { chainId } = useAccount();
67+
const [showDirectAllocationModal, setShowDirectAllocationModal] = useState<boolean>(false);
6168

6269
const { projectId } = useParams();
6370

@@ -167,6 +174,13 @@ export default function ViewProject() {
167174
setSelectedTab(tabIndex);
168175
};
169176

177+
178+
// const selectedPayoutToken = getVotingTokenForChain(chainId || 1);
179+
// const payoutTokenOptions: TToken[] = getVotingTokenOptions(
180+
// Number(chainId)
181+
// ).filter((p) => p.canVote);
182+
183+
170184
return (
171185
<>
172186
{projectData !== undefined || isProjectDataLoading ? (
@@ -191,7 +205,17 @@ export default function ViewProject() {
191205
</div>
192206
</div>
193207
<div className="md:flex gap-4 flex-row-reverse">
194-
<Sidebar projectApplications={projectApplications} />
208+
<div className="mb-4">
209+
<button
210+
type="button"
211+
data-testid="direct-allocation-button"
212+
className="w-full block m-3 rounded-md bg-indigo-600 py-2 px-3 text-center text-sm font-semibold leading-6 text-white shadow-sm hover:bg-indigo-500 disabled:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
213+
onClick={() => setShowDirectAllocationModal(true)}
214+
>
215+
Donate
216+
</button>
217+
<Sidebar projectApplications={projectApplications} />
218+
</div>
195219
<div className="flex-1">
196220
{projectError === undefined ? (
197221
<>
@@ -218,6 +242,40 @@ export default function ViewProject() {
218242
<p>Couldn't load project data.</p>
219243
)}
220244
</div>
245+
<InfoModal
246+
title="Donate!"
247+
body={
248+
<div className="flex gap-4">
249+
<p className="mt-4 md:mt-3 text-xs md:text-sm amount-text font-medium">
250+
Amount
251+
</p>
252+
<Input
253+
aria-label={"Donation amount for all projects "}
254+
id={"input-donationamount"}
255+
min="0"
256+
type="number"
257+
value={fixedDonation ?? ""}
258+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
259+
setFixedDonation(e.target.value);
260+
}}
261+
className="w-16 lg:w-18"
262+
/>
263+
<PayoutTokenDropdown
264+
selectedPayoutToken={selectedPayoutToken}
265+
setSelectedPayoutToken={(token) => {
266+
setVotingTokenForChain(chainId, token);
267+
}}
268+
payoutTokenOptions={payoutTokenOptions}
269+
/>
270+
</div>
271+
}
272+
isOpen={showDirectAllocationModal}
273+
cancelButtonAction={() => setShowDirectAllocationModal(false)}
274+
continueButtonAction={() => setShowDirectAllocationModal(false)}
275+
// disableContinueButton={true}
276+
continueButtonText={"Donate"}
277+
setIsOpen={setShowDirectAllocationModal}
278+
/>
221279
</div>
222280
</DefaultLayout>
223281
) : (

0 commit comments

Comments
 (0)