Skip to content

fix: hide button when round has ended #3558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useAccount } from "wagmi";
import { GrantApplication } from "../../features/api/types";
import { useDataLayer } from "data-layer";
import useSWR from "swr";
import { convertApplications } from "../api/utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import { errorModalDelayMs } from "../../constants";
import ErrorModal from "../common/ErrorModal";
import { getRoundStrategyType, useAllo } from "common";

export default function ApplicationsApproved() {
export default function ApplicationsApproved(props: {
roundHasEnded: boolean
}) {
const { id } = useParams();
const allo = useAllo();

Expand Down Expand Up @@ -177,7 +179,7 @@ const { data: applications, isLoading } = useApplicationsByRoundId(id);

return (
<>
{approvedApplications && approvedApplications.length > 0 && (
{!props.roundHasEnded && approvedApplications && approvedApplications.length > 0 && (
<div className="flex items-center justify-end mb-4">
<span className="text-grey-400 text-sm mr-6">
Save in gas fees by approving/rejecting multiple applications at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import ErrorModal from "../common/ErrorModal";
import { errorModalDelayMs } from "../../constants";
import { getRoundStrategyType, useAllo } from "common";

export default function ApplicationsRejected() {
export default function ApplicationsRejected(props: {
roundHasEnded: boolean;
}) {
const { id } = useParams();
const allo = useAllo();

Expand Down Expand Up @@ -175,21 +177,24 @@ export default function ApplicationsRejected() {

return (
<>
{rejectedApplications && rejectedApplications.length > 0 ? (
<div className="flex items-center justify-end mb-4">
<span className="text-grey-400 text-sm mr-6">
Save in gas fees by approving/rejecting multiple applications at
once.
</span>
{bulkSelectRejected ? (
<Cancel onClick={() => setBulkSelectRejected(false)} />
) : (
<Select onClick={() => setBulkSelectRejected(true)} />
)}
</div>
) : (
<div className="text-center">No Rejected Applications</div>
)}
{!props.roundHasEnded &&
<>
{rejectedApplications && rejectedApplications.length > 0 ? (
<div className="flex items-center justify-end mb-4">
<span className="text-grey-400 text-sm mr-6">
Save in gas fees by approving/rejecting multiple applications at
once.
</span>
{bulkSelectRejected ? (
<Cancel onClick={() => setBulkSelectRejected(false)} />
) : (
<Select onClick={() => setBulkSelectRejected(true)} />
)}
</div>
) : (
<div className="text-center">No Rejected Applications</div>
)}
</>}
<CardsContainer>
{!isLoading &&
rejectedApplications?.map((application, index) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ export async function exportAndDownloadCSV(

type Props = {
isDirectRound?: boolean;
roundHasEnded: boolean;
};

// Approve or reject applications received in bulk, both in QF & direct grants

export default function ApplicationsToApproveReject({
isDirectRound = false,
roundHasEnded
}: Props) {
const { id } = useParams();
const { chainId } = useAccount();
Expand Down Expand Up @@ -273,7 +275,7 @@ export default function ApplicationsToApproveReject({
)}
</Button>
)}
{filteredApplications && filteredApplications.length > 0 && (
{!roundHasEnded && filteredApplications && filteredApplications.length > 0 && (
<div className="flex items-center justify-end ml-auto">
<span className="text-grey-400 text-sm mr-6">
Save in gas fees by approving/rejecting multiple applications at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ import { useAccount } from "wagmi";

// Move applications received in direct grants to In Review

export default function ApplicationsToReview() {
export default function ApplicationsToReview(props: {
roundHasEnded: boolean;
}) {
const { id } = useParams();
const { chainId } = useAccount();

Expand Down Expand Up @@ -239,7 +241,7 @@ export default function ApplicationsToReview() {
)}
</Button>
)}
{filteredApplications && filteredApplications.length > 0 && (
{!props.roundHasEnded && filteredApplications && filteredApplications.length > 0 && (
<div className="flex items-center justify-end ml-auto">
<span className="text-grey-400 text-sm mr-6">
Save in gas fees by moving multiple applications to "In Review"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function GrantApplications(props: {
fetchRoundStatus: ProgressStatus;
chainId: string;
roundId: string | undefined;
roundHasEnded: boolean;
}) {
// Filter applications into pending, approved, rejected & in-review
const pendingApplications = (props.applications || [])
Expand Down Expand Up @@ -148,25 +149,27 @@ function GrantApplications(props: {
<Tab.Panels>
<Tab.Panel>
{props.isDirectRound ? (
<ApplicationsToReview />
<ApplicationsToReview roundHasEnded={props.roundHasEnded} />
) : (
<ApplicationsToApproveReject
isDirectRound={Boolean(props.isDirectRound)}
roundHasEnded={props.roundHasEnded}
/>
)}
</Tab.Panel>
{props.isDirectRound && (
<Tab.Panel>
<ApplicationsToApproveReject
isDirectRound={Boolean(props.isDirectRound)}
roundHasEnded={props.roundHasEnded}
/>
</Tab.Panel>
)}
<Tab.Panel>
<ApplicationsApproved />
<ApplicationsApproved roundHasEnded={props.roundHasEnded} />
</Tab.Panel>
<Tab.Panel>
<ApplicationsRejected />
<ApplicationsRejected roundHasEnded={props.roundHasEnded} />
</Tab.Panel>
</Tab.Panels>
</Tab.Group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,20 @@ export default function ViewApplicationPage() {
? getRoundStrategyType(application.payoutStrategy.strategyName)
: undefined;

const hasRoundEnded = round ? moment().isAfter(round?.roundEndTime) : false;

const showReviewButton = () =>
strategyType === "DirectGrants" &&
application?.status === "PENDING" &&
application?.inReview === false;
application?.inReview === false &&
!hasRoundEnded;

const showApproveReject = () => {
console.log("showApproveReject", application?.status, hasRoundEnded);
if (hasRoundEnded) {
return false;
}

if (strategyType !== "DirectGrants") {
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/round-manager/src/features/round/ViewRoundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ export default function ViewRoundPage() {
id.toLowerCase()
);

console.log("round", round);

const isRoundFetched =
fetchRoundStatus == ProgressStatus.IS_SUCCESS && !error;
const { data: applications } = useApplicationsByRoundId(id);
Expand All @@ -88,14 +86,15 @@ export default function ViewRoundPage() {
: true);
const roundNotFound = fetchRoundStatus === ProgressStatus.IS_ERROR;

const roundHasEnded = round ? moment().isAfter(round?.roundEndTime) : false;

useEffect(() => {
if (roundChainId !== chain?.id) {
switchChain({ connector, chainId: roundChainId as number });
}
}, [chain?.id, roundChainId, connector, switchChain]);

const strategyName = round?.payoutStrategy.strategyName;
console.log("strategyName", strategyName);
const badgeColor =
strategyName === "MERKLE" ? "gradient-border-qf" : "gradient-border-direct";

Expand Down Expand Up @@ -388,6 +387,7 @@ export default function ViewRoundPage() {
fetchRoundStatus={fetchRoundStatus}
chainId={`${chain?.id}`}
roundId={id}
roundHasEnded={roundHasEnded}
/>
</Tab.Panel>
{!isDirectRound(round) && (
Expand Down
Loading