Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 9525caa

Browse files
author
vigneshwaranc
committed
necessary basic packages are added
1 parent bdd7bfd commit 9525caa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+17333
-10
lines changed

.env.production

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# API End points
2+
3+
REACT_APP_API_URL=http://localhost:3000/api/

.prettierrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// prettier.config.js or .prettierrc.js
2+
module.exports = {
3+
trailingComma: 'es5',
4+
tabWidth: 4,
5+
useTabs: true,
6+
semi: true,
7+
singleQuote: true,
8+
'editor.formatOnSave': true,
9+
// printWidth: 80,
10+
proseWrap: 'always',
11+
};

package-lock.json

Lines changed: 15654 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,39 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@ant-design/icons": "^4.1.0",
67
"@testing-library/jest-dom": "^4.2.4",
78
"@testing-library/react": "^9.3.2",
89
"@testing-library/user-event": "^7.1.2",
10+
"antd": "^4.2.5",
11+
"axios": "^0.19.2",
12+
"cross-env": "^7.0.2",
13+
"formik": "^2.1.4",
14+
"formik-antd": "^2.0.1",
15+
"js-sha512": "^0.8.0",
16+
"lodash": "^4.17.15",
17+
"node-sass": "^4.14.1",
18+
"prop-types": "^15.7.2",
19+
"qs": "^6.9.4",
920
"react": "^16.13.1",
1021
"react-dom": "^16.13.1",
11-
"react-scripts": "3.4.1"
22+
"react-lottie": "^1.2.3",
23+
"react-redux": "^7.2.0",
24+
"react-router-dom": "^5.2.0",
25+
"react-scripts": "3.4.1",
26+
"redux": "^4.0.5",
27+
"redux-logger": "^3.0.6",
28+
"redux-thunk": "^2.3.0",
29+
"styled-components": "^5.1.1",
30+
"typeface-roboto": "0.0.75",
31+
"yup": "^0.29.1"
1232
},
1333
"scripts": {
14-
"start": "react-scripts start",
34+
"start": "cross-env PORT=3001 react-scripts start",
1535
"build": "react-scripts build",
1636
"test": "react-scripts test",
17-
"eject": "react-scripts eject"
37+
"eject": "react-scripts eject",
38+
"build:production": "env-cmd -f .env.production react-scripts build"
1839
},
1940
"eslintConfig": {
2041
"extends": "react-app"
@@ -31,4 +52,4 @@
3152
"last 1 safari version"
3253
]
3354
}
34-
}
55+
}

src/assets/Loader.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"v":"5.5.5","fr":30,"ip":0,"op":300,"w":1920,"h":1080,"nm":"loader","ddd":0,"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[960,540,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[678,678],"ix":2},"p":{"a":0,"k":[0,34],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"t":30,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":7,"s":[0]},{"t":37,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"st","c":{"a":0,"k":[0,0.5686274509803921,0.7764705882352941,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":59,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[-7,22],"ix":2},"a":{"a":0,"k":[-13.96,41.879],"ix":1},"s":{"a":0,"k":[85.962,85.962],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[678,678],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":4,"s":[0]},{"t":33,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":12,"s":[0]},{"t":40,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"st","c":{"a":0,"k":[0.403921568627451,0.7098039215686275,0.29411764705882354,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":59,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[6,15],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[85.962,85.962],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 2","np":4,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[678,678],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[0]},{"t":35,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":17,"s":[0]},{"t":43,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"st","c":{"a":0,"k":[0.5098039215686274,0.7529411764705882,0.4117647058823529,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":59,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[6,15],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[85.962,85.962],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 3","np":4,"cix":2,"bm":0,"ix":3,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":90,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"Loader comp","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[960,540,0],"ix":2},"a":{"a":0,"k":[960,540,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"tm":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"t":43,"s":[1.433]}],"ix":2,"x":"var $bm_rt;\n$bm_rt = loopOut('cycle');"},"w":1920,"h":1080,"ip":0,"op":313,"st":0,"bm":0}],"markers":[]}

src/components/common/AuthRoute.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { useSelector } from 'react-redux';
3+
import { Route, Redirect } from 'react-router-dom';
4+
import { SESSION } from '../../services';
5+
6+
function AuthRoute({ children, ...rest }) {
7+
const { recentlyVisitedUrl } = useSelector((state) => state.history);
8+
9+
if (SESSION.isLoggedIn()) {
10+
return (
11+
<Redirect
12+
to={{
13+
pathname: recentlyVisitedUrl,
14+
}}
15+
/>
16+
);
17+
} else {
18+
return <Route {...rest}>{children}</Route>;
19+
}
20+
}
21+
22+
export default AuthRoute;

