Skip to content

Commit

Permalink
update edit dates/rolling apps/linting
Browse files Browse the repository at this point in the history
  • Loading branch information
codenamejason committed Apr 29, 2024
1 parent 43b4257 commit d7fa17f
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 85 deletions.
2 changes: 1 addition & 1 deletion packages/round-manager/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const errorModalDelayMs = 3000;
export const modalDelayMs = 1000;
export const maxDateForUint256 = new Date(8640000000000000);
export const maxDateForUint256 = new Date(8640000000000);
30 changes: 3 additions & 27 deletions packages/round-manager/src/context/application/usePayout.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { Dispatch, SetStateAction, useState } from "react";
import { ProgressStatus, ProgressStep } from "../../features/api/types";
import {
DirectPayoutStrategy__factory,
Erc20__factory,
} from "../../types/generated/typechain";
import { BigNumber, ethers } from "ethers";
import { waitForSubgraphSyncTo } from "../../features/api/subgraph";
import { Erc20__factory } from "../../types/generated/typechain";
import { ethers } from "ethers";
import { PayoutToken } from "../../features/api/payoutTokens";
import { round } from "lodash";
import { Allo } from "common";
import { Hex } from "viem";
import { datadogRum } from "@datadog/browser-rum";
import { datadogLogs } from "@datadog/browser-logs";
import { useState } from "react";

export function usePayout() {
const [contractApproveSpendStatus, setContractApproveSpendStatus] =
Expand Down Expand Up @@ -48,25 +43,6 @@ export function usePayout() {
},
];

async function waitForSubgraphToUpdate(
setIndexingStatus: Dispatch<SetStateAction<ProgressStatus>>,
signerOrProvider: ethers.Signer,
transactionBlockNumber: number
) {
try {
setIndexingStatus(ProgressStatus.IN_PROGRESS);

const chainId = await signerOrProvider.getChainId();
await waitForSubgraphSyncTo(chainId, transactionBlockNumber);

setIndexingStatus(ProgressStatus.IS_SUCCESS);
} catch (error) {
console.error("waitForSubgraphToUpdate", error);
setIndexingStatus(ProgressStatus.IS_ERROR);
throw error;
}
}

