Skip to content

Commit

Permalink
Subgraph done and contract write + relocation done
Browse files Browse the repository at this point in the history
  • Loading branch information
kafann committed Nov 29, 2024
1 parent 967f5d8 commit 7e09636
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions apps/web/components/PoolHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { StopIcon } from "@heroicons/react/24/solid";
import { FetchTokenResult } from "@wagmi/core";
import Image from "next/image";
import { usePathname, useRouter } from "next/navigation";
import { Address, zeroAddress } from "viem";
import { useAccount, useContractRead } from "wagmi";
import {
Expand Down Expand Up @@ -95,7 +96,6 @@ function calculateMinimumConviction(weight: number, spendingLimit: number) {

return minimumConviction;
}

export default function PoolHeader({
ipfsResult,
poolId,
Expand All @@ -110,6 +110,8 @@ export default function PoolHeader({
const { address } = useAccount();
const { publish } = usePubSubContext();
const { id: chainId, safePrefix } = useChainFromPath()!;
const router = useRouter();
const path = usePathname();

const { data: passportStrategyData } =
useSubgraphQuery<getPassportStrategyQuery>({
Expand All @@ -128,7 +130,6 @@ export default function PoolHeader({
passportStrategy?.threshold ?
Number(passportStrategy?.threshold) / CV_PASSPORT_THRESHOLD_SCALE
: null;

const blockTime = chainConfigMap[chainId!].blockTime;
const spendingLimitPct =
(Number(strategy.config.maxRatio || 0) / CV_SCALE_PRECISION) * 100;
Expand Down Expand Up @@ -291,6 +292,16 @@ export default function PoolHeader({
chainId: chainId,
});
},
onSuccess: () => {
const pathSegments = path.split("/");
pathSegments.pop();
console.log("LENGTH", pathSegments.length);
if (pathSegments.length === 6) {
pathSegments.pop();
}
const newPath = pathSegments.join("/");
router.push(newPath);
},
});

const { write: addStrategyByPoolId } = useContractWriteWithConfirmations({
Expand Down Expand Up @@ -383,6 +394,7 @@ export default function PoolHeader({
>
Edit
</Button>

<Button
icon={<StopIcon height={24} width={24} />}
disabled={
Expand Down

0 comments on commit 7e09636

Please sign in to comment.