Commit 0eb344cf authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'syadziy' into 'master'

Syadziy

See merge request !131
parents 5aa6d230 0f383c22
import React, { Component } from 'react';
import Images from '../assets/Images';
import { TextField, InputAdornment, Button, Typography } from '@material-ui/core';
import { TextField, InputAdornment, Button, Typography, Snackbar } from '@material-ui/core';
import api from '../api';
import Constant from '../library/Constant';
import MuiAlert from '@material-ui/lab/Alert';
import { withStyles } from '@material-ui/core/styles';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
class ForgotPassword extends Component {
constructor(props) {
......@@ -11,7 +15,10 @@ class ForgotPassword extends Component {
this.state = {
email: '',
errorEmail: false,
msgEmail: ''
msgEmail: '',
alert: false,
tipeAlert: '',
messageAlert: ''
}
}
......@@ -46,18 +53,35 @@ class ForgotPassword extends Component {
"email": this.state.email
}
api.create().verification(payload).then((response) => {
if(response.data.status === 'success') {
this.props.history.push('/email-verification')
if (response.data) {
if (response.ok) {
if(response.data.status === 'success') {
this.props.history.push('/email-verification')
} else {
this.setState({ errorEmail: true, msgEmail: response.data.message })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ errorEmail: true, msgEmail: response.data.message })
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
closeAlert() {
this.setState({ alert: false })
}
render() {
return (
<div style={{ flex: 1, display: 'flex', backgroundColor: '#152d40', height: '100vh', justifyContent: 'center', alignItems: 'center' }}>
<div style={{padding: 60, display: 'flex', flexDirection: 'column', width: 378, height: 351, borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff', justifyContent: 'center', alignItems: 'center' }}>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div style={{padding: 60, display: 'flex', flexDirection: 'column', width: (this.state.msgEmail.length > 45 ? 403 : 378), height: 351, borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff', justifyContent: 'center', alignItems: 'center' }}>
<img src={Images.tia} />
<TextField
......@@ -78,7 +102,7 @@ class ForgotPassword extends Component {
}}
/>
<Button name="submit" variant="contained" disabled={this.state.email.trim() === '' ? true : false} onClick={() => this.validateEmail()} style={{ marginTop: this.state.errorEmail ? 35 : 23, width: '100%', height: 30, borderRadius: 4, color: this.state.email.trim() === '' ? '#4b4b4b' : '#fff', backgroundColor: this.state.email.trim() === '' ? '#d8d8d8' : '#51c6ea' }}>
<Button name="submit" variant="contained" disabled={this.state.email.trim() === '' ? true : false} onClick={() => this.validateEmail()} style={{ marginTop: this.state.errorEmail ? (this.state.msgEmail.length > 45 ? 60 : 35) : 23, width: '100%', height: 30, borderRadius: 4, color: this.state.email.trim() === '' ? '#4b4b4b' : '#fff', backgroundColor: this.state.email.trim() === '' ? '#d8d8d8' : '#51c6ea' }}>
<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Lanjut</Typography>
</Button>
......
import React, { Component } from 'react';
import Images from '../assets/Images';
import { Checkbox, Button, InputAdornment, TextField, InputLabel, Typography, IconButton } from '@material-ui/core';
import { Checkbox, Button, InputAdornment, TextField, Typography, IconButton, Snackbar } from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles';
import Visibility from '@material-ui/icons/Visibility';
import VisibilityOff from '@material-ui/icons/VisibilityOff';
import MuiAlert from '@material-ui/lab/Alert';
import api from '../api';
import Constant from '../library/Constant';
import { Link } from 'react-router-dom';
......@@ -18,6 +19,9 @@ const CustomCheckbox = withStyles({
checked: {},
})((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
class Login extends Component {
constructor(props) {
super(props)
......@@ -29,7 +33,10 @@ class Login extends Component {
errorPassword: false,
msgEmail: '',
msgPassword: '',
rememberMe: false
rememberMe: false,
alert: false,
tipeAlert: '',
messageAlert: ''
}
}
......@@ -68,6 +75,10 @@ class Login extends Component {
}
}
closeAlert() {
this.setState({ alert: false })
}
login() {
console.log('login');
let payload = {
......@@ -76,28 +87,32 @@ class Login extends Component {
}
api.create().login(payload).then((response) => {
if (response.data) {
if (response.data.status === 'success') {
console.log(response.data.data)
localStorage.setItem(Constant.TOKEN, response.data.data.token)
localStorage.setItem(Constant.USER, response.data.data.user_id)
if (this.state.rememberMe) {
localStorage.setItem(Constant.EMAIL, this.state.email)
localStorage.setItem(Constant.PASSWORD, this.state.password)
// console.log(this.state.email, this.state.password)
} else {
localStorage.setItem(Constant.EMAIL, '')
localStorage.setItem(Constant.PASSWORD, '')
}
this.props.history.push('/home/beranda')
if (response.ok) {
if (response.data.status === 'success') {
console.log(response.data.data)
localStorage.setItem(Constant.TOKEN, response.data.data.token)
localStorage.setItem(Constant.USER, response.data.data.user_id)
if (this.state.rememberMe) {
localStorage.setItem(Constant.EMAIL, this.state.email)
localStorage.setItem(Constant.PASSWORD, this.state.password)
// console.log(this.state.email, this.state.password)
} else {
localStorage.setItem(Constant.EMAIL, '')
localStorage.setItem(Constant.PASSWORD, '')
}
this.props.history.push('/home/beranda')
} else {
if (response.data.message == 'Kata sandi tidak sesuai.') {
this.setState({ errorPassword: true, msgPassword: response.data.message })
} else {
this.setState({ errorEmail: true, msgEmail: response.data.message })
}
}
} else {
if (response.data.message == 'Kata sandi tidak sesuai.') {
this.setState({ errorPassword: true, msgPassword: response.data.message })
} else {
this.setState({ errorEmail: true, msgEmail: response.data.message })
}
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.problem)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -116,6 +131,11 @@ class Login extends Component {
render() {
return (
<div style={{ flex: 1, display: 'flex' }}>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div style={{ width: '50%', height: '100vh', display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}>
<img src={Images.tia} />
<img src={Images.imageLogin} style={{ marginTop: 30 }} />
......
......@@ -7,8 +7,10 @@ import AddUser from './User/AddUser';
import EditUser from './User/EditUser'
import api from "../../api";
import { titleCase } from "../../library/Utils";
import { InputAdornment, TextField, InputBase } from "@material-ui/core";
import { InputAdornment, Snackbar, InputBase } from "@material-ui/core";
import MuiAlert from '@material-ui/lab/Alert';
import UploadFile from "../../library/Upload";
import { withStyles } from '@material-ui/core/styles';
import { ExcelRenderer } from 'react-excel-renderer';
import ReactTooltip from "react-tooltip";
import PopUpFailedSave from "../../library/PopUpFailedSave";
......@@ -17,6 +19,9 @@ var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class UserRole extends Component {
constructor(props) {
super(props)
......@@ -27,6 +32,9 @@ export default class UserRole extends Component {
edit: false,
visibleUser: true,
buttonError: false,
alert: false,
tipeAlert: '',
messageAlert: ''
}
}
......@@ -44,14 +52,22 @@ export default class UserRole extends Component {
getUser() {
api.create().getUser().then((response) => {
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.sort((a, b) => a.user_id - b.user_id).map((item, index) => {
return [index, item.user_id, item.fullname === null ? '-' : item.fullname, item.email, item.role_name, item.totalCompany, item.status]
})
this.setState({ listUser: listData })
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.sort((a, b) => a.user_id - b.user_id).map((item, index) => {
return [index, item.user_id, item.fullname === null ? '-' : item.fullname, item.email, item.role_name, item.totalCompany, item.status]
})
this.setState({ listUser: listData })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -61,14 +77,22 @@ export default class UserRole extends Component {
"keyword": this.state.search
}
api.create().searchUser(payload).then((response) => {
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.sort((a, b) => a.user_id - b.user_id).map((item, index) => {
return [index, item.user_id, item.fullname == null ? '-' : item.fullname, item.email, item.role_name, item.totalCompany, item.status]
})
this.setState({ listUser: listData })
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.sort((a, b) => a.user_id - b.user_id).map((item, index) => {
return [index, item.user_id, item.fullname == null ? '-' : item.fullname, item.email, item.role_name, item.totalCompany, item.status]
})
this.setState({ listUser: listData })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -281,16 +305,28 @@ export default class UserRole extends Component {
uploadUser() {
api.create().uploadUser(this.state.payload).then(response => {
if (response.data) {
if (response.data.status === "success") {
console.log(response)
alert(response.data.message)
this.getUser()
this.setState({ visibleUser: true })
if (response.ok) {
if (response.data.status === "success") {
console.log(response)
alert(response.data.message)
this.getUser()
this.setState({ visibleUser: true })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
closeAlert() {
this.setState({ alert: false })
}
render() {
const columns = [{
name: "Action",
......@@ -388,6 +424,11 @@ export default class UserRole extends Component {
<div style={{ height: this.props.height }}>
{/* <Row> */}
<div className={"main-color"} style={{ height: 199, width: '100%' }} />
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
{this.state.visibleUser ? <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - User</label>
......
import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse, Snackbar } from '@material-ui/core';
import api from '../../../api';
import Autocomplete from '@material-ui/lab/Autocomplete';
import { titleCase } from '../../../library/Utils';
......@@ -10,6 +10,7 @@ import AddIcon from '@material-ui/icons/Add';
import { DatePicker } from '@material-ui/pickers';
import * as R from 'ramda'
import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert';
const CustomCheckbox = withStyles({
root: {
......@@ -31,6 +32,9 @@ const CustomCheckboxDisabled = withStyles({
checked: {},
})((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class AddUser extends Component {
constructor(props) {
......@@ -60,6 +64,9 @@ export default class AddUser extends Component {
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
alert: false,
tipeAlert: '',
messageAlert: ''
}
}
......@@ -169,8 +176,22 @@ export default class AddUser extends Component {
api.create().createUser(payload).then((response) => {
// console.log(response)
// if (String(response.data.status).toLocaleUpperCase === 'Success' || String(response.data.status).toLocaleUpperCase === 'success') {
this.props.onClickClose()
this.props.refresh()
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.props.onClickClose()
this.props.refresh()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
// } else {
// alert(response.data.message)
// this.props.onClickClose()
......@@ -181,30 +202,48 @@ export default class AddUser extends Component {
getRole() {
api.create().getRoleActive().then((response) => {
if (response.data.status === 'success') {
let data = response.data.data
let roleData = data.map((item) => {
return {
role_id: item.role_id,
role_name: item.role_name
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let roleData = data.map((item) => {
return {
role_id: item.role_id,
role_name: item.role_name
}
})
let defaultProps = {
options: roleData,
getOptionLabel: (option) => titleCase(option.role_name),
};
this.setState({ listRole: defaultProps })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
})
let defaultProps = {
options: roleData,
getOptionLabel: (option) => titleCase(option.role_name),
};
this.setState({ listRole: defaultProps })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => {
if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data })
console.log(response.data.data)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data })
console.log(response.data.data)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -327,9 +366,18 @@ export default class AddUser extends Component {
return false;
};
closeAlert() {
this.setState({ alert: false })
}
render() {
return (
<div className="test app-popup-show">
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
......
import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse, Snackbar } from '@material-ui/core';
import api from '../../../api';
import { titleCase } from '../../../library/Utils';
import Autocomplete from '@material-ui/lab/Autocomplete';
......@@ -9,6 +9,7 @@ import RemoveIcon from '@material-ui/icons/Remove';
import AddIcon from '@material-ui/icons/Add';
import * as R from 'ramda'
import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert';
const CustomCheckbox = withStyles({
root: {
......@@ -30,6 +31,9 @@ const CustomCheckboxDisabled = withStyles({
checked: {},
})((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class EditUser extends Component {
constructor(props) {
......@@ -54,6 +58,9 @@ export default class EditUser extends Component {
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
alert: false,
tipeAlert: '',
messageAlert: ''
}
}
......@@ -117,11 +124,19 @@ export default class EditUser extends Component {
getDetailUser() {
api.create().getDetailUser(this.state.paramsId).then((response) => {
this.getRole()
if (response.data.status === 'success') {
this.setState({ tempData: response.data.data, company: response.data.data.company })
console.log(response.data.data)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ tempData: response.data.data, company: response.data.data.company })
console.log(response.data.data)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -168,34 +183,51 @@ export default class EditUser extends Component {
}
api.create().updateUser(payload).then((response) => {
if (response.data.status === 'success') {
this.props.onClickClose()
this.props.refresh()
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.props.onClickClose()
this.props.refresh()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getRole() {
api.create().getRoleActive().then((response) => {
if (response.data.status === 'success') {
let data = response.data.data
let roleData = data.map((item) => {
return {
role_id: item.role_id,
role_name: item.role_name
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let roleData = data.map((item) => {
return {
role_id: item.role_id,
role_name: item.role_name
}
})
let defaultProps = {
options: roleData,
getOptionLabel: (option) => titleCase(option.role_name),
};
let index = roleData.findIndex((val) => val.role_id === this.state.tempData.role_id)
this.setState({ listRole: defaultProps, role: index === -1 ? roleData[0] : roleData[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
})
let defaultProps = {
options: roleData,
getOptionLabel: (option) => titleCase(option.role_name),
};
let index = roleData.findIndex((val) => val.role_id === this.state.tempData.role_id)
this.setState({ listRole: defaultProps, role: index === -1 ? roleData[0] : roleData[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -203,11 +235,17 @@ export default class EditUser extends Component {
getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => {
if (response.data) {
if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data })
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.problem)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -330,9 +368,18 @@ export default class EditUser extends Component {
return false;
};
closeAlert() {
this.setState({ alert: false })
}
render() {
return (
<div className="test app-popup-show">
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
......
......@@ -9,12 +9,18 @@ import api from "../../api";
import { titleCase } from "../../library/Utils";
import InputAdornment from '@material-ui/core/InputAdornment';
import TextField from '@material-ui/core/TextField';
import { InputBase } from "@material-ui/core";
import { InputBase, Snackbar } from "@material-ui/core";
import ReactTooltip from "react-tooltip";
import MuiAlert from '@material-ui/lab/Alert';
import { withStyles } from '@material-ui/core/styles';
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
class UserRole extends Component {
constructor(props) {
super(props)
......@@ -23,7 +29,10 @@ class UserRole extends Component {
indexData: {},
add: false,
edit: false,
search: ''
search: '',
alert: false,
tipeAlert: '',
messageAlert: ''
}
}
......@@ -41,22 +50,28 @@ class UserRole extends Component {
getRole() {
api.create().getRole().then((response) => {
// console.log(response)
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.sort((a, b) => a.role_id - b.role_id).map((item, index) => {
return [index, item.role_id, item.role_name, item.access, item.status]
})
// console.log(listData)
this.setState({ listRole: listData })
// this.setState({listRole: response.data.data}, () => {
// console.log(this.state.listRole)
// })
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.sort((a, b) => a.role_id - b.role_id).map((item, index) => {
return [index, item.role_id, item.role_name, item.access, item.status]
})
// console.log(listData)
this.setState({ listRole: listData })
// this.setState({listRole: response.data.data}, () => {
// console.log(this.state.listRole)
// })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
// console.log(response.data.data)
})
}
......@@ -65,14 +80,22 @@ class UserRole extends Component {
"keyword": this.state.search
}
api.create().searchRole(payload).then((response) => {
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.sort((a, b) => a.role_id - b.role_id).map((item, index) => {
return [index, item.role_id, item.role_name, item.access, item.status]
})
this.setState({ listRole: listData })
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.sort((a, b) => a.role_id - b.role_id).map((item, index) => {
return [index, item.role_id, item.role_name, item.access, item.status]
})
this.setState({ listRole: listData })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -95,6 +118,10 @@ class UserRole extends Component {
}))
}
closeAlert() {
this.setState({ alert: false })
}
render() {
const columns = [{
name: "Action",
......@@ -173,6 +200,11 @@ class UserRole extends Component {
<div style={{ height: this.props.height }}>
{/* <Row> */}
<div className={"main-color"} style={{ height: 199, width: '100%' }} />
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Role & Otorisasi</label>
......
import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse, Snackbar } from '@material-ui/core';
import api from '../../../api';
import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove';
......@@ -8,6 +8,7 @@ import format from "date-fns/format";
import localeID from "date-fns/locale/id"
import * as R from 'ramda'
import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert';
const CustomCheckbox = withStyles({
root: {
......@@ -20,6 +21,9 @@ const CustomCheckbox = withStyles({
checked: {},
})((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class AddRole extends Component {
constructor(props) {
......@@ -43,6 +47,9 @@ export default class AddRole extends Component {
msgErrorED: '',
application: [],
setting: [],
alert: false,
tipeAlert: '',
messageAlert: ''
}
}
......@@ -127,11 +134,20 @@ export default class AddRole extends Component {
// console.log(payload)
api.create().addRole(payload).then((response) => {
console.log(response)
if (response.data.status === 'success') {
this.props.refresh()
this.props.onClickClose()
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.props.refresh()
this.props.onClickClose()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -151,23 +167,31 @@ export default class AddRole extends Component {
getMenu() {
api.create().getMenu().then((response) => {
if (response.data.status === 'success') {
let app = null
let set = null
response.data.data.map((item) => {
if (item.menu_name === "Application") {
app = this.parseChildren(item.sub_menu)
return app
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let app = null
let set = null
response.data.data.map((item) => {
if (item.menu_name === "Application") {
app = this.parseChildren(item.sub_menu)
return app
} else {
set = this.parseChildren(item.sub_menu)
return set
}
})
console.log(app)
this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application))
// this.setState({ menuData: response.data.data })
} else {
set = this.parseChildren(item.sub_menu)
return set
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
})
console.log(app)
this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application))
// this.setState({ menuData: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -242,10 +266,19 @@ export default class AddRole extends Component {
arr[index].collapse = !arr[index].collapse
this.setState({ ...this.state.setting, setting: arr })
}
closeAlert() {
this.setState({ alert: false })
}
render() {
return (
<div className="test app-popup-show">
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className="popup-content-middle background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
......
import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse, Snackbar } from '@material-ui/core';
import api from '../../../api';
import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove';
......@@ -7,6 +7,8 @@ import { DatePicker } from "@material-ui/pickers";
import format from "date-fns/format";
import * as R from 'ramda'
import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert';
const CustomCheckbox = withStyles({
root: {
color: '#51c6ea',
......@@ -18,6 +20,9 @@ const CustomCheckbox = withStyles({
checked: {},
})((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class EditRole extends Component {
constructor(props) {
......@@ -38,6 +43,9 @@ export default class EditRole extends Component {
msgErrorED: '',
application: [],
setting: [],
alert: false,
tipeAlert: '',
messageAlert: ''
}
}
......@@ -89,11 +97,19 @@ export default class EditRole extends Component {
getDetailRole() {
api.create().getDetailRole(this.state.paramsId).then((response) => {
if (response.data.status === 'success') {
this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
console.log(response.data.data.start_date)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
console.log(response.data.data.start_date)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -125,11 +141,20 @@ export default class EditRole extends Component {
// console.log(payload)
api.create().editRole(payload).then((response) => {
console.log(response)
if (response.data.status === 'success') {
this.props.refresh()
this.props.onClickClose()
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.props.refresh()
this.props.onClickClose()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -149,23 +174,31 @@ export default class EditRole extends Component {
getMenu() {
api.create().getMenu().then((response) => {
if (response.data.status === 'success') {
let app = null
let set = null
response.data.data.map((item) => {
if (item.menu_name === "Application") {
app = this.parseChildren(item.sub_menu)
return app
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let app = null
let set = null
response.data.data.map((item) => {
if (item.menu_name === "Application") {
app = this.parseChildren(item.sub_menu)
return app
} else {
set = this.parseChildren(item.sub_menu)
return set
}
})
console.log(app)
this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application))
// this.setState({ menuData: response.data.data })
} else {
set = this.parseChildren(item.sub_menu)
return set
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
})
console.log(app)
this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application))
// this.setState({ menuData: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -241,9 +274,18 @@ export default class EditRole extends Component {
return value
}
closeAlert() {
this.setState({ alert: false })
}
render() {
return (
<div className="test app-popup-show">
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className="popup-content-middle background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
......
import React, { Component } from 'react';
import Images from '../assets/Images';
import { TextField, InputAdornment, Button, Typography, IconButton } from '@material-ui/core';
import { TextField, InputAdornment, Button, Typography, IconButton, Snackbar } from '@material-ui/core';
import Visibility from '@material-ui/icons/Visibility';
import VisibilityOff from '@material-ui/icons/VisibilityOff';
import MuiAlert from '@material-ui/lab/Alert';
import { withStyles } from '@material-ui/core/styles';
import api from '../api';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
class ResetPassword extends Component {
constructor(props) {
......@@ -18,7 +22,10 @@ class ResetPassword extends Component {
errorConfirmPassword: false,
msgPassword: 'Terdiri 8 karakter dengan kombinasi angka.',
msgConfirmPassword: 'Terdiri 8 karakter dengan kombinasi angka.',
userId: 0
userId: 0,
alert: false,
tipeAlert: '',
messageAlert: ''
}
}
......@@ -32,11 +39,15 @@ class ResetPassword extends Component {
checkExpiredLink(userId) {
api.create().isResetPassword(userId).then((response) => {
if (response.data.status == 'success') {
//
if (response.data) {
if (response.data.status == 'success') {
//
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
this.props.history.push('/login')
}
} else {
alert(response.data.message)
this.props.history.push('/login')
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -83,15 +94,27 @@ class ResetPassword extends Component {
"user_id": this.state.userId
}
api.create().resetPassword(payload).then((response) => {
if(response.data.status === 'success') {
alert('success')
this.props.history.push('/login')
} else {
alert(response.data.message)
}
if (response.data) {
if (response.ok) {
if(response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.props.history.push('/login')
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
closeAlert() {
this.setState({ alert: false })
}
handleChange(e) {
let data = this.state
this.setState({...data, [e.target.name] : e.target.value})
......@@ -105,6 +128,11 @@ class ResetPassword extends Component {
render() {
return (
<div style={{ flex: 1, display: 'flex', backgroundColor: '#152d40', height: '100vh', justifyContent: 'center', alignItems: 'center' }}>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div style={{padding: 56, display: 'flex', flexDirection: 'column', width: 378, height: 415, borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff', justifyContent: 'center', alignItems: 'center' }}>
<img src={Images.tia}/>
......
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