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/') ...@@ -65,6 +65,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
const login = (body) => api.post('auth/login', body) const login = (body) => api.post('auth/login', body)
const resetPassword = (body) => api.post('auth/reset_password', body) const resetPassword = (body) => api.post('auth/reset_password', body)
const verification = (body) => api.post('email/reset_password', body) const verification = (body) => api.post('email/reset_password', body)
const isResetPassword = (userId) => api.post(`auth/is_reset_password/${userId}`)
//Role //Role
const getRole = () => api.get('role/get_all_role') const getRole = () => api.get('role/get_all_role')
...@@ -85,6 +86,8 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/') ...@@ -85,6 +86,8 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
// Perusahaan // Perusahaan
const getCompany = () => api.get('company/get_all_company') const getCompany = () => api.get('company/get_all_company')
// APPROVAL MATRIX
const getAM = () => api.get('approval_matrix/get_all_approval_matrix')
// ------ // ------
// STEP 3 // STEP 3
...@@ -104,6 +107,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/') ...@@ -104,6 +107,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
login, login,
verification, verification,
resetPassword, resetPassword,
isResetPassword,
getRole, getRole,
getDetailRole, getDetailRole,
searchRole, searchRole,
...@@ -115,6 +119,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/') ...@@ -115,6 +119,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
createUnitBisnis, createUnitBisnis,
updateUnitBisnis, updateUnitBisnis,
searchUnitBisnis, searchUnitBisnis,
getAM,
getCompany getCompany
} }
} }
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
background-color: #fff; } background-color: #fff; }
.app-popup-show { .app-popup-show {
display: flex; display: flex;
z-index: 2000; z-index: 1290;
-webkit-transition: all 0.35s cubic-bezier(0, 1, 0.5, 1); -webkit-transition: all 0.35s cubic-bezier(0, 1, 0.5, 1);
-moz-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); -ms-transition: all 0.35s cubic-bezier(0, 1, 0.5, 1);
...@@ -2,16 +2,20 @@ import React, { Component } from 'react'; ...@@ -2,16 +2,20 @@ import React, { Component } from 'react';
import { Container, Row, Col } from "react-bootstrap"; import { Container, Row, Col } from "react-bootstrap";
import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles'; import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import { TextField, InputBase } from "@material-ui/core"; import { TextField, InputBase } from "@material-ui/core";
import { ExcelRenderer } from 'react-excel-renderer';
import Images from '../../assets/Images'; import Images from '../../assets/Images';
import MUIDataTable from "mui-datatables"; import MUIDataTable from "mui-datatables";
import UploadFile from "../../library/Upload";
import CreateApprovalMatrix from "./CreateApprovalMatrix"; import CreateApprovalMatrix from "./CreateApprovalMatrix";
import EditApprovalMatrix from "./EditApprovalMatrix"; import EditApprovalMatrix from "./EditApprovalMatrix";
import PreviewAM from "./PreviewAM"; import PreviewAM from "./PreviewAM";
import VisualisasiAM from "./VisualisasiAM"; import VisualisasiAM from "./VisualisasiAM";
import api from "../../api";
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions(); const options = ct.customOptions();
const options2 = ct.customOptions2();
const type = [ const type = [
{ {
...@@ -32,11 +36,81 @@ export default class ApprovalMatrix extends Component { ...@@ -32,11 +36,81 @@ export default class ApprovalMatrix extends Component {
visibleCreate: false, visibleCreate: false,
visibleEdit: false, visibleEdit: false,
visibleVisual: false, visibleVisual: false,
dataTable: [],
listData: [],
data: [],
search: "", search: "",
cols: null,
rows: null,
dataLoaded: false
} }
this.fileHandler = this.fileHandler.bind(this);
}
fileHandler = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
if (err) {
// console.log(err);
}
else {
let judul = resp.rows[0]
let isi = resp.rows.slice(1)
// let body = isi.map((item) => {
// return {
// item
// ]
// })
// console.log(JSON.stringify(isi));
this.setState({
dataLoaded: true,
cols: judul,
rows: isi
});
}
});
} }
componentDidMount() { componentDidMount() {
this.getData()
}
getData() {
api.create().getAM().then((response) => {
// console.log(response)
let datas = response.data.data
let listData = datas.map((item, index) => {
return [item.fullname ]
})
console.log(listData)
if(response.status == null){
alert(response.problem)
}
else if (response.data.status == 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
return [index, item.approval_matrix_id, item.approval_type_name, item.orders, item.fullname, item.operator_type_name, item.status ]
})
this.setState({ dataTable: listData, listData: response.data.data })
} else {
alert(response.data.message)
}
})
}
openPopUp(index, type) {
if (type === 'edit') {
this.setState({
selectIndex: index,
visibleEdit: true
})
} else {
this.setState({
data: this.state.listData[index],
visibleCreate: true
})
}
} }
handleInputChange = (e) => { handleInputChange = (e) => {
...@@ -66,15 +140,88 @@ export default class ApprovalMatrix extends Component { ...@@ -66,15 +140,88 @@ export default class ApprovalMatrix extends Component {
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent' borderColor: 'transparent'
}} }}
onClick={() => null} onClick={() => this.openPopUp(tableMeta.rowIndex, 'edit')}
// onClick={() => this.setState({ visibleEdit: true })}
> >
<img src={Images.editCopy} onClick={() => this.setState({ visibleEdit: true })} /> <img src={Images.editCopy} />
</button> </button>
</div > </div >
); );
} }
} }
}, "ID", "Tipe Persetujuan", "Order", "Nama Pemberi Persetujuan", "Operator", "Status"] },
{
name: "ID",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Tipe Persetujuan",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Order",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Nama Pemberi Persetujuan",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Operator",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
},
{
name: "Status",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
}]
const data = [ const data = [
["", "1", "Yearly", "1", "John Doe", "-", "Aktif"], ["", "1", "Yearly", "1", "John Doe", "-", "Aktif"],
["", "2", "Yearly", "2", "John Doe", "-", "Aktif"], ["", "2", "Yearly", "2", "John Doe", "-", "Aktif"],
...@@ -126,7 +273,7 @@ export default class ApprovalMatrix extends Component { ...@@ -126,7 +273,7 @@ export default class ApprovalMatrix extends Component {
}} }}
onClick={() => null} onClick={() => null}
> >
<img src={Images.upload} /> <img src={Images.upload} onClick={() => this.setState({ visibleUpload: true })}/>
</button> </button>
<button <button
style={{ style={{
...@@ -168,7 +315,8 @@ export default class ApprovalMatrix extends Component { ...@@ -168,7 +315,8 @@ export default class ApprovalMatrix extends Component {
<div style={{ padding: 25, width: '100%' }}> <div style={{ padding: 25, width: '100%' }}>
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={data} theme={getMuiTheme()}
data={this.state.dataTable}
columns={columns} columns={columns}
options={options} options={options}
/> />
...@@ -176,16 +324,55 @@ export default class ApprovalMatrix extends Component { ...@@ -176,16 +324,55 @@ export default class ApprovalMatrix extends Component {
</div> </div>
</div> </div>
</div> </div>
: false :
<div style={{ height: this.props.height }}>
<div style={{ height: 199, width: '100%', backgroundColor: '#354960' }} />
<div>
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label>
</div>
<div style={{ padding: 25 }}>
{this.state.dataLoaded && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
theme={getMuiTheme()}
data={this.state.rows}
columns={this.state.cols}
options={options}
/>
</MuiThemeProvider>
)}
</div>
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button
type="button"
onClick={() => this.setState({ visibleAM: true })}
style={{ marginRight: 20}}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Batal</span>
</div>
</button>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div>
</div>
</div>
</div>
</div>
} }
{this.state.visibleCreate && ( {this.state.visibleCreate && (
<CreateApprovalMatrix <CreateApprovalMatrix
onClickClose={() => this.setState({ visibleCreate: false })} onClickClose={() => this.setState({ visibleCreate: false })}
data={this.state.listData}
/> />
)} )}
{this.state.visibleEdit && ( {this.state.visibleEdit && (
<EditApprovalMatrix <EditApprovalMatrix
type={"edit"}
onClickClose={() => this.setState({ visibleEdit: false })} onClickClose={() => this.setState({ visibleEdit: false })}
data={this.state.listData[this.state.selectIndex]}
/> />
)} )}
{this.state.visibleVisual && ( {this.state.visibleVisual && (
...@@ -193,6 +380,39 @@ export default class ApprovalMatrix extends Component { ...@@ -193,6 +380,39 @@ export default class ApprovalMatrix extends Component {
onClickClose={() => this.setState({ visibleVisual: false })} onClickClose={() => this.setState({ visibleVisual: false })}
/> />
)} )}
{this.state.visibleUpload && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })}
>
<i className="fa fa-lg fa-times" style={{ color: 'white' }} />
</button>
</div>
</div>
<UploadFile
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
acceptedFiles={["pdf"]}
onHandle={(dt) => {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
}}
onUpload={() => this.setState({ visibleUpload: false, visibleAM: false })}
/>
</div>
</div>
)}
</div> </div>
); );
} }
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { TextField } from '@material-ui/core'; import { TextField, Typography } from '@material-ui/core';
import { DateTimePicker, KeyboardDatePicker, DatePicker} from "@material-ui/pickers";
import MenuItem from '@material-ui/core/MenuItem'; import MenuItem from '@material-ui/core/MenuItem';
import format from "date-fns/format";
import localeID from "date-fns/locale/id"
const type = [ const type = [
{ {
value: 'KPI', value: 'YEARLY',
label: 'KPI', label: 'YEARLY',
}, },
{ {
value: 'Gatau', value: 'MONTHLY',
label: 'Gatau', label: 'MONTHLY',
},
{
value: 'DAILY',
label: 'DAILY',
}, },
]; ];
const approve_by = [ const approve_by = [
...@@ -24,20 +31,56 @@ const approve_by = [ ...@@ -24,20 +31,56 @@ const approve_by = [
]; ];
const operator = [ const operator = [
{ {
value: '1', value: '-',
label: '-', label: '-',
}, },
{ {
value: '2', value: 'AND',
label: 'AND', label: 'AND',
}, },
{ {
value: '3', value: 'OR',
label: 'OR', label: 'OR',
}, },
]; ];
export default class EditApprovalMatrix extends Component { export default class EditApprovalMatrix extends Component {
constructor(props) {
super(props)
this.state = {
startDate: null,
endDate: null,
date: new Date()
}
}
render() { render() {
let { type } = this.props
return type === 'edit' ? this.renderEdit() : false
}
componentDidMount() {
console.log(this.props.data);
}
handleChange(e, type) {
let data = this.state
let isDate = type !== ''? true : false
if (isDate && type == 'start_date') {
this.setState({...data, startDate : format(e, 'yyyy-MM-dd')})
} else if (isDate && type == 'end_date') {
this.setState({...data, endDate : format(e, 'yyyy-MM-dd')})
} else {
this.setState({...data, [e.target.name] : e.target.value})
}
}
handleDate(item) {
let value = format(item, 'dd MMMM yyyy')
return value
}
renderEdit() {
return ( return (
<div className="test app-popup-show" style={{ paddingTop: 100 }}> <div className="test app-popup-show" style={{ paddingTop: 100 }}>
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
...@@ -61,26 +104,47 @@ export default class EditApprovalMatrix extends Component { ...@@ -61,26 +104,47 @@ export default class EditApprovalMatrix extends Component {
<div className="border-bottom" style={{ padding: 20 }}> <div className="border-bottom" style={{ padding: 20 }}>
<div className="grid grid-2x grid-mobile-none gap-15px"> <div className="grid grid-2x grid-mobile-none gap-15px">
<div className="column-1"> <div className="column-1">
<div className="margin-bottom-20px"> <div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%', height: '90%' }} style={{ width: '100%' }}
id="id" id="id"
variant="filled"
label="ID" label="ID"
value="1" value={this.props.data.approval_matrix_id}
> disabled
</TextField> inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
/>
</div> </div>
</div> </div>
<div className="column-2"> <div className="column-2">
<div className="margin-bottom-20px" style={{ marginTop: 8 }}> <div className="" style={{ paddingTop: 4, paddingRight: 10, paddingBottom: 10, paddingLeft: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="type" id="type"
select select
label="Tipe Persetujuan" label="Tipe Persetujuan"
value="KPI" value={this.props.data.approval_type_name}
onChange={(e) => null} onChange={(e) => null}
selectProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
> >
{type.map((option) => ( {type.map((option) => (
<MenuItem key={option.value} value={option.value}> <MenuItem key={option.value} value={option.value}>
...@@ -93,26 +157,48 @@ export default class EditApprovalMatrix extends Component { ...@@ -93,26 +157,48 @@ export default class EditApprovalMatrix extends Component {
</div> </div>
<div className="grid grid-2x grid-mobile-none gap-15px"> <div className="grid grid-2x grid-mobile-none gap-15px">
<div className="column-1"> <div className="column-1">
<div className="margin-bottom-20px"> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="order" id="order"
variant="standard"
label="Order" label="Order"
value="1" value={this.props.data.orders}
onChange={(e) => this.handleChange(e, '')}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
> >
</TextField> </TextField>
</div> </div>
</div> </div>
<div className="column-2"> <div className="column-2">
<div className="margin-bottom-20px"> <div className="margin-top-10px" style={{ paddingTop: 4, paddingRight: 10, paddingBottom: 10, paddingLeft: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="approve-by" id="approve-by"
select select
label="Pemberi Persetujuan" label="Pemberi Persetujuan"
value="1" value={this.props.data.fullname}
onChange={(e) => null} onChange={(e) => null}
selectProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
> >
{approve_by.map((option) => ( {approve_by.map((option) => (
<MenuItem key={option.value} value={option.value}> <MenuItem key={option.value} value={option.value}>
...@@ -125,14 +211,25 @@ export default class EditApprovalMatrix extends Component { ...@@ -125,14 +211,25 @@ export default class EditApprovalMatrix extends Component {
</div> </div>
<div className="grid grid-2x grid-mobile-none gap-15px"> <div className="grid grid-2x grid-mobile-none gap-15px">
<div className="column-1"> <div className="column-1">
<div className="margin-bottom-20px"> <div className="margin-top-10px" style={{ paddingTop: 4, paddingRight: 10, paddingBottom: 10, paddingLeft: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="operator" id="operator"
select select
label="Operator" label="Operator"
value="1" value={this.props.data.operator_type_name}
onChange={(e) => null} onChange={(e) => null}
selectProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
> >
{operator.map((option) => ( {operator.map((option) => (
<MenuItem key={option.value} value={option.value}> <MenuItem key={option.value} value={option.value}>
...@@ -148,73 +245,107 @@ export default class EditApprovalMatrix extends Component { ...@@ -148,73 +245,107 @@ export default class EditApprovalMatrix extends Component {
</div> </div>
<div className="grid grid-2x grid-mobile-none gap-15px"> <div className="grid grid-2x grid-mobile-none gap-15px">
<div className="column-1"> <div className="column-1">
<div className="margin-bottom-20px"> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField <DatePicker
style={{ width: '100%' }} margin="normal"
id="start-period" id="startDate"
label="Berlaku Mulai" label="Berlaku Mulai"
value="31 Desember 2020" format="dd MMMM yyyy"
> value={this.state.startDate}
{/* {periode.map((option) => ( onChange={(e) => this.handleChange(e, 'start_date')}
<MenuItem key={option.value} value={option.value}> KeyboardButtonProps={{
{option.label} 'aria-label': 'change date',
</MenuItem> }}
))} */} style={{padding: 0, margin: 0, width: '100%'}}
</TextField> InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
/>
</div> </div>
</div> </div>
<div className="column-2"> <div className="column-2">
<div className="margin-bottom-20px"> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField <DatePicker
style={{ width: '100%' }} margin="normal"
id="end-period" id="endDate"
label="Berlaku Hingga" label="Berlaku Hingga"
value="31 Desember 2020" format="dd MMMM yyyy"
> value={this.state.endDate}
{/* {periode.map((option) => ( onChange={(e) => this.handleChange(e, 'end_date')}
<MenuItem key={option.value} value={option.value}> KeyboardButtonProps={{
{option.label} 'aria-label': 'change date',
</MenuItem> }}
))} */} style={{padding: 0, margin: 0, width: '100%'}}
</TextField> InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
/>
</div> </div>
</div> </div>
</div> </div>
<div className="grid grid-2x grid-mobile-none gap-15px"> <div className="grid grid-2x grid-mobile-none gap-15px">
<div className="column-1"> <div className="column-1">
<div className="margin-bottom-20px"> <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="status" id="status"
variant="filled" label="Status"
label="Aktif" value={this.props.data.status}
value="Aktif" disabled
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
> >
{/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))} */}
</TextField> </TextField>
</div> </div>
</div> </div>
<div className="column-2"> <div className="column-2">
<div className="margin-bottom-20px" style={{ marginTop: 8 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="max-value" id="max-value"
label="Max Value" label="Max Value"
value="10" value="10"
onChange={(e) => this.handleChange(e, '')}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
> >
</TextField> </TextField>
</div> </div>
</div> </div>
</div> </div>
<div className=""> {/* <div className="">
<span style={{ fontSize: 11, fontWeight: 600 }}>Dibuat<span style={{ marginLeft: 20}}> : Admin - 21 Jul 2020, 18:45</span></span> <span style={{ fontSize: 11, fontWeight: 600 }}>Dibuat<span style={{ marginLeft: 20}}> : Admin - 21 Jul 2020, 18:45</span></span>
</div> </div>
<div className=""> <div className="">
<span style={{ fontSize: 11, fontWeight: 'bold' }}>Diubah<span style={{ marginLeft: 17}}> : Admin - 21 Jul 2020, 18:45</span></span> <span style={{ fontSize: 11, fontWeight: 'bold' }}>Diubah<span style={{ marginLeft: 17}}> : Admin - 21 Jul 2020, 18:45</span></span>
</div> */}
<div style={{flexDirection:'column', display: 'flex', padding: 10 }}>
<Typography style={{fontSize: 12}}>{`Dibuat : ${format(this.state.date, 'dd MMMM yyyy', {locale: localeID})}`}</Typography>
{/* <Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData == null? '' : this.state.tempData.updated}`}</Typography> */}
</div> </div>
</div> </div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}> <div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
......
...@@ -22,12 +22,12 @@ class Login extends Component { ...@@ -22,12 +22,12 @@ class Login extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
username: '', email: '',
password: '', password: '',
showPass: false, showPass: false,
errorUsername: false, errorEmail: false,
errorPassword: false, errorPassword: false,
msgUsername: '', msgEmail: '',
msgPassword: '' msgPassword: ''
} }
} }
...@@ -39,16 +39,25 @@ class Login extends Component { ...@@ -39,16 +39,25 @@ class Login extends Component {
handleChange(e) { handleChange(e) {
let data = this.state let data = this.state
this.setState({...data, [e.target.name] : e.target.value}) this.setState({...data, [e.target.name] : e.target.value})
if (e.target.name == "username") { if (e.target.name == "email") {
this.setState({ errorUsername: false, msgUsername: '' }) this.setState({ errorEmail: false, msgEmail: '' })
} else if (e.target.name) { } else if (e.target.name) {
this.setState({ errorPassword: false, msgPassword: '' }) 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() { validateLogin() {
if (this.state.username.trim() == "") { var isEmail = this.isEmail(this.state.email)
this.setState({ errorUsername: true, msgUsername: 'Username harus diisi!' })
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() == "") { } else if (this.state.password.trim() == "") {
this.setState({ errorPassword: true, msgPassword: 'Password harus diisi!' }) this.setState({ errorPassword: true, msgPassword: 'Password harus diisi!' })
} else { } else {
...@@ -58,7 +67,7 @@ class Login extends Component { ...@@ -58,7 +67,7 @@ class Login extends Component {
login() { login() {
let payload = { let payload = {
"username": this.state.username, "email": this.state.email,
"password": this.state.password "password": this.state.password
} }
api.create().login(payload).then((response) => { api.create().login(payload).then((response) => {
...@@ -69,7 +78,7 @@ class Login extends Component { ...@@ -69,7 +78,7 @@ class Login extends Component {
if (response.data.message == 'Password Salah!') { if (response.data.message == 'Password Salah!') {
this.setState({ errorPassword: true, msgPassword: response.data.message }) this.setState({ errorPassword: true, msgPassword: response.data.message })
} else { } 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 { ...@@ -87,18 +96,18 @@ class Login extends Component {
<img src={Images.tia} /> <img src={Images.tia} />
<TextField <TextField
label={<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Username/Email *</Typography>} label={<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Email *</Typography>}
id="username" id="email"
type={"text"} type={"text"}
name={"username"} name={"email"}
value={this.state.username} value={this.state.email}
onChange={(username) => { onChange={(email) => {
this.handleChange(username) this.handleChange(email)
}} }}
variant="outlined" variant="outlined"
error={this.state.errorUsername} error={this.state.errorEmail}
style={{ width: '100%', height: 51, marginTop: 32, fontSize: 14 }} style={{ width: '100%', height: 51, marginTop: 32, fontSize: 14 }}
helperText={this.state.msgUsername} helperText={this.state.msgEmail}
InputProps={{ InputProps={{
endAdornment: <InputAdornment position="end"><img src={Images.email} /></InputAdornment>, endAdornment: <InputAdornment position="end"><img src={Images.email} /></InputAdornment>,
}} }}
...@@ -115,7 +124,7 @@ class Login extends Component { ...@@ -115,7 +124,7 @@ class Login extends Component {
}} }}
variant="outlined" variant="outlined"
error={this.state.errorPassword} 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} helperText={this.state.msgPassword}
InputProps={{ InputProps={{
endAdornment: <InputAdornment position="end"> endAdornment: <InputAdornment position="end">
...@@ -136,7 +145,7 @@ class Login extends Component { ...@@ -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> <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> <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> </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> <Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Login</Typography>
</Button> </Button>
</div> </div>
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { TextField, Typography } from '@material-ui/core'; import { TextField, Typography } from '@material-ui/core';
const companies = [
{
value: '',
label: '',
},
{
value: 'TIA1',
label: 'TIA',
},
{
value: 'TIA2',
label: 'TIA',
},
{
value: 'TIA3',
label: 'TIA',
},
];
export default class CreateItemLaporan extends Component { export default class CreateItemLaporan extends Component {
render() {
let { type } = this.props
return type === 'edit' ? this.renderEdit() : this.renderCreate()
}
componentDidMount() { componentDidMount() {
console.log(this.props.data); console.log(this.props.data);
} }
renderEdit() { render() {
return ( return (
<div className="test app-popup-show"> <div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}> <div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}> <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title"> <div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Edit Data</span> <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Tambah Data</span>
</div> </div>
</div> </div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}> <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
...@@ -38,7 +53,7 @@ export default class CreateItemLaporan extends Component { ...@@ -38,7 +53,7 @@ export default class CreateItemLaporan extends Component {
<div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}> <div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
value={this.props.data.business_unit_id} value={1}
id="status" id="status"
label="ID" label="ID"
disabled disabled
...@@ -57,30 +72,27 @@ export default class CreateItemLaporan extends Component { ...@@ -57,30 +72,27 @@ export default class CreateItemLaporan extends Component {
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} id="standard-select-currency-native"
id="periode" select
value={"1 Januari 2020"} label="Native select"
label="Berlaku Mulai" // onChange={handleChange}
onChange={(e) => null} SelectProps={{
inputProps={{ native: true,
style: { }}
fontSize: 11 helperText="Please select your currency"
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
> >
{companies.map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</TextField> </TextField>
</div> </div>
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
value={this.props.data.status} // value={this.props.data.status}
id="status" id="status"
label="Status" label="Status"
disabled disabled
...@@ -101,11 +113,11 @@ export default class CreateItemLaporan extends Component { ...@@ -101,11 +113,11 @@ export default class CreateItemLaporan extends Component {
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<div style={{display: 'flex'}}> <div style={{display: 'flex'}}>
<Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography> <Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography>
<Typography style={{ fontSize: 11 }}>: {this.props.data.created}</Typography> <Typography style={{ fontSize: 11 }}>: Admin - 21 Jul 2020, 18:45</Typography>
</div> </div>
<div style={{display: 'flex'}}> <div style={{display: 'flex'}}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography> <Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
<Typography style={{ fontSize: 11 }}>: {this.props.data.updated ==- null ? "" : this.props.data.updated}</Typography> <Typography style={{ fontSize: 11 }}>: Admin - 21 Jul 2020, 18:45</Typography>
</div> </div>
</div> </div>
</div> </div>
...@@ -116,7 +128,7 @@ export default class CreateItemLaporan extends Component { ...@@ -116,7 +128,7 @@ export default class CreateItemLaporan extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="unit" id="unit"
label="Unit Bisnis" label="Unit Bisnis"
value={this.props.data.business_unit_name} // value={this.props.data.business_unit_name}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11 fontSize: 11
...@@ -176,145 +188,4 @@ export default class CreateItemLaporan extends Component { ...@@ -176,145 +188,4 @@ export default class CreateItemLaporan extends Component {
</div> </div>
) )
} }
renderCreate() {
return (
<div className="test app-popup-show" style={{ paddingTop: 100 }}>
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Create Data</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<i className="fa fa-lg fa-times" style={{ color: 'white' }} />
</button>
</div>
</div>
<div className="border-bottom grid grid-2x grid-mobile-none gap-15px" style={{ padding: 20 }}>
<div className="column-1">
<div style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="periode"
value={"1 Januari 2020"}
label="Berlaku Mulai"
// value={this.state.periode}
onChange={(e) => null}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
>
</TextField>
</div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5, backgroundColor: '#e8e8e8', }}>
<TextField
style={{ width: '100%' }}
defaultValue={"Aktif"}
id="status"
label="Status"
disabled
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
/>
</div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Typography style={{ fontSize: 11 }}>Dibuat : Admin - 21 Jul 2020, 18:45</Typography>
<Typography style={{ fontSize: 11 }}>Diubah : Admin - 21 Jul 2020, 18:45</Typography>
</div>
</div>
<div className="column-2">
<div style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="unit"
label="Unit Bisnis"
defaultValue={"Agrobisnis"}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
>
</TextField>
</div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="unit"
label="Berlaku Hingga"
defaultValue={"31 Desember 2100"}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
>
</TextField>
</div>
</div>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.props.onClickClose()}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Batal</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div>
</div>
</div>
</div>
</div >
);
}
} }
...@@ -8,6 +8,7 @@ import AddRole from './UserRole/AddRole'; ...@@ -8,6 +8,7 @@ import AddRole from './UserRole/AddRole';
import EditRole from './UserRole/EditRole' import EditRole from './UserRole/EditRole'
import api from "../../api"; import api from "../../api";
import { titleCase } from "../../library/Utils"; import { titleCase } from "../../library/Utils";
import { InputAdornment, TextField } from "@material-ui/core";
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -148,16 +149,42 @@ export default class UserRole extends Component { ...@@ -148,16 +149,42 @@ export default class UserRole extends Component {
<div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} /> <div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} />
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <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: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}>
<div style={{width: '50%', backgroundColor:'white', padding: 10, borderRadius: 7.5, flexDirection: 'row', display: 'flex'}}> <div style={{width: '50%', backgroundColor:'white', padding: 10, borderRadius: 7.5}}>
<SearchIcon/> <TextField
<input type="text" placeholder={'Search Role'} style={{flexGrow: 1, marginLeft: 10}}/> 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>
</div> </div>
{/* <label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> */} {/* <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' }}> <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> </div>
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
......
...@@ -184,19 +184,12 @@ class UserRole extends Component { ...@@ -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> <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: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}>
<div style={{width: '50%', backgroundColor:'white', padding: 10, borderRadius: 7.5}}> <div style={{width: '50%', backgroundColor:'white', padding: 10, borderRadius: 7.5}}>
{/* <SearchIcon/> */}
<TextField <TextField
// className={classes.margin}
id="input-with-icon-textfield" id="input-with-icon-textfield"
// label="TextField"
name="search" name="search"
value={this.state.search} value={this.state.search}
placeholder={'Search Role'} placeholder={'Search'}
onChange={(e) => { onChange={(e) => {
// let { search } = this.state;
// search = [...search];
// search.push(e.target.value);
// search[0] = search;
this.setState({ search: e.target.value }, () => { this.setState({ search: e.target.value }, () => {
if (this.state.search.length > 0) { if (this.state.search.length > 0) {
this.searchRole() this.searchRole()
......
...@@ -235,6 +235,7 @@ export default class AddRole extends Component { ...@@ -235,6 +235,7 @@ export default class AddRole extends Component {
format="dd MMMM yyyy" format="dd MMMM yyyy"
value={this.state.endDate} value={this.state.endDate}
onChange={(e) => this.handleChange(e, 'end_date')} onChange={(e) => this.handleChange(e, 'end_date')}
minDate={this.state.startDate}
KeyboardButtonProps={{ KeyboardButtonProps={{
'aria-label': 'change date', 'aria-label': 'change date',
}} }}
......
...@@ -247,6 +247,7 @@ export default class EditRole extends Component { ...@@ -247,6 +247,7 @@ export default class EditRole extends Component {
label="Berlaku Hingga" label="Berlaku Hingga"
format="dd MMMM yyyy" format="dd MMMM yyyy"
value={this.state.tempData == null ? null : this.state.tempData.end_date} 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')} onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{ KeyboardButtonProps={{
'aria-label': 'change date', 'aria-label': 'change date',
......
...@@ -26,18 +26,51 @@ class ResetPassword extends Component { ...@@ -26,18 +26,51 @@ class ResetPassword extends Component {
console.log(this.props.match.params.id) console.log(this.props.match.params.id)
let userId = this.props.match.params.id let userId = this.props.match.params.id
this.setState({userId}) this.setState({userId})
this.checkExpiredLink(userId)
// console.log(this.props) // 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() { validateReset() {
if (this.state.password.trim() == "") { 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) { } 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() == "") { } 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) { } 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 { } else {
this.confirmPassword() this.confirmPassword()
} }
...@@ -113,7 +146,7 @@ class ResetPassword extends Component { ...@@ -113,7 +146,7 @@ class ResetPassword extends Component {
}} }}
variant="outlined" variant="outlined"
error={this.state.errorConfirmPassword} 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>} helperText={<Typography style={{fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif'}}>{this.state.msgConfirmPassword}</Typography>}
InputProps={{ InputProps={{
endAdornment: <InputAdornment position="end"> endAdornment: <InputAdornment position="end">
...@@ -129,7 +162,7 @@ class ResetPassword extends Component { ...@@ -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> <Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Lanjut</Typography>
</Button> </Button>
</div> </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