Skip to content

Commit

Permalink
fix: Badge "Active" status to be displayed only on active staking con…
Browse files Browse the repository at this point in the history
…tract (#345)

* fix StakingContractTag

* fix
  • Loading branch information
mohandast52 authored Sep 11, 2024
1 parent ee8d5f1 commit ab42ee9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { StakingProgramStatus } from '@/enums/StakingProgramStatus';
export const StakingContractTag = ({
status,
}: {
status?: StakingProgramStatus;
status: StakingProgramStatus | null;
}) => {
if (status === StakingProgramStatus.Selected) {
return <Tag color="purple">Active</Tag>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ export const StakingContractSection = ({
]);

const contractTagStatus = useMemo(() => {
if (activeStakingProgram === stakingProgram)
if (activeStakingProgram === stakingProgram) {
return StakingProgramStatus.Selected;
}

// not staked, set the default as the Selected contract
if (stakingProgram === defaultStakingProgram)
if (!activeStakingProgram && stakingProgram === defaultStakingProgram) {
return StakingProgramStatus.Selected;
}

// otherwise, no tag
return;
return null;
}, [activeStakingProgram, defaultStakingProgram, stakingProgram]);

// Show funding address
Expand All @@ -239,16 +239,14 @@ export const StakingContractSection = ({
activeStakingContractSupportsMigration &&
!hasEnoughOlasToMigrate;

const cardStyle = useMemo(() => {
if (isSelected || !activeStakingProgram) {
return { background: token.colorPrimaryBg };
}
return {};
}, [isSelected, activeStakingProgram, token.colorPrimaryBg]);

return (
<>
<CardSection style={cardStyle} borderbottom="true" vertical gap={16}>
<CardSection
style={contractTagStatus ? { background: token.colorPrimaryBg } : {}}
borderbottom="true"
vertical
gap={16}
>
<Flex gap={12}>
<Title level={5} className="m-0">
{`${stakingProgramMeta?.name} contract`}
Expand Down
5 changes: 4 additions & 1 deletion frontend/components/ManageStakingPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export const ManageStakingPage = () => {
}
>
<WhatAreStakingContractsSection />
<StakingContractSection stakingProgram={orderedStakingPrograms[0]} />

{activeStakingProgram && (
<StakingContractSection stakingProgram={orderedStakingPrograms[0]} />
)}

<CardSection borderbottom="true" vertical gap={16}>
{`Browse ${otherStakingPrograms.length} staking contract${otherStakingPrograms.length > 1 ? 's' : ''}.`}
Expand Down

0 comments on commit ab42ee9

Please sign in to comment.