Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codebadge frontend #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
674 changes: 0 additions & 674 deletions LICENSE

This file was deleted.

25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# codebadge-frontend
# Codebadge Frontend
This is the frontend repository of codebadge project. For backend section please install backend repository for the proper working of this project.
## Setup
1. Install modules
```npm i```

2. setup locally
Create a **.env.local** file in root dicrectory.
```
clientID_Production = <Id for production mode to be set>
clientID_Development = <Client id from github oauth app>
```

3. Create a oauth app

Application Name=> Codebadge-local-login

Homepage URL=> http://localhost:3000/

Authorization callbackURL=> http://localhost:3001/github/auth

4. Run app

```npm start```
14,293 changes: 14,293 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "test",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"bootstrap": "^4.5.0",
"dotenv": "^8.2.0",
"js-cookie": "^2.2.1",
"query-string": "^6.12.1",
"react": "^16.13.1",
"react-bootstrap": "^1.0.1",
"react-dom": "^16.13.1",
"react-fontawesome": "^1.7.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"stringquery": "^1.0.8"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added public/favicon.ico
Binary file not shown.
50 changes: 50 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
Binary file added public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
33 changes: 33 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.parent{
display: flex;
flex-direction: column;
}
.child1{
background-color: white;
width:100%;
height:8vh;
display: flex;
justify-content:space-around;
align-items: center;
border: 1px solid #E8E9EB;
box-shadow: 0px 1px 4px rgba(26, 27, 31, 0.12);
}

.image{
width:130%;
}
.tabs{
display: flex;
}

.font-white{
color:white !important;
}

.child2{
display:flex;
min-height:92vh !important;
width:100%;
/* margin-bottom:15vh */
/* margin-top:8vh */
}
139 changes: 139 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import React from 'react';
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";
import About from './Component/About'
import Home from './Component/Home'
import Register from './Component/Register'
import Dashboard from './Component/Dashboard'
import OrgDashboard from './Component/OrgDashboard'
import Login from './Component/Login'
import Footer from './Component/Footer'
import './App.css';
import Cookies from 'js-cookie';

import logoNameImg from './images/logo_name.svg'

var frontend = window.location.origin;
console.log(frontend);

function logout(){
Cookies.remove('token');
window.location.href=frontend;
}

function App() {
if(!Cookies.get('token')){
return (
<div class="parent">
<Router>
<div class="child1">

<div class="logo"><Link to="/"><img src={logoNameImg} alt="logo"/></Link></div>
<div></div>
<div></div>
<div class="tabs">
<nav class="navbar navbar-light navbar-expand-md bg-white">

<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"bg="white"></span>
</button>

<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<Link class="nav-link btn" to="/about">About</Link>
</li>
<li class="nav-item">
<Link class="nav-link btn" to="/">Join Us</Link>
</li>
<li class="nav-item">
<Link class="nav-link btn" to="/login">Login</Link>
</li>
</ul>
</div>
</nav>
</div>
</div>
{/* <div class="child2"> */}
<Switch>
<Route path="/register">
<Register/>
</Route>
<Route path="/about">
<About/>
</Route>
<Route path="/login">
<Login/>
</Route>
<Route path="/">
<Home/>
</Route>
</Switch>
{/* </div> */}
</Router>
</div>
);
}
else{
return (
<div class="parent">
<Router>
<div class="child1">

<div class="logo"><Link to="/"><img src={logoNameImg} alt="logo"/></Link></div>
<div></div>
<div></div>
<div class="tabs">
<nav class="navbar navbar-light navbar-expand-md bg-white">

<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"bg="white"></span>
</button>

<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<Link class="nav-link btn" to="/user">About</Link>
</li>
<li class="nav-item">
<Link class="nav-link btn" to="/user">Join Us</Link>
</li>
<li class="nav-item">
<Link class="nav-link btn btn-primary font-white" to="/login" onClick={logout}>Logout</Link>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="child2">
<Switch>
<Route path="/user">
<Dashboard/>
</Route>
<Route path="/org">
<OrgDashboard/>
</Route>
<Route path="/organization">
<Register/>
</Route>
<Route path="/contest">
<Register/>
</Route>
<Route path="/">
<Home/>
</Route>
</Switch>
</div>
</Router>
<Footer/>
</div>
)
}
}

export default App;
9 changes: 9 additions & 0 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import { render } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
11 changes: 11 additions & 0 deletions src/Component/About.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

const About = () => {
return (
<div>
About
</div>
);
}

export default About;
Loading