├── .gitignore
├── .idea
├── inspectionProfiles
│ └── Project_Default.xml
├── modules.xml
├── task-manager.iml
├── vcs.xml
└── workspace.xml
├── README.md
├── package.json
├── public
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
├── src
├── App.js
├── actions
│ ├── taskActions.js
│ └── userActions.js
├── components
│ ├── Header.jsx
│ ├── Loader.jsx
│ └── Message.jsx
├── constants
│ ├── taskConstants.js
│ └── userConstants.js
├── index.js
├── pages
│ ├── HomePage.jsx
│ ├── LoginPage.jsx
│ ├── RegisterPage.jsx
│ ├── TaskListPage.jsx
│ └── TaskPage.jsx
├── reducers
│ ├── taskReducers.js
│ └── userReducers.js
├── reportWebVitals.js
├── setupTests.js
├── store.js
└── styles
│ └── main.scss
└── yarn.lock
/.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 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/task-manager.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | 1637835750756
44 |
45 |
46 | 1637835750756
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/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 | ### `yarn start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13 |
14 | The page will reload if you make edits.\
15 | You will also see any lint errors in the console.
16 |
17 | ### `yarn 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 | ### `yarn 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 | ### `yarn 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 | ### `yarn 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 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "task-manager",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.11.4",
7 | "@testing-library/react": "^11.1.0",
8 | "@testing-library/user-event": "^12.1.10",
9 | "axios": "^0.24.0",
10 | "bootstrap": "5.1.3",
11 | "node-sass": "4.14.1",
12 | "react": "^17.0.2",
13 | "react-bootstrap": "^2.0.2",
14 | "react-dom": "^17.0.2",
15 | "react-hook-form": "^7.20.2",
16 | "react-redux": "^7.2.6",
17 | "react-router-bootstrap": "^0.25.0",
18 | "react-router-dom": "^6.0.2",
19 | "react-scripts": "4.0.3",
20 | "redux": "^4.1.2",
21 | "redux-devtools-extension": "^2.13.9",
22 | "redux-thunk": "^2.4.0",
23 | "web-vitals": "^1.0.1"
24 | },
25 | "scripts": {
26 | "start": "react-scripts start",
27 | "build": "react-scripts build",
28 | "test": "react-scripts test",
29 | "eject": "react-scripts eject"
30 | },
31 | "eslintConfig": {
32 | "extends": [
33 | "react-app",
34 | "react-app/jest"
35 | ]
36 | },
37 | "browserslist": {
38 | "production": [
39 | ">0.2%",
40 | "not dead",
41 | "not op_mini all"
42 | ],
43 | "development": [
44 | "last 1 chrome version",
45 | "last 1 firefox version",
46 | "last 1 safari version"
47 | ]
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AmilAbdullazadeh/task-manager/640a65ac3bfc128f48faf67ae92a0527bbf86923/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/AmilAbdullazadeh/task-manager/640a65ac3bfc128f48faf67ae92a0527bbf86923/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AmilAbdullazadeh/task-manager/640a65ac3bfc128f48faf67ae92a0527bbf86923/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 { Container } from "react-bootstrap";
2 | import { BrowserRouter, Routes, Route } from "react-router-dom";
3 |
4 | import Header from "./components/Header";
5 | import HomePage from "./pages/HomePage";
6 | import LoginPage from "./pages/LoginPage";
7 | import TaskListPage from "./pages/TaskListPage";
8 | import RegisterPage from "./pages/RegisterPage";
9 |
10 | function App() {
11 | return (
12 |
13 |
14 |
15 |
16 |
17 |
18 | } exact />
19 | } />
20 | } />
21 | } />
22 |
23 |
24 |
25 |
26 |
27 | );
28 | }
29 |
30 | export default App;
31 |
--------------------------------------------------------------------------------
/src/actions/taskActions.js:
--------------------------------------------------------------------------------
1 | import axios from "axios";
2 | import {
3 | TASK_CREATE_FAIL,
4 | TASK_CREATE_REQUEST,
5 | TASK_CREATE_RESET,
6 | TASK_CREATE_SUCCESS,
7 | TASK_LIST_FAIL,
8 | TASK_LIST_REQUEST,
9 | TASK_LIST_SUCCESS,
10 | } from "../constants/taskConstants";
11 |
12 | export const createTask = () => async (dispatch, getState) => {
13 | try {
14 | dispatch({ type: TASK_CREATE_REQUEST });
15 | const {
16 | userLogin: { userInfo },
17 | } = getState();
18 | const config = {
19 | headers: {
20 | "Content-type": "application/json",
21 | Authorization: `Bearer ${userInfo.token}`,
22 | },
23 | };
24 | const { data } = await axios.post("", {}, config);
25 | dispatch({
26 | type: TASK_CREATE_SUCCESS,
27 | payload: data,
28 | });
29 | } catch (error) {
30 | dispatch({
31 | type: TASK_CREATE_FAIL,
32 | payload:
33 | error.response && error.response.data.detail
34 | ? error.response.data.detail
35 | : error.message,
36 | });
37 | }
38 | };
39 |
40 | export const listTasks = () => async (dispatch) => {
41 | try {
42 | dispatch({ type: TASK_LIST_REQUEST });
43 | const { data } = await axios.get("");
44 | dispatch({
45 | type: TASK_LIST_SUCCESS,
46 | payload: data,
47 | });
48 | } catch (error) {
49 | dispatch({
50 | type: TASK_LIST_FAIL,
51 | payload:
52 | error.response && error.response.data.detail
53 | ? error.response.data.detail
54 | : error.message,
55 | });
56 | }
57 | };
58 |
--------------------------------------------------------------------------------
/src/actions/userActions.js:
--------------------------------------------------------------------------------
1 | import axios from "axios";
2 | import {
3 | USER_LIST_FAIL,
4 | USER_LIST_REQUEST,
5 | USER_LIST_RESET,
6 | USER_LIST_SUCCESS,
7 | USER_LOGIN_FAIL,
8 | USER_LOGIN_REQUEST,
9 | USER_LOGIN_SUCCESS,
10 | USER_LOGOUT,
11 | USER_REGISTER_FAIL,
12 | USER_REGISTER_REQUEST,
13 | USER_REGISTER_SUCCESS,
14 | } from "../constants/userConstants";
15 |
16 | export const login = (email, password) => async (dispatch) => {
17 | try {
18 | dispatch({ type: USER_LOGIN_REQUEST });
19 | const config = {
20 | headers: {
21 | "Content-Type": "application/json",
22 | },
23 | };
24 | const { data } = await axios.post(
25 | "/api/login",
26 | { email: email, password: password },
27 | config
28 | );
29 | dispatch({ type: USER_LOGIN_SUCCESS, payload: data });
30 | localStorage.setItem("userInfo", JSON.stringify(data));
31 | } catch (error) {
32 | dispatch({
33 | type: USER_LOGIN_FAIL,
34 | payload:
35 | error.response && error.response.data.detail
36 | ? error.response.data.detail
37 | : error.message,
38 | });
39 | }
40 | };
41 |
42 | export const logout = () => (dispatch) => {
43 | localStorage.removeItem("userInfo");
44 | dispatch({ type: USER_LOGOUT });
45 | dispatch({ type: USER_LIST_RESET });
46 | };
47 |
48 | export const register =
49 | (username, email, password, address, phoneNumber, organizationName) =>
50 | async (dispatch) => {
51 | try {
52 | dispatch({ type: USER_REGISTER_REQUEST });
53 | const config = {
54 | headers: {
55 | "Content-type": "application/json",
56 | },
57 | };
58 | const { data } = await axios.post(
59 | "/register",
60 | {
61 | username: username,
62 | email: email,
63 | password: password,
64 | address: address,
65 | phonenumber: phoneNumber,
66 | organizationName: organizationName,
67 | },
68 | config
69 | );
70 | dispatch({ type: USER_REGISTER_SUCCESS, payload: data });
71 | dispatch({ type: USER_LOGIN_SUCCESS, payload: data });
72 | } catch (error) {
73 | dispatch({
74 | type: USER_REGISTER_FAIL,
75 | payload:
76 | error.response && error.response.data.detail
77 | ? error.response.data.detail
78 | : error.message,
79 | });
80 | }
81 | };
82 |
83 | export const listUsers = () => async (dispatch, getState) => {
84 | try {
85 | dispatch({ type: USER_LIST_REQUEST });
86 | const {
87 | userLogin: { userInfo },
88 | } = getState();
89 | const config = {
90 | headers: {
91 | "Content-Type": "application/json",
92 | Authorization: `Bearer ${userInfo.token}`,
93 | },
94 | };
95 | const { data } = await axios.get("/api/users/", config);
96 | dispatch({ type: USER_LIST_SUCCESS, payload: data });
97 | } catch (error) {
98 | dispatch({
99 | type: USER_LIST_FAIL,
100 | payload:
101 | error.response && error.response.data.detail
102 | ? error.response.data.detail
103 | : error.message,
104 | });
105 | }
106 | };
107 |
--------------------------------------------------------------------------------
/src/components/Header.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Navbar, Container, Nav, Button } from "react-bootstrap";
3 |
4 | import { Link } from "react-router-dom";
5 |
6 | function Header() {
7 | return (
8 |
9 |
10 |
11 | Task Manager
12 |
19 |
20 |
21 |
22 | );
23 | }
24 |
25 | export default Header;
26 |
--------------------------------------------------------------------------------
/src/components/Loader.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Spinner } from "react-bootstrap";
3 |
4 | function Loader() {
5 | return (
6 |
16 | Loading...
17 |
18 | );
19 | }
20 |
21 | export default Loader;
22 |
--------------------------------------------------------------------------------
/src/components/Message.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Alert } from "react-bootstrap";
3 |
4 | function Message({ variant, children }) {
5 | return {children};
6 | }
7 |
8 | export default Message;
--------------------------------------------------------------------------------
/src/constants/taskConstants.js:
--------------------------------------------------------------------------------
1 | export const TASK_LIST_REQUEST = "TASK_LIST_REQUEST";
2 | export const TASK_LIST_SUCCESS = "TASK_LIST_SUCCESS";
3 | export const TASK_LIST_FAIL = "TASK_LIST_FAIL";
4 |
5 | export const TASK_CREATE_REQUEST = "TASK_CREATE_REQUEST";
6 | export const TASK_CREATE_SUCCESS = "TASK_CREATE_SUCCESS";
7 | export const TASK_CREATE_FAIL = "TASK_CREATE_FAIL";
8 | export const TASK_CREATE_RESET = "TASK_CREATE_RESET";
9 |
10 |
--------------------------------------------------------------------------------
/src/constants/userConstants.js:
--------------------------------------------------------------------------------
1 | export const USER_LOGIN_REQUEST = "USER_LOGIN_REQUEST";
2 | export const USER_LOGIN_SUCCESS = "USER_LOGIN_SUCCESS";
3 | export const USER_LOGIN_FAIL = "USER_LOGIN_FAIL";
4 |
5 | export const USER_LOGOUT = "USER_LOGOUT";
6 |
7 | export const USER_REGISTER_REQUEST = "USER_REGISTER_REQUEST";
8 | export const USER_REGISTER_SUCCESS = "USER_REGISTER_SUCCESS";
9 | export const USER_REGISTER_FAIL = "USER_REGISTER_FAIL";
10 |
11 | export const USER_DETAILS_REQUEST = "USER_DETAILS_REQUEST";
12 | export const USER_DETAILS_SUCCESS = "USER_DETAILS_SUCCESS";
13 | export const USER_DETAILS_FAIL = "USER_DETAILS_FAIL";
14 | export const USER_DETAILS_RESET = "USER_DETAILS_RESET";
15 |
16 | export const USER_UPDATE_PROFILE_REQUEST = "USER_UPDATE_PROFILE_REQUEST";
17 | export const USER_UPDATE_PROFILE_SUCCESS = "USER_UPDATE_PROFILE_SUCCESS";
18 | export const USER_UPDATE_PROFILE_FAIL = "USER_UPDATE_PROFILE_FAIL";
19 | export const USER_UPDATE_PROFILE_RESET = "USER_UPDATE_PROFILE_RESET";
20 |
21 | export const USER_LIST_REQUEST = "USER_LIST_REQUEST";
22 | export const USER_LIST_SUCCESS = "USER_LIST_SUCCESS";
23 | export const USER_LIST_FAIL = "USER_LIST_FAIL";
24 | export const USER_LIST_RESET = "USER_LIST_RESET";
25 |
26 | export const USER_DELETE_REQUEST = "USER_DELETE_REQUEST";
27 | export const USER_DELETE_SUCCESS = "USER_DELETE_SUCCESS";
28 | export const USER_DELETE_FAIL = "USER_DELETE_FAIL";
29 |
30 | export const USER_UPDATE_REQUEST = "USER_UPDATE_REQUEST";
31 | export const USER_UPDATE_SUCCESS = "USER_UPDATE_SUCCESS";
32 | export const USER_UPDATE_FAIL = "USER_UPDATE_FAIL";
33 | export const USER_UPDATE_RESET = "USER_UPDATE_RESET";
34 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import { Provider } from "react-redux";
4 | import "../node_modules/bootstrap/dist/css/bootstrap.min.css";
5 | import "./styles/main.scss";
6 | import App from "./App";
7 | import reportWebVitals from "./reportWebVitals";
8 | import store from "./store";
9 |
10 | ReactDOM.render(
11 |
12 |
13 | ,
14 | document.getElementById("root")
15 | );
16 |
17 | // If you want to start measuring performance in your app, pass a function
18 | // to log results (for example: reportWebVitals(console.log))
19 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
20 | reportWebVitals();
21 |
--------------------------------------------------------------------------------
/src/pages/HomePage.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | function HomePage() {
4 | return (
5 | asdasd
6 | )
7 | }
8 |
9 | export default HomePage;
10 |
--------------------------------------------------------------------------------
/src/pages/LoginPage.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import { useDispatch, useSelector } from "react-redux";
3 | import { Container, Button, Col, Form, Row } from "react-bootstrap";
4 | import { Link } from "react-router-dom";
5 |
6 | import { login } from "../actions/userActions";
7 | import Loader from "../components/Loader";
8 | import Message from "../components/Message";
9 |
10 | function LoginPage({ location, history }) {
11 | const [email, setEmail] = useState("");
12 | const [password, setPassword] = useState("");
13 |
14 | const dispatch = useDispatch();
15 | const userLogin = useSelector((state) => state.userLogin);
16 | const { error, loading, userInfo } = userLogin;
17 |
18 | const submitHandler = (e) => {
19 | e.preventDefault();
20 | dispatch(login(email, password));
21 | };
22 |
23 | return (
24 |
25 | Sign in
26 | {error && {error}}
27 | {loading && }
28 |
30 | Email Address
31 | setEmail(e.target.value)}
36 | >
37 |
38 |
39 |
40 | Password
41 | setPassword(e.target.value)}
46 | >
47 |
48 |
49 |
52 |
53 |
54 |
55 |
56 | New Customer?
57 | Register
58 |
59 |
60 |
61 | );
62 | }
63 |
64 | export default LoginPage;
65 |
--------------------------------------------------------------------------------
/src/pages/RegisterPage.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import { Container, Button, Col, Form, Row } from "react-bootstrap";
3 | import { Link } from "react-router-dom";
4 | import { useDispatch, useSelector } from "react-redux";
5 |
6 | import { register } from "../actions/userActions";
7 | import Loader from "../components/Loader";
8 | import Message from "../components/Message";
9 |
10 | function RegisterPage({ location, history }) {
11 | const [userName, setUserName] = "";
12 | const [email, setEmail] = "amil@admin.com";
13 | const [password, setPassword] = "qwqerty123@";
14 | const [confirmPassword, setConfirmPassword] = "qwqerty123@";
15 |
16 | const [organizationName, setOrganizationName] = "Golden Pay";
17 | const [phoneNumber, setPhoneNumber] = "0704400500";
18 | const [address, setAddress] = "A.Abbazsade 110";
19 |
20 | const [message, setMessage] = useState("");
21 |
22 | const dispatch = useDispatch();
23 | const userRegister = useSelector((state) => state.userRegister);
24 | const { error, loading, userInfo } = userRegister;
25 |
26 | const submitHandler = (e) => {
27 | e.preventDefault();
28 |
29 | if (password !== confirmPassword) {
30 | setMessage("Passwords dont match");
31 | } else {
32 | dispatch(
33 | register(
34 | userName,
35 | email,
36 | password,
37 | address,
38 | phoneNumber,
39 | organizationName
40 | )
41 | );
42 | }
43 | };
44 |
45 | return (
46 |
47 |
54 | Username
55 | setUserName(e.target.value)}
61 | >
62 |
63 |
64 |
65 | Email Address
66 | setEmail(e.target.value)}
72 | >
73 |
74 |
75 |
76 | Password
77 | setPassword(e.target.value)}
83 | >
84 |
85 |
86 |
87 | Confirm password
88 | setConfirmPassword(e.target.value)}
94 | >
95 |
96 |
97 |
98 | Organization Name
99 | setOrganizationName(e.target.value)}
104 | >
105 |
106 |
107 |
108 | Phone
109 | setPhoneNumber(e.target.value)}
114 | >
115 |
116 |
117 |
118 | Address
119 | setAddress(e.target.value)}
124 | />
125 |
126 |
127 |
130 |
131 |
132 |
133 |
134 | Have an Account?
135 |
136 | Sign In
137 |
138 |
139 |
140 |
141 | );
142 | }
143 |
144 | export default RegisterPage;
145 |
--------------------------------------------------------------------------------
/src/pages/TaskListPage.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect } from "react";
2 | import { Button, Col, Row, Table } from "react-bootstrap";
3 | import { useDispatch, useSelector } from "react-redux";
4 |
5 | import { createTask, listTasks } from "../actions/taskActions";
6 | import Loader from "../components/Loader";
7 | import Message from "../components/Message";
8 |
9 | function TaskListPage({ history }) {
10 | const dispatch = useDispatch();
11 | const taskList = useSelector((state) => state.taskList);
12 | const { loading, error, tasks } = taskList;
13 |
14 | const taskCreate = useSelector((state) => state.taskCreate);
15 | const {
16 | error: errorCreate,
17 | loading: loadingCreate,
18 | success: successCreate,
19 | task: taskCreated,
20 | } = taskCreate;
21 |
22 | const userLogin = useSelector((state) => state.userLogin);
23 | const { userInfo } = userLogin;
24 |
25 | useEffect(() => {
26 | // if (!userInfo.isAdmin) {
27 | // history.push("/login");
28 | // }
29 | if (successCreate) {
30 | dispatch(listTasks);
31 | }
32 | }, [dispatch, history, userInfo, successCreate, taskCreated]);
33 |
34 | const createTaskHandler = () => {
35 | dispatch(createTask());
36 | };
37 |
38 | return (
39 |
40 |
41 |
42 | Tasks
43 |
44 |
45 |
46 |
49 |
50 |
51 |
52 | {loadingCreate &&
}
53 | {errorCreate &&
{errorCreate}}
54 |
55 | {loading ? (
56 |
57 | ) : error ? (
58 |
{error}
59 | ) : (
60 |
61 |
62 |
63 |
64 | Title |
65 | Status |
66 | Description |
67 | Deadline |
68 |
69 |
70 |
71 |
72 | {tasks.map((task, idx) => (
73 |
74 | {task.title} |
75 | {task.status} |
76 | ${task.description} |
77 | {task.deadline} |
78 |
79 | ))}
80 |
81 |
82 |
83 | )}
84 |
85 | );
86 | }
87 |
88 | export default TaskListPage;
89 |
--------------------------------------------------------------------------------
/src/pages/TaskPage.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import {
3 | Button,
4 | Card,
5 | Col,
6 | Form,
7 | Image,
8 | ListGroup,
9 | Row,
10 | } from "react-bootstrap";
11 | import { useDispatch, useSelector } from "react-redux";
12 |
13 | import {
14 | createProductReview,
15 | listProductDetails,
16 | } from "../actions/productActions";
17 | import Loader from "../components/Loader";
18 | import Message from "../components/Message";
19 |
20 | function TaskPage({history}) {
21 | const dispatch = useDispatch();
22 | const userLogin = useSelector((state) => state.userLogin);
23 | const {userInfo} = userLogin;
24 |
25 |
26 | return ;
27 | }
28 |
29 | export default TaskPage;
30 |
--------------------------------------------------------------------------------
/src/reducers/taskReducers.js:
--------------------------------------------------------------------------------
1 | import {
2 | TASK_CREATE_FAIL,
3 | TASK_CREATE_REQUEST,
4 | TASK_CREATE_RESET,
5 | TASK_CREATE_SUCCESS,
6 | TASK_LIST_FAIL,
7 | TASK_LIST_REQUEST,
8 | TASK_LIST_SUCCESS,
9 | } from "../constants/taskConstants";
10 |
11 | export const taskCreateReducer = (state = {}, action) => {
12 | switch (action.type) {
13 | case TASK_CREATE_REQUEST:
14 | return { loading: true };
15 | case TASK_CREATE_SUCCESS:
16 | return { loading: false, success: true, task: action.payload };
17 | case TASK_CREATE_FAIL:
18 | return { loading: false, error: action.payload };
19 | case TASK_CREATE_RESET:
20 | return {};
21 | default:
22 | return state;
23 | }
24 | };
25 |
26 | export const taskListReducer = (state = { tasks: [] }, action) => {
27 | switch (action.type) {
28 | case TASK_LIST_REQUEST:
29 | return { loading: true };
30 | case TASK_LIST_SUCCESS:
31 | return { loading: false, tasks: action.payload };
32 | case TASK_LIST_FAIL:
33 | return { loading: false, error: action.payload };
34 | default:
35 | return state;
36 | }
37 | };
38 |
--------------------------------------------------------------------------------
/src/reducers/userReducers.js:
--------------------------------------------------------------------------------
1 | import {
2 | USER_LIST_FAIL,
3 | USER_LIST_REQUEST,
4 | USER_LIST_RESET,
5 | USER_LIST_SUCCESS,
6 | USER_LOGIN_FAIL,
7 | USER_LOGIN_REQUEST,
8 | USER_LOGIN_SUCCESS,
9 | USER_LOGOUT,
10 | USER_REGISTER_FAIL,
11 | USER_REGISTER_REQUEST,
12 | USER_REGISTER_SUCCESS,
13 | } from "../constants/userConstants";
14 |
15 | export const userLoginReducer = (state = {}, action) => {
16 | switch (action.type) {
17 | case USER_LOGIN_REQUEST:
18 | return { loading: true };
19 | case USER_LOGIN_SUCCESS:
20 | return { loading: false, userInfo: action.payload };
21 | case USER_LOGIN_FAIL:
22 | return { loading: false, error: action.payload };
23 | case USER_LOGOUT:
24 | return {};
25 | default:
26 | return state;
27 | }
28 | };
29 |
30 | export const userRegisterReducer = (state = {}, action) => {
31 | switch (action.type) {
32 | case USER_REGISTER_REQUEST:
33 | return { loading: true };
34 | case USER_REGISTER_SUCCESS:
35 | return { loading: false, userInfo: action.payload };
36 | case USER_REGISTER_FAIL:
37 | return { loading: false, error: action.payload };
38 | case USER_LOGOUT:
39 | return {};
40 | default:
41 | return state;
42 | }
43 | };
44 |
45 | export const userListReducer = (state = { users: [] }, action) => {
46 | switch (action.type) {
47 | case USER_LIST_REQUEST:
48 | return { loading: true };
49 | case USER_LIST_SUCCESS:
50 | return { loading: false, users: action.payload };
51 | case USER_LIST_FAIL:
52 | return { loading: false, error: action.payload };
53 | case USER_LIST_RESET:
54 | return { users: [] };
55 | default:
56 | return state;
57 | }
58 | };
59 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/src/store.js:
--------------------------------------------------------------------------------
1 | import {
2 | applyMiddleware,
3 | combineReducers,
4 | createStore,
5 | } from "redux";
6 | import { composeWithDevTools } from "redux-devtools-extension";
7 | import thunk from "redux-thunk";
8 | import {
9 | userListReducer,
10 | userLoginReducer,
11 | userRegisterReducer,
12 | } from "./reducers/userReducers";
13 | import {
14 | taskCreateReducer,
15 | taskListReducer
16 | } from "./reducers/taskReducers";
17 |
18 | const reducer = combineReducers({
19 | userLogin: userLoginReducer,
20 | userRegister: userRegisterReducer,
21 | userList: userListReducer,
22 |
23 | taskList: taskListReducer,
24 | taskCreate: taskCreateReducer
25 | });
26 |
27 | const userInfofromStorage =
28 | localStorage.getItem("userInfo") &&
29 | localStorage.getItem("userInfo") !== null &&
30 | JSON.parse(localStorage.getItem("userInfo"));
31 |
32 | const initialState = {
33 | userLogin: {
34 | userInfo: userInfofromStorage,
35 | },
36 | };
37 |
38 | const middleware = [thunk];
39 |
40 | const store = createStore(
41 | reducer,
42 | initialState,
43 | composeWithDevTools(applyMiddleware(...middleware))
44 | );
45 |
46 | export default store;
47 |
--------------------------------------------------------------------------------
/src/styles/main.scss:
--------------------------------------------------------------------------------
1 | .navbar__links {
2 | align-items: center;
3 | column-gap: 10px;
4 | }
--------------------------------------------------------------------------------