|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import PropTypes from 'prop-types'; |
| 3 | +import { Route } from 'react-router-dom'; |
| 4 | +import { Cell } from '@material/react-layout-grid'; |
| 5 | +import Fab from '@material/react-fab'; |
| 6 | +import MaterialIcon from '@material/react-material-icon'; |
| 7 | +import ContestDetails from './ContestDetails'; |
| 8 | +import Announcements from './Announcements'; |
| 9 | +import Submit from './SubmitOnProblemPage'; |
| 10 | +import ContestTabBar from './ContestTabBar'; |
| 11 | +import './Split.css'; |
| 12 | + |
| 13 | +const ContestPageElement = ({ children, contestDetails, isMobile, parentClassName }) => { |
| 14 | + const { name, description, endsAt, announcement, startsAt } = contestDetails; |
| 15 | + const [isEditorOpen, setEditorOpen] = useState(false); |
| 16 | + return ( |
| 17 | + <React.Fragment key="ChildrenElement"> |
| 18 | + {(!isMobile || !isEditorOpen) && ( |
| 19 | + <Cell desktopColumns={9} tabletColumns={8} className={`${parentClassName} scrollbar`}> |
| 20 | + <Cell> |
| 21 | + <Route path="/contests/:contestId" exact component={ContestTabBar} /> |
| 22 | + <Route path="/contests/:contestId/status" exact component={ContestTabBar} /> |
| 23 | + <Route path="/contests/:contestId/my" exact component={ContestTabBar} /> |
| 24 | + <Route path="/contests/:contestId/scoreboard" exact component={ContestTabBar} /> |
| 25 | + {/* <Route path="/contests/:contestId/submit" exact component={ContestTabBar} /> */} |
| 26 | + <Route path="/contests/:contestId/change" exact component={ContestTabBar} /> |
| 27 | + <Route path="/contests/:contestId/problem/:problemId" exact component={ContestTabBar} /> |
| 28 | + {children} |
| 29 | + </Cell> |
| 30 | + |
| 31 | + <Cell> |
| 32 | + <ContestDetails |
| 33 | + name={name} |
| 34 | + description={description} |
| 35 | + endsAt={endsAt} |
| 36 | + startsAt={startsAt} |
| 37 | + /> |
| 38 | + </Cell> |
| 39 | + <Cell> |
| 40 | + <Announcements announcement={announcement} /> |
| 41 | + </Cell> |
| 42 | + </Cell> |
| 43 | + )} |
| 44 | + {isMobile && ( |
| 45 | + <Fab |
| 46 | + textLabel={!isEditorOpen ? 'Editor' : 'Back'} |
| 47 | + className="center editor-btn-fab" |
| 48 | + icon={<MaterialIcon icon={!isEditorOpen ? 'data_object' : 'arrow_back_ios'} />} |
| 49 | + onClick={() => setEditorOpen(!isEditorOpen)} |
| 50 | + /> |
| 51 | + )} |
| 52 | + {(!isMobile || isEditorOpen) && ( |
| 53 | + <Cell className="editor scrollbar"> |
| 54 | + <Submit setEditorOpen={setEditorOpen} /> |
| 55 | + </Cell> |
| 56 | + )} |
| 57 | + </React.Fragment> |
| 58 | + ); |
| 59 | +}; |
| 60 | + |
| 61 | +ContestPageElement.propTypes = { |
| 62 | + children: PropTypes.any.isRequired, |
| 63 | + contestDetails: PropTypes.object.isRequired, |
| 64 | + isMobile: PropTypes.bool.isRequired, |
| 65 | + parentClassName: PropTypes.string.isRequired, |
| 66 | +}; |
| 67 | +export default ContestPageElement; |
0 commit comments