Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into community-and-pools-me…
Browse files Browse the repository at this point in the history
…trics
  • Loading branch information
Mati0x committed Jan 9, 2025
2 parents bb46cab + 0ca0a12 commit fecde8d
Show file tree
Hide file tree
Showing 134 changed files with 12,453 additions and 4,141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
Button,
DisplayNumber,
EthAddress,
InfoBox,
Statistic,
DataTable,
} from "@/components";
Expand Down Expand Up @@ -263,13 +264,13 @@ export default function Page({
);
}

const handleRefreshConviction = async (e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
setConvictionRefreshing(true);
await triggerConvictionRefetch?.();
setConvictionRefreshing(false);
};
// const handleRefreshConviction = async (e: React.MouseEvent) => {
// e.preventDefault();
// e.stopPropagation();
// setConvictionRefreshing(true);
// await triggerConvictionRefetch?.();
// setConvictionRefreshing(false);
// };

const status = ProposalStatus[proposalData.proposalStatus];
return (
Expand Down Expand Up @@ -337,77 +338,87 @@ export default function Page({
<CancelButton
proposalData={{ ...proposalData, ...metadata }}
/>
: <DisputeButton
isMemberCommunity={isMemberCommunity}
proposalData={{ ...proposalData, ...metadata }}
/>
: proposalData.strategy.isEnabled && (
<DisputeButton
isMemberCommunity={isMemberCommunity}
proposalData={{ ...proposalData, ...metadata }}
/>
)
}
</div>
</div>
</div>
</div>
{!proposalData.strategy.isEnabled && (
<InfoBox infoBoxType="warning">The pool is not enabled.</InfoBox>
)}
</header>
<section className="section-layout">
{status && status !== "active" && status !== "disputed" ?
<h4
className={`text-center ${status === "executed" ? "text-primary-content" : "text-error-content"}`}
>
{status === "executed" ?
"Proposal passed and executed successfully!"
: `Proposal has been ${status}.`}
</h4>
: <>
<div className="flex justify-between">
<h2>Metrics</h2>
<Button
icon={<AdjustmentsHorizontalIcon height={24} width={24} />}
onClick={() => manageSupportClicked()}
disabled={!isConnected || missmatchUrl || !isMemberCommunity}
tooltip={tooltipMessage}
>
Manage support
</Button>
</div>
<div className="flex flex-col gap-7">
<ConvictionBarChart
currentConvictionPct={currentConvictionPct}
thresholdPct={thresholdPct}
proposalSupportPct={totalSupportPct}
isSignalingType={isSignalingType}
proposalNumber={Number(proposalIdNumber)}
timeToPass={Number(timeToPass)}
onReadyToExecute={triggerConvictionRefetch}
defaultChartMaxValue
/>
<div className="flex justify-center lg:justify-end w-full">
{status === "active" && !isSignalingType && (
<Button
onClick={() =>
writeDistribute?.({
args: [
BigInt(poolId),
[proposalData?.strategy.id as Address],
encodedDataProposalId(proposalIdNumber),
],
})
}
disabled={
currentConvictionPct < thresholdPct || !isConnected
}
tooltip={
(tooltipMessage ?? currentConvictionPct < thresholdPct) ?
"Proposal not executable"
: undefined
}
>
Execute
</Button>
)}
{proposalData.strategy.isEnabled && (
<section className="section-layout">
{status && status !== "active" && status !== "disputed" ?
<h4
className={`text-center ${status === "executed" ? "text-primary-content" : "text-error-content"}`}
>
{status === "executed" ?
"Proposal passed and executed successfully!"
: `Proposal has been ${status}.`}
</h4>
: <>
<div className="flex justify-between">
<h2>Metrics</h2>
<Button
icon={<AdjustmentsHorizontalIcon height={24} width={24} />}
onClick={() => manageSupportClicked()}
disabled={!isConnected || missmatchUrl || !isMemberCommunity}
tooltip={tooltipMessage}
>
Manage support
</Button>
</div>
</div>
</>
}
</section>
<div className="flex flex-col gap-7">
<ConvictionBarChart
currentConvictionPct={currentConvictionPct}
thresholdPct={thresholdPct}
proposalSupportPct={totalSupportPct}
isSignalingType={isSignalingType}
proposalNumber={Number(proposalIdNumber)}
timeToPass={Number(timeToPass)}
onReadyToExecute={triggerConvictionRefetch}
defaultChartMaxValue
/>
<div className="flex justify-center lg:justify-end w-full">
{status === "active" && !isSignalingType && (
<Button
onClick={() =>
writeDistribute?.({
args: [
BigInt(poolId),
[proposalData?.strategy.id as Address],
encodedDataProposalId(proposalIdNumber),
],
})
}
disabled={
currentConvictionPct < thresholdPct || !isConnected
}
tooltip={
(
(tooltipMessage ??
currentConvictionPct < thresholdPct)
) ?
"Proposal not executable"
: undefined
}
>
Execute
</Button>
)}
</div>
</div>
</>
}
</section>
)}
{filteredAndSortedProposalSupporters.length > 0 && (
<ProposalSupportersTable
supporters={filteredAndSortedProposalSupporters}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,20 @@ export default function Page({
chainId={chain}
/>
)}
<section ref={proposalSectionRef}>
<Proposals
poolToken={poolToken}
strategy={strategyObj}
alloInfo={alloInfo}
communityAddress={communityAddress}
createProposalUrl={`/gardens/${chain}/${garden}/${communityAddress}/${poolId}/create-proposal`}
proposalType={proposalType}
/>
</section>
</>
)}
{strategyObj && isEnabled && (
<section ref={proposalSectionRef}>
<Proposals
poolToken={poolToken}
strategy={strategyObj}
alloInfo={alloInfo}
communityAddress={communityAddress}
createProposalUrl={`/gardens/${chain}/${garden}/${communityAddress}/${poolId}/create-proposal`}
proposalType={proposalType}
/>
</section>
)}
</div>
);
}
41 changes: 39 additions & 2 deletions apps/web/app/(app)/gardens/[chain]/[garden]/[community]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Dnum, multiply } from "dnum";
import Image from "next/image";
import Link from "next/link";
import { Address } from "viem";
import { useAccount, useToken } from "wagmi";
import { useAccount, useContractRead, useToken } from "wagmi";
import {
getCommunityDocument,
getCommunityQuery,
Expand Down Expand Up @@ -41,6 +41,7 @@ import { QUERY_PARAMS } from "@/constants/query-params";
import { useCollectQueryParams } from "@/contexts/collectQueryParams.context";
import { useDisableButtons } from "@/hooks/useDisableButtons";
import { useSubgraphQuery } from "@/hooks/useSubgraphQuery";
import { safeABI } from "@/src/generated";
import { PoolTypes, Column } from "@/types";
import { fetchIpfs } from "@/utils/ipfsUtils";
import {
Expand Down Expand Up @@ -94,6 +95,18 @@ export default function Page({
});
const registryCommunity = result?.registryCommunity;

const { data: isCouncilMember } = useContractRead({
address: registryCommunity?.councilSafe as Address,
abi: safeABI,
functionName: "isOwner",
chainId: Number(chain),
enabled: !!accountAddress,
args: [accountAddress as Address],
onError: () => {
console.error("Error reading isOwner from Coucil Safe");
},
});

let {
communityName,
members,
Expand Down Expand Up @@ -162,7 +175,11 @@ export default function Page({
);
const activePools = strategies?.filter((strategy) => strategy?.isEnabled);

const poolsInReview = strategies.filter((strategy) => !strategy.isEnabled);
const poolsInReview = strategies.filter(
(strategy) => !strategy.isEnabled && !strategy.archived,
);

const poolsArchived = strategies.filter((strategy) => strategy.archived);

// const [tokenDataArray, setTokenDataArray] = useState([]);

Expand Down Expand Up @@ -411,6 +428,26 @@ export default function Page({
))}
</div>
</div>
{(!!isCouncilMember ||
accountAddress?.toLowerCase() ===
registryCommunity.councilSafe?.toLowerCase() ||
localStorage.getItem("showArchived") === "true") && (
<div className="flex flex-col gap-4">
<h4 className="text-secondary-content">
Pools archived ({poolsArchived.length})
</h4>
<div className="flex flex-row flex-wrap gap-10">
{poolsArchived.map((pool) => (
<PoolCard
key={pool.poolId}
token={pool.token}
chainId={chain}
pool={pool}
/>
))}
</div>
</div>
)}
</section>
<section ref={covenantSectionRef} className="section-layout">
<h2 className="mb-4">Covenant</h2>
Expand Down
8 changes: 8 additions & 0 deletions apps/web/components/Forms/FormSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export function FormSelect({
tooltip,
readOnly,
disabled,
errors,
}: Props) {
const hasError = errors?.[registerKey];

return (
<div className="flex flex-col">
<label htmlFor={registerKey} className="label w-fit cursor-pointer">
Expand Down Expand Up @@ -69,6 +72,11 @@ export function FormSelect({
</option>
))}
</select>
{hasError && (
<span className="text-danger-content text-sm mt-2">
{hasError.message || "This field is required"}
</span>
)}
</div>
);
}
5 changes: 1 addition & 4 deletions apps/web/components/Forms/PoolEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,7 @@ export default function PoolEditForm({

Object.entries(reorderedData).forEach(([key, value]) => {
const formRow = formRowTypes[key];
if (
formRow
// && shouldRenderInPreview(key)
) {
if (formRow && shouldRenderInput(key)) {
const parsedValue = formRow.parse ? formRow.parse(value) : value;
formattedRows.push({
label: formRow.label,
Expand Down
9 changes: 6 additions & 3 deletions apps/web/components/PoolCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import {
ArchiveBoxIcon,
BoltIcon,
ClockIcon,
CurrencyDollarIcon,
Expand Down Expand Up @@ -28,7 +29,7 @@ type Props = {
token: string;
pool: Pick<
CVStrategy,
"id" | "isEnabled" | "poolAmount" | "poolId" | "metadata"
"id" | "isEnabled" | "poolAmount" | "poolId" | "metadata" | "archived"
> & {
proposals: Pick<CVProposal, "id">[];
config: Pick<CVStrategyConfig, "proposalType" | "pointSystem">;
Expand Down Expand Up @@ -95,8 +96,10 @@ export function PoolCard({ pool, token, chainId }: Props) {
</div>
{!isEnabled ?
<div className="banner md:min-w-[262px]">
<ClockIcon className="h-8 w-8 text-secondary-content" />
<h6>Waiting for approval</h6>
{pool.archived ?
<ArchiveBoxIcon className="h-8 w-8 text-secondary-content" />
: <ClockIcon className="h-8 w-8 text-secondary-content" />}
<h6>{pool.archived ? "Archived" : "Waiting for approval"}</h6>
</div>
: <Image
src={poolType && PoolTypes[poolType] === "funding" ? blueLand : grass}
Expand Down
12 changes: 9 additions & 3 deletions apps/web/components/PoolHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
ChartBarIcon,
CheckIcon,
ClockIcon,
ArchiveBoxIcon,
InformationCircleIcon,
Square3Stack3DIcon,
} from "@heroicons/react/24/outline";
import {
ArchiveBoxIcon,
NoSymbolIcon,
StopIcon,
Cog6ToothIcon,
Expand Down Expand Up @@ -581,8 +581,14 @@ export default function PoolHeader({
)}
{!isEnabled ?
<div className="banner">
<ClockIcon className="h-8 w-8 text-secondary-content" />
<h6>Waiting for council approval</h6>
{isArchived ?
<ArchiveBoxIcon className="h-8 w-8 text-secondary-content" />
: <ClockIcon className="h-8 w-8 text-secondary-content" />}
<h6>
{isArchived ?
"This pool has been archived"
: "Waiting for council approval"}
</h6>
</div>
: <Image
src={PoolTypes[proposalType] === "funding" ? blueLand : grassLarge}
Expand Down
Loading

0 comments on commit fecde8d

Please sign in to comment.