-
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
9559c4f
commit 7d06384
Showing
21 changed files
with
923 additions
and
113 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
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 |
---|---|---|
@@ -1,18 +1,36 @@ | ||
import React from 'react'; | ||
import { Route, Switch } from 'react-router-dom'; | ||
import { useSelector } from 'react-redux'; | ||
import { Layout } from 'antd'; | ||
import 'antd/dist/antd.css'; | ||
|
||
import { NavBar, PrivateRoute } from './components'; | ||
import { Home, ApaKabar, Login } from './pages'; | ||
|
||
|
||
const { Header, Footer, Sider, Content } = Layout; | ||
|
||
const App = () => { | ||
const user = useSelector(state => state.UserReducer.User); | ||
return ( | ||
<div> | ||
<NavBar/> | ||
<Switch> | ||
<Route path='/login' component={Login} /> | ||
<PrivateRoute path={'/apa-kabar'} component={ApaKabar} /> | ||
<PrivateRoute exact path='/' component={Home}/> | ||
</Switch> | ||
</div> | ||
<Layout> | ||
{ user.token !== '' && <Header>Header</Header> } | ||
|
||
<Layout> | ||
{ user.token !== '' && <Sider><NavBar/></Sider> } | ||
|
||
<Content> | ||
<Switch> | ||
<Route path='/login' component={Login} /> | ||
<PrivateRoute path={'/apa-kabar'} component={ApaKabar} /> | ||
<PrivateRoute exact path='/' component={Home}/> | ||
</Switch> | ||
</Content> | ||
</Layout> | ||
|
||
{ user.token !== '' && <Footer>Footer</Footer> } | ||
|
||
</Layout> | ||
) | ||
} | ||
export default App; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
const App = { | ||
API: { | ||
URL: 'https://localhost' | ||
} | ||
}; | ||
|
||
export default App; | ||
|
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,9 @@ | ||
const logo = require('../assets/images/logo.png'); | ||
const loginBg = require('../assets/images/loginBg.png'); | ||
|
||
const Images = { | ||
logo, | ||
loginBg | ||
}; | ||
|
||
export default Images; |
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 Images from './images'; | ||
import App from './App'; | ||
|
||
export { Images, App }; |
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
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 |
---|---|---|
@@ -1,34 +1,95 @@ | ||
import { useEffect, useCallback } from 'react'; | ||
import { useHistory, useLocation } from 'react-router-dom'; | ||
import { useEffect, useCallback, useState } from 'react'; | ||
import { useHistory, useLocation, Link } from 'react-router-dom'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { Row, Col, Form, Input, Button } from 'antd'; | ||
import { actions } from '../../store'; | ||
|
||
// import { FakeAuth } from '../../components'; | ||
import { Images } from '../../constant'; | ||
import { ImgBg, DivLogoContainer, DivForm } from './style'; | ||
|
||
const App = () => { | ||
const history = useHistory(); | ||
const user = useSelector(state => state.UserReducer.User); | ||
const dispatch = useDispatch(); | ||
const { state } = useLocation(); | ||
const { from } = state || { from: { pathname: '/' } }; | ||
|
||
const login = useCallback(() => { | ||
dispatch(actions.UserAction.Login); | ||
}, [dispatch]); | ||
|
||
const [username, setUsername] = useState(''); | ||
const [password, setPassword] = useState(''); | ||
|
||
const login = useCallback((event) => { | ||
event.preventDefault(); | ||
dispatch(actions.UserAction.Login({username, password})); | ||
}, [dispatch, password, username]); | ||
|
||
useEffect(() => { | ||
if (user.token !== '') { | ||
history.push(from); | ||
} | ||
}, | ||
[user.token, from, history]); | ||
|
||
const onChangeUsername = useCallback((event) => { | ||
setUsername(event.target.value); | ||
}, []); | ||
|
||
const onChangePassword = useCallback((event) => { | ||
setPassword(event.target.value); | ||
}, []); | ||
|
||
|
||
return ( | ||
<div> | ||
<h1>Login</h1> | ||
<p>You must log in to view the page at {from.pathname}</p> | ||
<button onClick={login}>Login</button> | ||
</div>); | ||
<Row> | ||
<Col span={12}> | ||
<ImgBg src={ Images.loginBg.default } alt='erp' /> | ||
<DivLogoContainer> | ||
<img src={ Images.logo.default } alt='logo'/> | ||
</DivLogoContainer> | ||
</Col> | ||
|
||
<Col span={12}> | ||
<DivForm> | ||
<Form name='basic'> | ||
<h3>Aplikasi ERP Lion Head Corp</h3> | ||
<div className='input-form'> | ||
<label>Username</label> | ||
<Form.Item | ||
name='username' | ||
rules={ [{ | ||
required: true, | ||
message: 'Silahkan isi username!', | ||
}] } | ||
> | ||
<Input value={username} onChange={onChangeUsername} className='base-input' /> | ||
</Form.Item> | ||
</div> | ||
|
||
<div className='input-form'> | ||
<label>Password</label> | ||
<Form.Item | ||
name='password' | ||
rules={ [{ | ||
required: true, | ||
message: 'Silahkan isi password!', | ||
},] } | ||
> | ||
<Input.Password value={password} onChange={onChangePassword} /> | ||
</Form.Item> | ||
</div> | ||
|
||
<div className='footer-form'> | ||
<Form.Item> | ||
<Button type='primary' htmlType='submit' onClick={ login }>Login</Button> | ||
</Form.Item> | ||
|
||
<Form.Item> | ||
<Link to=''>Lupa Password ?</Link> | ||
</Form.Item> | ||
</div> | ||
</Form> | ||
</DivForm> | ||
</Col> | ||
</Row> | ||
); | ||
} | ||
|
||
export default App; |
Oops, something went wrong.