This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdad002
commit 3e8bd1e
Showing
21 changed files
with
3,073 additions
and
1,491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
coverage/* | ||
dist/ | ||
node_modules/ | ||
jest.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true, | ||
"jest": true | ||
}, | ||
"extends": [ | ||
"airbnb", | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": 12, | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["react", "prettier"], | ||
"rules": { | ||
"react/react-in-jsx-scope": "off", | ||
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], | ||
"comma-dangle": "off", | ||
"array-callback-return": "off", | ||
"no-param-reassign": "off", | ||
"import/no-named-as-default": 0, | ||
"import/no-named-as-default-member": 0, | ||
"import/prefer-default-export": "off", | ||
"react/jsx-props-no-spreading": "off", | ||
"arrow-parens": "off", | ||
"no-alert": 0, | ||
"no-console": 0, | ||
"linebreak-style": 0, | ||
"prettier/prettier": [ | ||
"error", | ||
{ | ||
"printWidth": 120, | ||
"trailingComma": "es5", | ||
"jsxSingleQuote": true, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"bracketSpacing": true, | ||
"jsxBracketSameLine": true, | ||
"semi": true | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"*.+(js|jsx)": ["eslint --fix", "git add"], | ||
"*.+(json|css|md)": ["prettier --write", "git add"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,19 @@ | ||
import logo from './logo.svg'; | ||
import './App.css'; | ||
import React from 'react'; | ||
import { Switch, Route } from 'react-router-dom'; | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.js</code> and save to reload. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
); | ||
} | ||
import ProtectedRoute from './routes/ProtectedRoute'; | ||
import Login from './components/Login'; | ||
import ROUTES from './routes/Routes'; | ||
import './App.scss'; | ||
|
||
const App = () => ( | ||
<Switch> | ||
<Route path='/login' exact component={Login} /> | ||
{ROUTES.map((route) => ( | ||
<ProtectedRoute key={route.key} {...route} /> | ||
))} | ||
<Route component={() => <h1>Not Found!</h1>} /> | ||
</Switch> | ||
); | ||
|
||
export default App; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { render } from '@testing-library/react'; | ||
import App from './App'; | ||
|
||
test('renders learn react link', () => { | ||
render(<App />); | ||
const linkElement = screen.getByText(/learn react/i); | ||
expect(linkElement).toBeInTheDocument(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import React from 'react'; | ||
|
||
const Example = () => <h1>hi Example</h1>; | ||
export default Example; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import React from 'react'; | ||
|
||
const Login = () => <h1>hi Login</h1>; | ||
export default Login; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import React from 'react'; | ||
|
||
const Page = () => <h1>hi page</h1>; | ||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import './index.css'; | ||
import { Provider } from 'react-redux'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
|
||
import App from './App'; | ||
import reportWebVitals from './reportWebVitals'; | ||
import initializeStore from './store'; | ||
|
||
import 'bootstrap/dist/css/bootstrap.css'; | ||
import './index.scss'; | ||
|
||
ReactDOM.render( | ||
<React.StrictMode> | ||
<App /> | ||
<BrowserRouter> | ||
<Provider store={initializeStore()}> | ||
<App /> | ||
</Provider> | ||
</BrowserRouter> | ||
</React.StrictMode>, | ||
document.getElementById('root') | ||
); | ||
|
||
// If you want to start measuring performance in your app, pass a function | ||
// to log results (for example: reportWebVitals(console.log)) | ||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals | ||
reportWebVitals(); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* eslint-disable no-param-reassign */ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
|
||
const slice = createSlice({ | ||
name: 'discussions', | ||
initialState: { | ||
appIds: [], | ||
status: '', | ||
}, | ||
reducers: { | ||
selectApp: (state, { payload }) => { | ||
const { appId } = payload; | ||
state.selectedAppId = appId; | ||
}, | ||
updateStatus: (state, { payload }) => { | ||
const { status } = payload; | ||
state.status = status; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { loadApps, selectApp, updateStatus } = slice.actions; | ||
|
||
export const { reducer } = slice; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { combineReducers } from 'redux'; | ||
import { reducer as exampleReducer } from './exampleReducer'; | ||
|
||
const rootReducer = combineReducers({ | ||
exampleReducer, | ||
}); | ||
|
||
export default rootReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import { Route, Redirect } from 'react-router-dom'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const ProtectedRoute = ({ isAuth, component: Component, ...rest }) => { | ||
console.log('route', { ...rest }); | ||
return ( | ||
<Route | ||
{...rest} | ||
render={(props) => { | ||
if (isAuth) { | ||
return <Component {...props} />; | ||
} | ||
return <Redirect to={{ pathname: '/login', state: { from: props.location } }} />; | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
ProtectedRoute.propTypes = { | ||
isAuth: PropTypes.bool, | ||
component: PropTypes.elementType.isRequired, | ||
location: PropTypes.instanceOf(Object), | ||
}; | ||
|
||
ProtectedRoute.defaultProps = { | ||
isAuth: false, | ||
location: {}, | ||
}; | ||
|
||
export default ProtectedRoute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Example from '../components/Example'; | ||
import Page from '../components/Page'; | ||
|
||
const ROUTES = [ | ||
{ | ||
path: '/app', | ||
key: 'APP', | ||
exact: true, | ||
component: Example, | ||
}, | ||
{ | ||
path: '/app/page', | ||
key: 'APP_PAGE', | ||
exact: true, | ||
component: Page, | ||
}, | ||
]; | ||
|
||
export default ROUTES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import logger from 'redux-logger'; | ||
|
||
import rootReducer from './reducers/rootReducer'; | ||
|
||
export const initializeStore = () => | ||
configureStore({ | ||
reducer: rootReducer, | ||
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(logger), | ||
}); | ||
|
||
export default initializeStore; |
Oops, something went wrong.