const resetStatuses = () => {
setContractApproveSpendStatus(ProgressStatus.NOT_STARTED);
setContractUpdatingStatus(ProgressStatus.NOT_STARTED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { getProgramById, listPrograms } from "../../features/api/program";
import { datadogLogs } from "@datadog/browser-logs";
import { Web3Provider } from "@ethersproject/providers";
import { DataLayer, useDataLayer } from "data-layer";
import { getAlloVersion } from "common/src/config";
import { useAlloVersion } from "common/src/components/AlloVersionSwitcher";

export interface ReadProgramState {
Expand Down
1 change: 0 additions & 1 deletion packages/round-manager/src/context/round/RoundContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useWallet } from "../../features/common/Auth";
import { getRoundById, listRounds } from "../../features/api/round";
import { datadogLogs } from "@datadog/browser-logs";
import { DataLayer, useDataLayer } from "data-layer";
import { switchAlloVersionAndReloadPage } from "common/src/config";
import { useAlloVersion } from "common/src/components/AlloVersionSwitcher";

export interface RoundState {
Expand Down
1 change: 0 additions & 1 deletion packages/round-manager/src/features/api/AlloWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
AlloProvider,
AlloV1,
AlloV2,
ChainId,
createEthersTransactionSender,
createPinataIpfsUploader,
createWaitForIndexerSyncTo,
Expand Down
2 changes: 1 addition & 1 deletion packages/round-manager/src/features/api/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Program, Web3Instance } from "./types";
import { datadogLogs } from "@datadog/browser-logs";
import { ChainId } from "common";
import { DataLayer } from "data-layer";
import { getAlloVersion, getConfig } from "common/src/config";
import { getAlloVersion } from "common/src/config";

/**
* Fetch a list of programs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { errorModalDelayMs } from "../../constants";
import ErrorModal from "../common/ErrorModal";
import { getRoundStrategyType, renderToPlainText, useAllo } from "common";
import { useWallet } from "../common/Auth";
import { roundApplicationsToCSV } from "../api/exports";
import { CheckIcon } from "@heroicons/react/solid";
import { useApplicationsByRoundId } from "../common/useApplicationsByRoundId";
import { exportAndDownloadCSV } from "./ApplicationsToApproveReject";
Expand Down
3 changes: 1 addition & 2 deletions packages/round-manager/src/features/round/FundContract.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { datadogLogs } from "@datadog/browser-logs";
import { InformationCircleIcon } from "@heroicons/react/solid";
import { getConfig } from "common/src/config";
import { BigNumber, ethers } from "ethers";
import { Logger } from "ethers/lib.esm/utils";
import { useEffect, useState } from "react";
Expand Down Expand Up @@ -219,7 +218,7 @@ export default function FundContract(props: {
matchingFundPayoutToken?.decimal ?? 18
);
// todo: replace 0x0000000000000000000000000000000000000000 with native token for respective chain
const alloVersion = getConfig().allo.version;
// const alloVersion = getConfig().allo.version;

const tokenDetailUser =
matchingFundPayoutToken?.address == ethers.constants.AddressZero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
} from "../api/types";
import { VerifiableCredential } from "@gitcoinco/passport-sdk-types";
import { Lit } from "../api/lit";
import { utils } from "ethers";
import NotFoundPage from "../common/NotFoundPage";
import AccessDenied from "../common/AccessDenied";
import { Spinner } from "../common/Spinner";
Expand Down Expand Up @@ -70,8 +69,6 @@ import { getPayoutRoundDescription } from "../common/Utils";
import moment from "moment";
import ApplicationDirectPayout from "./ApplicationDirectPayout";
import { useApplicationsByRoundId } from "../common/useApplicationsByRoundId";
import { getAddress } from "ethers/lib/utils.js";
import { getAlloAddress } from "common/dist/allo/backends/allo-v2";

type Status = "done" | "current" | "rejected" | "approved" | undefined;

Expand Down
106 changes: 59 additions & 47 deletions packages/round-manager/src/features/round/ViewRoundSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ export default function ViewRoundSettings(props: { id?: string }) {
/* All DG rounds have rolling applications enabled */
useEffect(() => {
if (
(round?.applicationsEndTime == new Date(UINT64_MAX.toString()))
&& isDirectRound(round)
round?.applicationsEndTime == new Date(UINT64_MAX.toString()) &&
isDirectRound(round)
) {
setRollingApplicationsEnabled(true);
} else {
Expand Down Expand Up @@ -1298,8 +1298,10 @@ function RoundApplicationPeriod(props: {
return inputTime.isBefore(moment());
};

const showApplicationPeriod = (isV2 && isDirectRound(editedRound)) || !isDirectRound(editedRound);
const showRoundPeriod = (!isV2 && isDirectRound(editedRound)) || !isDirectRound(editedRound);
const showApplicationPeriod =
(isV2 && isDirectRound(editedRound)) || !isDirectRound(editedRound);
const showRoundPeriod =
(!isV2 && isDirectRound(editedRound)) || !isDirectRound(editedRound);

return (
<div className="w-full w-10/12">
Expand All @@ -1312,7 +1314,9 @@ function RoundApplicationPeriod(props: {
<>
<div>
<div
className={"text-sm leading-5 pb-1 flex items-center gap-1 mb-2"}
className={
"text-sm leading-5 pb-1 flex items-center gap-1 mb-2"
}
>
Applications
</div>
Expand Down Expand Up @@ -1432,34 +1436,42 @@ function RoundApplicationPeriod(props: {
</div>
)}
<div className="flex items-center mt-2">
<input
id="rollingApplications"
name="rollingApplications"
type="checkbox"
className="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"
checked={rollingApplicationsEnabled}
disabled={
!props.editMode.canEdit ||
moment(editedRound.applicationsEndTime).isBefore(
new Date()
)
}
onChange={() => {
setRollingApplicationsEnabled(
!rollingApplicationsEnabled
);
props.setEditedRound({
...props.editedRound,
applicationsEndTime: rollingApplicationsEnabled ?
new Date(UINT64_MAX.toString()) :
props.editedRound.applicationsStartTime
});
props.setValue(
"applicationsEndTime",
rollingApplicationsEnabled ? new Date(UINT64_MAX.toString()) : props.editedRound.applicationsStartTime
);
}}
<Controller
name="roundEndTimeDisabled"
control={props.control}
// Note: Destructuring `value` out to avoid spreading it to the checkbox.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
render={({ field: { value, ...fieldProps } }) => (
<input
{...fieldProps}
{...props.register("roundEndTimeDisabled")}
id="rollingApplications"
name="rollingApplications"
type="checkbox"
className="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"
checked={rollingApplicationsEnabled}
disabled={
!props.editMode.canEdit ||
moment(editedRound.applicationsEndTime).isBefore(
new Date()
)
}
onChange={(e) => {
const isChecked = e.target.checked;
setRollingApplicationsEnabled(isChecked);
const newEndTime = isChecked
? new Date(maxDateForUint256)
: moment(new Date()).add(1, "days").toDate();
props.setEditedRound({
...props.editedRound,
applicationsEndTime: newEndTime,
});
props.setValue("applicationsEndTime", newEndTime);
}}
/>
)}
/>

<label
htmlFor="rollingApplications"
className="ml-2 block text-sm text-grey-400"
Expand All @@ -1478,8 +1490,8 @@ function RoundApplicationPeriod(props: {
className="text-grey-400"
>
<span>
If enabled, applications will be accepted until the round
ends.
If enabled, applications will be accepted until the
round ends.
</span>
</ReactTooltip>
</div>
Expand All @@ -1488,14 +1500,18 @@ function RoundApplicationPeriod(props: {
</div>
<div>
<div
className={"text-sm leading-5 pb-1 flex items-center gap-1 mb-2"}
className={
"text-sm leading-5 pb-1 flex items-center gap-1 mb-2"
}
>
&nbsp;
</div>
<div className="leading-8 font-normal">
{props.editMode.canEdit &&
!rollingApplicationsEnabled &&
!moment(editedRound.applicationsEndTime).isBefore(new Date()) ? (
!moment(editedRound.applicationsEndTime).isBefore(
new Date()
) ? (
<div className="col-span-6 sm:col-span-3">
<div
className={`${
Expand Down Expand Up @@ -1566,7 +1582,9 @@ function RoundApplicationPeriod(props: {
className={`${
!props.editMode.canEdit ||
rollingApplicationsEnabled ||
timeHasPassed(moment(props.editedRound.applicationsEndTime))
timeHasPassed(
moment(props.editedRound.applicationsEndTime)
)
? "bg-grey-50"
: ""
} relative border rounded-md shadow-sm focus-within:ring-1 ${
Expand All @@ -1585,20 +1603,14 @@ function RoundApplicationPeriod(props: {
timeHasPassed(
moment(props.editedRound.applicationsEndTime)
)
? "bg-grey-50 text-gray-400"
: ""
? "bg-grey-50 text-gray-400"
: ""
}
${props.editedRound.applicationsEndTime == new Date(UINT64_MAX.toString()) ?
"invisible" : ""
}
border-0 pt-0 ml-2 pl-0 -mt-2 text-sm`
}
${rollingApplicationsEnabled ? "invisible" : ""}
border-0 pt-0 ml-2 pl-0 -mt-2 text-sm`}
defaultValue={`${getUTCDate(
editedRound.applicationsEndTime
)} ${getUTCTime(editedRound.applicationsEndTime)}`}
value={`${getUTCDate(
editedRound.applicationsEndTime
)} ${getUTCTime(editedRound.applicationsEndTime)}`}
disabled
/>
</div>
Expand Down

0 comments on commit d7fa17f

Please sign in to comment.