generated from BlossomLabs/web3-turbo-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #278 from 1Hive/implement-breadcrumbs
Implement breadcrumbs
- Loading branch information
Showing
22 changed files
with
709 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
apps/web/app/(app)/gardens/[chain]/[garden]/[community]/[poolId]/create-proposal/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
"use client"; | ||
|
||
import { getPoolDataDocument, getPoolDataQuery } from "#/subgraph/.graphclient"; | ||
import { ProposalForm } from "@/components/Forms"; | ||
import LoadingSpinner from "@/components/LoadingSpinner"; | ||
import useSubgraphQuery from "@/hooks/useSubgraphQuery"; | ||
import { getIpfsMetadata } from "@/utils/ipfsUtils"; | ||
import { MAX_RATIO_CONSTANT, CV_SCALE_PRECISION } from "@/utils/numbers"; | ||
import React, { useEffect, useState } from "react"; | ||
import { Address } from "viem"; | ||
|
||
export default function Page({ | ||
params: { chain, poolId, garden }, | ||
}: { | ||
params: { chain: string; poolId: number; garden: string }; | ||
}) { | ||
const { data } = useSubgraphQuery<getPoolDataQuery>({ | ||
query: getPoolDataDocument, | ||
variables: { poolId: poolId, garden: garden }, | ||
}); | ||
const strategyObj = data?.cvstrategies?.[0]; | ||
|
||
const [metadata, setMetadata] = useState({ title: "", description: "" }); | ||
|
||
useEffect(() => { | ||
const fetchMetadata = async () => { | ||
if (strategyObj?.metadata) { | ||
const fetchedMetadata = await getIpfsMetadata( | ||
strategyObj.metadata as string, | ||
); | ||
setMetadata(fetchedMetadata); | ||
} | ||
}; | ||
|
||
fetchMetadata(); | ||
}, [strategyObj]); | ||
|
||
if (!strategyObj) { | ||
return <div>{`Pool ${poolId} not found`}</div>; | ||
} | ||
|
||
const alloInfo = data?.allos[0]; | ||
const proposalType = strategyObj.config?.proposalType as number; | ||
const poolAmount = strategyObj.poolAmount as number; | ||
const tokenGarden = data.tokenGarden; | ||
|
||
const maxRatioDivPrecision = | ||
(Number(strategyObj.config?.maxRatio) / CV_SCALE_PRECISION) * | ||
MAX_RATIO_CONSTANT; | ||
|
||
const spendingLimitPct = maxRatioDivPrecision * 100; | ||
const poolAmountSpendingLimit = poolAmount * maxRatioDivPrecision; | ||
|
||
if (!tokenGarden) { | ||
return <LoadingSpinner />; | ||
} | ||
|
||
return ( | ||
<div className="page-layout"> | ||
<section className="section-layout"> | ||
<div className="text-center sm:mt-5"> | ||
<h2 className="text-xl font-semibold leading-6 text-gray-900"> | ||
Create a Proposal in Pool | ||
</h2> | ||
<div className="mt-1"> | ||
<p className="text-sm">{metadata.title}</p> | ||
</div> | ||
</div> | ||
<ProposalForm | ||
poolId={poolId} | ||
proposalType={proposalType} | ||
alloInfo={alloInfo} | ||
tokenGarden={tokenGarden} | ||
tokenAddress={garden as Address} | ||
spendingLimit={poolAmountSpendingLimit} | ||
spendingLimitPct={spendingLimitPct} | ||
poolAmount={poolAmount} | ||
/> | ||
</section> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 0 additions & 70 deletions
70
...web/app/(app)/gardens/[chain]/[garden]/[community]/pool/[poolId]/create-proposal/page.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.