Skip to content

Commit 30026a2

Browse files
committed
feat: support last cycle modal open
1 parent 0a149bb commit 30026a2

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

apps/evm/src/pages/PrimeLeaderboard/EndOfCycle/__tests__/index.spec.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { screen } from '@testing-library/react';
1+
import { fireEvent, screen } from '@testing-library/react';
22

33
import { renderComponent } from 'testUtils/render';
44
import { EndOfCycle } from '..';
@@ -13,6 +13,14 @@ describe('pages/PrimeLeaderboard/EndOfCycle', () => {
1313
expect(screen.getByText("See last cycle's Prime summary")).toBeInTheDocument();
1414
});
1515

16+
it('opens the last cycle summary modal from the helper link', async () => {
17+
renderComponent(<EndOfCycle endDate={new Date(Date.now() + 5 * ONE_DAY_MS)} />);
18+
19+
fireEvent.click(screen.getByText("See last cycle's Prime summary"));
20+
21+
expect(await screen.findByText('Last Cycle Prime Summary')).toBeInTheDocument();
22+
});
23+
1624
it('renders the ended state for a past end date', () => {
1725
renderComponent(<EndOfCycle endDate={new Date(Date.now() - ONE_DAY_MS)} />);
1826

apps/evm/src/pages/PrimeLeaderboard/EndOfCycle/index.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { cn } from '@venusprotocol/ui';
1+
import { Button, cn } from '@venusprotocol/ui';
2+
import { useState } from 'react';
23
import ReactCountdown from 'react-countdown';
34

45
import { Card } from 'components';
56
import { useTranslation } from 'libs/translations';
67

8+
import { LastCycleSummaryModal } from '../LastCycleSummaryModal';
79
import { Timer } from './Timer';
810

911
export interface EndOfCycleProps {
@@ -21,6 +23,7 @@ interface CountdownState {
2123

2224
export const EndOfCycle: React.FC<EndOfCycleProps> = ({ endDate, className }) => {
2325
const { t, Trans } = useTranslation();
26+
const [isSummaryModalOpen, setIsSummaryModalOpen] = useState(false);
2427

2528
const deadline = t('primeLeaderboard.endOfCycle.deadline', { date: endDate });
2629

@@ -49,13 +52,27 @@ export const EndOfCycle: React.FC<EndOfCycleProps> = ({ endDate, className }) =>
4952
values={{ deadline }}
5053
components={{
5154
bold: <span className="text-b1s text-white" />,
52-
summaryLink: <span className="text-b1s text-blue underline" />,
55+
summaryLink: (
56+
<Button
57+
variant="text"
58+
onClick={() => setIsSummaryModalOpen(true)}
59+
className="h-auto p-0 text-b1s text-blue underline"
60+
/>
61+
),
5362
}}
5463
/>
5564
</p>
5665
)}
5766
</Card>
5867
);
5968

60-
return <ReactCountdown date={endDate} renderer={renderCard} />;
69+
return (
70+
<>
71+
<ReactCountdown date={endDate} renderer={renderCard} />
72+
73+
{isSummaryModalOpen && (
74+
<LastCycleSummaryModal isOpen handleClose={() => setIsSummaryModalOpen(false)} />
75+
)}
76+
</>
77+
);
6178
};

0 commit comments

Comments
 (0)