├── .gitignore
├── README.md
├── db.json
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
└── src
├── App.css
├── App.js
├── App.test.js
├── Appheader.js
├── Customer.js
├── Home.js
├── Login.js
├── Register.js
├── index.css
├── index.js
├── logo.svg
├── reportWebVitals.js
└── setupTests.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35 |
36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39 |
40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/db.json:
--------------------------------------------------------------------------------
1 | {
2 | "user": [
3 | {
4 | "id": "adminuser",
5 | "name": "Nihira",
6 | "password": "admin",
7 | "email": "nihiratechiees@gmail.com",
8 | "phone": "8989898989",
9 | "country": "usa",
10 | "address": "",
11 | "role":"admin",
12 | "gender": "female"
13 | },
14 | {
15 | "id": "ntuser",
16 | "name": "Fullname",
17 | "password": "ntuser",
18 | "email": "email@email.com",
19 | "phone": "56778889989",
20 | "country": "singapore",
21 | "address": "address1\naddrees2",
22 | "role":"user",
23 | "gender": "male"
24 | }
25 | ],
26 | "roleaccess":[
27 | {
28 | "role": "admin",
29 | "menu": "customer",
30 | "haveadd": true,
31 | "haveedit": true,
32 | "havedelete": true
33 | },
34 | {
35 | "role": "admin",
36 | "menu": "supplier",
37 | "haveadd": true,
38 | "haveedit": true,
39 | "havedelete": true
40 | },
41 | {
42 | "role": "user",
43 | "menu": "customer",
44 | "haveadd": false,
45 | "haveedit": false,
46 | "havedelete": false
47 | },
48 | {
49 | "role": "user1",
50 | "menu": "customer",
51 | "haveadd": false,
52 | "haveedit": false,
53 | "havedelete": false
54 | }
55 | ],
56 | "customer":[
57 | {
58 | "code":1,
59 | "name":"Chris",
60 | "email":"chris@in.com"
61 | },
62 | {
63 | "code":2,
64 | "name":"Lynn",
65 | "email":"lynn@in.com"
66 | },
67 | {
68 | "code":3,
69 | "name":"Tim",
70 | "email":"tim@in.com"
71 | },
72 | {
73 | "code":4,
74 | "name":"Southee",
75 | "email":"southee@in.com"
76 | },{
77 | "code":5,
78 | "name":"boult",
79 | "email":"bould@in.com"
80 | }
81 | ]
82 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "reactauthentication",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.16.5",
7 | "@testing-library/react": "^13.4.0",
8 | "@testing-library/user-event": "^13.5.0",
9 | "bootstrap": "^5.2.3",
10 | "react": "^18.2.0",
11 | "react-dom": "^18.2.0",
12 | "react-router-dom": "^6.4.5",
13 | "react-scripts": "5.0.1",
14 | "react-toastify": "^9.1.1",
15 | "web-vitals": "^2.1.4"
16 | },
17 | "scripts": {
18 | "start": "react-scripts start",
19 | "build": "react-scripts build",
20 | "test": "react-scripts test",
21 | "eject": "react-scripts eject"
22 | },
23 | "eslintConfig": {
24 | "extends": [
25 | "react-app",
26 | "react-app/jest"
27 | ]
28 | },
29 | "browserslist": {
30 | "production": [
31 | ">0.2%",
32 | "not dead",
33 | "not op_mini all"
34 | ],
35 | "development": [
36 | "last 1 chrome version",
37 | "last 1 firefox version",
38 | "last 1 safari version"
39 | ]
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nihira2020/reactauthentication/ae00208ec85cf5dc77f9724691dadd45038750b7/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nihira2020/reactauthentication/ae00208ec85cf5dc77f9724691dadd45038750b7/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nihira2020/reactauthentication/ae00208ec85cf5dc77f9724691dadd45038750b7/public/logo512.png
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: left;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 | .errmsg{
31 | color: red;
32 | }
33 | .header{
34 | width: 100%;
35 | background-color: blue;
36 | color: #fff;
37 | padding: 1%;
38 | }
39 | a{
40 | text-decoration: none !important;
41 | color: white !important;
42 | padding: 2px;
43 | }
44 | app-check{
45 | height: 20px;
46 | width: 20px;
47 | margin: 1%;
48 | }
49 | .header{
50 | width: 100%;
51 | background-color: blue;
52 | color: #fff;
53 | padding: 1%;
54 | }
55 | a{
56 | text-decoration: none !important;
57 | color: white !important;
58 | padding: 2px;
59 | }
60 |
61 | @keyframes App-logo-spin {
62 | from {
63 | transform: rotate(0deg);
64 | }
65 | to {
66 | transform: rotate(360deg);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import logo from './logo.svg';
2 | import './App.css';
3 | import { BrowserRouter, Route, Routes } from 'react-router-dom';
4 | import Home from './Home';
5 | import Login from './Login';
6 | import Register from './Register';
7 | import { ToastContainer } from 'react-toastify';
8 | import Appheader from './Appheader';
9 | import Customer from './Customer';
10 |
11 | function App() {
12 | return (
13 |
14 |
15 |
16 |
17 |
18 | }>
19 | }>
20 | }>
21 | }>
22 |
23 |
24 |
25 |
26 |
27 | );
28 | }
29 |
30 | export default App;
31 |
--------------------------------------------------------------------------------
/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/src/Appheader.js:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from "react";
2 | import { Link, useLocation, useNavigate } from "react-router-dom";
3 |
4 | const Appheader = () => {
5 | const [displayusername, displayusernameupdate] = useState('');
6 | const [showmenu, showmenuupdateupdate] = useState(false);
7 | const usenavigate = useNavigate();
8 | const location = useLocation();
9 | useEffect(() => {
10 | if (location.pathname === '/login' || location.pathname === '/register') {
11 | showmenuupdateupdate(false);
12 | } else {
13 | showmenuupdateupdate(true);
14 | let username = sessionStorage.getItem('username');
15 | if (username === '' || username === null) {
16 | usenavigate('/login');
17 | } else {
18 | displayusernameupdate(username);
19 | }
20 | }
21 |
22 | }, [location])
23 | return (
24 |
25 | {showmenu &&
26 |
27 |
28 | Home
29 | Customer
30 | Welcome {displayusername}
31 | Logout
32 |
33 | }
34 |
35 | );
36 | }
37 |
38 | export default Appheader;
--------------------------------------------------------------------------------
/src/Customer.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import { useNavigate } from "react-router-dom";
3 | import { toast } from "react-toastify";
4 |
5 | const Customer = () => {
6 | const [custlist, custupdate] = useState([]);
7 | const [haveedit, editchange] = useState(false);
8 | const [haveview, viewchange] = useState(false);
9 | const [haveadd, addchange] = useState(false);
10 | const [haveremove, removechange] = useState(false);
11 |
12 | const navigate=useNavigate();
13 |
14 |
15 | useEffect(() => {
16 | GetUserAccess();
17 | loadcustomer();
18 |
19 | }, []);
20 |
21 | const loadcustomer = () => {
22 | fetch("http://localhost:8000/customer").then(res => {
23 | if (!res.ok) {
24 | return false
25 | }
26 | return res.json();
27 | }).then(res => {
28 | custupdate(res)
29 | });
30 | }
31 |
32 | const GetUserAccess = () => {
33 | const userrole = sessionStorage.getItem('userrole') != null ? sessionStorage.getItem('userrole').toString() : '';
34 | fetch("http://localhost:8000/roleaccess?role=" + userrole + "&menu=customer").then(res => {
35 | if (!res.ok) {
36 | navigate('/');
37 | toast.warning('You are not authorized to access');
38 | return false;
39 | }
40 | return res.json();
41 | }).then(res => {
42 | console.log(res);
43 | if (res.length > 0) {
44 | viewchange(true);
45 | let userobj = res[0];
46 | editchange(userobj.haveedit);
47 | addchange(userobj.haveadd);
48 | removechange(userobj.havedelete);
49 | }else{
50 | navigate('/');
51 | toast.warning('You are not authorized to access');
52 | }
53 | })
54 | }
55 |
56 | const handleadd = () => {
57 | if(haveadd){
58 | toast.success('added')
59 | }else{
60 | toast.warning('You are not having access for add');
61 | }
62 | }
63 | const handleedit = () => {
64 | if(haveedit){
65 | toast.success('edited')
66 | }
67 | else{
68 | toast.warning('You are not having access for Edit');
69 | }
70 | }
71 |
72 | const handleremove = () => {
73 | if(haveremove){
74 | toast.success('removed')
75 | }else{
76 | toast.warning('You are not having access for remove');
77 | }
78 | }
79 |
80 |
81 | return (
82 |
83 |
84 |
85 |
86 |
Customer Listing
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 | Code |
95 | Name |
96 | Email |
97 | Action |
98 |
99 |
100 |
101 | {custlist &&
102 | custlist.map(item => (
103 |
104 | {item.code} |
105 | {item.name} |
106 | {item.email} |
107 |
108 | |
109 |
110 | |
111 |
112 |
113 | ))
114 | }
115 |
116 |
117 |
118 |
119 |
120 | );
121 | }
122 |
123 | export default Customer;
--------------------------------------------------------------------------------
/src/Home.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import { Link, useNavigate } from "react-router-dom";
3 |
4 | const Home = () => {
5 | const usenavigate = useNavigate();
6 | const [customerlist, listupdate] = useState(null);
7 |
8 | useEffect(() => {
9 |
10 |
11 | // let jwttoken = sessionStorage.getItem('jwttoken');
12 | // fetch("https://localhost:44308/Customer", {
13 | // headers: {
14 | // 'Authorization': 'bearer ' + jwttoken
15 | // }
16 | // }).then((res) => {
17 | // return res.json();
18 | // }).then((resp) => {
19 | // listupdate(resp);
20 | // }).catch((err) => {
21 | // console.log(err.messsage)
22 | // });
23 |
24 | }, []);
25 |
26 | return (
27 |
28 |
29 |
Welcome to Nihira Techiees
30 | {/*
31 |
32 |
33 | Code |
34 | Name |
35 | Email |
36 | Credit Limit |
37 |
38 |
39 |
40 | {customerlist &&
41 | customerlist.map(item => (
42 |
43 | {item.id} |
44 | {item.name} |
45 | {item.email} |
46 | {item.creditLimit} |
47 |
48 |
49 | ))
50 | }
51 |
52 |
53 |
*/}
54 |
55 | );
56 | }
57 |
58 | export default Home;
--------------------------------------------------------------------------------
/src/Login.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import { Link, useNavigate } from "react-router-dom";
3 | import { toast } from "react-toastify";
4 |
5 | const Login = () => {
6 | const [username, usernameupdate] = useState('');
7 | const [password, passwordupdate] = useState('');
8 |
9 | const usenavigate=useNavigate();
10 |
11 | useEffect(()=>{
12 | sessionStorage.clear();
13 | },[]);
14 |
15 | const ProceedLogin = (e) => {
16 | e.preventDefault();
17 | if (validate()) {
18 | ///implentation
19 | // console.log('proceed');
20 | fetch("http://localhost:8000/user/" + username).then((res) => {
21 | return res.json();
22 | }).then((resp) => {
23 | //console.log(resp)
24 | if (Object.keys(resp).length === 0) {
25 | toast.error('Please Enter valid username');
26 | } else {
27 | if (resp.password === password) {
28 | toast.success('Success');
29 | sessionStorage.setItem('username',username);
30 | sessionStorage.setItem('userrole',resp.role);
31 | usenavigate('/')
32 | }else{
33 | toast.error('Please Enter valid credentials');
34 | }
35 | }
36 | }).catch((err) => {
37 | toast.error('Login Failed due to :' + err.message);
38 | });
39 | }
40 | }
41 |
42 | const ProceedLoginusingAPI = (e) => {
43 | e.preventDefault();
44 | if (validate()) {
45 | ///implentation
46 | // console.log('proceed');
47 | let inputobj={"username": username,
48 | "password": password};
49 | fetch("https://localhost:44308/User/Authenticate",{
50 | method:'POST',
51 | headers:{'content-type':'application/json'},
52 | body:JSON.stringify(inputobj)
53 | }).then((res) => {
54 | return res.json();
55 | }).then((resp) => {
56 | console.log(resp)
57 | if (Object.keys(resp).length === 0) {
58 | toast.error('Login failed, invalid credentials');
59 | }else{
60 | toast.success('Success');
61 | sessionStorage.setItem('username',username);
62 | sessionStorage.setItem('jwttoken',resp.jwtToken);
63 | usenavigate('/')
64 | }
65 | // if (Object.keys(resp).length === 0) {
66 | // toast.error('Please Enter valid username');
67 | // } else {
68 | // if (resp.password === password) {
69 | // toast.success('Success');
70 | // sessionStorage.setItem('username',username);
71 | // usenavigate('/')
72 | // }else{
73 | // toast.error('Please Enter valid credentials');
74 | // }
75 | // }
76 | }).catch((err) => {
77 | toast.error('Login Failed due to :' + err.message);
78 | });
79 | }
80 | }
81 | const validate = () => {
82 | let result = true;
83 | if (username === '' || username === null) {
84 | result = false;
85 | toast.warning('Please Enter Username');
86 | }
87 | if (password === '' || password === null) {
88 | result = false;
89 | toast.warning('Please Enter Password');
90 | }
91 | return result;
92 | }
93 | return (
94 |
119 | );
120 | }
121 |
122 | export default Login;
--------------------------------------------------------------------------------
/src/Register.js:
--------------------------------------------------------------------------------
1 | import { useState } from "react";
2 | import { Link, useNavigate } from "react-router-dom";
3 | import { toast } from "react-toastify";
4 |
5 | const Register = () => {
6 |
7 | const [id, idchange] = useState("");
8 | const [name, namechange] = useState("");
9 | const [password, passwordchange] = useState("");
10 | const [email, emailchange] = useState("");
11 | const [phone, phonechange] = useState("");
12 | const [country, countrychange] = useState("india");
13 | const [address, addresschange] = useState("");
14 | const [gender, genderchange] = useState("female");
15 |
16 | const navigate = useNavigate();
17 |
18 | const IsValidate = () => {
19 | let isproceed = true;
20 | let errormessage = 'Please enter the value in ';
21 | if (id === null || id === '') {
22 | isproceed = false;
23 | errormessage += ' Username';
24 | }
25 | if (name === null || name === '') {
26 | isproceed = false;
27 | errormessage += ' Fullname';
28 | }
29 | if (password === null || password === '') {
30 | isproceed = false;
31 | errormessage += ' Password';
32 | }
33 | if (email === null || email === '') {
34 | isproceed = false;
35 | errormessage += ' Email';
36 | }
37 |
38 | if(!isproceed){
39 | toast.warning(errormessage)
40 | }else{
41 | if(/^[a-zA-Z0-9]+@[a-zA-Z0-9]+\.[A-Za-z]+$/.test(email)){
42 |
43 | }else{
44 | isproceed = false;
45 | toast.warning('Please enter the valid email')
46 | }
47 | }
48 | return isproceed;
49 | }
50 |
51 |
52 | const handlesubmit = (e) => {
53 | e.preventDefault();
54 | let regobj = { id, name, password, email, phone, country, address, gender };
55 | if (IsValidate()) {
56 | //console.log(regobj);
57 | fetch("http://localhost:8000/user", {
58 | method: "POST",
59 | headers: { 'content-type': 'application/json' },
60 | body: JSON.stringify(regobj)
61 | }).then((res) => {
62 | toast.success('Registered successfully.')
63 | navigate('/login');
64 | }).catch((err) => {
65 | toast.error('Failed :' + err.message);
66 | });
67 | }
68 | }
69 | return (
70 |
150 | );
151 | }
152 |
153 | export default Register;
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 | import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
7 | import 'react-toastify/dist/ReactToastify.css';
8 |
9 | const root = ReactDOM.createRoot(document.getElementById('root'));
10 | root.render(
11 |
12 |
13 |
14 | );
15 |
16 | // If you want to start measuring performance in your app, pass a function
17 | // to log results (for example: reportWebVitals(console.log))
18 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
19 | reportWebVitals();
20 |
--------------------------------------------------------------------------------
/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------