From be15239507437cb9a689fa09cb97e8a6c0e74324 Mon Sep 17 00:00:00 2001 From: Matias Date: Tue, 22 Oct 2024 14:02:11 -0300 Subject: [PATCH 1/6] order garden card by communities length from most to least --- apps/web/app/(app)/gardens/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/app/(app)/gardens/page.tsx b/apps/web/app/(app)/gardens/page.tsx index 98d968d20..4efcfeeaf 100644 --- a/apps/web/app/(app)/gardens/page.tsx +++ b/apps/web/app/(app)/gardens/page.tsx @@ -49,7 +49,7 @@ export default function Page() { {tokenGardens .sort( (a, b) => - (a.communities?.length ?? 0) - (b.communities?.length ?? 0), + (b.communities?.length ?? 0) - (a.communities?.length ?? 0), ) .map((garden) => (
From edf496e85ada0b5be314ffe88cf8b7f43c8b3dc2 Mon Sep 17 00:00:00 2001 From: Lucianosc Date: Wed, 23 Oct 2024 19:18:33 +0700 Subject: [PATCH 2/6] fix fund pool check balance --- apps/web/components/PoolMetrics.tsx | 50 ++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/apps/web/components/PoolMetrics.tsx b/apps/web/components/PoolMetrics.tsx index db40b1401..fbaa6acd4 100644 --- a/apps/web/components/PoolMetrics.tsx +++ b/apps/web/components/PoolMetrics.tsx @@ -2,8 +2,9 @@ import { FC, useEffect, useState } from "react"; import { FetchTokenResult } from "@wagmi/core"; +import { useForm } from "react-hook-form"; import { parseUnits } from "viem"; -import { Address, useAccount } from "wagmi"; +import { Address, useAccount, useBalance } from "wagmi"; import { Allo } from "#/subgraph/.graphclient"; import { Button } from "./Button"; import { DisplayNumber } from "./DisplayNumber"; @@ -35,12 +36,27 @@ export const PoolMetrics: FC = ({ }) => { const INPUT_TOKEN_MIN_VALUE = 1 / 10 ** poolToken.decimals; + const { + register, + handleSubmit, + formState: { errors }, + watch, + } = useForm<{ amount: number }>(); + const [isOpenModal, setIsOpenModal] = useState(false); - const [amount, setAmount] = useState(""); const { address: accountAddress } = useAccount(); const { publish } = usePubSubContext(); + const { data } = useBalance({ + address: accountAddress, + formatUnits: poolToken.decimals, + token: poolToken.address, + watch: true, + chainId: Number(chainId), + }); - const requestedAmount = parseUnits(amount, poolToken.decimals); + const tokenWalletBalance = data ? Number(data.value) : 0; + const amount = watch("amount") ? watch("amount") : 0; + const requestedAmount = parseUnits(amount.toString(), poolToken.decimals); const { write: writeFundPool, @@ -108,15 +124,18 @@ export const PoolMetrics: FC = ({ isOpen={isOpenModal} onClose={() => setIsOpenModal(false)} > -
+

Adding:

- +

Pool Funds

-
+

Funds available:

= ({
{ - e.preventDefault(); - handleFundPool(); - }} + onSubmit={handleSubmit(handleFundPool)} > setAmount(e.target.value)} + register={register} + registerKey="amount" + errors={errors} value={amount} otherProps={{ step: INPUT_TOKEN_MIN_VALUE, min: INPUT_TOKEN_MIN_VALUE, }} + registerOptions={{ + max: { + value: tokenWalletBalance, + message: "Not enough balance", + }, + min: { + value: INPUT_TOKEN_MIN_VALUE, + message: `Amount must be greater than ${INPUT_TOKEN_MIN_VALUE}`, + }, + }} suffix={poolToken.symbol} />