src/components/common/FormDebug.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react';
2+
import { FormikConsumer } from 'formik';
3+
4+
export const Debug = () => (
5+
<div
6+
style={{
7+
margin: '3rem 0',
8+
borderRadius: 4,
9+
background: '#f6f8fa',
10+
11+
boxShadow: '0 0 1px #eee inset',
12+
}}
13+
>
14+
<div
15+
style={{
16+
textTransform: 'uppercase',
17+
fontSize: 11,
18+
borderTopLeftRadius: 4,
19+
borderTopRightRadius: 4,
20+
fontWeight: 500,
21+
padding: '.5rem',
22+
background: '#555',
23+
color: '#fff',
24+
letterSpacing: '1px',
25+
}}
26+
>
27+
Formik State
28+
</div>
29+
<FormikConsumer>
30+
{({ validationSchema, validate, onSubmit, ...rest }) => (
31+
<pre
32+
style={{
33+
fontSize: '.65rem',
34+
padding: '.25rem .5rem',
35+
overflowX: 'scroll',
36+
}}
37+
>
38+
{JSON.stringify(rest, null, 2)}
39+
</pre>
40+
)}
41+
</FormikConsumer>
42+
</div>
43+
);

src/components/common/Loader.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import { useSelector } from 'react-redux';
3+
import Lottie from 'react-lottie';
4+
import animationData from '../../assets/Loader.json';
5+
6+
export default function Loader() {
7+
const loader = useSelector((state) => state.api.showLoader);
8+
9+
const defaultOptions = {
10+
loop: true,
11+
autoplay: true,
12+
animationData: animationData,
13+
rendererSettings: {
14+
preserveAspectRatio: 'xMidYMid slice',
15+
},
16+
};
17+
18+
return (
19+
<>
20+
{loader && (
21+
<div className="loaderbox">
22+
<Lottie options={defaultOptions} height={128} width={128} />
23+
</div>
24+
)}
25+
</>
26+
);
27+
}

src/components/common/PrivateRoute.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React, { useEffect } from 'react';
2+
import { Route } from 'react-router-dom';
3+
import { Layout } from 'antd';
4+
import { useDispatch } from 'react-redux';
5+
import { SESSION } from '../../services';
6+
import { Sidebar } from '../common';
7+
8+
const { Content } = Layout;
9+
10+
function PrivateRoute({ children, location, ...rest }) {
11+
const dispatch = useDispatch();
12+
const { pathname } = location;
13+
14+
useEffect(() => {
15+
return () => {
16+
/**
17+
* to set last visited page url in redux store
18+
*/
19+
dispatch({
20+
type: 'SET_HISTORY_RECENT',
21+
payload: pathname,
22+
});
23+
};
24+
// eslint-disable-next-line react-hooks/exhaustive-deps
25+
}, [pathname]);
26+
27+
if (SESSION.isLoggedIn()) {
28+
return (
29+
<Layout>
30+
<Sidebar />
31+
<Content>
32+
<div className="p-10 height-100">
33+
<Route {...rest}>{children}</Route>
34+
</div>
35+
</Content>
36+
</Layout>
37+
);
38+
} else {
39+
SESSION.logout();
40+
}
41+
}
42+
43+
export default PrivateRoute;

src/components/common/Sidebar.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import React, { useState, useEffect } from 'react';
2+
import { Layout, Menu } from 'antd';
3+
import { NavLink, withRouter } from 'react-router-dom';
4+
import {
5+
PoweroffOutlined,
6+
FormOutlined,
7+
HighlightOutlined,
8+
} from '@ant-design/icons';
9+
import { SESSION } from '../../services';
10+
11+
const { Sider } = Layout;
12+
const { SubMenu } = Menu;
13+
14+
export function findUrlPathId(path) {
15+
switch (path) {
16+
case '/input':
17+
return '2';
18+
case '/dropdown':
19+
return '3';
20+
default:
21+
return '1';
22+
}
23+
}
24+
25+
function Sidebar(props) {
26+
const [collapsed, setCollapsed] = useState(false);
27+
const [key, setKey] = useState();
28+
29+
useEffect(() => {
30+
let path = props.location.pathname;
31+
const pathId = findUrlPathId(path);
32+
setKey(pathId);
33+
// eslint-disable-next-line react-hooks/exhaustive-deps
34+
}, [props.location.pathname]);
35+
36+
function onCollapse(collapsed) {
37+
setCollapsed(collapsed);
38+
}
39+
40+
const handleLogout = () => {
41+
SESSION.logout();
42+
};
43+
44+
return (
45+
<Sider collapsible collapsed={collapsed} onCollapse={onCollapse}>
46+
<>
47+
<Menu
48+
theme="dark"
49+
mode="inline"
50+
defaultSelectedKeys={[key]}
51+
selectedKeys={[key]}
52+
>
53+
<SubMenu
54+
key="sub2"
55+
title={
56+
<span>
57+
<FormOutlined />
58+
<span>Forms</span>
59+
</span>
60+
}
61+
>
62+
<Menu.Item key="2">
63+
<NavLink to="/input" />
64+
<HighlightOutlined />
65+
<span>Input</span>
66+
</Menu.Item>
67+
<Menu.Item key="3">
68+
<NavLink to="/dropdown" />
69+
<HighlightOutlined />
70+
<span>Dropdown</span>
71+
</Menu.Item>
72+
</SubMenu>
73+
<Menu.Item key="4" onClick={handleLogout}>
74+
<PoweroffOutlined />
75+
<span>Log Out</span>
76+
</Menu.Item>
77+
</Menu>
78+
</>
79+
</Sider>
80+
);
81+
}
82+
83+
export default withRouter(Sidebar);

0 commit comments

Comments
 (0)