Skip to content

Commit

Permalink
Merge branch 'dev' into proposal-supporters
Browse files Browse the repository at this point in the history
  • Loading branch information
Mati0x committed Dec 12, 2024
2 parents f55544e + effe34f commit 582021b
Show file tree
Hide file tree
Showing 68 changed files with 10,507 additions and 2,435 deletions.
24 changes: 20 additions & 4 deletions apps/web/app/(app)/gardens/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,26 @@ export default function Page() {
return (
<>
{tokenGardens
.sort(
(a, b) =>
(b.communities?.length ?? 0) - (a.communities?.length ?? 0),
)
.sort((a, b) => {
const communitiesDiff =
(b.communities?.length ?? 0) - (a.communities?.length ?? 0);

if (communitiesDiff === 0) {
const aTotalMembers =
a.communities?.reduce(
(sum, community) => sum + (community.members?.length ?? 0),
0,
) ?? 0;
const bTotalMembers =
b.communities?.reduce(
(sum, community) => sum + (community.members?.length ?? 0),
0,
) ?? 0;
return bTotalMembers - aTotalMembers;
}

return communitiesDiff;
})
.map((garden) => (
<div key={garden.id}>
<GardenCard garden={garden} />
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { redirect } from "next/navigation";

export default function Page() {
redirect("/gardens");
}
}
5 changes: 4 additions & 1 deletion apps/web/components/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type BadgeProps = {
className?: string;
icon?: React.ReactNode;
isCapitalize?: boolean;
tooltip?: string;
};

// Styles for different pool badge types
Expand Down Expand Up @@ -39,6 +40,7 @@ export function Badge({
status,
label,
className,
tooltip,
icon,
}: BadgeProps): JSX.Element {
const isStatusBadge = status !== undefined;
Expand Down Expand Up @@ -70,7 +72,8 @@ export function Badge({

return (
<div
className={`${BASE_STYLES} ${styles} ${className} flex items-center gap-2`}
className={`${BASE_STYLES} ${styles} ${tooltip ? "tooltip" : ""} ${className} flex items-center gap-2`}
data-tip={tooltip}
>
{iconIncluded && (
<div className="h-6 w-6 text-inherit">{iconIncluded}</div>
Expand Down
6 changes: 3 additions & 3 deletions apps/web/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ const btnStyles: BtnStyles = {
},
outline: {
primary:
"text-primary-content border border-primary-content hover:text-primary-hover-content hover:outline-primary-hover-content",
"text-primary-content border border-primary-content hover:text-primary-hover-content hover:border-primary-hover-content",
secondary:
"text-secondary-content border border-secondary-content hover:text-secondary-hover-content hover:outline-secondary-hover-content",
"text-secondary-content border border-secondary-content hover:text-secondary-hover-content hover:border-secondary-hover-content",
tertiary: "",
danger:
"text-danger-button border border-danger-button hover:text-danger-hover-content hover:outline-danger-hover-content",
"text-danger-button border border-danger-button hover:text-danger-hover-content hover:border-danger-hover-content",
disabled: "text-neutral-soft-content border border-neutral-soft-content",
},
link: {
Expand Down
20 changes: 8 additions & 12 deletions apps/web/components/Forms/PoolForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import { FormRadioButton } from "./FormRadioButton";
import { FormSelect } from "./FormSelect";
import { EthAddress } from "../EthAddress";
import { Button } from "@/components/Button";
import { DEFAULT_RULING_TIMEOUT_SEC } from "@/configs/constants";
import {
DEFAULT_RULING_TIMEOUT_SEC,
VOTING_POINT_SYSTEM_DESCRIPTION,
} from "@/configs/constants";
import { QUERY_PARAMS } from "@/constants/query-params";
import { usePubSubContext } from "@/contexts/pubsub.context";
import { useChainFromPath } from "@/hooks/useChainFromPath";
Expand Down Expand Up @@ -227,6 +230,7 @@ export function PoolForm({ token, communityAddr }: Props) {
const { isConnected, missmatchUrl, tooltipMessage } = useDisableButtons();

const watchedAddress = watch("poolTokenAddress").toLowerCase() as Address;

const { data: customTokenData } = useToken({
address: watchedAddress ?? "0x",
chainId: +chain,
Expand Down Expand Up @@ -595,14 +599,6 @@ export function PoolForm({ token, communityAddr }: Props) {
}
}, [customTokenData, watchedAddress, trigger]);

const votingWeightSystemDescriptions = {
fixed: "Everyone has the same voting weight, limited to registration stake",
capped: "Voting weight is equal to tokens staked, up to a limit",
unlimited: "Voting weight is equal to tokens staked, no limit.",
quadratic:
"Voting weight increases as more tokens are staked, following a quadratic curve.",
};

return (
<form onSubmit={handleSubmit(handlePreview)} className="w-full">
{showPreview ?
Expand Down Expand Up @@ -676,18 +672,18 @@ export function PoolForm({ token, communityAddr }: Props) {
<span className="ml-1">*</span>
</label>
<div className="ml-2 flex flex-col gap-2">
{Object.entries(PointSystems).map(([value, label], i) => (
{Object.entries(PointSystems).map(([value, id], i) => (
<div key={value}>
<FormRadioButton
value={value}
label={capitalize(label)}
label={capitalize(id)}
inline={true}
onChange={() =>
setValue("pointSystemType", parseInt(value))
}
checked={parseInt(value) === pointSystemType}
registerKey="pointSystemType"
description={votingWeightSystemDescriptions[label]}
description={VOTING_POINT_SYSTEM_DESCRIPTION[id]}
/>
{PointSystems[pointSystemType] === "capped" &&
i === Object.values(PointSystems).indexOf("capped") && (
Expand Down
13 changes: 6 additions & 7 deletions apps/web/components/PoolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,12 @@ export function PoolCard({ pool, token, chainId }: Props) {
label="voting weight"
count={capitalize(PointSystems[config?.pointSystem])}
/>
{isEnabled && (
<Statistic
icon={<HandRaisedIcon />}
count={proposals.length}
label="proposals"
/>
)}
<Statistic
icon={<HandRaisedIcon />}
count={proposals.length}
label="proposals"
className={`${isEnabled ? "visible" : "invisible"}`}
/>
{isEnabled && poolType && PoolTypes[poolType] === "funding" && (
<Statistic icon={<CurrencyDollarIcon />} label="funds">
<DisplayNumber
Expand Down
Loading

0 comments on commit 582021b

Please sign in to comment.