@@ -4,7 +4,10 @@ import axios from 'axios';
44import { camelizeKeys } from 'humps' ;
55import { useSelector } from 'react-redux' ;
66
7- import { selectDefaultAvatarUrl } from '@/selectors' ;
7+ import {
8+ selectDefaultAvatarUrl ,
9+ currentUserIsAdminSelector ,
10+ } from '@/selectors' ;
811
912import i18n from '../../../i18n' ;
1013
@@ -51,136 +54,142 @@ const SeasonProfilePanel = ({
5154 liveTournaments = [ ] ,
5255 user,
5356 controls,
54- } ) => (
55- < div className = "d-flex flex-column-reverse flex-lg-row flex-md-row my-0 my-lg-2 my-md-2" >
56- < div className = "col-12 col-lg-8 col-md-8 my-2 my-lg-0 my-md-0" >
57- < div className = "cb-bg-panel cb-rounded d-flex flex-column p-3 h-100 w-100 text-center" >
58- < h2 className = "text-white" > Codebattle Season Competition</ h2 >
59- < p className = "m-auto pb-3 px-4 text-white" >
60- Challenge the best! Participate in the Competition tournaments
61- { ', ' }
62- defeat your rivals to earn points
63- { ', ' }
64- and claim the first place in the programmer ranking.
65- </ p >
66- { seasonTournaments ?. length || liveTournaments ?. length ? (
67- < div className = "cb-bg-highlight-panel" >
68- { liveTournaments ?. length !== 0 && (
69- < >
70- < div className = "d-flex justify-content-center align-items-center pt-2 cb-bg-panel" >
71- < span className = "text-white text-uppercase h4" >
72- Live Tournaments
73- </ span >
74- </ div >
75- { liveTournaments . map ( tournament => (
76- < TournamentListItem
77- key = { tournament . id }
78- tournament = { tournament }
79- icon = { activeIcon }
80- />
81- ) ) }
82- </ >
83- ) }
84- { seasonTournaments ?. length !== 0 && (
85- < >
86- < div className = "d-flex justify-content-center pt-2 cb-bg-panel" >
87- < span className = "text-white text-uppercase h4" >
88- Upcoming Tournaments
89- </ span >
90- </ div >
91- < div
92- className = "d-flex flex-column cb-overflow-y-scroll position-relative"
93- style = { { maxHeight : '280px' } }
94- >
95- { seasonTournaments . map ( tournament => (
57+ } ) => {
58+ const isAdmin = useSelector ( currentUserIsAdminSelector ) ;
59+
60+ return (
61+ < div className = "d-flex flex-column-reverse flex-lg-row flex-md-row my-0 my-lg-2 my-md-2" >
62+ < div className = "col-12 col-lg-8 col-md-8 my-2 my-lg-0 my-md-0" >
63+ < div className = "cb-bg-panel cb-rounded d-flex flex-column p-3 h-100 w-100 text-center" >
64+ < h2 className = "text-white" > Codebattle Season Competition</ h2 >
65+ < p className = "m-auto pb-3 px-4 text-white" >
66+ Challenge the best! Participate in the Competition tournaments
67+ { ', ' }
68+ defeat your rivals to earn points
69+ { ', ' }
70+ and claim the first place in the programmer ranking.
71+ </ p >
72+ { seasonTournaments ?. length || liveTournaments ?. length ? (
73+ < div className = "cb-bg-highlight-panel" >
74+ { liveTournaments ?. length !== 0 && (
75+ < >
76+ < div className = "d-flex justify-content-center align-items-center pt-2 cb-bg-panel" >
77+ < span className = "text-white text-uppercase h4" >
78+ Live Tournaments
79+ </ span >
80+ </ div >
81+ { liveTournaments . map ( tournament => (
9682 < TournamentListItem
83+ isAdmin = { isAdmin }
9784 key = { tournament . id }
9885 tournament = { tournament }
86+ icon = { activeIcon }
9987 />
10088 ) ) }
101- </ div >
102- </ >
103- ) }
89+ </ >
90+ ) }
91+ { seasonTournaments ?. length !== 0 && (
92+ < >
93+ < div className = "d-flex justify-content-center pt-2 cb-bg-panel" >
94+ < span className = "text-white text-uppercase h4" >
95+ Upcoming Tournaments
96+ </ span >
97+ </ div >
98+ < div
99+ className = "d-flex flex-column cb-overflow-y-scroll position-relative"
100+ style = { { maxHeight : '280px' } }
101+ >
102+ { seasonTournaments . map ( tournament => (
103+ < TournamentListItem
104+ isAdmin = { isAdmin }
105+ key = { tournament . id }
106+ tournament = { tournament }
107+ />
108+ ) ) }
109+ </ div >
110+ </ >
111+ ) }
112+ </ div >
113+ ) : (
114+ < div className = "pt-2 mt-2" > Competition not started yet</ div >
115+ ) }
116+ < div className = "d-flex flex-column flex-lg-row flex-md-row w-100 pt-2 mt-2" >
117+ < a
118+ href = "/schedule#contest"
119+ type = "button"
120+ className = "btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
121+ >
122+ { i18n . t ( 'Contests History' ) }
123+ </ a >
124+ < a
125+ href = "/schedule#my"
126+ type = "button"
127+ className = "btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
128+ >
129+ { i18n . t ( 'My Tournaments' ) }
130+ </ a >
131+ < a
132+ href = "/tournaments"
133+ type = "button"
134+ className = "btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
135+ >
136+ { i18n . t ( 'Create a Tournament' ) }
137+ </ a >
104138 </ div >
105- ) : (
106- < div className = "pt-2 mt-2" > Competition not started yet</ div >
107- ) }
108- < div className = "d-flex flex-column flex-lg-row flex-md-row w-100 pt-2 mt-2" >
109- < a
110- href = "/schedule#contest"
111- type = "button"
112- className = "btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
113- >
114- { i18n . t ( 'Contests History' ) }
115- </ a >
116- < a
117- href = "/schedule#my"
118- type = "button"
119- className = "btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
120- >
121- { i18n . t ( 'My Tournaments' ) }
122- </ a >
123- < a
124- href = "/tournaments"
125- type = "button"
126- className = "btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
127- >
128- { i18n . t ( 'Create a Tournament' ) }
129- </ a >
130139 </ div >
131140 </ div >
132- </ div >
133- < div className = "col-12 col-lg-4 col-md-4 d-flex flex-column my-2 my-lg-0 my-md-0" >
134- < div className = "cb-bg-panel cb-rounded" >
135- < div className = "text-center p-2 py-3" >
136- < UserLogo user = { user } />
137- < span className = "clan-tag mt-2" > { user . name } </ span >
138- < span className = "h1 clan-title m-0 text-white text-uppercase" >
139- Clan
140- { ': ' }
141- { user . clanId ? (
142- user . clan
143- ) : (
144- < a href = "/settings" className = "text-lowercase text-primary" >
145- < small > add clan</ small >
146- </ a >
147- ) }
148- </ span >
149- </ div >
150-
151- < div className = "cb-bg-highlight-panel d-flex py-2 px-1" >
152- < div className = "stat-item py-1 w-100" >
153- < span className = "stat-value d-block cb-text-danger" >
154- { user . rating }
141+ < div className = "col-12 col-lg-4 col-md-4 d-flex flex-column my-2 my-lg-0 my-md-0" >
142+ < div className = "cb-bg-panel cb-rounded" >
143+ < div className = "text-center p-2 py-3" >
144+ < UserLogo user = { user } />
145+ < span className = "clan-tag mt-2" > { user . name } </ span >
146+ < span className = "h1 clan-title m-0 text-white text-uppercase" >
147+ Clan
148+ { ': ' }
149+ { user . clanId ? (
150+ user . clan
151+ ) : (
152+ < a href = "/settings" className = "text-lowercase text-primary" >
153+ < small > add clan</ small >
154+ </ a >
155+ ) }
155156 </ span >
156- < span className = "stat-label text-uppercase" > (Elo Rating)</ span >
157157 </ div >
158- < div className = "stat-item py-1 w-100" >
159- { user . points ? (
160- < span className = "stat-value d-block cb-text-success " >
161- #
162- { user . rank }
158+
159+ < div className = "cb-bg-highlight-panel d-flex py-2 px-1" >
160+ < div className = "stat-item py-1 w-100 " >
161+ < span className = "stat-value d-block cb-text-danger" >
162+ { user . rating }
163163 </ span >
164- ) : (
165- < span className = "stat-value d-block cb-text-danger" > #0</ span >
166- ) }
167- < span className = "stat-label text-uppercase" > Place</ span >
168- </ div >
169- < div className = "stat-item py-1 w-100" >
170- < span className = "stat-value d-block cb-text-danger" >
171- { user . points || 0 }
172- </ span >
173- < span className = "stat-label text-uppercase" > Points</ span >
164+ < span className = "stat-label text-uppercase" > (Elo Rating)</ span >
165+ </ div >
166+ < div className = "stat-item py-1 w-100" >
167+ { user . points ? (
168+ < span className = "stat-value d-block cb-text-success" >
169+ #
170+ { user . rank }
171+ </ span >
172+ ) : (
173+ < span className = "stat-value d-block cb-text-danger" > #0</ span >
174+ ) }
175+ < span className = "stat-label text-uppercase" > Place</ span >
176+ </ div >
177+ < div className = "stat-item py-1 w-100" >
178+ < span className = "stat-value d-block cb-text-danger" >
179+ { user . points || 0 }
180+ </ span >
181+ < span className = "stat-label text-uppercase" > Points</ span >
182+ </ div >
174183 </ div >
175- </ div >
176184
177- < div className = "d-flex justify-content-center cb-font-size-small py-2 px-3 text-white" >
178- < span className = "d-block" > { contestDatesText } </ span >
185+ < div className = "d-flex justify-content-center cb-font-size-small py-2 px-3 text-white" >
186+ < span className = "d-block" > { contestDatesText } </ span >
187+ </ div >
179188 </ div >
189+ { controls }
180190 </ div >
181- { controls }
182191 </ div >
183- </ div >
184- ) ;
192+ ) ;
193+ } ;
185194
186195export default SeasonProfilePanel ;
0 commit comments