├── .eslintrc.json
├── .gitignore
├── .prettierrc.json
├── README.md
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
└── src
├── App.js
├── components
├── User.js
└── Users.js
├── index.css
└── index.js
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "es2021": true,
5 | "jest": true
6 | },
7 | "extends": [
8 | "eslint:recommended",
9 | "plugin:react/recommended",
10 | "plugin:prettier/recommended"
11 | ],
12 | "overrides": [],
13 | "parserOptions": {
14 | "ecmaVersion": "latest",
15 | "sourceType": "module"
16 | },
17 | "plugins": ["react"],
18 | "rules": { "react/react-in-jsx-scope": "off" }
19 | }
20 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "semi": true,
3 | "tabWidth": 2,
4 | "printWidth": 100,
5 | "singleQuote": true,
6 | "trailingComma": "none",
7 | "jsxBracketSameLine": true
8 | }
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React assigment - 4 : User Management App
2 |
3 | ## Total points = 5
4 |
5 | ### Purpose of this assignment : Testing students skills on
6 |
7 | - useEffect() hook
8 | - error handling when loading data
9 |
10 | ### [Click here to see the project demo](https://users-mgt-app.netlify.app/)
11 |
12 | ### Assignment steps:
13 |
14 | - all the instructtions are given in App component
15 | - only 3 tasks to do in App component
16 | - finally check the project demo and try to match your one as much as possible
17 |
18 | #### [Assignment was created with ♥ by [anisul islam](https://www.youtube.com/c/anisulislamrubel) ©Anisul Islam]
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "counter-app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.16.5",
7 | "@testing-library/react": "^13.3.0",
8 | "@testing-library/user-event": "^13.5.0",
9 | "react": "^18.2.0",
10 | "react-dom": "^18.2.0",
11 | "react-scripts": "5.0.1",
12 | "uuid": "^9.0.0",
13 | "web-vitals": "^2.1.4"
14 | },
15 | "scripts": {
16 | "start": "react-scripts start",
17 | "build": "react-scripts build",
18 | "test": "react-scripts test",
19 | "eject": "react-scripts eject"
20 | },
21 | "eslintConfig": {
22 | "extends": [
23 | "react-app",
24 | "react-app/jest"
25 | ]
26 | },
27 | "browserslist": {
28 | "production": [
29 | ">0.2%",
30 | "not dead",
31 | "not op_mini all"
32 | ],
33 | "development": [
34 | "last 1 chrome version",
35 | "last 1 firefox version",
36 | "last 1 safari version"
37 | ]
38 | },
39 | "devDependencies": {
40 | "eslint": "^8.22.0",
41 | "eslint-config-prettier": "^8.5.0",
42 | "eslint-plugin-prettier": "^4.2.1",
43 | "eslint-plugin-react": "^7.31.0",
44 | "prettier": "^2.7.1"
45 | },
46 | "lint": "eslint .",
47 | "lint:fix": "eslint --fix",
48 | "format": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc"
49 | }
50 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anisul-Islam/react-assignment-4-users-management-app/037314859d689f7fdea5a77ed76d0798ac345e9c/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/anisul-Islam/react-assignment-4-users-management-app/037314859d689f7fdea5a77ed76d0798ac345e9c/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anisul-Islam/react-assignment-4-users-management-app/037314859d689f7fdea5a77ed76d0798ac345e9c/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.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import Users from './components/Users';
4 |
5 | const App = () => {
6 | // step1 : declare three states here : users, isLoading, error
7 |
8 | // step2 : use useEffect for fetching the data including updating isLoading and error states
9 |
10 | return (
11 |
12 |
Users Management App
13 | {isLoading &&
Loading users...
}
14 | {error &&
{error}
}
15 | {/* step3 : pass the users data to Users component */}
16 |
17 | );
18 | };
19 |
20 | export default App;
21 |
--------------------------------------------------------------------------------
/src/components/User.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | const User = ({ id, name, email, phone }) => {
5 | return (
6 |
7 | {id}
8 | {name}
9 | {email}
10 |
11 | {phone}
12 |
13 |
14 | );
15 | };
16 |
17 | User.propTypes = {
18 | id: PropTypes.number,
19 | name: PropTypes.string,
20 | email: PropTypes.string,
21 | phone: PropTypes.string
22 | };
23 |
24 | export default User;
25 |
--------------------------------------------------------------------------------
/src/components/Users.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | import User from './User';
5 |
6 | const Users = (props) => {
7 | return (
8 |
9 | {props.users.map((user) => (
10 |
11 | ))}
12 |
13 | );
14 | };
15 |
16 | Users.propTypes = {
17 | users: PropTypes.array
18 | };
19 |
20 | export default Users;
21 |
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | :root {
2 | --border-radius: 0.6rem;
3 | --text-color: #fff;
4 | }
5 |
6 | * {
7 | box-sizing: border-box;
8 | margin: 0;
9 | padding: 0;
10 | list-style-type: none;
11 | text-decoration: none;
12 | outline: none;
13 | }
14 | html {
15 | scroll-behavior: smooth;
16 | }
17 |
18 | body {
19 | background-color: #4c4c4c;
20 | }
21 |
22 | .container {
23 | min-height: 100vh;
24 | display: flex;
25 | flex-direction: column;
26 | align-items: center;
27 | }
28 |
29 | .title {
30 | text-align: center;
31 | margin: 1rem 0;
32 | color: white;
33 | font-size: 2rem;
34 | }
35 |
36 | .users {
37 | display: grid;
38 | grid-template-columns: repeat(4, minmax(0, 1fr));
39 | padding: 1rem;
40 | color: white;
41 | gap: 1rem;
42 | }
43 | .user {
44 | display: flex;
45 | flex-direction: column;
46 | gap: 0.5rem;
47 | background-color: #2c2c2c;
48 | color: white;
49 | padding: 0.6rem;
50 | border-radius: 0.6rem;
51 | transition: all 0.3s;
52 | }
53 | .user:hover {
54 | background-color: black;
55 | }
56 | .user__name {
57 | color: yellow;
58 | }
59 | .user__phone {
60 | color: white;
61 | }
62 | .user__phone:hover {
63 | text-decoration: underline;
64 | }
65 | @media screen and (max-width: 992px) {
66 | .users {
67 | grid-template-columns: repeat(3, minmax(0, 1fr));
68 | }
69 | }
70 | @media screen and (max-width: 768px) {
71 | .users {
72 | grid-template-columns: repeat(2, minmax(0, 1fr));
73 | }
74 | }
75 | @media screen and (max-width: 600px) {
76 | .users {
77 | width: 100%;
78 | grid-template-columns: repeat(1, minmax(0, 1fr));
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import App from './App';
4 |
5 | import './index.css';
6 |
7 | const root = ReactDOM.createRoot(document.getElementById('root'));
8 |
9 | root.render();
10 |
--------------------------------------------------------------------------------