Skip to content

Commit

Permalink
smol tweaks/lint
Browse files Browse the repository at this point in the history
  • Loading branch information
codenamejason committed Jun 10, 2024
1 parent 0090dd6 commit 0abda82
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 78 deletions.
1 change: 1 addition & 0 deletions packages/round-manager/src/context/round/RoundContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export const useRoundsByAddress = (chainIds: number[], address?: string) => {
address.toLowerCase()
);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [switchToVersion]);

return { ...context.state, dispatch: context.dispatch };
Expand Down
2 changes: 1 addition & 1 deletion packages/round-manager/src/features/api/AlloWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function AlloWrapper({ children }: { children: JSX.Element | JSX.Element[] }) {
}

return alloBackend;
}, [address, chainID]);
}, [address, chain?.id, chainID]);

return (
<AlloProvider backend={backend}>
Expand Down
69 changes: 11 additions & 58 deletions packages/round-manager/src/features/program/ProgramListPage.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
import React from "react";
import { Link } from "react-router-dom";

import {
ArrowNarrowRightIcon,
ChevronUpIcon,
PlusIcon,
} from "@heroicons/react/solid";
import { ArrowNarrowRightIcon, PlusIcon } from "@heroicons/react/solid";
import { Spinner } from "../common/Spinner";
import Navbar from "../common/Navbar";
// import { ReactComponent as Banner } from "../../assets/programs/city-voxel.svg";
import Footer from "common/src/components/Footer";
import { datadogLogs } from "@datadog/browser-logs";
import { usePrograms } from "../../context/program/ReadProgramContext";
import { ProgressStatus } from "../api/types";
import { useAlloVersion } from "common/src/components/AlloVersionSwitcher";
import { ExclamationCircleIcon } from "@heroicons/react/solid";
import { allChains } from "../../app/wagmi";
import { useRoundsByAddress } from "../../context/round/RoundContext";
import { useAccount } from "wagmi";
import { getChainById, stringToBlobUrl } from "common";
import { ProgramCard } from "./ProgramCard";
import { RoundCard } from "../round/RoundCard";

const maxProgramsPerRow = 4;
const maxRoundsPerSite = 5;

const startAProgramCard = (
<Link to="/program/create">
Expand All @@ -43,27 +30,20 @@ const startAProgramCard = (
);

function ListPrograms() {
datadogLogs.logger.info("====> Route: /");
datadogLogs.logger.info("====> Route: /ProgramListPage.tsx");
datadogLogs.logger.info(`====> URL: ${window.location.href}`);

const { address } = useAccount();
const { version, switchToVersion } = useAlloVersion();
const { programs, fetchProgramsStatus, listProgramsError } = usePrograms();
const { data: rounds } = useRoundsByAddress(
allChains.map((chain) => chain.id),
address
);
const [viewAllPrograms, setViewAllPrograms] = React.useState(false);
const [viewAllRounds, setViewAllRounds] = React.useState(false);
const isSuccess =
fetchProgramsStatus === ProgressStatus.IS_SUCCESS && !listProgramsError;

function hasNoPrograms() {
return !programs || programs.length === 0;
}

const isSuccess =
fetchProgramsStatus === ProgressStatus.IS_SUCCESS && !listProgramsError;

const programList = programs.map((program, key) => (
const ProgramList = programs.map((program, key) => (
<Link to={`/program/${program.id}`} key={key}>
<ProgramCard
key={program.id}
Expand All @@ -88,33 +68,6 @@ function ListPrograms() {
</Link>
));

const roundList = rounds.map((round, key) => {
if (!round.chainId) return;
const chain = getChainById(round.chainId);
return (
<Link to={`/round/${round.id}`} key={key}>
<RoundCard
key={round.id}
title={round.roundMetadata.name}
description={""}
footerContent={
<>
<div className="flex flex-row items-center">
{/* todo: add the chain/network icon */}
<img
src={stringToBlobUrl(chain.icon)}
alt="Chain"
className="rounded-full w-5 h-5 mr-2"
/>
<span className="text-gray-500">{chain.prettyName}</span>
</div>
</>
}
/>
</Link>
);
});

return (
<div className="bg-grey-50">
{fetchProgramsStatus === ProgressStatus.IN_PROGRESS && (
Expand Down Expand Up @@ -155,8 +108,8 @@ function ListPrograms() {
)}
<main className="container mx-14 px-8 max-h-full">
<div className="flex flex-col mb-6">
<div className="flex flex-row items-center justify-between">
<div className="flex flex-row items-center justify-start pt-8">
<div className="flex flex-row items-center justify-between pt-8">
<div className="flex flex-row items-center justify-start">
<span className="text-2xl font-medium text-gray-500 antialiased">
Programs
</span>
Expand All @@ -169,7 +122,7 @@ function ListPrograms() {
{viewAllPrograms ? "View less" : "View all"}
</span>
</div>
<div className="flex flex-row items-center justify-end pt-8">
<div className="flex flex-row items-center justify-end">
<Link to="/program/create">
<span className="flex flex-row items-center justify-between p-2 bg-white hover:border-gray-200 border border-transparent rounded-lg text-xs font-mono font-medium hover:cursor-pointer">
<PlusIcon className="h-5 w-5 inline mr-2" />
Expand All @@ -179,12 +132,12 @@ function ListPrograms() {
</div>
</div>
</div>
<div className="w-full overflow-hidden items-center">
<div className="w-full overflow-hidden">
{isSuccess && hasNoPrograms() && startAProgramCard}
<div className="flex flex-row flex-wrap justify-start items-center">
{viewAllPrograms
? programList
: programList.slice(0, maxProgramsPerRow * 2)}
? ProgramList
: ProgramList.slice(0, maxProgramsPerRow * 2)}
</div>
</div>
</main>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useWallet } from "../common/Auth";
import { useForm } from "react-hook-form";
import { yupResolver } from "@hookform/resolvers/yup";
import * as yup from "yup";

import { ExternalLinkIcon } from "@heroicons/react/outline";
import { Erc20__factory } from "../../types/generated/typechain";
import { usePayout } from "../../context/application/usePayout";
Expand Down Expand Up @@ -322,7 +321,7 @@ export default function ApplicationDirectPayout({ round, application }: Props) {
setPayoutTokensMap(map);
};
createPayoutTokenMap();
}, [fetchTokenData, application.applicationIndex, payouts]);
}, [fetchTokenData, application.applicationIndex, payouts, chain.id]);

return (
<>
Expand Down
8 changes: 2 additions & 6 deletions packages/round-manager/src/features/round/RoundListPage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from "react";
import { Link } from "react-router-dom";

import { ChevronUpIcon, PlusIcon } from "@heroicons/react/solid";
import { ChevronUpIcon } from "@heroicons/react/solid";
import { Spinner } from "../common/Spinner";
import Navbar from "../common/Navbar";
// import { ReactComponent as Banner } from "../../assets/programs/city-voxel.svg";
import Footer from "common/src/components/Footer";
import { datadogLogs } from "@datadog/browser-logs";
import { ProgressStatus } from "../api/types";
import { useAlloVersion } from "common/src/components/AlloVersionSwitcher";
Expand All @@ -19,7 +16,7 @@ import { RoundCard } from "./RoundCard";
const maxRoundsPerSite = 5;

function ListRounds() {
datadogLogs.logger.info("====> Route: /");
datadogLogs.logger.info("====> Route: /RoundListPage.tsx");
datadogLogs.logger.info(`====> URL: ${window.location.href}`);

const { address } = useAccount();
Expand All @@ -32,7 +29,6 @@ function ListRounds() {
allChains.map((chain) => chain.id),
address
);
const [viewAllPrograms, setViewAllPrograms] = React.useState(false);
const [viewAllRounds, setViewAllRounds] = React.useState(false);

function hasNoRounds() {
Expand Down
12 changes: 2 additions & 10 deletions packages/round-manager/src/features/round/ViewFundGrantees.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Tab } from "@headlessui/react";
import { ExclamationCircleIcon as NonFinalizedRoundIcon } from "@heroicons/react/outline";
Expand Down Expand Up @@ -56,13 +57,13 @@ export default function ViewFundGrantees(props: {
}
setPaidProjects(projects["paid"]);
setUnpaidProjects(projects["unpaid"]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [projects]);

return (
<div className="flex flex-center flex-col mx-auto mt-3">
<p className="text-xl">Fund Grantees</p>
{props.isRoundFinalized ? (
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
<FinalizedRoundContent
round={props.round!}
paidProjects={paidProjects}
Expand Down Expand Up @@ -199,9 +200,6 @@ export function PayProjectsTable(props: {
round: Round;
allProjects: MatchingStatsData[];
}) {
// TODO: Add button check
// TOOD: Connect wallet and payout contracts to pay grantees
const { signer } = useWallet();
const allo = useAllo();
const alloVersion = getConfig().allo.version;
const roundId = props.round.id;
Expand All @@ -215,30 +213,24 @@ export function PayProjectsTable(props: {
const [showConfirmationModal, setShowConfirmationModal] =
useState<boolean>(false);
const [showInfoModal, setShowInfoModal] = useState<boolean>(false);

const [
openReadyForDistributionProgressModal,
setOpenReadyForDistributionProgressModal,
] = useState(false);

const [finalizingDistributionStatus, setFinalizingDistributionStatus] =
useState<ProgressStatus>(ProgressStatus.IN_PROGRESS);

const [indexingStatus, setIndexingStatus] = useState<ProgressStatus>(
ProgressStatus.NOT_STARTED
);

const tokenDetail =
props.token.address == ethers.constants.AddressZero
? { address: assertAddress(props.round?.payoutStrategy.id) }
: {
address: assertAddress(props.round?.payoutStrategy.id),
token: assertAddress(props.token.address),
};

const tokenBalance = useBalance(tokenDetail);
const navigate = useNavigate();

const distributionSteps: ProgressStep[] = [
{
name: "Distributing Funds",
Expand Down
1 change: 0 additions & 1 deletion packages/round-manager/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import AccessDenied from "./features/common/AccessDenied";
import Auth from "./features/common/Auth";
import NotFound from "./features/common/NotFoundPage";
import CreateProgram from "./features/program/CreateProgramPage";
import Program from "./features/program/ProgramListPage";
import LandingPage from "./features/common/LandingPage";
import ViewProgram from "./features/program/ViewProgramPage";
import CreateRound from "./features/round/CreateRoundPage";
Expand Down

0 comments on commit 0abda82

Please sign in to comment.