Commit bfad4ca8 authored by faisalhamdi's avatar faisalhamdi

merge master

parents 8b97e209 42e2449f
......@@ -65,6 +65,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
const login = (body) => api.post('auth/login', body)
const resetPassword = (body) => api.post('auth/reset_password', body)
const verification = (body) => api.post('email/reset_password', body)
const isResetPassword = (userId) => api.post(`auth/is_reset_password/${userId}`)
//Role
const getRole = () => api.get('role/get_all_role')
......@@ -85,6 +86,8 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
// Perusahaan
const getCompany = () => api.get('company/get_all_company')
// APPROVAL MATRIX
const getAM = () => api.get('approval_matrix/get_all_approval_matrix')
// ------
// STEP 3
......@@ -104,6 +107,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
login,
verification,
resetPassword,
isResetPassword,
getRole,
getDetailRole,
searchRole,
......@@ -115,6 +119,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
createUnitBisnis,
updateUnitBisnis,
searchUnitBisnis,
getAM,
getCompany
}
}
......
......@@ -103,7 +103,7 @@
background-color: #fff; }
.app-popup-show {
display: flex;
z-index: 2000;
z-index: 1290;
-webkit-transition: all 0.35s cubic-bezier(0, 1, 0.5, 1);
-moz-transition: all 0.35s cubic-bezier(0, 1, 0.5, 1);
-ms-transition: all 0.35s cubic-bezier(0, 1, 0.5, 1);
......@@ -22,12 +22,12 @@ class Login extends Component {
constructor(props) {
super(props)
this.state = {
username: '',
email: '',
password: '',
showPass: false,
errorUsername: false,
errorEmail: false,
errorPassword: false,
msgUsername: '',
msgEmail: '',
msgPassword: ''
}
}
......@@ -39,16 +39,25 @@ class Login extends Component {
handleChange(e) {
let data = this.state
this.setState({...data, [e.target.name] : e.target.value})
if (e.target.name == "username") {
this.setState({ errorUsername: false, msgUsername: '' })
if (e.target.name == "email") {
this.setState({ errorEmail: false, msgEmail: '' })
} else if (e.target.name) {
this.setState({ errorPassword: false, msgPassword: '' })
}
}
isEmail(email) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
validateLogin() {
if (this.state.username.trim() == "") {
this.setState({ errorUsername: true, msgUsername: 'Username harus diisi!' })
var isEmail = this.isEmail(this.state.email)
if (this.state.email.trim() == "") {
this.setState({ errorEmail: true, msgEmail: 'Email harus diisi!' })
} else if (!isEmail) {
this.setState({ errorEmail: true, msgEmail: 'Format email tidak sesuai!' })
} else if (this.state.password.trim() == "") {
this.setState({ errorPassword: true, msgPassword: 'Password harus diisi!' })
} else {
......@@ -58,7 +67,7 @@ class Login extends Component {
login() {
let payload = {
"username": this.state.username,
"email": this.state.email,
"password": this.state.password
}
api.create().login(payload).then((response) => {
......@@ -69,7 +78,7 @@ class Login extends Component {
if (response.data.message == 'Password Salah!') {
this.setState({ errorPassword: true, msgPassword: response.data.message })
} else {
this.setState({ errorUsername: true, msgUsername: response.data.message })
this.setState({ errorEmail: true, msgEmail: response.data.message })
}
}
})
......@@ -87,18 +96,18 @@ class Login extends Component {
<img src={Images.tia} />
<TextField
label={<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Username/Email *</Typography>}
id="username"
label={<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Email *</Typography>}
id="email"
type={"text"}
name={"username"}
value={this.state.username}
onChange={(username) => {
this.handleChange(username)
name={"email"}
value={this.state.email}
onChange={(email) => {
this.handleChange(email)
}}
variant="outlined"
error={this.state.errorUsername}
error={this.state.errorEmail}
style={{ width: '100%', height: 51, marginTop: 32, fontSize: 14 }}
helperText={this.state.msgUsername}
helperText={this.state.msgEmail}
InputProps={{
endAdornment: <InputAdornment position="end"><img src={Images.email} /></InputAdornment>,
}}
......@@ -115,7 +124,7 @@ class Login extends Component {
}}
variant="outlined"
error={this.state.errorPassword}
style={{ width: '100%', height: 51, marginTop: this.state.errorUsername ? 35 : 20 }}
style={{ width: '100%', height: 51, marginTop: this.state.errorEmail ? 35 : 20 }}
helperText={this.state.msgPassword}
InputProps={{
endAdornment: <InputAdornment position="end">
......@@ -136,7 +145,7 @@ class Login extends Component {
<span style={{ color: 'rgba(0, 0, 0, 0.5)', fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Remember Me</span>
<Link to={{pathname: '/forgot-password'}} style={{textDecoration: 'none'}}><span style={{marginLeft: 30, color: '#51c6ea', cursor: 'pointer', fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Lupa Kata Sandi?</span></Link>
</div>
<Button name="submit" variant="contained" disabled={this.state.username.trim() == '' && this.state.password.trim() == '' ? true : false} onClick={() => this.validateLogin()} style={{ marginTop: 23, width: '100%', height: 35, borderRadius: 4, color: this.state.username.trim() == '' && this.state.password.trim() == '' ? '#4b4b4b' : '#fff', backgroundColor: this.state.username.trim() == '' && this.state.password.trim() == '' ? '#d8d8d8' : '#51c6ea' }}>
<Button name="submit" variant="contained" disabled={this.state.email.trim() == '' && this.state.password.trim() == '' ? true : false} onClick={() => this.validateLogin()} style={{ marginTop: 23, width: '100%', height: 35, borderRadius: 4, color: this.state.email.trim() == '' && this.state.password.trim() == '' ? '#4b4b4b' : '#fff', backgroundColor: this.state.email.trim() == '' && this.state.password.trim() == '' ? '#d8d8d8' : '#51c6ea' }}>
<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Login</Typography>
</Button>
</div>
......
......@@ -8,6 +8,7 @@ import AddRole from './UserRole/AddRole';
import EditRole from './UserRole/EditRole'
import api from "../../api";
import { titleCase } from "../../library/Utils";
import { InputAdornment, TextField } from "@material-ui/core";
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
......@@ -148,16 +149,42 @@ export default class UserRole extends Component {
<div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} />
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', width: '20%', alignSelf: 'center'}}>Master Data - Role & Otorisasi</label>
<label style={{ fontFamily: 'nunito', color: 'white', width: '20%', alignSelf: 'center', fontSize: 18}}>Master Data - User</label>
<div style={{width: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}>
<div style={{width: '50%', backgroundColor:'white', padding: 10, borderRadius: 7.5, flexDirection: 'row', display: 'flex'}}>
<SearchIcon/>
<input type="text" placeholder={'Search Role'} style={{flexGrow: 1, marginLeft: 10}}/>
<div style={{width: '50%', backgroundColor:'white', padding: 10, borderRadius: 7.5}}>
<TextField
id="input-with-icon-textfield"
name="search"
value={this.state.search}
placeholder={'Search'}
onChange={(e) => {
this.setState({ search: e.target.value }, () => {
if (this.state.search.length > 0) {
this.searchRole()
} else {
this.getRole()
}
});
}}
onKeyDown={(e) => this._handleKeyDown(e)}
style={{width: '100%', borderBottomWidth: 0, borderBottomColor: 'red'}}
InputProps={{
style: { fontFamily: 'nunito', borderBottomColor: 'white'},
startAdornment: (
<InputAdornment position="start">
<SearchIcon />
</InputAdornment>
),
}}
/>
</div>
</div>
{/* <label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> */}
<div style={{ width: '20%', justifyContent: 'flex-end', display: 'flex' }}>
<img src={Images.add} onClick={() => this.setState({add: true})}/>
<img src={Images.template}/>
<img src={Images.upload} style={{marginLeft: 20}}/>
<img src={Images.download} style={{marginLeft: 20}}/>
<img src={Images.add} onClick={() => this.setState({add: true})} style={{marginLeft: 20}}/>
</div>
</div>
<div style={{ padding: 25 }}>
......
......@@ -184,19 +184,12 @@ class UserRole extends Component {
<label style={{ fontFamily: 'nunito', color: 'white', width: '20%', alignSelf: 'center', fontSize: 18}}>Master Data - Role & Otorisasi</label>
<div style={{width: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}>
<div style={{width: '50%', backgroundColor:'white', padding: 10, borderRadius: 7.5}}>
{/* <SearchIcon/> */}
<TextField
// className={classes.margin}
id="input-with-icon-textfield"
// label="TextField"
name="search"
value={this.state.search}
placeholder={'Search Role'}
placeholder={'Search'}
onChange={(e) => {
// let { search } = this.state;
// search = [...search];
// search.push(e.target.value);
// search[0] = search;
this.setState({ search: e.target.value }, () => {
if (this.state.search.length > 0) {
this.searchRole()
......
......@@ -235,6 +235,7 @@ export default class AddRole extends Component {
format="dd MMMM yyyy"
value={this.state.endDate}
onChange={(e) => this.handleChange(e, 'end_date')}
minDate={this.state.startDate}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
......
......@@ -247,6 +247,7 @@ export default class EditRole extends Component {
label="Berlaku Hingga"
format="dd MMMM yyyy"
value={this.state.tempData == null ? null : this.state.tempData.end_date}
minDate={this.state.tempData == null ? null : this.state.tempData.start_date}
onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
......
......@@ -26,18 +26,51 @@ class ResetPassword extends Component {
console.log(this.props.match.params.id)
let userId = this.props.match.params.id
this.setState({userId})
this.checkExpiredLink(userId)
// console.log(this.props)
}
checkExpiredLink(userId) {
api.create().isResetPassword(userId).then((response) => {
if (response.data.status == 'success') {
//
} else {
alert(response.data.message)
this.props.history.push('/login')
}
})
}
isRegex(value) {
// const re = /^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/;
const re = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{1,}$/;
return re.test(String(value));
}
isEmail(email) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
validateReset() {
if (this.state.password.trim() == "") {
this.setState({ errorPassword: true, msgPassword: 'Password harus diisi!' })
this.setState({ errorPassword: true, msgPassword: 'Kata sandi harus diisi!' })
} else if (this.state.password.length < 8) {
this.setState({ errorPassword: true, msgPassword: 'Password minimal 8 karakter!' })
this.setState({ errorPassword: true, msgPassword: 'Kata sandi minimal 8 karakter!' })
} else if (this.isEmail(this.state.password)) {
this.setState({ errorPassword: true, msgPassword: 'Format kata sandi tidak boleh menggunakan email!' })
} else if (!this.isRegex(this.state.password)) {
this.setState({ errorPassword: true, msgPassword: 'Kata sandi harus berupa kombinasi karakter, huruf dan angka!' })
} else if (this.state.confirmPassword.trim() == "") {
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Konfirmasi Password harus diisi!' })
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Konfirmasi kata sandi harus diisi!' })
} else if (this.state.confirmPassword.length < 8) {
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Konfirmasi Password minimal 8 karakter!' })
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Konfirmasi kata sandi minimal 8 karakter!' })
} else if (this.isEmail(this.state.confirmPassword)) {
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Format konfirmasi kata sandi tidak boleh menggunakan email!' })
} else if (!this.isRegex(this.state.confirmPassword)) {
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Konfirmasi kata sandi harus berupa kombinasi karakter, huruf dan angka!' })
} else if (this.state.password !== this.state.confirmPassword) {
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Konfirmasi kata sandi harus sama dengan kata sandi!' })
} else {
this.confirmPassword()
}
......@@ -113,7 +146,7 @@ class ResetPassword extends Component {
}}
variant="outlined"
error={this.state.errorConfirmPassword}
style={{ width: 250, height: 51, marginTop: 40 }}
style={{ width: 250, height: 51, marginTop: 45 }}
helperText={<Typography style={{fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif'}}>{this.state.msgConfirmPassword}</Typography>}
InputProps={{
endAdornment: <InputAdornment position="end">
......@@ -129,7 +162,7 @@ class ResetPassword extends Component {
}}
/>
<Button name="submit" variant="contained" disabled={this.state.password.trim() == '' && this.state.confirmPassword.trim() == '' ? true : false} onClick={() => this.validateReset()} style={{ marginTop: 40, width: '100%', height: 35, borderRadius: 4, color: this.state.password.trim() == '' && this.state.confirmPassword.trim() == '' ? '#4b4b4b' : '#fff', backgroundColor: this.state.password.trim() == '' && this.state.confirmPassword.trim() == '' ? '#d8d8d8' : '#51c6ea' }}>
<Button name="submit" variant="contained" disabled={this.state.password.trim() == '' && this.state.confirmPassword.trim() == '' ? true : false} onClick={() => this.validateReset()} style={{ marginTop: 50, width: '100%', height: 35, borderRadius: 4, color: this.state.password.trim() == '' && this.state.confirmPassword.trim() == '' ? '#4b4b4b' : '#fff', backgroundColor: this.state.password.trim() == '' && this.state.confirmPassword.trim() == '' ? '#d8d8d8' : '#51c6ea' }}>
<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Lanjut</Typography>
</Button>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment