Skip to content

Commit

Permalink
Merge pull request #141 from siesgstarena/dev
Browse files Browse the repository at this point in the history
Restructured the codebase
  • Loading branch information
ac030540 authored Jan 15, 2023
2 parents 84c1ba7 + 47c0a63 commit 6876134
Show file tree
Hide file tree
Showing 39 changed files with 365 additions and 333 deletions.
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

531 changes: 290 additions & 241 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
import Switch from '@material/react-switch';
import '../../user/settings/settings.scss';
import { RESET_SUBMISSION, CHANGE_PLAGIARISM_STATUS } from '../../../graphql/mutations';
import { getSubmissionColor } from '../../../commonFunctions';
import { getSubmissionColor } from '../../../utils/commonFunctions';
import useSessionExpired from '../../../customHooks/useSessionExpired';
import useSentry from '../../../customHooks/useSentry';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import React, { useContext } from 'react';
import { Redirect, Route, useLocation } from 'react-router-dom';
import PropTypes from 'prop-types';
import AuthContext from './Contexts/AuthContext';
import AuthContext from '../../Contexts/AuthContext';

const PrivateRoute = ({ component: Component, data, ...rest }) => {
const { authState } = useContext(AuthContext);
Expand Down
29 changes: 29 additions & 0 deletions src/Components/common/ScrollToTop.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import PropTypes from 'prop-types';
import { useEffect, useRef } from 'react';
import { useLocation } from 'react-router-dom';

const usePrevLocation = () => {
const location = useLocation();
const prevLocRef = useRef(location);

useEffect(() => {
prevLocRef.current = location;
}, [location]);

return prevLocRef.current;
};

const ScrollToTop = ({ children }) => {
const { pathname: prevPath, search: prevSearch } = usePrevLocation();
const { pathname: currentPath, search: currentSearch } = useLocation();
if (currentPath !== prevPath || currentSearch !== prevSearch) {
window.scrollTo(0, 0);
}
return children;
};

ScrollToTop.propTypes = {
children: PropTypes.any.isRequired,
};

export default ScrollToTop;
4 changes: 2 additions & 2 deletions src/Components/drawer/blogs/BlogCard/BlogCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { DELETE_BLOG, CHANGE_BLOG_PIN_STATUS } from '../../../../graphql/mutatio
// import { GET_ALL_BLOGS } from '../../../../graphql/queries';
import AlertBox from '../../../common/AlertBox/index';
import Pill from '../../../common/Pill/index';
import { userColor } from '../../../../commonFunctions';
import { userColor } from '../../../../utils/commonFunctions';
import AuthContext from '../../../../Contexts/AuthContext';
import './BlogCard.scss';
import useSessionExpired from '../../../../customHooks/useSessionExpired';
import useSentry from '../../../../customHooks/useSentry';
import { myBlogsLimit, allBlogsLimit } from '../../../../constants';
import { myBlogsLimit, allBlogsLimit } from '../../../../utils/constants';
import { GET_BLOGS_BY_USER, GET_ALL_BLOGS } from '../../../../graphql/queries';

const BlogCard = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
// getYear,
// convertTime,
// adding330Minutes,
} from '../../../../../../commonFunctions';
} from '../../../../../../utils/commonFunctions';
import AuthContext from '../../../../../../Contexts/AuthContext';
import {
UPVOTE_COMMENT,
Expand Down
2 changes: 1 addition & 1 deletion src/Components/drawer/blogs/blogPage/BlogHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Link } from 'react-router-dom';
import { Headline4, Headline6 } from '@material/react-typography';
import PropTypes from 'prop-types';
import Pill from '../../../common/Pill/index';
import { userColor } from '../../../../commonFunctions';
import { userColor } from '../../../../utils/commonFunctions';

