[ ADD ] react configuration
This commit is contained in:
parent
89c9cfe099
commit
5078a1a96e
@ -53,6 +53,8 @@ volumes:
|
|||||||
driver: ${VOLUMES_DRIVER}
|
driver: ${VOLUMES_DRIVER}
|
||||||
docker-in-docker:
|
docker-in-docker:
|
||||||
driver: ${VOLUMES_DRIVER}
|
driver: ${VOLUMES_DRIVER}
|
||||||
|
react:
|
||||||
|
driver: ${VOLUMES_DRIVER}
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
||||||
@ -1813,3 +1815,20 @@ services:
|
|||||||
- ${DATA_PATH_HOST}/tomcat/logs:/usr/local/tomcat/logs
|
- ${DATA_PATH_HOST}/tomcat/logs:/usr/local/tomcat/logs
|
||||||
# restart: always
|
# restart: always
|
||||||
|
|
||||||
|
### react #####################################################
|
||||||
|
react:
|
||||||
|
build:
|
||||||
|
context: ./react
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
container_name: react
|
||||||
|
stdin_open: true
|
||||||
|
environment:
|
||||||
|
- CHOKIDAR_USEPOLLING=true
|
||||||
|
networks:
|
||||||
|
- frontend
|
||||||
|
- backend
|
||||||
|
volumes:
|
||||||
|
- ./react:/usr/src/app/react
|
||||||
|
- /usr/src/app/react/node_modules
|
||||||
|
|
||||||
|
23
react/.gitignore
vendored
Normal file
23
react/.gitignore
vendored
Normal file
@ -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*
|
11
react/Dockerfile
Normal file
11
react/Dockerfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
FROM node:10
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app/react
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
RUN npm install node-sass && npm install
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["npm", "start"]
|
68
react/README.md
Normal file
68
react/README.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
This project was bootstrapped with [react-redux-boilerplate](https://github.com/Marinashafiq/react-redux-boilerplate).
|
||||||
|
|
||||||
|
## Available Scripts
|
||||||
|
|
||||||
|
In the project directory, you can run:
|
||||||
|
|
||||||
|
### `npm start`
|
||||||
|
|
||||||
|
Runs the app in the development mode.<br />
|
||||||
|
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||||
|
|
||||||
|
The page will reload if you make edits.<br />
|
||||||
|
You will also see any lint errors in the console.
|
||||||
|
|
||||||
|
### `npm test`
|
||||||
|
|
||||||
|
Launches the test runner in the interactive watch mode.<br />
|
||||||
|
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||||
|
|
||||||
|
### `npm run build`
|
||||||
|
|
||||||
|
Builds the app for production to the `build` folder.<br />
|
||||||
|
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||||
|
|
||||||
|
The build is minified and the filenames include the hashes.<br />
|
||||||
|
Your app is ready to be deployed!
|
||||||
|
|
||||||
|
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||||
|
|
||||||
|
### `npm run eject`
|
||||||
|
|
||||||
|
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Learn More
|
||||||
|
|
||||||
|
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||||
|
|
||||||
|
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||||
|
|
||||||
|
### Code Splitting
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
|
||||||
|
|
||||||
|
### Analyzing the Bundle Size
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
|
||||||
|
|
||||||
|
### Making a Progressive Web App
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
|
||||||
|
|
||||||
|
### Advanced Configuration
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
|
||||||
|
|
||||||
|
### Deployment
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
|
||||||
|
|
||||||
|
### `npm run build` fails to minify
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
|
15979
react/package-lock.json
generated
Normal file
15979
react/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
48
react/package.json
Normal file
48
react/package.json
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"name": "react-redux-boilerplate",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@material-ui/core": "^4.11.0",
|
||||||
|
"@material-ui/icons": "^4.9.1",
|
||||||
|
"@material-ui/lab": "^4.0.0-alpha.56",
|
||||||
|
"@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.3",
|
||||||
|
"jss-rtl": "^0.3.0",
|
||||||
|
"node-sass": "^4.14.1",
|
||||||
|
"prop-types": "^15.7.2",
|
||||||
|
"react": "^17.0.1",
|
||||||
|
"react-bootstrap": "^1.4.0",
|
||||||
|
"react-dom": "^17.0.1",
|
||||||
|
"react-intl": "^4.7.6",
|
||||||
|
"react-redux": "^7.2.2",
|
||||||
|
"react-router-dom": "^5.2.0",
|
||||||
|
"react-scripts": "3.4.1",
|
||||||
|
"redux": "^4.0.5",
|
||||||
|
"redux-saga": "^1.1.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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
BIN
react/public/favicon.ico
Normal file
BIN
react/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
43
react/public/index.html
Normal file
43
react/public/index.html
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<!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`.
|
||||||
|
-->
|
||||||
|
<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>
|
BIN
react/public/logo192.png
Normal file
BIN
react/public/logo192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
BIN
react/public/logo512.png
Normal file
BIN
react/public/logo512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
25
react/public/manifest.json
Normal file
25
react/public/manifest.json
Normal file
@ -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
react/public/robots.txt
Normal file
3
react/public/robots.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# https://www.robotstxt.org/robotstxt.html
|
||||||
|
User-agent: *
|
||||||
|
Disallow:
|
39
react/src/Theme.js
Normal file
39
react/src/Theme.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { createMuiTheme } from "@material-ui/core/styles";
|
||||||
|
import { ThemeProvider } from "@material-ui/styles";
|
||||||
|
import rtl from "jss-rtl";
|
||||||
|
import { create } from "jss";
|
||||||
|
import { StylesProvider, jssPreset } from "@material-ui/styles";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
import App from "./containers/App";
|
||||||
|
|
||||||
|
function ThemeApp() {
|
||||||
|
const jss = create({ plugins: [...jssPreset().plugins, rtl()] });
|
||||||
|
const lang = useSelector(state => state.lang);
|
||||||
|
const [direction, setDirection] = useState(lang === "en" ? "ltr" : "rtl");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setDirection(lang === "en" ? "ltr" : "rtl");
|
||||||
|
}, [lang]);
|
||||||
|
|
||||||
|
const theme = createMuiTheme({
|
||||||
|
direction: direction,
|
||||||
|
palette: {
|
||||||
|
primary: {
|
||||||
|
main: "#1976d2"
|
||||||
|
},
|
||||||
|
secondary: {
|
||||||
|
main: "#ac4556"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<StylesProvider jss={jss}>
|
||||||
|
<ThemeProvider theme={theme}>
|
||||||
|
<App />
|
||||||
|
</ThemeProvider>
|
||||||
|
</StylesProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ThemeApp;
|
13
react/src/assets/Local/ar.js
Normal file
13
react/src/assets/Local/ar.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
export default {
|
||||||
|
ar: {
|
||||||
|
hello: "مرحبا",
|
||||||
|
langBtn : "English",
|
||||||
|
home: {
|
||||||
|
content:
|
||||||
|
'لوريم إيبسوم(Lorem Ipsum) هو ببساطة نص شكلي (بمعنى أن الغاية هي الشكل وليس المحتوى) ويُستخدم في صناعات المطابع ودور النشر. كان لوريم إيبسوم ولايزال المعيار للنص الشكلي منذ القرن الخامس عشر عندما قامت مطبعة مجهولة برص مجموعة من الأحرف بشكل عشوائي أخذتها من نص، لتكوّن كتيّب بمثابة دليل أو مرجع شكلي لهذه الأحرف. خمسة قرون من الزمن لم تقضي على هذا النص، بل انه حتى صار مستخدماً وبشكله الأصلي في الطباعة والتنضيد الإلكتروني. انتشر بشكل كبير في ستينيّات هذا القرن مع إصدار رقائق "ليتراسيت" (Letraset) البلاستيكية تحوي مقاطع من هذا النص، وعاد لينتشر مرة أخرى مؤخراَ مع ظهور برامج النشر الإلكتروني مثل "ألدوس بايج مايكر" (Aldus PageMaker) والتي حوت أيضاً على نسخ من نص لوريم إيبسوم.'
|
||||||
|
},
|
||||||
|
snackbar: {
|
||||||
|
'success' : 'تم بنجاح'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
13
react/src/assets/Local/en.js
Normal file
13
react/src/assets/Local/en.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
export default {
|
||||||
|
en: {
|
||||||
|
hello : 'Hello',
|
||||||
|
langBtn : "عربى",
|
||||||
|
home: {
|
||||||
|
content:
|
||||||
|
"What is Lorem Ipsum?Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
|
||||||
|
},
|
||||||
|
snackbar: {
|
||||||
|
'success' : 'Done successfully'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
react/src/assets/Local/messages.js
Normal file
9
react/src/assets/Local/messages.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import en from './en';
|
||||||
|
import ar from './ar';
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
...ar,
|
||||||
|
...en
|
||||||
|
}
|
||||||
|
|
||||||
|
export default messages;
|
BIN
react/src/assets/fonts/Roboto/Roboto-Black.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-Black.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/fonts/Roboto/Roboto-BlackItalic.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-BlackItalic.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/fonts/Roboto/Roboto-Bold.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-Bold.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/fonts/Roboto/Roboto-BoldItalic.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/fonts/Roboto/Roboto-Italic.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-Italic.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/fonts/Roboto/Roboto-Light.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-Light.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/fonts/Roboto/Roboto-LightItalic.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-LightItalic.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/fonts/Roboto/Roboto-Medium.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-Medium.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/fonts/Roboto/Roboto-MediumItalic.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-MediumItalic.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/fonts/Roboto/Roboto-Regular.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-Regular.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/fonts/Roboto/Roboto-Thin.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-Thin.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/fonts/Roboto/Roboto-ThinItalic.ttf
Normal file
BIN
react/src/assets/fonts/Roboto/Roboto-ThinItalic.ttf
Normal file
Binary file not shown.
BIN
react/src/assets/images/reactjs.jpg
Normal file
BIN
react/src/assets/images/reactjs.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
10
react/src/components/Controls/Button/Button.js
Normal file
10
react/src/components/Controls/Button/Button.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import React from "react";
|
||||||
|
import Button from '@material-ui/core/Button';
|
||||||
|
|
||||||
|
export const Btn = ({text , handleClick}) => {
|
||||||
|
return (
|
||||||
|
<Button variant="contained" color="primary" onClick={handleClick}>
|
||||||
|
{text}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
};
|
32
react/src/components/Controls/InputField/InputField.js
Normal file
32
react/src/components/Controls/InputField/InputField.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { TextField } from "@material-ui/core";
|
||||||
|
|
||||||
|
export const InputField = ({
|
||||||
|
name,
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
error,
|
||||||
|
handleChange,
|
||||||
|
helperText,
|
||||||
|
isMultiline,
|
||||||
|
isRequired
|
||||||
|
}) => {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TextField
|
||||||
|
className="my-3"
|
||||||
|
name={name}
|
||||||
|
type="text"
|
||||||
|
label={isRequired ? label+"*" : label}
|
||||||
|
inputProps={{ maxLength: isMultiline ? 500 : 50 }}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
value={value}
|
||||||
|
error={error}
|
||||||
|
helperText={error && helperText}
|
||||||
|
onChange={handleChange}
|
||||||
|
multiline={isMultiline}
|
||||||
|
rows={isMultiline ? 3 : 1}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
14
react/src/components/Loader/Loader.js
Normal file
14
react/src/components/Loader/Loader.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import React from "react";
|
||||||
|
import "./Loader.scss";
|
||||||
|
|
||||||
|
const Loader = () => {
|
||||||
|
return (
|
||||||
|
<div className="spinnerContainer d-flex justify-content-center align-items-center h-100">
|
||||||
|
<div className="spinner-border text-primary" role="status">
|
||||||
|
<span className="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Loader;
|
31
react/src/components/Loader/Loader.scss
Normal file
31
react/src/components/Loader/Loader.scss
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
.spinnerContainer {
|
||||||
|
height: 100vh;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-indicator:before {
|
||||||
|
content: "";
|
||||||
|
background: #000000cc;
|
||||||
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-indicator:after {
|
||||||
|
content: "\f1ce";
|
||||||
|
font-family: FontAwesome;
|
||||||
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
top: 50%;
|
||||||
|
left: 0;
|
||||||
|
z-index: 1001;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: 100;
|
||||||
|
font-size: 4rem;
|
||||||
|
-webkit-animation: fa-spin 1s infinite linear;
|
||||||
|
animation: fa-spin 1s infinite linear;
|
||||||
|
}
|
33
react/src/components/Navbar/Navbar.js
Normal file
33
react/src/components/Navbar/Navbar.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import React from "react";
|
||||||
|
import messages from "./../../assets/Local/messages";
|
||||||
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
|
import { setCurrentLang } from "../../store/Lang/LangAction";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import { Btn } from "../Controls/Button/Button";
|
||||||
|
|
||||||
|
export default function Navbar() {
|
||||||
|
const lang = useSelector(state => state.lang);
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const message = messages[lang];
|
||||||
|
const switchLanguage = lang => {
|
||||||
|
dispatch(setCurrentLang(lang === "ar" ? "en" : "ar"));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<nav className="navbar navbar-dark bg-dark">
|
||||||
|
<a className="navbar-brand">{message.hello}</a>
|
||||||
|
<div className="d-flex align-items-center">
|
||||||
|
{/* This private route won't be accessible if no token in lcoal storage */}
|
||||||
|
<Link to="/" className="text-white mx-3">
|
||||||
|
Private Route
|
||||||
|
</Link>
|
||||||
|
<Btn
|
||||||
|
handleClick={() => switchLanguage(lang)}
|
||||||
|
text={message.langBtn}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
12
react/src/components/NotFound/NotFound.js
Normal file
12
react/src/components/NotFound/NotFound.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const NotFound = () => {
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<div className="text-center">
|
||||||
|
<h1 className="my-5 pt-5">Sorry we can’t find this page</h1>
|
||||||
|
</div>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default NotFound;
|
33
react/src/components/Snackbar/Snackbar.js
Normal file
33
react/src/components/Snackbar/Snackbar.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import React from "react";
|
||||||
|
import Snackbar from "@material-ui/core/Snackbar";
|
||||||
|
import MuiAlert from "@material-ui/lab/Alert";
|
||||||
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
|
import { hideSnackbarAction } from "../../store/Snackbar/SnackbarAction";
|
||||||
|
|
||||||
|
function Alert(props) {
|
||||||
|
return <MuiAlert elevation={6} variant="filled" {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MaterialSnackbar(props) {
|
||||||
|
const { isOpen, message, type } = useSelector(state => state.snackbar);
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const handleClose = (event, reason) => {
|
||||||
|
if (reason === "clickaway") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dispatch(hideSnackbarAction());
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Snackbar
|
||||||
|
open={isOpen}
|
||||||
|
autoHideDuration={4000}
|
||||||
|
anchorOrigin={{ vertical: "bottom", horizontal: "center" }}
|
||||||
|
key={`bottom,center`}
|
||||||
|
onClose={() => handleClose}
|
||||||
|
>
|
||||||
|
<Alert onClose={handleClose} severity={type} className="medium_font">
|
||||||
|
{message}
|
||||||
|
</Alert>
|
||||||
|
</Snackbar>
|
||||||
|
);
|
||||||
|
}
|
40
react/src/containers/App.js
Normal file
40
react/src/containers/App.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import React from "react";
|
||||||
|
import Navbar from "../components/Navbar/Navbar";
|
||||||
|
import { Router } from "react-router-dom";
|
||||||
|
import history from "../routes/History";
|
||||||
|
import Routes from "../routes/Routes";
|
||||||
|
import { IntlProvider } from "react-intl";
|
||||||
|
import messages from "../assets/Local/messages";
|
||||||
|
import { MaterialSnackbar } from "../components/Snackbar/Snackbar";
|
||||||
|
import Loader from "../components/Loader/Loader";
|
||||||
|
import "./App.scss";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
|
||||||
|
class App extends React.Component {
|
||||||
|
// App contains routes and also wrapped with snackbar and intl for localization
|
||||||
|
render() {
|
||||||
|
const { lang , loading } = this.props;
|
||||||
|
return (
|
||||||
|
<IntlProvider locale={lang} messages={messages[lang]}>
|
||||||
|
<div
|
||||||
|
className={lang === "ar" ? "rtl" : "ltr"}
|
||||||
|
dir={lang === "ar" ? "rtl" : "ltr"}
|
||||||
|
>
|
||||||
|
{loading ? <Loader /> : null}
|
||||||
|
<Router history={history}>
|
||||||
|
<MaterialSnackbar />
|
||||||
|
<Navbar />
|
||||||
|
{Routes}
|
||||||
|
</Router>
|
||||||
|
</div>
|
||||||
|
</IntlProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapStateToProps = ({ lang, loading }) => ({
|
||||||
|
lang,
|
||||||
|
loading
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, null)(App);
|
1
react/src/containers/App.scss
Normal file
1
react/src/containers/App.scss
Normal file
@ -0,0 +1 @@
|
|||||||
|
@import '../scss/base.scss';
|
23
react/src/containers/Home/Home.js
Normal file
23
react/src/containers/Home/Home.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import messages from "./../../assets/Local/messages";
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
class Home extends React.Component {
|
||||||
|
render(){
|
||||||
|
const { lang } = this.props;
|
||||||
|
const message = messages[lang]
|
||||||
|
return(
|
||||||
|
<div className="container my-5">
|
||||||
|
<p>{message.home.content}</p>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapStateToProps = (state) => {
|
||||||
|
return {
|
||||||
|
lang : state.lang
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(mapStateToProps,null)(Home);
|
23
react/src/containers/Login/Login.js
Normal file
23
react/src/containers/Login/Login.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {Btn} from '../../components/Controls/Button/Button';
|
||||||
|
import History from '../../routes/History';
|
||||||
|
class Login extends React.Component {
|
||||||
|
|
||||||
|
// this method is only to trigger route guards , remove and use your own logic
|
||||||
|
handleLogin = () => {
|
||||||
|
localStorage.setItem('token','token');
|
||||||
|
History.push('/')
|
||||||
|
}
|
||||||
|
|
||||||
|
render(){
|
||||||
|
return(
|
||||||
|
<div className="container my-5">
|
||||||
|
<h1>Login Page</h1>
|
||||||
|
<Btn text='Login' handleClick={this.handleLogin}/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default Login;
|
12
react/src/index.js
Normal file
12
react/src/index.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import React from "react";
|
||||||
|
import ReactDOM from "react-dom";
|
||||||
|
import { Provider } from "react-redux";
|
||||||
|
import store from "./store";
|
||||||
|
import ThemeApp from "./Theme";
|
||||||
|
|
||||||
|
ReactDOM.render(
|
||||||
|
<Provider store={store}>
|
||||||
|
<ThemeApp />
|
||||||
|
</Provider>,
|
||||||
|
document.querySelector('#root')
|
||||||
|
);
|
19
react/src/network/apis/index.js
Normal file
19
react/src/network/apis/index.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
import { requestHandler, successHandler, errorHandler } from "../interceptors";
|
||||||
|
import { BASE_URL } from "../../utils/Constants";
|
||||||
|
|
||||||
|
//add your BASE_URL to Constants file
|
||||||
|
export const axiosInstance = axios.create({
|
||||||
|
baseURL: BASE_URL,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle request process
|
||||||
|
axiosInstance.interceptors.request.use(request => requestHandler(request));
|
||||||
|
// Handle response process
|
||||||
|
axiosInstance.interceptors.response.use(
|
||||||
|
response => successHandler(response),
|
||||||
|
error => errorHandler(error)
|
||||||
|
);
|
35
react/src/network/interceptors/index.js
Normal file
35
react/src/network/interceptors/index.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import store from "../../store";
|
||||||
|
import { loader } from "../../store/Loader/LoaderAction";
|
||||||
|
import Auth from "../../utils/Auth";
|
||||||
|
|
||||||
|
export const isHandlerEnabled = (config = {}) => {
|
||||||
|
return config.hasOwnProperty("handlerEnabled") && !config.handlerEnabled
|
||||||
|
? false
|
||||||
|
: true;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const requestHandler = request => {
|
||||||
|
if (isHandlerEnabled(request)) {
|
||||||
|
// Modify request here
|
||||||
|
store.dispatch(loader(true));
|
||||||
|
}
|
||||||
|
return request;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const successHandler = response => {
|
||||||
|
if (isHandlerEnabled(response)) {
|
||||||
|
// Hanlde Response
|
||||||
|
store.dispatch(loader(false));
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const errorHandler = error => {
|
||||||
|
if (isHandlerEnabled(error.config)) {
|
||||||
|
store.dispatch(loader(false));
|
||||||
|
// You can decide what you need to do to handle errors.
|
||||||
|
// here's example for unautherized user to log them out .
|
||||||
|
// error.response.status === 401 && Auth.signOut();
|
||||||
|
}
|
||||||
|
return Promise.reject({ ...error });
|
||||||
|
};
|
2
react/src/routes/History.js
Normal file
2
react/src/routes/History.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import { createBrowserHistory } from "history";
|
||||||
|
export default createBrowserHistory();
|
22
react/src/routes/Routes.js
Normal file
22
react/src/routes/Routes.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import React, { Suspense } from "react";
|
||||||
|
import { Router, Switch } from "react-router-dom";
|
||||||
|
import history from "./History";
|
||||||
|
import * as LazyComponent from "../utils/LazyLoaded";
|
||||||
|
import Loader from "../components/Loader/Loader";
|
||||||
|
import PrivateRoute from "../utils/PrivateRoute";
|
||||||
|
|
||||||
|
const Routes = (
|
||||||
|
<Suspense fallback={<Loader />}>
|
||||||
|
<Router history={history}>
|
||||||
|
<Switch>
|
||||||
|
{/* For private routes */}
|
||||||
|
<PrivateRoute component={LazyComponent.Home} path="/" exact />
|
||||||
|
{/* Public routes that doesn't need any auth */}
|
||||||
|
<LazyComponent.Login path="/login" exact />
|
||||||
|
<LazyComponent.NotFound path="**" title="This page doesn't exist..." exact />
|
||||||
|
</Switch>
|
||||||
|
</Router>
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default Routes;
|
1
react/src/scss/_general.scss
Normal file
1
react/src/scss/_general.scss
Normal file
@ -0,0 +1 @@
|
|||||||
|
// Add you general and shared styles here
|
4
react/src/scss/_rtl.scss
Normal file
4
react/src/scss/_rtl.scss
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.rtl{
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
text-align: right;
|
||||||
|
}
|
2
react/src/scss/_variables.scss
Normal file
2
react/src/scss/_variables.scss
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$primaryColor: rgb(50, 61, 165);
|
||||||
|
$secondaryColor : rgba(62, 62, 62, 1);
|
4
react/src/scss/base.scss
Normal file
4
react/src/scss/base.scss
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
@import 'bootstrap/scss/bootstrap';
|
||||||
|
@import './variables';
|
||||||
|
@import './rtl';
|
||||||
|
@import './general';
|
11
react/src/store/Feature1/FeatureAction.js
Normal file
11
react/src/store/Feature1/FeatureAction.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import * as types from "./FeatureTypes";
|
||||||
|
|
||||||
|
//Replace action name and update action types
|
||||||
|
export const actionRequest = () => ({
|
||||||
|
type: types.GET_DATA_REQUEST
|
||||||
|
});
|
||||||
|
|
||||||
|
export const actionReceive = payload => ({
|
||||||
|
type: types.GET_DATA_REQUEST,
|
||||||
|
payload
|
||||||
|
});
|
11
react/src/store/Feature1/FeatureApis.js
Normal file
11
react/src/store/Feature1/FeatureApis.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import {axiosInstance} from '../../network/apis';
|
||||||
|
const handlerEnabled = false;
|
||||||
|
|
||||||
|
// Replace endpoint and change api name
|
||||||
|
const apiExampleRequest = async () => {
|
||||||
|
return await axiosInstance.get(`ENDPOINT`, { handlerEnabled });
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
apiExampleRequest
|
||||||
|
};
|
16
react/src/store/Feature1/FeatureReducer.js
Normal file
16
react/src/store/Feature1/FeatureReducer.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import * as types from "./FeatureTypes";
|
||||||
|
|
||||||
|
const INITIAL_STATE = {};
|
||||||
|
|
||||||
|
// Replace with you own reducer
|
||||||
|
export default (state = INITIAL_STATE, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case types.GET_DATA_RECEIVE:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
...action.payload
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
21
react/src/store/Feature1/FeatureSagas.js
Normal file
21
react/src/store/Feature1/FeatureSagas.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { call, put } from "redux-saga/effects";
|
||||||
|
import API from "./FeatureApis";
|
||||||
|
import * as ACTIONS from "./FeatureAction";
|
||||||
|
import { dispatchSnackbarError } from "../../utils/Shared";
|
||||||
|
import { takeLatest } from "redux-saga/effects";
|
||||||
|
import * as TYPES from "./FeatureTypes";
|
||||||
|
|
||||||
|
// Replace with your sagas
|
||||||
|
export function* sagasRequestExample() {
|
||||||
|
try {
|
||||||
|
const response = yield call(API.apiExampleRequest);
|
||||||
|
yield put(ACTIONS.actionReceive(response.data));
|
||||||
|
} catch (err) {
|
||||||
|
dispatchSnackbarError(err.response.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function* FeatureSaga1() {
|
||||||
|
yield takeLatest(TYPES.GET_DATA_REQUEST, sagasRequestExample);
|
||||||
|
}
|
3
react/src/store/Feature1/FeatureTypes.js
Normal file
3
react/src/store/Feature1/FeatureTypes.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// Replace with your request types
|
||||||
|
export const GET_DATA_REQUEST = 'GET_DATA_REQUEST';
|
||||||
|
export const GET_DATA_RECEIVE = 'GET_DATA_RECEIVE';
|
10
react/src/store/Lang/LangAction.js
Normal file
10
react/src/store/Lang/LangAction.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import * as types from './LangTypes';
|
||||||
|
|
||||||
|
export const setCurrentLang = payload => {
|
||||||
|
localStorage.setItem('lang', payload);
|
||||||
|
return { type: types.SET_LANG, payload };
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getCurrentLang = () => {
|
||||||
|
return { type: types.GET_LANG };
|
||||||
|
};
|
14
react/src/store/Lang/LangReducer.js
Normal file
14
react/src/store/Lang/LangReducer.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import * as types from "./LangTypes";
|
||||||
|
|
||||||
|
const INITIAL_STATE = localStorage.getItem("lang") || "en";
|
||||||
|
|
||||||
|
export default function locale(state = INITIAL_STATE, action) {
|
||||||
|
switch (action.type) {
|
||||||
|
case types.SET_LANG:
|
||||||
|
return action.payload;
|
||||||
|
case types.GET_LANG:
|
||||||
|
return action.payload;
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
2
react/src/store/Lang/LangTypes.js
Normal file
2
react/src/store/Lang/LangTypes.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export const SET_LANG = 'SET_LANG';
|
||||||
|
export const GET_LANG = 'GET_LANG';
|
13
react/src/store/Loader/LoaderAction.js
Normal file
13
react/src/store/Loader/LoaderAction.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import * as types from "./LoaderTypes";
|
||||||
|
|
||||||
|
export const loader = isLoading => {
|
||||||
|
return isLoading
|
||||||
|
? {
|
||||||
|
type: types.SHOW_LOADER,
|
||||||
|
data: isLoading
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
type: types.HIDE_LOADER,
|
||||||
|
data: isLoading
|
||||||
|
};
|
||||||
|
};
|
14
react/src/store/Loader/LoaderReducer.js
Normal file
14
react/src/store/Loader/LoaderReducer.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import * as types from "./LoaderTypes";
|
||||||
|
|
||||||
|
const INITIAL_STATE = false;
|
||||||
|
|
||||||
|
export default (state = INITIAL_STATE, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case types.SHOW_LOADER:
|
||||||
|
return action.data;
|
||||||
|
case types.HIDE_LOADER:
|
||||||
|
return action.data;
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
2
react/src/store/Loader/LoaderTypes.js
Normal file
2
react/src/store/Loader/LoaderTypes.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export const SHOW_LOADER = 'SHOW_LOADER';
|
||||||
|
export const HIDE_LOADER = 'HIDE_LOADER';
|
15
react/src/store/Snackbar/SnackbarAction.js
Normal file
15
react/src/store/Snackbar/SnackbarAction.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import * as types from './SnackbarTypes';
|
||||||
|
|
||||||
|
export const showSnackbarAction = (message , snacknarType) => {
|
||||||
|
return {
|
||||||
|
type: types.SHOW_SNACKBAR,
|
||||||
|
message ,
|
||||||
|
snacknarType
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const hideSnackbarAction = () => {
|
||||||
|
return {
|
||||||
|
type: types.HIDE_SNACKBAR
|
||||||
|
};
|
||||||
|
};
|
21
react/src/store/Snackbar/SnackbarReducer.js
Normal file
21
react/src/store/Snackbar/SnackbarReducer.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import * as types from "./SnackbarTypes";
|
||||||
|
|
||||||
|
export default (state = {}, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case types.SHOW_SNACKBAR:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
isOpen: true,
|
||||||
|
message: action.message,
|
||||||
|
type: action.snacknarType
|
||||||
|
};
|
||||||
|
case types.HIDE_SNACKBAR:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
isOpen: false
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
2
react/src/store/Snackbar/SnackbarTypes.js
Normal file
2
react/src/store/Snackbar/SnackbarTypes.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export const SHOW_SNACKBAR = 'SHOW_SNACKBAR';
|
||||||
|
export const HIDE_SNACKBAR = 'HIDE_SNACKBAR';
|
17
react/src/store/index.js
Normal file
17
react/src/store/index.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { createStore, applyMiddleware, compose } from "redux";
|
||||||
|
import reducers from "./reducers";
|
||||||
|
import createSagaMiddleware from "redux-saga";
|
||||||
|
import { watchSagas } from "./sagas";
|
||||||
|
const saga = createSagaMiddleware();
|
||||||
|
//redux dev tool
|
||||||
|
const composeEnhancers =
|
||||||
|
typeof window === "object" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||||
|
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
|
||||||
|
: compose;
|
||||||
|
const enhancer = composeEnhancers(applyMiddleware(saga));
|
||||||
|
|
||||||
|
const store = createStore(reducers, enhancer);
|
||||||
|
|
||||||
|
saga.run(watchSagas);
|
||||||
|
|
||||||
|
export default store;
|
12
react/src/store/reducers/index.js
Normal file
12
react/src/store/reducers/index.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { combineReducers } from "redux";
|
||||||
|
import lang from "../Lang/LangReducer";
|
||||||
|
import loader from "../Loader/LoaderReducer";
|
||||||
|
import snackbar from "../Snackbar/SnackbarReducer";
|
||||||
|
import Feature1 from "../Feature1/FeatureReducer";
|
||||||
|
|
||||||
|
export default combineReducers({
|
||||||
|
lang,
|
||||||
|
loader,
|
||||||
|
snackbar,
|
||||||
|
Feature1
|
||||||
|
});
|
9
react/src/store/sagas/index.js
Normal file
9
react/src/store/sagas/index.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { FeatureSaga1 } from '../Feature1/FeatureSagas';
|
||||||
|
import { fork, all } from "redux-saga/effects";
|
||||||
|
|
||||||
|
export function* watchSagas() {
|
||||||
|
//Combine sagas with
|
||||||
|
yield all([FeatureSaga1()]);
|
||||||
|
// OR
|
||||||
|
// yield all([fork(FeatureSaga1)]);
|
||||||
|
}
|
10
react/src/utils/Auth.js
Normal file
10
react/src/utils/Auth.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Service to check authentication for user and to signOut
|
||||||
|
const Auth = {
|
||||||
|
signOut() {
|
||||||
|
localStorage.removeItem("token");
|
||||||
|
},
|
||||||
|
isAuth() {
|
||||||
|
return localStorage.getItem("token");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export default Auth;
|
1
react/src/utils/Constants.js
Normal file
1
react/src/utils/Constants.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const BASE_URL = 'BASE_URL';
|
5
react/src/utils/LazyLoaded.js
Normal file
5
react/src/utils/LazyLoaded.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export const Home = React.lazy(() => import('../containers/Home/Home'));
|
||||||
|
export const Login = React.lazy(() => import('../containers/Login/Login'));
|
||||||
|
export const NotFound = React.lazy(() => import('../components/NotFound/NotFound'));
|
18
react/src/utils/PrivateRoute.js
Normal file
18
react/src/utils/PrivateRoute.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Route, Redirect } from "react-router-dom";
|
||||||
|
import Auth from "../utils/Auth";
|
||||||
|
|
||||||
|
const PrivateRoute = ({ component: Component, ...rest }) => {
|
||||||
|
return (
|
||||||
|
// Show the component only when the user is logged in
|
||||||
|
// Otherwise, redirect the user to /signin page
|
||||||
|
<Route
|
||||||
|
{...rest}
|
||||||
|
render={props =>
|
||||||
|
Auth.isAuth() ? <Component {...props} /> : <Redirect to="/login" />
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PrivateRoute;
|
18
react/src/utils/Shared.js
Normal file
18
react/src/utils/Shared.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import store from "../store";
|
||||||
|
import { showSnackbarAction } from "../store/Snackbar/SnackbarAction";
|
||||||
|
import messages from "../assets/Local/messages";
|
||||||
|
|
||||||
|
// To show error message that returned from backend
|
||||||
|
export function dispatchSnackbarError(data) {
|
||||||
|
if (data) {
|
||||||
|
const errorMsg = data.error.message;
|
||||||
|
store.dispatch(showSnackbarAction(errorMsg, "error"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// To show success message after any success request if needed and rendered from locale files
|
||||||
|
export function dispatchSnackbarSuccess(message) {
|
||||||
|
const lang = store.getState().lang;
|
||||||
|
store.dispatch(
|
||||||
|
showSnackbarAction(messages[lang].snackbar[message], "success")
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user