Skip to content

Commit

Permalink
Finished token fix in pools, and finish adding manage support access …
Browse files Browse the repository at this point in the history
…from proposal id page
  • Loading branch information
kafann committed Nov 15, 2024
1 parent 4f8d959 commit 18d1de4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export default function Page({
},
],
});
console.log("data", data);
const strategyObj = data?.cvstrategies?.[0];
const poolTokenAddr = strategyObj?.token as Address;
const proposalType = strategyObj?.config.proposalType;
Expand Down Expand Up @@ -103,11 +102,10 @@ export default function Page({
refetch();
}
}, [searchParams, strategyObj?.proposals]);

const tokenGarden = data?.tokenGarden;

useEffect(() => {
console.log("QUERY PARAM ALLOCATION",searchParams[QUERY_PARAMS.poolPage.allocationView]);
if (
searchParams[QUERY_PARAMS.poolPage.allocationView] !== undefined &&
proposalSectionRef.current
Expand Down Expand Up @@ -163,18 +161,16 @@ export default function Page({
chainId={chain}
/>
)}
<section ref={proposalSectionRef} className="section-layout">

<Proposals
poolToken={poolToken}
strategy={strategyObj}
alloInfo={alloInfo}
communityAddress={communityAddress}
createProposalUrl={`/gardens/${chain}/${garden}/${communityAddress}/${poolId}/create-proposal`}
proposalType={proposalType}
allocationViewInit={searchParams[QUERY_PARAMS.poolPage.allocationView] === "true"}
/>
</section>
<section ref={proposalSectionRef} className="section-layout">
<Proposals
poolToken={poolToken}
strategy={strategyObj}
alloInfo={alloInfo}
communityAddress={communityAddress}
createProposalUrl={`/gardens/${chain}/${garden}/${communityAddress}/${poolId}/create-proposal`}
proposalType={proposalType}
/>
</section>
</>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export default function Page({
{ topic: "member", containerId: communityAddr },
],
});
console.log(result);
const registryCommunity = result?.registryCommunity;

let {
Expand Down Expand Up @@ -343,11 +342,7 @@ export default function Page({
<div className="flex flex-row flex-wrap gap-10">
{fundingPools.map((pool) => (
<Fragment key={pool.poolId}>
<PoolCard
token={pool.token}
chainId={chain}
pool={pool}
/>
<PoolCard token={pool.token} chainId={chain} pool={pool} />
</Fragment>
))}
</div>
Expand Down
12 changes: 2 additions & 10 deletions apps/web/components/PoolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
} from "@heroicons/react/24/outline";
import Image from "next/image";
import { usePathname } from "next/navigation";
import { Address, useToken } from "wagmi";
import {
CVProposal,
CVStrategy,
CVStrategyConfig,
TokenGarden,
} from "#/subgraph/.graphclient";
import { Skeleton } from "./Skeleton";
import TooltipIfOverflow from "./TooltipIfOverflow";
Expand All @@ -23,8 +23,6 @@ import { useCollectQueryParams } from "@/contexts/collectQueryParams.context";
import { useMetadataIpfsFetch } from "@/hooks/useIpfsFetch";
import { PointSystems, PoolTypes } from "@/types";
import { capitalize } from "@/utils/text";
import { Address, useToken } from "wagmi";
import { useEffect } from "react";

type Props = {
token: string;
Expand All @@ -38,7 +36,7 @@ type Props = {
chainId: number;
};

export function PoolCard({ pool, token,chainId }: Props) {
export function PoolCard({ pool, token, chainId }: Props) {
const pathname = usePathname();
const searchParams = useCollectQueryParams();

Expand All @@ -54,12 +52,6 @@ export function PoolCard({ pool, token,chainId }: Props) {
address: token as Address,
chainId: +chainId,
});
//MAYBE: use getPoolDataQuery to get token address, but should be done
// from community page that already fetches pools and their data
useEffect(() => {
console.log("chainID", chainId);
console.log("token", token);
}, [chainId]);

const isNewPool =
searchParams[QUERY_PARAMS.communityPage.newPool] === pool.poolId.toString();
Expand Down
2 changes: 0 additions & 2 deletions apps/web/components/PoolMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export const PoolMetrics: FC<PoolMetricsProps> = ({
poolId,
chainId,
}) => {
const INPUT_TOKEN_MIN_VALUE = 1 / 10 ** poolToken.decimals;

const {
register,
handleSubmit,
Expand Down
55 changes: 32 additions & 23 deletions apps/web/components/Proposals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import {
PoolGovernance,
ProposalCard,
} from "@/components";
import { QUERY_PARAMS } from "@/constants/query-params";
import { useCollectQueryParams } from "@/contexts/collectQueryParams.context";
import { SubscriptionId, usePubSubContext } from "@/contexts/pubsub.context";
import { useChainIdFromPath } from "@/hooks/useChainIdFromPath";
import useCheckAllowList from "@/hooks/useCheckAllowList";
Expand Down Expand Up @@ -85,7 +87,6 @@ interface ProposalsProps {
communityAddress: Address;
createProposalUrl: string;
proposalType: number;
allocationViewInit?: boolean;
}

export function Proposals({
Expand All @@ -94,10 +95,9 @@ export function Proposals({
poolToken,
communityAddress,
createProposalUrl,
allocationViewInit
}: ProposalsProps) {
// State
const [allocationView, setAllocationView] = useState(allocationViewInit ?? false);
const [allocationView, setAllocationView] = useState(false);
const [inputAllocatedTokens, setInputAllocatedTokens] = useState<number>(0);
const [inputs, setInputs] = useState<{ [key: string]: ProposalInputItem }>(
{},
Expand All @@ -116,7 +116,7 @@ export function Proposals({
const { subscribe, unsubscribe, connected } = usePubSubContext();

const tokenDecimals = strategy.registryCommunity.garden.decimals;

const searchParams = useCollectQueryParams();
// Queries
const { data: memberData, error } = useSubgraphQuery<isMemberQuery>({
query: isMemberDocument,
Expand Down Expand Up @@ -240,6 +240,33 @@ export function Proposals({
}
}, [memberActivatedStrategy]);

const disableManageSupportBtnCondition: ConditionObject[] = [
{
condition: !memberActivatedStrategy,
message: "Must have points activated to support proposals",
},
{
condition: !isAllowed,
message: "Address not in allowlist",
},
];

const disableManSupportButton = disableManageSupportBtnCondition.some(
(cond) => cond.condition,
);
const { tooltipMessage, isConnected, missmatchUrl } = useDisableButtons(
disableManageSupportBtnCondition,
);
useEffect(() => {
if (
searchParams[QUERY_PARAMS.poolPage.allocationView] === "true" &&
!disableManSupportButton &&
isConnected
) {
setAllocationView(true);
}
}, [disableManSupportButton, isConnected, searchParams]);

useEffect(() => {
if (!proposals) return;

Expand Down Expand Up @@ -399,6 +426,7 @@ export function Proposals({
console.error("Inputs not yet computed");
return;
}

const proposalsDifferencesArr = getProposalsInputsDifferences(
inputs,
stakedFilters,
Expand Down Expand Up @@ -467,25 +495,6 @@ export function Proposals({
},
];

const disableManageSupportBtnCondition: ConditionObject[] = [
{
condition: !memberActivatedStrategy,
message: "Must have points activated to support proposals",
},
{
condition: !isAllowed,
message: "Address not in allowlist",
},
];

const disableManSupportButton = disableManageSupportBtnCondition.some(
(cond) => cond.condition,
);

const { tooltipMessage, isConnected, missmatchUrl } = useDisableButtons(
disableManageSupportBtnCondition,
);

const endedProposals = proposals.filter(
(x) =>
ProposalStatus[x.proposalStatus] === "cancelled" ||
Expand Down

0 comments on commit 18d1de4

Please sign in to comment.