Skip to content

Commit e42c0d7

Browse files
fix: wrong project added to cart bug (#3594)
* chore: update direct donation description * fix: add to cart issue & update side cart ui
1 parent c1f5817 commit e42c0d7

File tree

1 file changed

+60
-31
lines changed

1 file changed

+60
-31
lines changed

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

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ import { useDirectAllocation } from "./hooks/useDirectAllocation";
5050
import { getDirectAllocationPoolId } from "common/dist/allo/backends/allo-v2";
5151
import { Address, getAddress, zeroAddress } from "viem";
5252
import GenericModal from "../common/GenericModal";
53-
import { BoltIcon, InformationCircleIcon } from "@heroicons/react/24/outline";
53+
import { InformationCircleIcon } from "@heroicons/react/24/outline";
54+
import { BoltIcon } from "@heroicons/react/24/solid";
5455
import { useConnectModal } from "@rainbow-me/rainbowkit";
5556
import { getBalance } from "@wagmi/core";
5657
import { config } from "../../app/wagmi";
@@ -361,32 +362,16 @@ export default function ViewProject() {
361362
</div>
362363
<div className="md:flex gap-4 flex-row-reverse">
363364
<div className="mb-4">
364-
<Sidebar projectApplications={projectApplications} />
365-
{directAllocationPoolId && (
366-
<button
367-
type="button"
368-
data-testid="direct-allocation-button"
369-
className="w-full block my-0 mx-1 bg-gitcoin-violet-100 py-2 text-center text-sm font-semibold rounded-lg leading-6 text-gitcoin-violet-400 shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
370-
onClick={() => {
371-
if (!isConnected) {
372-
openConnectModal?.();
373-
return;
374-
}
375-
if (project?.chainId === undefined) {
376-
console.error("project chainId is undefined");
377-
return;
378-
}
379-
if (chainId !== project?.chainId) {
380-
setShowSwitchNetworkModal(true);
381-
} else {
382-
setShowDirectAllocationModal(true);
383-
}
384-
}}
385-
>
386-
<BoltIcon className="w-4 h-4 inline-block mr-1 mb-1" />
387-
Donate
388-
</button>
389-
)}
365+
<Sidebar
366+
projectApplications={projectApplications}
367+
directAllocationPoolId={directAllocationPoolId}
368+
isConnected={isConnected}
369+
chainId={Number(chainId)}
370+
project={project}
371+
setShowSwitchNetworkModal={setShowSwitchNetworkModal}
372+
setShowDirectAllocationModal={setShowDirectAllocationModal}
373+
openConnectModal={openConnectModal}
374+
/>
390375
</div>
391376
<div className="flex-1">
392377
{projectError === undefined ? (
@@ -573,9 +558,14 @@ export function DirectDonationModalComponent(props: {
573558
return (
574559
<>
575560
<div>
576-
<p className="mb-4">
561+
<p className="mb-4 text-lg font-bold">
577562
<BoltIcon className="w-4 h-4 mb-1 inline-block mr-2" />
578-
Donate now
563+
Direct Donation
564+
</p>
565+
<p className="mb-2">
566+
This is a direct donation to the project. Please note that as the
567+
donation is outside of a quadratic funding round it doesn't receive
568+
any matching funds.
579569
</p>
580570
</div>
581571

@@ -821,6 +811,13 @@ function ProjectLogo({ logoImg }: { logoImg?: string }) {
821811

822812
function Sidebar(props: {
823813
projectApplications?: ProjectApplicationWithRoundAndProgram[];
814+
directAllocationPoolId: number | undefined;
815+
isConnected: boolean;
816+
chainId: number;
817+
project?: v2Project;
818+
setShowSwitchNetworkModal: (value: boolean) => void;
819+
setShowDirectAllocationModal: (value: boolean) => void;
820+
openConnectModal?: () => void;
824821
}) {
825822
const activeQFRoundApplications = props.projectApplications?.filter(
826823
(projectApplication) =>
@@ -834,8 +831,40 @@ function Sidebar(props: {
834831
<div className="min-w-[320px] h-fit mb-6 rounded-3xl bg-gray-50">
835832
<ProjectStats projectApplications={props.projectApplications} />
836833
</div>
834+
{props.directAllocationPoolId && (
835+
<button
836+
type="button"
837+
data-testid="direct-allocation-button"
838+
className="w-full block mb-8 mx-1 bg-gitcoin-violet-100 py-2 text-center text-sm font-semibold rounded-lg leading-6 text-gitcoin-violet-400 shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
839+
onClick={() => {
840+
if (!props.isConnected) {
841+
props.openConnectModal?.();
842+
return;
843+
}
844+
if (props.project?.chainId === undefined) {
845+
console.error("project chainId is undefined");
846+
return;
847+
}
848+
if (props.chainId !== props.project?.chainId) {
849+
props.setShowSwitchNetworkModal(true);
850+
} else {
851+
props.setShowDirectAllocationModal(true);
852+
}
853+
}}
854+
>
855+
<BoltIcon className="w-4 h-4 inline-block mr-1 mb-1" />
856+
Donate
857+
</button>
858+
)}
837859
{activeQFRoundApplications && activeQFRoundApplications?.length > 0 && (
838-
<h4 className="text-xl font-medium">Active rounds</h4>
860+
<>
861+
<h4 className="text-xl font-medium">Active rounds</h4>
862+
<p className="text-md mt-2 text-gray-500 max-w-[320px]">
863+
The project is currently participating in the below active rounds.
864+
Donating to the project in these rounds will help it receive
865+
matching funds.
866+
</p>
867+
</>
839868
)}
840869
<div className="mt-4 max-w-[320px] h-fit rounded-3xl ">
841870
{activeQFRoundApplications?.map((projectApplication) => (
@@ -1012,7 +1041,7 @@ export function ActiveRoundComponent(props: {
10121041
projectMetadata: props.projectApplication.metadata.application.project,
10131042
grantApplicationFormAnswers: [],
10141043
status: props.projectApplication.status,
1015-
applicationIndex: 0,
1044+
applicationIndex: Number(props.projectApplication.id),
10161045
roundId: props.projectApplication.roundId,
10171046
chainId: props.projectApplication.chainId,
10181047
amount: "0",

0 commit comments

Comments
 (0)