Commit a4779251 authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into rifka

parents c3f4073c 4a5b3424
...@@ -104,6 +104,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -104,6 +104,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getDetailPerusahaan = (id) => api.get(`company/get_company_by_id/${id}`) const getDetailPerusahaan = (id) => api.get(`company/get_company_by_id/${id}`)
const uploadPerusahaan = (body) => api.post('company/import_company', body) const uploadPerusahaan = (body) => api.post('company/import_company', body)
const searchPerusahaan = (body) => api.post('company/search_company', body) const searchPerusahaan = (body) => api.post('company/search_company', body)
const deletePerusahaan = (id) => api.post(`company/delete_company/${id}`)
// APPROVAL MATRIX // APPROVAL MATRIX
const getAM = () => api.get('approval_matrix/get_all_approval_matrix') const getAM = () => api.get('approval_matrix/get_all_approval_matrix')
...@@ -125,7 +126,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -125,7 +126,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const searchUser = (body) => api.post('user/search_user', body) const searchUser = (body) => api.post('user/search_user', body)
const createUser = (body) => api.post('user/create_user', body) const createUser = (body) => api.post('user/create_user', body)
const updateUser = (body) => api.post('user/update_user', body) const updateUser = (body) => api.post('user/update_user', body)
const deleteUser = (userId) => api.get(`user/delete_user/${userId}`) const deleteUser = (userId) => api.post(`user/delete_user/${userId}`)
const changePassword = (body) => api.post('/user/change_password', body) const changePassword = (body) => api.post('/user/change_password', body)
const checkUploadUser = (body) => api.post('/user/check_import', body) const checkUploadUser = (body) => api.post('/user/check_import', body)
const uploadUser = (body) => api.post('/user/import_user', body) const uploadUser = (body) => api.post('/user/import_user', body)
...@@ -143,6 +144,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -143,6 +144,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getItemReportHierarki = (body) => api.post('item_report/get_item_report_hierarki', body) const getItemReportHierarki = (body) => api.post('item_report/get_item_report_hierarki', body)
const saveVisualisasiReport = (body) => api.post('item_report/save_visualization', body) const saveVisualisasiReport = (body) => api.post('item_report/save_visualization', body)
const getReportParent = (body) => api.post('item_report/get_parent_item_report', body) const getReportParent = (body) => api.post('item_report/get_parent_item_report', body)
const deleteReportItems = (id) => api.post(`item_report/delete_item_report/${id}`)
//PARAMETER //PARAMETER
const getAllParameter = () => api.get('/setting/get_all_setting') const getAllParameter = () => api.get('/setting/get_all_setting')
...@@ -271,7 +273,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -271,7 +273,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
deleteAttachment, deleteAttachment,
getDetailReportMB, getDetailReportMB,
deleteUnitBisnis, deleteUnitBisnis,
deleteParameter deleteParameter,
deletePerusahaan,
deleteReportItems
} }
} }
......
...@@ -12,6 +12,10 @@ class EmailVerification extends Component { ...@@ -12,6 +12,10 @@ class EmailVerification extends Component {
} }
} }
componentDidMount(){
console.log("forgot-password")
}
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})
......
...@@ -22,6 +22,10 @@ class ForgotPassword extends Component { ...@@ -22,6 +22,10 @@ class ForgotPassword extends Component {
} }
} }
componentDidMount(){
console.log("forgot-password")
}
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})
......
...@@ -53,12 +53,12 @@ export default class CreatePerusahaan extends Component { ...@@ -53,12 +53,12 @@ export default class CreatePerusahaan extends Component {
} }
componentDidMount() { componentDidMount() {
this.getCompanyActive()
this.getAllUnitBisnis()
if(this.props.type === 'edit') { if(this.props.type === 'edit') {
this.getDetailPerusahaan() this.getDetailPerusahaan()
// console.log(this.props.data); // console.log(this.props.data);
} else { } else {
this.getCompanyActive()
this.getAllUnitBisnis()
let date = format(new Date, 'yyyy-MM-dd') let date = format(new Date, 'yyyy-MM-dd')
// console.log(date); // console.log(date);
this.setState({ this.setState({
...@@ -86,7 +86,12 @@ export default class CreatePerusahaan extends Component { ...@@ -86,7 +86,12 @@ export default class CreatePerusahaan extends Component {
totalReport: response.data.data.total_report, totalReport: response.data.data.total_report,
created: response.data.data.created, created: response.data.data.created,
updated: response.data.data.updated === null ? "" : response.data.data.updated updated: response.data.data.updated === null ? "" : response.data.data.updated
}, () => this.getAllUnitBisnis(), this.getCompanyActive()) }, () => {
// setTimeout(() => {
this.getAllUnitBisnis()
this.getCompanyActive()
// }, 1000);
})
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) { if (response.data.message.includes("Token")) {
...@@ -107,6 +112,7 @@ export default class CreatePerusahaan extends Component { ...@@ -107,6 +112,7 @@ export default class CreatePerusahaan extends Component {
} }
getCompanyActive() { getCompanyActive() {
console.log(this.state.company)
if (this.state.company !== null) { if (this.state.company !== null) {
console.log(this.state.company) console.log(this.state.company)
let payload = { let payload = {
...@@ -118,12 +124,20 @@ export default class CreatePerusahaan extends Component { ...@@ -118,12 +124,20 @@ export default class CreatePerusahaan extends Component {
if (response.ok) { if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let perusahaanData = data.map((item) => { let currentIndex = null
let perusahaanData = data.map((item, index) => {
if (this.state.companyID !== item.company_id) {
return { return {
company_id: item.company_id, company_id: item.company_id,
company_name: item.company_name company_name: item.company_name
} }
} else {
currentIndex = index
}
}) })
if (currentIndex !== null) {
perusahaanData.splice(currentIndex, 1)
}
let index = perusahaanData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.parentID) let index = perusahaanData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.parentID)
let typeProps = { let typeProps = {
options: perusahaanData, options: perusahaanData,
......
import React, { Component } from 'react';
import Images from '../../../assets/Images';
import { Typography } from '@material-ui/core';
import api from "../../../api";
import Constant from '../../../library/Constant';
export default class DeletePerusahaan extends Component {
constructor(props) {
super(props)
this.state = {
companyID: '',
company: null,
}
}
componentDidMount() {
if (this.props.type === 'delete') {
this.getDetailPerusahaan()
}
}
getDetailPerusahaan() {
api.create().getDetailPerusahaan(this.props.data[1]).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
let data = response.data.data
this.setState({
companyID: data.company_id,
company: data.company_name,
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
delete() {
if (this.props.type == 'delete') {
let payload = this.state.id
this.props.deleteCompany(payload)
}
}
render() {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8, padding: 50 }}>
<div style={{ display: 'flex', justifyContent: 'center' }}>
<img src={Images.failedCopy} />
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 20 }}>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold' }}>
Delete {this.state.company} ?
</span>
</div>
<div style={{ display: 'flex', justifyContent: 'center', marginTop: 24 }}>
<button
className={"btn-save"}
onClick={()=> this.props.onClickClose()}
>
<span style={{ color: 'white' }}>Cancel</span>
</button>
<button
className={"btn-save"}
style={{ marginLeft: 50}}
onClick={()=> this.delete()}
>
<span style={{ color: 'white' }}>Delete</span>
</button>
</div>
</div>
</div>
);
}
}
This diff is collapsed.
...@@ -60,8 +60,13 @@ export default class CreateReportItems extends Component { ...@@ -60,8 +60,13 @@ export default class CreateReportItems extends Component {
options: ['WARNING', 'STOPPER'], options: ['WARNING', 'STOPPER'],
alert: false, alert: false,
tipeAlert: '', tipeAlert: '',
messageAlert: '' messageAlert: '',
kpiType: ['HIG', 'HIB'],
maxAch: ['50%', '100%', 'Unlimited'],
formulaYtd: ['SUM', 'AVG', 'MIN', 'MAX'],
kpiTypeValue: null,
maxAchValue: null,
formulaYTDValue: null
} }
} }
...@@ -194,6 +199,9 @@ export default class CreateReportItems extends Component { ...@@ -194,6 +199,9 @@ export default class CreateReportItems extends Component {
"weight": this.state.weight, "weight": this.state.weight,
"condition_if_wrong": this.state.condition, "condition_if_wrong": this.state.condition,
"condition_it_should_be": this.state.realVal, "condition_it_should_be": this.state.realVal,
"type_kpi": this.state.kpiTypeValue,
"max_ach": this.state.maxAchValue,
"formula_ytd": this.state.formulaYTDValue,
"start_date": this.state.startDate, "start_date": this.state.startDate,
"end_date": this.state.endDate "end_date": this.state.endDate
} }
...@@ -442,7 +450,10 @@ export default class CreateReportItems extends Component { ...@@ -442,7 +450,10 @@ export default class CreateReportItems extends Component {
<Autocomplete <Autocomplete
{...this.state.listReportType} {...this.state.listReportType}
id="reportType" id="reportType"
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, ()=> this.clearMessage())} onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () => {
newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ kpiTypeValue: null, maxAchValue: null, formulaYTDValue: null }, () => this.clearMessage())
: this.clearMessage();
})}
debug debug
renderInput={(params) => renderInput={(params) =>
<TextField {...params} <TextField {...params}
...@@ -778,6 +789,90 @@ export default class CreateReportItems extends Component { ...@@ -778,6 +789,90 @@ export default class CreateReportItems extends Component {
</div> </div>
</div> </div>
{this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.kpiTypeValue}
id="kpiType"
onChange={(event, newValue) => {
this.setState({ kpiTypeValue: newValue }, () => this.clearMessage());
}}
options={this.state.kpiType}
renderInput={(params) =>
<TextField {...params}
label="KPI Type"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.maxAchValue}
id="maxAch"
onChange={(event, newValue) => {
this.setState({ maxAchValue: newValue }, () => this.clearMessage());
}}
options={this.state.maxAch}
renderInput={(params) =>
<TextField {...params}
label="Max Achievement"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div>
))}
{this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.formulaYTDValue}
id="formulaYTD"
onChange={(event, newValue) => {
this.setState({ formulaYTDValue: newValue }, () => this.clearMessage());
}}
options={this.state.formulaYtd}
renderInput={(params) =>
<TextField {...params}
label="Formula YTD"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div>
))}
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1"> <div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
......
...@@ -62,7 +62,13 @@ export default class EditReportItems extends Component { ...@@ -62,7 +62,13 @@ export default class EditReportItems extends Component {
options: ['WARNING', 'STOPPER'], options: ['WARNING', 'STOPPER'],
alert: false, alert: false,
tipeAlert: '', tipeAlert: '',
messageAlert: '' messageAlert: '',
kpiType: ['HIG', 'HIB'],
maxAch: ['50%', '100%', 'Unlimited'],
formulaYtd: ['SUM', 'AVG', 'MIN', 'MAX'],
kpiTypeValue: null,
maxAchValue: null,
formulaYTDValue: null
} }
} }
...@@ -169,6 +175,9 @@ export default class EditReportItems extends Component { ...@@ -169,6 +175,9 @@ export default class EditReportItems extends Component {
"weight": this.state.tempData.weight == null ? "" : this.state.tempData.weight, "weight": this.state.tempData.weight == null ? "" : this.state.tempData.weight,
"condition_if_wrong": this.state.tempData.condition_if_wrong, "condition_if_wrong": this.state.tempData.condition_if_wrong,
"condition_it_should_be": this.state.tempData.condition_it_should_be, "condition_it_should_be": this.state.tempData.condition_it_should_be,
"type_kpi": this.state.tempData.kpi_type,
"max_ach": this.state.tempData.max_ach,
"formula_ytd": this.state.tempData.formula_ytd,
"start_date": this.state.tempData.start_date, "start_date": this.state.tempData.start_date,
"end_date": this.state.tempData.end_date "end_date": this.state.tempData.end_date
} }
...@@ -456,7 +465,10 @@ export default class EditReportItems extends Component { ...@@ -456,7 +465,10 @@ export default class EditReportItems extends Component {
<Autocomplete <Autocomplete
{...this.state.listReportType} {...this.state.listReportType}
id="reportType" id="reportType"
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () => this.getParent(), this.clearMessage() )} onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () =>
newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ tempData: { ...this.state.tempData, kpi_type: null, max_ach: null, formula_ytd: null } }, () => this.getParent(), this.clearMessage())
: this.getParent(), this.clearMessage()
)}
debug debug
renderInput={(params) => renderInput={(params) =>
<TextField {...params} <TextField {...params}
...@@ -760,6 +772,91 @@ export default class EditReportItems extends Component { ...@@ -760,6 +772,91 @@ export default class EditReportItems extends Component {
</div> </div>
</div> </div>
</div> </div>
{this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.tempData === null ? "" : this.state.tempData.kpi_type}
id="kpiType"
onChange={(event, newValue) => {
this.setState({ tempData: { ...this.state.tempData, kpi_type: newValue } }, () => this.clearMessage());
}}
options={this.state.kpiType}
renderInput={(params) =>
<TextField {...params}
label="KPI Type"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.tempData === null ? "" : this.state.tempData.max_ach}
id="maxAch"
onChange={(event, newValue) => {
this.setState({ tempData: { ...this.state.tempData, max_ach: newValue } }, () => this.clearMessage());
}}
options={this.state.maxAch}
renderInput={(params) =>
<TextField {...params}
label="Max Achievement"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div>
))}
{this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.tempData === null ? "" : this.state.tempData.formula_ytd}
id="kpiType"
onChange={(event, newValue) => {
this.setState({ tempData: { ...this.state.tempData, formula_ytd: newValue } }, () => this.clearMessage());
}}
options={this.state.formulaYtd}
renderInput={(params) =>
<TextField {...params}
label="Formula YTD"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div>
))}
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1"> <div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
......
This diff is collapsed.
...@@ -139,6 +139,33 @@ export default class AddUser extends Component { ...@@ -139,6 +139,33 @@ export default class AddUser extends Component {
} }
clearError() { clearError() {
let listCompany = this.state.listCompany
let company = this.state.company
const handlePushChild = (item) => {
let indexIDzz = company.findIndex((val) => val === item.id)
if (indexIDzz === -1) {
company.push(item.id)
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items,indexs) => {
handlePushChild(items)
})
}
}
}
listCompany.map((item, index) => {
company.push(item.id)
handlePushChild(item)
})
let uniqueCompany = company.filter((val, id, array) => {
return array.indexOf(val) == id;
});
company = this.state.role.role_id === 1? uniqueCompany : []
// console.log(uniqueCompany)
this.setState({ this.setState({
errorFullname: false, errorFullname: false,
errorEmail: false, errorEmail: false,
...@@ -150,6 +177,9 @@ export default class AddUser extends Component { ...@@ -150,6 +177,9 @@ export default class AddUser extends Component {
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
company
}, () => {
console.log(this.state.company)
}) })
} }
...@@ -262,41 +292,58 @@ export default class AddUser extends Component { ...@@ -262,41 +292,58 @@ export default class AddUser extends Component {
handleItemClick(item) { handleItemClick(item) {
let indexID = this.state.company.findIndex((val) => val === item.id) let indexID = this.state.company.findIndex((val) => val === item.id)
let listCompany = this.state.listCompany
let company = this.state.company let company = this.state.company
if (indexID === -1) { const handlePushChild = (item) => {
let indexIDzz = company.findIndex((val) => val === item.id)
if (indexIDzz === -1) {
company.push(item.id) company.push(item.id)
if (item.parent !== null) { }
let indexIDs = this.state.company.findIndex((val) => val === item.parent) if (item.children !== null) {
if (indexIDs === -1) { if (item.children.length > 0) {
company.push(item.parent) item.children.map((items,indexs) => {
handlePushChild(items)
})
}
} }
} }
const handleSpliceChild = (item) => {
let indexIDzz = company.findIndex((val) => val === item.id)
if (indexIDzz !== -1) {
company.splice(indexIDzz, 1)
}
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
item.children.map((items, indexs) => { item.children.map((items,indexs) => {
this.handleItemClick(items) handleSpliceChild(items)
}) })
} }
} }
} else {
company.splice(indexID, 1)
if (item.parent !== null) {
let indexIDs = this.state.company.findIndex((val) => val === item.parent)
if (indexIDs !== -1) {
company.splice(indexIDs, 1)
} }
if (indexID === -1) {
company.push(item.id)
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
item.children.map((items, indexs) => { item.children.map((items,indexs) => {
this.handleItemClick(items) handlePushChild(items)
}) })
} }
} }
} else {
company.splice(indexID, 1)
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items,indexs) => {
handleSpliceChild(items)
})
} }
} }
this.setState({ company }) }
// console.log(company)
this.setState({ company})
} }
renderChildren = (item, pad) => { renderChildren = (item, pad) => {
...@@ -570,7 +617,7 @@ export default class AddUser extends Component { ...@@ -570,7 +617,7 @@ export default class AddUser extends Component {
margin="normal" margin="normal"
id="startDate" id="startDate"
label="Valid From" label="Valid From"
format="dd MMMM yyyy" format="dd-MM-yyyy"
value={this.state.startDate} value={this.state.startDate}
error={this.state.errorStartDate} error={this.state.errorStartDate}
helperText={this.state.msgErrorSD} helperText={this.state.msgErrorSD}
...@@ -603,7 +650,7 @@ export default class AddUser extends Component { ...@@ -603,7 +650,7 @@ export default class AddUser extends Component {
margin="normal" margin="normal"
id="endDate" id="endDate"
label="Valid To" label="Valid To"
format="dd MMMM yyyy" format="dd-MM-yyyy"
value={this.state.endDate} value={this.state.endDate}
error={this.state.errorEndDate} error={this.state.errorEndDate}
helperText={this.state.msgErrorED} helperText={this.state.msgErrorED}
......
...@@ -123,6 +123,33 @@ export default class EditUser extends Component { ...@@ -123,6 +123,33 @@ export default class EditUser extends Component {
} }
clearError() { clearError() {
let listCompany = this.state.listCompany
let company = this.state.company
const handlePushChild = (item) => {
let indexIDzz = company.findIndex((val) => val === item.id)
if (indexIDzz === -1) {
company.push(item.id)
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items,indexs) => {
handlePushChild(items)
})
}
}
}
listCompany.map((item, index) => {
company.push(item.id)
handlePushChild(item)
})
let uniqueCompany = company.filter((val, id, array) => {
return array.indexOf(val) == id;
});
company = this.state.role.role_id === 1? uniqueCompany : []
// console.log(uniqueCompany)
this.setState({ this.setState({
errorFullname: false, errorFullname: false,
errorEmail: false, errorEmail: false,
...@@ -134,6 +161,7 @@ export default class EditUser extends Component { ...@@ -134,6 +161,7 @@ export default class EditUser extends Component {
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
company
}) })
} }
...@@ -251,7 +279,10 @@ export default class EditUser extends Component { ...@@ -251,7 +279,10 @@ export default class EditUser extends Component {
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data }) let dataBaru = response.data.data.map((item,index) => {
return {...item, check: false}
})
this.setState({ listCompany: dataBaru })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) { if (response.data.message.includes("Token")) {
...@@ -279,40 +310,57 @@ export default class EditUser extends Component { ...@@ -279,40 +310,57 @@ export default class EditUser extends Component {
handleItemClick(item) { handleItemClick(item) {
let indexID = this.state.company.findIndex((val) => val === item.id) let indexID = this.state.company.findIndex((val) => val === item.id)
let company = this.state.company let company = this.state.company
if (indexID === -1) { const handlePushChild = (item) => {
let indexIDzz = company.findIndex((val) => val === item.id)
if (indexIDzz === -1) {
company.push(item.id) company.push(item.id)
if (item.parent !== null) { }
let indexIDs = this.state.company.findIndex((val) => val === item.parent) if (item.children !== null) {
if (indexIDs === -1) { if (item.children.length > 0) {
company.push(item.parent) item.children.map((items,indexs) => {
handlePushChild(items)
})
}
} }
} }
const handleSpliceChild = (item) => {
let indexIDzz = company.findIndex((val) => val === item.id)
if (indexIDzz !== -1) {
company.splice(indexIDzz, 1)
}
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
item.children.map((items,indexs) => { item.children.map((items,indexs) => {
this.handleItemClick(items) handleSpliceChild(items)
}) })
} }
} }
} else { }
company.splice(indexID, 1)
if (item.parent !== null) { if (indexID === -1) {
let indexIDs = this.state.company.findIndex((val) => val === item.parent) company.push(item.id)
if (indexIDs !== -1) { if (item.children !== null) {
company.splice(indexIDs, 1) if (item.children.length > 0) {
item.children.map((items,indexs) => {
handlePushChild(items)
})
} }
} }
} else {
company.splice(indexID, 1)
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
item.children.map((items,indexs) => { item.children.map((items,indexs) => {
this.handleItemClick(items) handleSpliceChild(items)
}) })
} }
} }
} }
this.setState({ company })
// console.log(company)
this.setState({ company})
} }
renderChildren = (item, pad) => { renderChildren = (item, pad) => {
...@@ -583,7 +631,7 @@ export default class EditUser extends Component { ...@@ -583,7 +631,7 @@ export default class EditUser extends Component {
margin="normal" margin="normal"
id="startDate" id="startDate"
label="Valid From" label="Valid From"
format="dd MMMM yyyy" format="dd-MM-yyyy"
value={this.state.tempData === null ? null : this.state.tempData.start_date} value={this.state.tempData === null ? null : this.state.tempData.start_date}
error={this.state.errorStartDate} error={this.state.errorStartDate}
helperText={this.state.msgErrorSD} helperText={this.state.msgErrorSD}
...@@ -615,7 +663,7 @@ export default class EditUser extends Component { ...@@ -615,7 +663,7 @@ export default class EditUser extends Component {
margin="normal" margin="normal"
id="endDate" id="endDate"
label="Valid To" label="Valid To"
format="dd MMMM yyyy" format="dd-MM-yyyy"
value={this.state.tempData === null ? null : this.state.tempData.end_date} value={this.state.tempData === null ? null : this.state.tempData.end_date}
error={this.state.errorEndDate} error={this.state.errorEndDate}
helperText={this.state.msgErrorED} helperText={this.state.msgErrorED}
......
...@@ -152,7 +152,7 @@ class UserRole extends Component { ...@@ -152,7 +152,7 @@ class UserRole extends Component {
handleChange(e) { handleChange(e) {
let data = this.state let data = this.state
window.requestIdleCallback((e) => this.setState({ ...data, [e.target.name]: e.target.value }, () => { window.requestIdleCallback((e) => this.setState({ ...data, [e.target.name]: e.target.value }, () => {
alert('asdk') // alert('asdk')
})) }))
} }
...@@ -161,6 +161,33 @@ class UserRole extends Component { ...@@ -161,6 +161,33 @@ class UserRole extends Component {
this.setState({ alert: false }) this.setState({ alert: false })
} }
deleteRole() {
let data = this.state.rowData
api.create().deleteRole(data[1]).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', popupDel: false })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', popupDel: false }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', popupDel: false })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', popupDel: false })
}
this.getRole()
})
}
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -186,7 +213,22 @@ class UserRole extends Component { ...@@ -186,7 +213,22 @@ class UserRole extends Component {
null null
} }
</div > </div >
</button>
)}
{this.state.buttonEdit && (
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginLeft: 10
}}
onClick={() => this.setState({popupDel: true, rowData: tableMeta.rowData})}
>
{tableMeta.rowData[2] !== "superadmin" ?
<img src={Images.delete} /> :
null
}
</button> </button>
)} )}
</div > </div >
...@@ -317,6 +359,38 @@ class UserRole extends Component { ...@@ -317,6 +359,38 @@ class UserRole extends Component {
data={this.state.indexData} data={this.state.indexData}
/> />
)} )}
{this.state.popupDel && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8, padding: 50 }}>
<div style={{ display: 'flex', justifyContent: 'center' }}>
<img src={Images.failedCopy} />
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 20 }}>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold' }}>
Delete {this.state.rowData[2]} ?
</span>
{/* <span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold' }}>
{`Please try again later.`}
</span> */}
</div>
<div style={{ display: 'flex', justifyContent: 'center', marginTop: 24 }}>
<button
className={"btn-save"}
onClick={()=> this.setState({popupDel: false})}
>
<span style={{ color: 'white' }}>Cancel</span>
</button>
<button
className={"btn-save"}
style={{ marginLeft: 50}}
onClick={()=> this.deleteRole()}
>
<span style={{ color: 'white' }}>Delete</span>
</button>
</div>
</div>
</div>
)}
</div> </div>
); );
} }
......
This diff is collapsed.
...@@ -94,7 +94,7 @@ export default class Profile extends Component { ...@@ -94,7 +94,7 @@ export default class Profile extends Component {
} else if (!this.isRegex(this.state.password)) { } else if (!this.isRegex(this.state.password)) {
this.setState({ errorPassword: true, msgPassword: 'Password Must be a Combination of Characters, Letters and Numbers.' }) this.setState({ errorPassword: true, msgPassword: 'Password Must be a Combination of Characters, Letters and Numbers.' })
} else if (this.state.confirmPassword.trim() == "") { } else if (this.state.confirmPassword.trim() == "") {
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Password Confirmation Cannot be Empty.' }) this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Repeat Password Cannot be Empty.' })
} else if (this.state.password !== this.state.confirmPassword) { } else if (this.state.password !== this.state.confirmPassword) {
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Password Does Not Match.' }) this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Password Does Not Match.' })
} else { } else {
......
...@@ -190,7 +190,7 @@ class ResetPassword extends Component { ...@@ -190,7 +190,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: 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' }}> <Button name="submit" variant="contained" disabled={this.state.password.trim() == '' && this.state.confirmPassword.trim() == '' ? true : false} onClick={() => this.validateReset()} style={{ marginTop: 60, 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' }}>Reset Password</Typography> <Typography style={{ fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Reset Password</Typography>
</Button> </Button>
</div> </div>
......
...@@ -76,7 +76,7 @@ class SetPassword extends Component { ...@@ -76,7 +76,7 @@ class SetPassword extends Component {
} else if (!this.isRegex(this.state.password)) { } else if (!this.isRegex(this.state.password)) {
this.setState({ errorPassword: true, msgPassword: 'Invalid password. Must using combination of characters, letters and numbers.' }) this.setState({ errorPassword: true, msgPassword: 'Invalid password. Must using combination of characters, letters and numbers.' })
} else if (this.state.confirmPassword.trim() == "") { } else if (this.state.confirmPassword.trim() == "") {
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Password Confirmation Cannot be Empty.' }) this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Repeat Password Cannot be Empty.' })
} else if (this.state.password !== this.state.confirmPassword) { } else if (this.state.password !== this.state.confirmPassword) {
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'The password and password confirmation do not match.' }) this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'The password and password confirmation do not match.' })
} else { } else {
...@@ -190,7 +190,7 @@ class SetPassword extends Component { ...@@ -190,7 +190,7 @@ class SetPassword extends Component {
}} }}
/> />
<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' }}> <Button name="submit" variant="contained" disabled={this.state.password.trim() == '' && this.state.confirmPassword.trim() == '' ? true : false} onClick={() => this.validateReset()} style={{ marginTop: 60, 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' }}>Next</Typography> <Typography style={{ fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Next</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