Skip to content
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*
34 changes: 34 additions & 0 deletions debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[0819/011705.953:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0819/011705.953:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0819/014919.856:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0819/014919.857:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0819/015422.700:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0819/015422.700:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0819/020520.946:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0819/020520.947:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0819/161054.095:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0819/161054.096:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0819/181123.169:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0819/181123.170:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/172228.119:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/172228.144:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/182730.538:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/182730.538:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/205148.243:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/205148.243:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/211759.665:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/211759.666:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/213059.913:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/213059.914:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/213858.172:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0820/213858.172:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0822/011913.774:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0822/011913.781:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0822/140143.839:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0822/140143.839:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0822/142240.391:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0822/142240.392:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0822/151112.241:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0822/151112.242:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0823/142957.234:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0823/142957.247:ERROR:crash_report_database_win.cc(469)] failed to stat report
15,150 changes: 15,150 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "logintest",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/user-event": "^7.2.1",
"node-fetch": "^2.6.0",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3"
},
"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"
]
},
"devDependencies": {
"@testing-library/react": "^9.5.0",
"jest": "^24.9.0"
}
}
Binary file added public/favicon.ico
Binary file not shown.
47 changes: 47 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!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
href="https://fonts.googleapis.com/css2?family=Roboto+Condensed&display=swap"
rel="stylesheet"
/>
<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`.
-->
<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`.
-->
</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:
44 changes: 44 additions & 0 deletions src/Components/HomePage/_test_/home.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { increase } from "../increment";
import { decrease } from "../decrement";

const getData = jest.fn(async () => {
return Promise.resolve({
json: () =>
Promise.resolve([
{
id: 1,
name: "cerulean",
year: 2000,
color: "#98B2D1",
pantone_value: "15-4020",
},
{
id: 2,
name: "fuchsia rose",
year: 2001,
color: "#C74375",
pantone_value: "17-2031",
},
]),
});
});

test("api calls", async () => {
let response = await getData("https://reqres.in/api/unknown");
let data = await response.json();

expect(data[0].id).toBe(1);
expect(data[0].name).toBe("cerulean");
expect(data[1].id).toBe(2);
expect(data[1].name).toBe("fuchsia rose");
});

test("next button increments index", () => {
expect(increase(1, 6)).toBe(2);
expect(increase(5, 6)).toBe(0);
});

test("back button decrements index", () => {
expect(decrease(1, 6)).toBe(0);
expect(decrease(0, 6)).toBe(5);
});
10 changes: 10 additions & 0 deletions src/Components/HomePage/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import fetch from "node-fetch";

const getData = async (link) => {
const json = await fetch(link);
const data = await json.json();

return data.data;
};

export { getData };
5 changes: 5 additions & 0 deletions src/Components/HomePage/decrement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const decrease = (num, length) => {
return num - 1 < 0 ? (num = length - 1) : num - 1;
};

export { decrease };
73 changes: 73 additions & 0 deletions src/Components/HomePage/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { useEffect, useState } from "react";

import { NavLink } from "react-router-dom";
import Butt from "../button/Button";

import { getData } from "./data";
import { increase } from "./increment";
import { decrease } from "./decrement";

import "./home.scss";

export default function Home(props) {
const setAppState = props.setAppState;
const [num, setNum] = useState(0);

const [data, setData] = useState({
color: "",
id: 0,
name: "",
pantoneValue: 0,
year: 0,
total: 0,
});
const url = "https://reqres.in/api/unknown";

const increment = () => {
let newNum = increase(num, data.total);
setNum(newNum);
};

const decrement = () => {
let newNum = decrease(num, data.total);
setNum(newNum);
};

useEffect(() => {
getData(url).then((response) => {
setData({
color: response[num].color,
id: response[num].id,
name: response[num].name,
pantoneValue: response[num].pantoneValue,
year: response[num].year,
total: response.length,
});
});
}, [num]);

return (
<div className="container">
<div className="Data" data-testid="data">
<div>Name : {data.name}</div>
<div data-testid="id">Id : {data.id}</div>
<div>Pantone Value : {data.pantoneValue}</div>
<div>Color : {data.color}</div>
<div>Year : {data.year}</div>

<div className="buttgroup">
<Butt text="Back" function={decrement} />
<Butt text="Next" function={increment} />
</div>
<NavLink className="link" exact to={process.env.PUBLIC_URL + "/login"}>
<Butt
text="Log Out"
function={() => {
setAppState({ loading: false, logged: false, msg: "" });
}}
/>
</NavLink>
</div>
</div>
);
}
24 changes: 24 additions & 0 deletions src/Components/HomePage/home.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.container {
height: 100%;
width: 100%;

.Data {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;

div {
margin: 15px;
}

.buttgroup {
margin: 30px 0 5px 0;

Button {
margin: 5px;
}
}
}
}
5 changes: 5 additions & 0 deletions src/Components/HomePage/increment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const increase = (num, length) => {
return (num + 1) % length;
};

export { increase };
15 changes: 15 additions & 0 deletions src/Components/LandingPage/LandingPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import { NavLink } from "react-router-dom";
import Butt from "../button/Button";

import "./Landingpage.scss";

export default function Landing() {
return (
<div className="lp">
<NavLink className="link" exact to={process.env.PUBLIC_URL + "/login"}>
<Butt text="Get Started" />
</NavLink>
</div>
);
}
10 changes: 10 additions & 0 deletions src/Components/LandingPage/Landingpage.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.lp {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

.link {
text-decoration: none;
}
}
17 changes: 17 additions & 0 deletions src/Components/LandingPage/_test_/LandingPage.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";
import ReactDOm from "react";
import { BrowserRouter } from "react-router-dom";

import LandingPage from "../LandingPage";

import { render, fireEvent } from "@testing-library/react";

test("render the correct contemt", () => {
const { getByText } = render(
<BrowserRouter>
<LandingPage />
</BrowserRouter>
);

getByText("Get Started");
});
Loading