@@ -19,6 +19,12 @@ import { CampaignType, campaignConfig } from './constants'
1919import { useNearIntentSelectedWallet } from './hooks/useNearIntentSelectedWallet'
2020import { Tab , Tabs , Wrapper } from './styles'
2121
22+ enum TabKey {
23+ Information = 'information' ,
24+ Leaderboard = 'leaderboard' ,
25+ YourTransactions = 'your-transactions' ,
26+ }
27+
2228export default function CampaignPage ( ) {
2329 const navigate = useNavigate ( )
2430 const { pathname } = useLocation ( )
@@ -46,7 +52,7 @@ export default function CampaignPage() {
4652
4753 const params = useNearIntentSelectedWallet ( )
4854 const page = + ( searchParams . get ( 'page' ) || '1' )
49- const tab = searchParams . get ( 'tab' ) || 'information'
55+ const tab = searchParams . get ( 'tab' ) || TabKey . Information
5056 const upToExtraSmall = useMedia ( `(max-width: ${ MEDIA_WIDTHS . upToExtraSmall } px)` )
5157
5258 useEffect ( ( ) => {
@@ -98,19 +104,19 @@ export default function CampaignPage() {
98104 < Tabs >
99105 < Tab
100106 role = "button"
101- active = { tab === 'information' }
107+ active = { tab === TabKey . Information }
102108 onClick = { ( ) => {
103- searchParams . set ( 'tab' , 'information' )
109+ searchParams . set ( 'tab' , TabKey . Information )
104110 setSearchParams ( searchParams )
105111 } }
106112 >
107113 < Trans > Information</ Trans >
108114 </ Tab >
109115 < Tab
110116 role = "button"
111- active = { tab === 'leaderboard' }
117+ active = { tab === TabKey . Leaderboard }
112118 onClick = { ( ) => {
113- searchParams . set ( 'tab' , 'leaderboard' )
119+ searchParams . set ( 'tab' , TabKey . Leaderboard )
114120 setSearchParams ( searchParams )
115121 } }
116122 >
@@ -119,9 +125,9 @@ export default function CampaignPage() {
119125 { isRaffleCampaign && (
120126 < Tab
121127 role = "button"
122- active = { tab === 'your-transactions' }
128+ active = { tab === TabKey . YourTransactions }
123129 onClick = { ( ) => {
124- searchParams . set ( 'tab' , 'your-transactions' )
130+ searchParams . set ( 'tab' , TabKey . YourTransactions )
125131 setSearchParams ( searchParams )
126132 } }
127133 >
@@ -135,9 +141,9 @@ export default function CampaignPage() {
135141 </ StyledInternalLink >
136142 </ Flex >
137143
138- { tab === 'information' && < Information type = { type } week = { selectedWeek } /> }
144+ { tab === TabKey . Information && < Information type = { type } week = { selectedWeek } /> }
139145
140- { tab === 'leaderboard' &&
146+ { tab === TabKey . Leaderboard &&
141147 ( isRaffleCampaign ? (
142148 < RaffleLeaderboard />
143149 ) : (
@@ -152,7 +158,7 @@ export default function CampaignPage() {
152158 />
153159 ) ) }
154160
155- { tab === 'your-transactions' && < RaffleLeaderboard type = "owner" /> }
161+ { tab === TabKey . YourTransactions && < RaffleLeaderboard type = "owner" /> }
156162 </ Wrapper >
157163 )
158164}
0 commit comments