Skip to content

Commit

Permalink
Prettified Code!
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKevinOConnell authored and actions-user committed Nov 5, 2021
1 parent 90bb6e0 commit 4a55ebd
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
4 changes: 2 additions & 2 deletions backend/src/api/clarifications/getClarifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ const hasAccessTo = ({ type, division, uid }: any, user?: User) => {
}

export const getClarifications = async (req: Request, res: Response) => {
const { page } = JSON.parse(req.body);
const { page } = JSON.parse(req.body)
const errors = validationResult(req).array()
if (errors.length > 0) {
res.status(400).json({ message: errors[0].msg })
return
}
const newPage = page ? page : null;
const newPage = page ? page : null
const query = matchedData(req)
const users = transpose(await contest.get_users(), 'uid') as Record<string, User>

Expand Down
14 changes: 11 additions & 3 deletions backend/src/api/submissions/getSubmissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,24 @@ const showToUser = (user: User | undefined, problem: Problem, settings: Settings
}

export const getSubmissions = async (req: Request, res: Response) => {
const { page } = JSON.parse(req.body)
const { page } = JSON.parse(req.body)
const errors = validationResult(req).array()
if (errors.length > 0) {
res.status(400).json({ message: errors[0].msg })
return
}
//if the page number isn't included in the request, make it null
const newPage = page ? page : null;
const newPage = page ? page : null
const problems = transpose(
await contest.get_problems({}, undefined, ['pid', 'division', 'id', 'name', 'max_points', 'capped_points', 'practice']),
await contest.get_problems({}, undefined, [
'pid',
'division',
'id',
'name',
'max_points',
'capped_points',
'practice'
]),
'pid'
)
const users = transpose(await contest.get_users(), 'uid') as unknown as User[]
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/users/getUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const getUsers = async (req: Request, res: Response) => {
}
const params = matchedData(req)

const newPage = page ? page : null;
const newPage = page ? page : null
if (req.user?.role == 'team') params.uid = req.user?.uid
if (req.user?.role == 'judge') {
params.role = 'team'
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/pages/admin/Clarifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Clarifications = (): JSX.Element => {
const loadClarifications = async () => {
const response = await fetch(`${config.API_URL}/clarifications`, {
headers: { Authorization: `Bearer ${localStorage.accessToken}` },
body: JSON.stringify(page),
body: JSON.stringify(page)
})
if (response.ok) {
const clarifications = Object.values(await response.json()) as ClarificationItem[]
Expand Down Expand Up @@ -201,7 +201,11 @@ const Clarifications = (): JSX.Element => {
)}
</Table.Body>
</Table>
<Pagination defaultActivePage={page} totalPages={numberOfPages} onPageChange={((_event, data) => handlePageChange(data.activePage as number))} />
<Pagination
defaultActivePage={page}
totalPages={numberOfPages}
onPageChange={(_event, data) => handlePageChange(data.activePage as number)}
/>
</Block>
</>
)
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/pages/admin/submissions/Submissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Submissions = (): JSX.Element => {
headers: {
Authorization: `Bearer ${localStorage.accessToken}`
},
body: JSON.stringify(page),
body: JSON.stringify(page)
})
const submissions = Object.values(await response.json()) as SubmissionItem[]

Expand Down Expand Up @@ -218,7 +218,11 @@ const Submissions = (): JSX.Element => {
)}
</Table.Body>
</Table>
<Pagination defaultActivePage={page} totalPages={numberOfPages} onPageChange={((_event, data) => handlePageChange(data.activePage as number))} />
<Pagination
defaultActivePage={page}
totalPages={numberOfPages}
onPageChange={(_event, data) => handlePageChange(data.activePage as number)}
/>
</Block>
</>
)
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/pages/admin/users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,12 @@ const Users = (): JSX.Element => {
}
*/
const loadUsers = async (page: number) => {

try {
const response = await fetch(`${config.API_URL}/users`, {
headers: {
Authorization: `Bearer ${localStorage.accessToken}`
},
body: JSON.stringify(page),
body: JSON.stringify(page)
})
if (isMounted) {
const data = Object.values(await response.json()) as UserItem[]
Expand Down Expand Up @@ -271,7 +270,11 @@ const Users = (): JSX.Element => {
))}
</Table.Body>
</Table>
<Pagination defaultActivePage={page} totalPages={numberOfPages} onPageChange={((_event, data) => handlePageChange(data.activePage as number))} />
<Pagination
defaultActivePage={page}
totalPages={numberOfPages}
onPageChange={(_event, data) => handlePageChange(data.activePage as number)}
/>
</>
)
}
Expand Down

0 comments on commit 4a55ebd

Please sign in to comment.