Skip to content

Commit 4cd7e90

Browse files
committed
feat: support last cycle modal open
1 parent 7c8e4e0 commit 4cd7e90

2 files changed

Lines changed: 26 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: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
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,9 +52,12 @@ export const EndOfCycle: React.FC<EndOfCycleProps> = ({ endDate, className }) =>
4952
values={{ deadline }}
5053
components={{
5154
bold: <span className="text-b1s text-white" />,
52-
// TODO: open the last cycle summary modal once it's available
5355
summaryLink: (
54-
<Button variant="text" className="h-auto p-0 text-b1s text-blue underline" />
56+
<Button
57+
variant="text"
58+
onClick={() => setIsSummaryModalOpen(true)}
59+
className="h-auto p-0 text-b1s text-blue underline"
60+
/>
5561
),
5662
}}
5763
/>
@@ -60,5 +66,13 @@ export const EndOfCycle: React.FC<EndOfCycleProps> = ({ endDate, className }) =>
6066
</Card>
6167
);
6268

63-
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+
);
6478
};

0 commit comments

Comments
 (0)