Skip to content

Commit 9a00c81

Browse files
committed
chore: integrate hook to display staked amount in application view page
1 parent bc36caf commit 9a00c81

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

packages/grant-explorer/src/features/round/ViewProjectDetails/ViewProjectDetails.tsx

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import {
3333
ProjectLogo,
3434
StakingBannerAndModal,
3535
} from "./components";
36-
36+
import { useGetApplicationStakes } from "./hooks/useGetApplicationStakes";
37+
import { useIsStakable } from "./components/StakingBannerAndModal/hooks/useIsStakable";
3738
export default function ViewProjectDetails() {
3839
const [selectedTab, setSelectedTab] = useState(0);
3940

@@ -58,6 +59,11 @@ export default function ViewProjectDetails() {
5859
applicationId = paramApplicationId;
5960
}
6061

62+
const isStakableRound = useIsStakable({
63+
chainId: Number(chainId),
64+
roundId,
65+
});
66+
6167
const {
6268
data: application,
6369
error,
@@ -70,6 +76,13 @@ export default function ViewProjectDetails() {
7076
},
7177
dataLayer
7278
);
79+
const { data: totalStaked } = useGetApplicationStakes(
80+
Number(chainId),
81+
Number(roundId),
82+
application?.anchorAddress ?? "",
83+
isStakableRound
84+
);
85+
7386
const { round: roundDetails } = useRoundById(Number(chainId), roundId);
7487

7588
const projectToRender = application && mapApplicationToProject(application);
@@ -218,12 +231,15 @@ export default function ViewProjectDetails() {
218231
</div>
219232
)}
220233
</div>
221-
<div className="mb-4">
234+
<div className="mb-4 relative">
222235
<ProjectBanner
223236
bannerImgCid={bannerImg ?? null}
224237
classNameOverride="h-32 w-full object-cover lg:h-80 rounded md:rounded-3xl"
225238
resizeHeight={320}
226239
/>
240+
{totalStaked && Number(totalStaked) > 0 && (
241+
<StakedAmountCard totalStaked={Number(totalStaked)} />
242+
)}
227243
<div className="pl-4 sm:pl-6 lg:pl-8">
228244
<div className="sm:flex sm:items-end sm:space-x-5">
229245
<div className="flex">
@@ -275,3 +291,40 @@ export default function ViewProjectDetails() {
275291
</>
276292
);
277293
}
294+
295+
const StakedAmountCard = ({ totalStaked }: { totalStaked: number }) => {
296+
return (
297+
<div className="p-2 bg-white/80 rounded-2xl backdrop-blur-sm inline-flex justify-start items-center gap-2 absolute top-4 right-4">
298+
<div data-svg-wrapper className="relative">
299+
<svg
300+
width="20"
301+
height="20"
302+
viewBox="0 0 20 20"
303+
fill="none"
304+
xmlns="http://www.w3.org/2000/svg"
305+
>
306+
<path
307+
d="M10.8334 8.33333V2.5L3.33337 11.6667H9.16671L9.16671 17.5L16.6667 8.33333L10.8334 8.33333Z"
308+
stroke="#7D67EB"
309+
stroke-width="2"
310+
stroke-linecap="round"
311+
stroke-linejoin="round"
312+
/>
313+
</svg>
314+
</div>
315+
<div className="inline-flex flex-col justify-start items-start">
316+
<div className="self-stretch inline-flex justify-start items-center gap-1">
317+
<div className="justify-start text-text-primary text-lg font-medium font-['DM_Mono'] leading-normal">
318+
{totalStaked}
319+
</div>
320+
<div className="justify-start text-text-primary text-lg font-medium font-['DM_Mono'] leading-normal">
321+
GTC
322+
</div>
323+
</div>
324+
<div className="self-stretch justify-start text-text-primary text-sm font-normal font-['DM_Mono'] leading-[14px]">
325+
Total staked
326+
</div>
327+
</div>
328+
</div>
329+
);
330+
};

0 commit comments

Comments
 (0)