const tagsArray = (tags) =>
tags.map((tag) => (
Expand Down
2 changes: 1 addition & 1 deletion src/Components/drawer/blogs/blogsList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useSessionExpired from '../../../../customHooks/useSessionExpired';
import useActivePageState from '../../../../customHooks/useAcitvePageState';
import LoadingCardArray from '../../../common/LoadingCardArray';
import BlogsArray from '../../../user/myBlogs/BlogsArray';
import { allBlogsLimit } from '../../../../constants';
import { allBlogsLimit } from '../../../../utils/constants';

const AllBlogsPageContainer = ({ isSuperuserRoute = false }) => {
const { redirectOnSessionExpiredBeforeRender, isSessionExpired } = useSessionExpired();
Expand Down
2 changes: 1 addition & 1 deletion src/Components/drawer/blogs/create/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import MessageCard from '../../../common/MessageCard';
import BlogDetails from './BlogDetails';
import { CREATE_BLOG } from '../../../../graphql/mutations';
import { GET_ALL_BLOGS, GET_BLOGS_BY_USER } from '../../../../graphql/queries';
import { allBlogsLimit, profileMyPostsLimit, myBlogsLimit } from '../../../../constants';
import { allBlogsLimit, profileMyPostsLimit, myBlogsLimit } from '../../../../utils/constants';
import AuthContext from '../../../../Contexts/AuthContext';

const CreateBlog = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Components/drawer/contests/common/CountDownTimer.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-param-reassign */
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { countDownTimerValues } from '../../../../commonFunctions';
import { countDownTimerValues } from '../../../../utils/commonFunctions';

const CountDownTimer = ({ countDownTill }) => {
const [timer, setTimer] = useState('');
Expand Down
2 changes: 1 addition & 1 deletion src/Components/drawer/contests/dashboard/ProblemsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Link, useRouteMatch } from 'react-router-dom';
import Table from '../../../common/Table/index';
import { problemBackgroundColor } from '../../../../commonFunctions';
import { problemBackgroundColor } from '../../../../utils/commonFunctions';

const ProblemsTable = ({ problems }) => {
const tableHeadings = ['#', 'Points', 'Problem Name'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import Table from '../../../common/Table/index';
import { userColor } from '../../../../commonFunctions';
import { userColor } from '../../../../utils/commonFunctions';

const RatingChangesTable = ({ ratingChanges }) => {
const tableHeadings = ['#', 'Who', 'Δ', 'Rating'];
Expand Down
2 changes: 1 addition & 1 deletion src/Components/drawer/contests/schedule/ContestsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import { format, formatDistanceStrict, formatDistanceToNowStrict, isPast } from 'date-fns/esm';
import { userColor } from '../../../../commonFunctions';
import { userColor } from '../../../../utils/commonFunctions';

const ContestsTable = ({ contests }) => {
// hidden variable is used to hide the licontestAdmin when the width
Expand Down
2 changes: 1 addition & 1 deletion src/Components/drawer/contests/scoreboard/DataTable.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import { userColor } from '../../../../commonFunctions';
import { userColor } from '../../../../utils/commonFunctions';
import Table from '../../../common/Table/index';

const DataTable = ({ problems, scoreboardDetails }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { format } from 'date-fns';
import Table from '../../../common/Table/index';
import { getSubmissionColor, userColor } from '../../../../commonFunctions';
import { getSubmissionColor, userColor } from '../../../../utils/commonFunctions';
import AuthContext from '../../../../Contexts/AuthContext';

const ProblemsubmissionTable = ({
Expand Down
2 changes: 1 addition & 1 deletion src/Components/drawer/contests/submissionPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { GET_SUBMISSION_PAGE_DETAILS } from '../../../../graphql/queries';
import SomethingWentWrong from '../../../common/SomethingWentWrong/index';
import useSessionExpired from '../../../../customHooks/useSessionExpired';
import Spinner from '../../../common/Spinner/index';
import { languageCodeAppender } from '../../../../commonFunctions';
import { languageCodeAppender } from '../../../../utils/commonFunctions';
import WrongAnswerContent from './WrongAnwerContent';

const SubmitContainer = () => {
Expand Down
14 changes: 7 additions & 7 deletions src/Components/drawer/lab/Style.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.datasets-container{
padding: 0.2rem 1rem;
.datasets-container {
padding: 0.2rem 1rem;
}
.datasets-discription{
margin-bottom: 2rem;
.datasets-discription {
margin-bottom: 2rem;
}

.und-clr{
text-decoration-color: gray !important;
}
.und-clr {
text-decoration-color: gray !important;
}
2 changes: 1 addition & 1 deletion src/Components/drawer/problemSet/ProblemSetTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import Button from '@material/react-button';
import Table from '../../common/Table/index';
import { problemBackgroundColor } from '../../../commonFunctions';
import { problemBackgroundColor } from '../../../utils/commonFunctions';

const ProblemsSetTable = ({ problemsList }) => {
// Trimming tags because of database inconsistency
Expand Down
2 changes: 1 addition & 1 deletion src/Components/drawer/ratings/RatingsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import Table from '../../common/Table/index';
import { userColor } from '../../../commonFunctions';
import { userColor } from '../../../utils/commonFunctions';

const RatingsTable = ({ users, activePageNumber, limit }) => {
const tableHeadings = ['#', 'Name', 'Ratings'];
Expand Down
4 changes: 2 additions & 2 deletions src/Components/editor/Style.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
.global-border {
border-right: none;
}
.run-btn{
.run-btn {
margin-top: 0.4rem !important;
}
}
}
2 changes: 1 addition & 1 deletion src/Components/search/resultFiles/PostResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Headline6 } from '@material/react-typography';
import PropTypes from 'prop-types';
import { format } from 'date-fns';
import Pill from '../../common/Pill';
import { userColor } from '../../../commonFunctions';
import { userColor } from '../../../utils/commonFunctions';

const tagsArray = (tags) =>
tags.map((tag) => (
Expand Down
2 changes: 1 addition & 1 deletion src/Components/search/resultFiles/UserResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { format } from 'date-fns';
import { Headline6 } from '@material/react-typography';
import { userColor } from '../../../commonFunctions';
import { userColor } from '../../../utils/commonFunctions';

const UserResults = ({ userArray }) => (
<div className="">
Expand Down
5 changes: 2 additions & 3 deletions src/Components/superuser/announcements/Style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
border-radius: 10px;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.2);
}
.title{
.title {
font-size: 1.75rem;
}
.p0 {
Expand All @@ -25,13 +25,12 @@
width: 100%;
}


@media (max-width: 390px) {
.card-grid {
flex-direction: column;
align-items: flex-start;
}
.card-delete{
.card-delete {
margin-top: 1rem;
}
}
2 changes: 1 addition & 1 deletion src/Components/superuser/contests/AllContestsContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import AllContestPage from './AllContests';
import PageCountDisplayer from '../../common/PageCountDisplayer';
import useActivePageState from '../../../customHooks/useAcitvePageState';
import CustomSnackbar from '../../common/Snackbar/index';
import { superuserContestsLimit } from '../../../constants';
import { superuserContestsLimit } from '../../../utils/constants';

const AllContestsContainer = () => {
const limit = superuserContestsLimit;
Expand Down
2 changes: 1 addition & 1 deletion src/Components/superuser/contests/ContestCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import AlertBox from '../../common/AlertBox/index';
import '@material/react-dialog/dist/dialog.css';
import { DELETE_CONTEST } from '../../../graphql/mutations';
import { GET_ALL_CONTEST_DETAILS, GET_CONTEST_HOMEPAGE_DETAILS } from '../../../graphql/queries';
import { superuserContestsLimit } from '../../../constants';
import { superuserContestsLimit } from '../../../utils/constants';

const ContestCard = ({ name, startTime, duration, endTime, code, setSnackbarMessage }) => {
// isAlertOpen is the state, used to indicate whether the alertbox is open or not
Expand Down
2 changes: 1 addition & 1 deletion src/Components/superuser/createContest/CreateContest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ContestDetails from './ContestDetails';
import MessageCard from '../../common/MessageCard/index';
import { CREATE_CONTEST } from '../../../graphql/mutations';
import { GET_CONTEST_HOMEPAGE_DETAILS, GET_ALL_CONTEST_DETAILS } from '../../../graphql/queries';
import { superuserContestsLimit } from '../../../constants';
import { superuserContestsLimit } from '../../../utils/constants';

const CreateContest = () => {
const intialFormDetails = {
Expand Down
2 changes: 1 addition & 1 deletion src/Components/superuser/editContest/EditContest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useApolloClient } from '@apollo/client';
import { Headline4, Body2 } from '@material/react-typography';
import ContestDetails from '../createContest/ContestDetails';
import MessageCard from '../../common/MessageCard/index';
// import { subtracting330Minutes } from '../../../commonFunctions';
// import { subtracting330Minutes } from '../../../utils/commonFunctions';
import { EDIT_CONTEST } from '../../../graphql/mutations';

const EditContest = ({ contestData }) => {
Expand Down
10 changes: 5 additions & 5 deletions src/Components/superuser/manageSuperusers/Style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
margin: 1.5rem 0;
}

.mr-2{
margin-right: 0.5rem !important;
.mr-2 {
margin-right: 0.5rem !important;
}

.mb-2{
margin-bottom: 0.5rem !important;
}
.mb-2 {
margin-bottom: 0.5rem !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import TextField, { Input } from '@material/react-text-field';
import { userColor } from '../../../commonFunctions';
import { userColor } from '../../../utils/commonFunctions';

const UpdateRatingsTableData = ({ ratingData, setUpdatedRatings }) => {
const [rating, setRating] = useState(ratingData.newRating);
Expand Down
2 changes: 1 addition & 1 deletion src/Components/user/myBlogs/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useActivePageState from '../../../customHooks/useAcitvePageState';
import AuthContext from '../../../Contexts/AuthContext';
import BlogsArray from './BlogsArray';
import LoadingCardArray from '../../common/LoadingCardArray';
import { myBlogsLimit } from '../../../constants';
import { myBlogsLimit } from '../../../utils/constants';

const MyBlogsContainer = () => {
const limit = myBlogsLimit;
Expand Down
2 changes: 1 addition & 1 deletion src/Components/user/profile/Info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Cell, Grid, Row } from '@material/react-layout-grid';
import { Button } from '@material/react-button';
import { Headline4, Body1, Headline6 } from '@material/react-typography';
import { format } from 'date-fns';
import { userColor, userStatus } from '../../../commonFunctions';
import { userColor, userStatus } from '../../../utils/commonFunctions';
import AuthContext from '../../../Contexts/AuthContext';
import EditAbout from './EditAbout';
import MessageCard from '../../common/MessageCard/index';
Expand Down
2 changes: 1 addition & 1 deletion src/Components/user/profile/Posts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AuthContext from '../../../Contexts/AuthContext';
import useSentry from '../../../customHooks/useSentry';
import BlogsArray from '../myBlogs/BlogsArray';
import LoadingCardArray from '../../common/LoadingCardArray';
import { profileMyPostsLimit } from '../../../constants';
import { profileMyPostsLimit } from '../../../utils/constants';

const PostsContainer = ({ user }) => {
const limit = profileMyPostsLimit;
Expand Down
2 changes: 1 addition & 1 deletion src/Components/user/profile/Submissions.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { getSubmissionColor } from '../../../commonFunctions';
import { getSubmissionColor } from '../../../utils/commonFunctions';
import Table from '../../common/Table';

// SubmissionTab Content
Expand Down
4 changes: 2 additions & 2 deletions src/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { lazy, Suspense } from 'react';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import { useQuery } from '@apollo/client';
import AppBar from './Components/common/AppBar/index';
import ScrollToTop from './ScrollToTop';
import ScrollToTop from './Components/common/ScrollToTop';
import Footer from './Components/common/Footer/index';
import Spinner from './Components/common/Spinner/index';
import AuthContext from './Contexts/AuthContext';
Expand All @@ -11,7 +11,7 @@ import ErrorBoundary from './Components/common/ErrorBoundary/index';
import SomethingWentWrong from './Components/common/SomethingWentWrong/index';
import './App.scss';

const PrivateRoute = lazy(() => import('./PrivateRoute'));
const PrivateRoute = lazy(() => import('./Components/common/PrivateRoute'));
const SignIn = lazy(() => import('./Components/auth/signin/index'));
const SignUp = lazy(() => import('./Components/auth/signup/index'));
const Forgot = lazy(() => import('./Components/auth/forgot/index'));
Expand Down
Loading

0 comments on commit 6876134

Please sign in to comment.