Commit e552be16 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into deni-dev(pc)

parents 9ba71bfb 8d4d3d4e
......@@ -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 uploadPerusahaan = (body) => api.post('company/import_company', body)
const searchPerusahaan = (body) => api.post('company/search_company', body)
const deletePerusahaan = (id) => api.post(`company/delete_company/${id}`)
// 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/') =>
const searchUser = (body) => api.post('user/search_user', body)
const createUser = (body) => api.post('user/create_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 checkUploadUser = (body) => api.post('/user/check_import', 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/') =>
const getItemReportHierarki = (body) => api.post('item_report/get_item_report_hierarki', body)
const saveVisualisasiReport = (body) => api.post('item_report/save_visualization', 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
const getAllParameter = () => api.get('/setting/get_all_setting')
......@@ -271,7 +273,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
deleteAttachment,
getDetailReportMB,
deleteUnitBisnis,
deleteParameter
deleteParameter,
deletePerusahaan,
deleteReportItems
}
}
......
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 PopUpDeleteAM extends Component {
constructor(props) {
super(props)
this.state = {
id: '',
getApprovedBy: null,
getTypes: null,
}
}
componentDidMount() {
if (this.props.type === 'delete') {
this.getDetailAM()
}
}
getDetailAM() {
api.create().getDetailAM(this.props.data[1]).then(response => {
console.log(response.data)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
let data = response.data.data
this.setState({
id: data.approval_matrix_id,
getTypes: data.approval_type_name,
getApprovedBy: data.fullname
})
} 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.problem, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
onClickDelete() {
if (this.props.type == 'delete') {
let payload = this.state.id
this.props.deleteAM(payload)
}
}
render() {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'center', paddingTop: 20 }}>
<img src={Images.failed} />
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 20, paddingBottom: 20 }}>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold', fontFamily: 'Nunito Sans, sans-serif' }}>
Delete {this.state.getTypes} - {this.state.getApprovedBy}?
</span>
</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 }}>Cancel</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={()=> this.onClickDelete()}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Delete</span>
</div>
</button>
</div>
</div>
</div>
</div>
);
}
}
......@@ -618,7 +618,11 @@ export default class BudgetTahunan extends Component {
{this.state.visibleTP && (
<TaxPlanning
report_id={this.state.report_id}
height={this.props.height}
width={this.props.width}
company={this.state.company}
revision={this.state.revisionTable}
periode={this.state.periode.periode}
onClickClose={() => this.setState({ visibleTP: false, visibleBudgetTahunan: true })}
/>
)}
......
......@@ -12,6 +12,10 @@ class EmailVerification extends Component {
}
}
componentDidMount(){
console.log("forgot-password")
}
handleChange(e) {
let data = this.state
this.setState({...data, [e.target.name] : e.target.value})
......
......@@ -22,6 +22,10 @@ class ForgotPassword extends Component {
}
}
componentDidMount(){
console.log("forgot-password")
}
handleChange(e) {
let data = this.state
this.setState({...data, [e.target.name] : e.target.value})
......
......@@ -53,12 +53,12 @@ export default class CreatePerusahaan extends Component {
}
componentDidMount() {
this.getCompanyActive()
this.getAllUnitBisnis()
if(this.props.type === 'edit') {
this.getDetailPerusahaan()
// console.log(this.props.data);
} else {
this.getCompanyActive()
this.getAllUnitBisnis()
let date = format(new Date, 'yyyy-MM-dd')
// console.log(date);
this.setState({
......@@ -86,7 +86,12 @@ export default class CreatePerusahaan extends Component {
totalReport: response.data.data.total_report,
created: response.data.data.created,
updated: response.data.data.updated === null ? "" : response.data.data.updated
}, () => this.getAllUnitBisnis(), this.getCompanyActive())
}, () => {
// setTimeout(() => {
this.getAllUnitBisnis()
this.getCompanyActive()
// }, 1000);
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
......@@ -107,6 +112,7 @@ export default class CreatePerusahaan extends Component {
}
getCompanyActive() {
console.log(this.state.company)
if (this.state.company !== null) {
console.log(this.state.company)
let payload = {
......@@ -118,12 +124,20 @@ export default class CreatePerusahaan extends Component {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let perusahaanData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name
let currentIndex = null
let perusahaanData = data.map((item, index) => {
if (this.state.companyID !== item.company_id) {
return {
company_id: item.company_id,
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 typeProps = {
options: perusahaanData,
......@@ -374,7 +388,7 @@ export default class CreatePerusahaan extends Component {
margin="normal"
id="startDate"
label="Valid From"
format="dd MMMM yyyy"
format="dd-MM-yyyy"
value={this.state.startDate}
onChange={(e) => this.handleChange(e, 'start_date')}
KeyboardButtonProps={{
......@@ -477,7 +491,7 @@ export default class CreatePerusahaan extends Component {
margin="normal"
id="endDate"
label="Valid To"
format="dd MMMM yyyy"
format="dd-MM-yyyy"
value={this.state.endDate}
minDate={this.state.startDate}
onChange={(e) => this.handleChange(e, 'end_date')}
......@@ -600,7 +614,7 @@ export default class CreatePerusahaan extends Component {
margin="normal"
id="startDate"
label="Valid From"
format="dd MMMM yyyy"
format="dd-MM-yyyy"
value={this.state.startDate == "" ? null : this.state.startDate}
onChange={(e) => this.handleChange(e, 'start_date')}
KeyboardButtonProps={{
......@@ -696,7 +710,7 @@ export default class CreatePerusahaan extends Component {
margin="normal"
id="endDate"
label="Valid To"
format="dd MMMM yyyy"
format="dd-MM-yyyy"
error={this.state.errorED}
helperText={this.state.msgErrorED}
minDate={this.state.startDate}
......
import React, { Component } from 'react';
import Images from '../../assets/Images';
import Images from '../../../assets/Images';
import { Typography } from '@material-ui/core';
import api from "../../api";
import Constant from '../../library/Constant';
import api from "../../../api";
import Constant from '../../../library/Constant';
export default class PopUpDelete extends Component {
export default class DeletePerusahaan extends Component {
constructor(props) {
super(props)
this.state = {
id: '',
getApprovedBy: null,
getTypes: null,
companyID: '',
company: null,
}
}
componentDidMount() {
if (this.props.type === 'delete') {
this.getDetailAM()
this.getDetailPerusahaan()
}
}
getDetailAM() {
api.create().getDetailAM(this.props.data[1]).then(response => {
console.log(response.data)
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({
id: data.approval_matrix_id,
getTypes: data.approval_type_name,
getApprovedBy: data.fullname
companyID: data.company_id,
company: data.company_name,
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
......@@ -43,47 +41,18 @@ export default class PopUpDelete extends Component {
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
}
})
}
// hapus(){
// this.setState({ popupDel: false })
// api.create().deleteAM(this.state.id).then(response => {
// console.log(response.data)
// if (response.data) {
// if (response.ok) {
// if (response.data.status == 'success') {
// // this.getData()
// this.props.getList()
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
// } 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' })
// }
// })
// }
hapus() {
delete() {
if (this.props.type == 'delete') {
let payload = this.state.id
this.props.deleteAM(payload)
this.props.deleteCompany(payload)
}
}
......@@ -96,11 +65,8 @@ export default class PopUpDelete extends Component {
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 20 }}>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold' }}>
Delete {this.state.getTypes} - {this.state.getApprovedBy} ?
Delete {this.state.company} ?
</span>
{/* <span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold' }}>
{`Please try again later.`}
</span> */}
</div>
<div style={{ display: 'flex', justifyContent: 'center', marginTop: 24 }}>
<button
......@@ -112,7 +78,7 @@ export default class PopUpDelete extends Component {
<button
className={"btn-save"}
style={{ marginLeft: 50}}
onClick={()=> this.hapus()}
onClick={()=> this.delete()}
>
<span style={{ color: 'white' }}>Delete</span>
</button>
......
This diff is collapsed.
......@@ -60,8 +60,13 @@ export default class CreateReportItems extends Component {
options: ['WARNING', 'STOPPER'],
alert: false,
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 {
"weight": this.state.weight,
"condition_if_wrong": this.state.condition,
"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,
"end_date": this.state.endDate
}
......@@ -442,7 +450,10 @@ export default class CreateReportItems extends Component {
<Autocomplete
{...this.state.listReportType}
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
renderInput={(params) =>
<TextField {...params}
......@@ -778,6 +789,90 @@ export default class CreateReportItems extends Component {
</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="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
......
......@@ -62,7 +62,13 @@ export default class EditReportItems extends Component {
options: ['WARNING', 'STOPPER'],
alert: false,
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 {
"weight": this.state.tempData.weight == null ? "" : this.state.tempData.weight,
"condition_if_wrong": this.state.tempData.condition_if_wrong,
"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,
"end_date": this.state.tempData.end_date
}
......@@ -456,7 +465,10 @@ export default class EditReportItems extends Component {
<Autocomplete
{...this.state.listReportType}
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
renderInput={(params) =>
<TextField {...params}
......@@ -760,6 +772,91 @@ export default class EditReportItems extends Component {
</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="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
......
This diff is collapsed.
......@@ -139,6 +139,33 @@ export default class AddUser extends Component {
}
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({
errorFullname: false,
errorEmail: false,
......@@ -150,6 +177,9 @@ export default class AddUser extends Component {
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
company
}, () => {
console.log(this.state.company)
})
}
......@@ -262,41 +292,58 @@ export default class AddUser extends Component {
handleItemClick(item) {
let indexID = this.state.company.findIndex((val) => val === item.id)
let listCompany = this.state.listCompany
let company = this.state.company
if (indexID === -1) {
company.push(item.id)
if (item.parent !== null) {
let indexIDs = this.state.company.findIndex((val) => val === item.parent)
if (indexIDs === -1) {
company.push(item.parent)
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)
})
}
}
}
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.length > 0) {
item.children.map((items, indexs) => {
this.handleItemClick(items)
item.children.map((items,indexs) => {
handleSpliceChild(items)
})
}
}
}
if (indexID === -1) {
company.push(item.id)
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items,indexs) => {
handlePushChild(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 (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
this.handleItemClick(items)
})
}
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) => {
......@@ -570,7 +617,7 @@ export default class AddUser extends Component {
margin="normal"
id="startDate"
label="Valid From"
format="dd MMMM yyyy"
format="dd-MM-yyyy"
value={this.state.startDate}
error={this.state.errorStartDate}
helperText={this.state.msgErrorSD}
......@@ -603,7 +650,7 @@ export default class AddUser extends Component {
margin="normal"
id="endDate"
label="Valid To"
format="dd MMMM yyyy"
format="dd-MM-yyyy"
value={this.state.endDate}
error={this.state.errorEndDate}
helperText={this.state.msgErrorED}
......
......@@ -123,6 +123,33 @@ export default class EditUser extends Component {
}
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({
errorFullname: false,
errorEmail: false,
......@@ -134,6 +161,7 @@ export default class EditUser extends Component {
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
company
})
}
......@@ -251,7 +279,10 @@ export default class EditUser extends Component {
if (response.data) {
if (response.ok) {
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 {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
......@@ -279,40 +310,57 @@ export default class EditUser extends Component {
handleItemClick(item) {
let indexID = this.state.company.findIndex((val) => val === item.id)
let company = this.state.company
if (indexID === -1) {
company.push(item.id)
if (item.parent !== null) {
let indexIDs = this.state.company.findIndex((val) => val === item.parent)
if (indexIDs === -1) {
company.push(item.parent)
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)
})
}
}
}
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.length > 0) {
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.length > 0) {
item.children.map((items,indexs) => {
handlePushChild(items)
})
}
}
} else {
company.splice(indexID, 1)
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items,indexs) => {
this.handleItemClick(items)
handleSpliceChild(items)
})
}
}
}
this.setState({ company })
// console.log(company)
this.setState({ company})
}
renderChildren = (item, pad) => {
......@@ -583,7 +631,7 @@ export default class EditUser extends Component {
margin="normal"
id="startDate"
label="Valid From"
format="dd MMMM yyyy"
format="dd-MM-yyyy"
value={this.state.tempData === null ? null : this.state.tempData.start_date}
error={this.state.errorStartDate}
helperText={this.state.msgErrorSD}
......@@ -615,7 +663,7 @@ export default class EditUser extends Component {
margin="normal"
id="endDate"
label="Valid To"
format="dd MMMM yyyy"
format="dd-MM-yyyy"
value={this.state.tempData === null ? null : this.state.tempData.end_date}
error={this.state.errorEndDate}
helperText={this.state.msgErrorED}
......
......@@ -152,7 +152,7 @@ class UserRole extends Component {
handleChange(e) {
let data = this.state
window.requestIdleCallback((e) => this.setState({ ...data, [e.target.name]: e.target.value }, () => {
alert('asdk')
// alert('asdk')
}))
}
......@@ -161,6 +161,33 @@ class UserRole extends Component {
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() {
const columns = [{
name: "Action",
......@@ -186,9 +213,24 @@ class UserRole extends Component {
null
}
</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>
)}
</div >
);
}
......@@ -317,6 +359,38 @@ class UserRole extends Component {
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>
);
}
......
This diff is collapsed.
......@@ -94,7 +94,7 @@ export default class Profile extends Component {
} else if (!this.isRegex(this.state.password)) {
this.setState({ errorPassword: true, msgPassword: 'Password Must be a Combination of Characters, Letters and Numbers.' })
} 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) {
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'Password Does Not Match.' })
} else {
......
......@@ -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>
</Button>
</div>
......
......@@ -76,7 +76,7 @@ class SetPassword extends Component {
} else if (!this.isRegex(this.state.password)) {
this.setState({ errorPassword: true, msgPassword: 'Invalid password. Must using combination of characters, letters and numbers.' })
} 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) {
this.setState({ errorConfirmPassword: true, msgConfirmPassword: 'The password and password confirmation do not match.' })
} else {
......@@ -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>
</Button>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment