-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathApp.js
More file actions
201 lines (186 loc) · 7.28 KB
/
Copy pathApp.js
File metadata and controls
201 lines (186 loc) · 7.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import React, { useState, useEffect } from 'react'
import 'antd/dist/antd.css'
import {
BrowserRouter as Router,
Routes,
Route,
useParams,
useLocation,
} from 'react-router-dom'
import Homepage from './pages/Homepage'
import Login from './pages/LogReg/Login'
import Register from './pages/LogReg/Register'
import Parent from './pages/Ladders-Practice/Parent'
import Profile from './pages/Profile/Profile'
import FillInfo from './pages/LogReg/FillInfo'
import './App.css'
import Questions from './pages/Ladders-Practice/Questions'
import ForgotPass from './pages/LogReg/ForgotPass'
import NewPassword from './pages/LogReg/NewPassword'
import Playlists from './pages/Playlists/Playlists'
import PlaylistQuestions from './pages/Playlists/PlaylistQuestions'
import Problems from './pages/Problems'
import queryString from 'query-string'
import ChangePassword from './pages/LogReg/ChangePassword'
import EmailVerfiedMsg from './pages/LogReg/EmailVerifiedMsg'
import Error404 from './pages/Error404'
import UpdateProfile from './pages/Profile/UpdateProfile'
import AboutUs from './pages/ExtraInfo/AboutUs'
import PrivacyPolicy from './pages/ExtraInfo/PrivacyPolicy'
import TermsAndConditions from './pages/ExtraInfo/TermsAndConditions'
import Contests from '../src/pages/Contests/Contests'
import { Layout, Menu } from 'antd'
import ContestAPI from './actions/Contest'
import mainUpsolve from './pages/Upsolve/mainUpsolve'
import { atcoder, codechef, codeforces } from './actions/upsolve.actions'
import Navbar from './pages/Navbar'
const { Header, Footer, Content } = Layout
//react context
export const CredentialsContext = React.createContext()
const App = () => {
// setInterval(Validate,300*1000);
const PlaylistsMatch = () => {
let params = useParams()
return (
//passing handle as prop
<Playlists handle={params.id} />
)
}
const PlaylistList1 = () => {
let params = useParams()
return (
//passing slug and handle as props
<PlaylistQuestions slug={params.slug} handle={params.id} />
)
}
const ProfileMatch = () => {
let params = useParams()
return (
//passing handle as prop
<Profile handle={params.id} />
)
}
const LaddersQuestionPage1 = () => {
let params = useParams()
let location = useLocation()
const dat = queryString.parse(location.search)
const [pageNo, setPageNo] = useState(dat.page ? dat.page : '')
return (
// PARSEINT IS A JS FUNCTION WHICH WILL CONVERT THE THE GIVEN STRING OF NUMBERS
// ACCORDING TO THE BASE OR RADIX SPECIFIED
<Questions
wise={params.wise}
type={params.type}
slug={params.slug}
pageNo={pageNo}
/>
)
}
const LaddersLevel1 = () => {
let params = useParams()
return (
// PARSEINT IS A JS FUNCTION WHICH WILL CONVERT THE THE GIVEN STRING OF NUMBERS
// ACCORDING TO THE BASE OR RADIX SPECIFIED
<Parent wise={params.wise} type={params.type} />
)
}
const ContestPage1 = () => {
let location = useLocation()
return (
//location.search is the part of url after ? symbol
<Contests queryStr={location.search} ContestAPI={ContestAPI} />
)
}
const ProblemsPage1 = () => {
let location = useLocation()
// console.log(location.search);
const info = queryString.parse(location.search)
// console.log(JSON.stringify(match.params));
return <Problems filters={info} />
}
const [creds, setCreds] = useState({})
return (
<>
<CredentialsContext.Provider value={{ creds, setCreds }}>
<Layout>
{/* <Header>
<div className="logo" />
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['2']}>
{new Array(7).fill(null).map((_, index) => {
const key = index + 1
return <Menu.Item key={key}>{`nav ${key}`}</Menu.Item>
})}
</Menu>
</Header> */}
<Navbar />
<Content>
<Router>
<Routes>
<Route path="/list/:id" element={<PlaylistsMatch />} />
{/* All Playlists - id is username */}
<Route path="/list/:id/:slug" element={<PlaylistList1 />} />
{/* Questions in a Particular playlist - slug is of that problem-list */}
<Route path="/login" element={<Login />} />
<Route path="/register" element={<Register />} />
{/* Login/Registration */}
<Route
path="/upsolve/codeforces"
element={mainUpsolve('virtualData', codeforces, 'codeforces')}
/>
{/* Codeforces upsolve */}
<Route
path="/upsolve/atcoder"
element={mainUpsolve('PracticeData', atcoder, 'atcoder')}
/>
{/* Atcoder Upsolve */}
<Route
path="/upsolve/codechef"
element={mainUpsolve('simpleData', codechef, 'codechef')}
/>
{/* Codechef upsolve */}
<Route path="/" element={<Homepage />} /> {/* Homepage */}
<Route path="/profile" element={<Profile />} />
{/* Profile, id - username */}
<Route path="/:wise/:type" element={<LaddersLevel1 />} />
{/* wise - topic,level | type - ladder,practice */}
<Route
path="/:wise/:type/:slug"
element={<LaddersQuestionPage1 />}
/>
{/* wise - topic,level | type - ladder,practice | slug is selected series */}
<Route path="/problems" element={<ProblemsPage1 />} />
{/* Problems page */}
<Route path="/contests" element={<ContestPage1 />} />
{/* Contest page */}
<Route
path="/change_password_request"
element={<ChangePassword />}
/>
{/* request to change [passowrd] */}
<Route path="/email-verified" element={<EmailVerfiedMsg />} />
<Route path="/home" element={<Homepage />} /> {/* Homepage */}
<Route path="/createProfile" element={<FillInfo />} />
{/* Creating profile for first time login */}
<Route path="/forgotPass" element={<ForgotPass />} />
{/* Forgot password - email form */}
<Route path="/aboutus" element={<AboutUs />} />
<Route path="/setNewPass" element={<NewPassword />} />
{/* Form to set new password */}
<Route path="/error" element={<Error404 />} />
<Route path="/updateProfile" element={<UpdateProfile />} />
{/* Form to update prpfile */}
<Route path="/privacy" element={<PrivacyPolicy />} />
<Route path="/terms" element={<TermsAndConditions />} />
<Route path="/" element={<Homepage />} /> {/* Homepage */}
<Route path="*" element={<Error404 />} />
</Routes>
{/* <Route element={ErrorPage}/> */}
</Router>
</Content>
<Footer style={{ textAlign: 'center' }}>Codedigger ©2021 </Footer>
</Layout>
</CredentialsContext.Provider>
</>
)
}
export default App