Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Badge "Active" status to be displayed only on active staking contract #345

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading