Commit 353230fa authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'master' into 'faisal'

# Conflicts:
#   src/api/index.js
parents 464dde29 2821fd69
...@@ -1448,6 +1448,18 @@ ...@@ -1448,6 +1448,18 @@
"@babel/runtime": "^7.4.4" "@babel/runtime": "^7.4.4"
} }
}, },
"@material-ui/lab": {
"version": "4.0.0-alpha.56",
"resolved": "https://registry.npmjs.org/@material-ui/lab/-/lab-4.0.0-alpha.56.tgz",
"integrity": "sha512-xPlkK+z/6y/24ka4gVJgwPfoCF4RCh8dXb1BNE7MtF9bXEBLN/lBxNTK8VAa0qm3V2oinA6xtUIdcRh0aeRtVw==",
"requires": {
"@babel/runtime": "^7.4.4",
"@material-ui/utils": "^4.10.2",
"clsx": "^1.0.4",
"prop-types": "^15.7.2",
"react-is": "^16.8.0"
}
},
"@material-ui/pickers": { "@material-ui/pickers": {
"version": "3.2.10", "version": "3.2.10",
"resolved": "https://registry.npmjs.org/@material-ui/pickers/-/pickers-3.2.10.tgz", "resolved": "https://registry.npmjs.org/@material-ui/pickers/-/pickers-3.2.10.tgz",
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
"@date-io/moment": "^2.8.0", "@date-io/moment": "^2.8.0",
"@material-ui/core": "^4.11.0", "@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1", "@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@material-ui/pickers": "^3.2.10", "@material-ui/pickers": "^3.2.10",
"@testing-library/jest-dom": "^4.2.4", "@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0", "@testing-library/react": "^9.5.0",
......
...@@ -91,6 +91,10 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/') ...@@ -91,6 +91,10 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
// APPROVAL MATRIX // APPROVAL MATRIX
const getAM = () => api.get('approval_matrix/get_all_approval_matrix') const getAM = () => api.get('approval_matrix/get_all_approval_matrix')
const getApprovedByAM = () => api.get('approval_matrix/get_all_approver')
const createAM = (body) => api.post('/approval_matrix/create_approval_matrix', body)
const updateAM = (body) => api.post('/approval_matrix/update_approval_matrix', body)
// ------ // ------
// STEP 3 // STEP 3
...@@ -126,6 +130,9 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/') ...@@ -126,6 +130,9 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
getPerusahaan, getPerusahaan,
createPerusahaan, createPerusahaan,
updatePerusahaan updatePerusahaan
getApprovedByAM,
createAM,
updateAM
} }
} }
......
...@@ -78,12 +78,6 @@ export default class ApprovalMatrix extends Component { ...@@ -78,12 +78,6 @@ export default class ApprovalMatrix extends Component {
getData() { getData() {
api.create().getAM().then((response) => { api.create().getAM().then((response) => {
// console.log(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){ if(response.status == null){
alert(response.problem) alert(response.problem)
} }
...@@ -127,6 +121,17 @@ export default class ApprovalMatrix extends Component { ...@@ -127,6 +121,17 @@ export default class ApprovalMatrix extends Component {
// Delayed logic goes here // Delayed logic goes here
} }
createAM = (payload) => {
this.setState({ visibleCreate: false })
api.create().createAM(payload).then(response => {
if (response.data.status == 'success') {
this.getData()
} else {
alert(response.data.message)
}
})
}
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -366,6 +371,7 @@ export default class ApprovalMatrix extends Component { ...@@ -366,6 +371,7 @@ export default class ApprovalMatrix extends Component {
<CreateApprovalMatrix <CreateApprovalMatrix
onClickClose={() => this.setState({ visibleCreate: false })} onClickClose={() => this.setState({ visibleCreate: false })}
data={this.state.listData} data={this.state.listData}
createAM={this.createAM.bind(this)}
/> />
)} )}
{this.state.visibleEdit && ( {this.state.visibleEdit && (
......
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 * as R from 'ramda'
import format from "date-fns/format";
import api from "../../api";
import Autocomplete from '@material-ui/lab/Autocomplete';
const type = [ const type = [
{ {
value: 'KPI', value: '1',
label: 'KPI', label: 'YEARLY',
}, },
{ {
value: 'Gatau', value: '2',
label: 'Gatau', label: 'MONTHLY',
}, },
]; {
value: '3',
label: 'DAILY',
},
];
const approve_by = [ const approve_by = [
{ {
value: '1', user_id: '1',
label: 'John Doe', fullname: 'John Doe',
}, },
{ {
value: '2', user_id: '2',
label: 'John Doe lagi', fullname: 'John Doe lagi',
}, },
]; ];
const operator = [ const operator = [
...@@ -38,6 +47,91 @@ const operator = [ ...@@ -38,6 +47,91 @@ const operator = [
]; ];
export default class CreateApprovalMatrix extends Component { export default class CreateApprovalMatrix extends Component {
constructor(props) {
super(props)
this.state = {
userId: null,
// type: '',
order: '',
approvedBy: null,
// operator: '',
startDate: '',
endDate: '',
}
}
componentDidMount() {
// console.log(this.props.data);
// let datas = this.props.data
// let userData = datas.map((item, index) => {
// return [item.fullname, item.user_id ]
// })
// console.log(userData)
this.getUserData()
}
getUserData() {
api.create().getApprovedByAM().then((response) => {
// console.log("data masuk")
// console.log(response)
if (response.data.status == 'success') {
let data = response.data.data
let userData = data.map((item) => {
// return [item.user_id, item.fullname]
return {
user_id: item.user_id,
fullname: item.fullname
}
})
console.log(userData)
let defaultProps = {
options: userData,
getOptionLabel: (option) => option.fullname,
};
this.setState({ approvedBy: defaultProps, userData: response.data.data })
} else {
alert(response.data.message)
}
})
}
handleChange(e, type) {
let data = this.state
let isDate = type !== '' ? true : false
if (isDate && type == 'start_date') {
this.setState({ startDate: format(e, 'yyyy-MM-dd') }, () => {
// console.log(this.state.startDate)
})
} else if (isDate && type == 'end_date') {
this.setState({ endDate: format(e, 'yyyy-MM-dd') }, () => {
// console.log(this.state.endDate)
})
} else {
// this.setState({...data, tempData: {...this.state.tempData, [e.target.name] : e.target.value}})
}
}
validasi() {
if (R.isEmpty(this.state.order)) return alert("Order is Required.");
if (!R.isEmpty(this.state.startDate) && !R.isEmpty(this.state.endDate) && (this.state.startDate > this.state.endDate)) return alert("Masa Berlaku Tidak Boleh Kurang Dari Tanggal Mulai");
if (R.isEmpty(this.state.startDate)) return alert("Tanggal Mulai is Required.");
if (R.isEmpty(this.state.endDate)) return alert("Tanggal Berakhir is Required.");
console.log('masuk');
let payload = {
"approval_type_id": 2,
"orders": this.state.order,
"user_id": this.state.userId,
"operator_type_id": 2,
"start_date": this.state.startDate,
"end_date": this.state.endDate
}
this.props.createAM(payload)
// console.log(payload)
}
render() { render() {
return ( return (
<div className="test app-popup-show" style={{ paddingTop: 100 }}> <div className="test app-popup-show" style={{ paddingTop: 100 }}>
...@@ -68,6 +162,7 @@ export default class CreateApprovalMatrix extends Component { ...@@ -68,6 +162,7 @@ export default class CreateApprovalMatrix extends Component {
id="id" id="id"
variant="filled" variant="filled"
label="ID" label="ID"
disabled
// value={this.state.periode} // value={this.state.periode}
> >
{/* {periode.map((option) => ( {/* {periode.map((option) => (
...@@ -85,7 +180,7 @@ export default class CreateApprovalMatrix extends Component { ...@@ -85,7 +180,7 @@ export default class CreateApprovalMatrix extends Component {
id="type" id="type"
select select
label="Tipe Persetujuan" label="Tipe Persetujuan"
// value={this.state.periode} value={this.state.type}
onChange={(e) => null} onChange={(e) => null}
> >
{type.map((option) => ( {type.map((option) => (
...@@ -104,32 +199,21 @@ export default class CreateApprovalMatrix extends Component { ...@@ -104,32 +199,21 @@ export default class CreateApprovalMatrix extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="order" id="order"
label="Order" label="Order"
// value={this.state.periode} value={this.state.order}
onChange={(e) => this.setState({ order: e.target.value })}
> >
{/* {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"> <div className="margin-bottom-20px">
<TextField <Autocomplete
style={{ width: '100%' }} {...this.state.approvedBy}
id="approve-by" id="debug"
select onChange={(event, newInputValue) => this.setState({userId:newInputValue.user_id}, () => console.log(this.state.userId))}
label="Pemberi Persetujuan" debug
// value={this.state.periode} renderInput={(params) => <TextField {...params} label="debug" margin="normal" />}
onChange={(e) => null} />
>
{approve_by.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))}
</TextField>
</div> </div>
</div> </div>
</div> </div>
...@@ -141,7 +225,7 @@ export default class CreateApprovalMatrix extends Component { ...@@ -141,7 +225,7 @@ export default class CreateApprovalMatrix extends Component {
id="operator" id="operator"
select select
label="Operator" label="Operator"
// value={this.state.periode} value={this.state.operator}
onChange={(e) => null} onChange={(e) => null}
> >
{operator.map((option) => ( {operator.map((option) => (
...@@ -159,34 +243,35 @@ export default class CreateApprovalMatrix extends Component { ...@@ -159,34 +243,35 @@ export default class CreateApprovalMatrix extends Component {
<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-bottom-20px">
<TextField <DatePicker
style={{ width: '100%' }} margin="normal"
id="start-period" id="startDate"
label="Berlaku Mulai" label="Berlaku Mulai"
// value={this.state.periode} format="dd MMMM yyyy"
> value={this.state.startDate == "" ? null : 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> }}
))} */}
</TextField> style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div> </div>
</div> </div>
<div className="column-2"> <div className="column-2">
<div className="margin-bottom-20px"> <div className="margin-bottom-20px">
<TextField <DatePicker
style={{ width: '100%' }} margin="normal"
id="end-period" id="endDate"
label="Berlaku Hingga" label="Berlaku Hingga"
// value={this.state.periode} format="dd MMMM yyyy"
> value={this.state.endDate == "" ? null : 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> />
</div> </div>
</div> </div>
</div> </div>
...@@ -195,16 +280,12 @@ export default class CreateApprovalMatrix extends Component { ...@@ -195,16 +280,12 @@ export default class CreateApprovalMatrix extends Component {
<div className="margin-bottom-20px"> <div className="margin-bottom-20px">
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="status"
variant="filled" variant="filled"
label="Aktif" id="status"
// value={this.state.periode} label="Status"
disabled
defaultValue={"Aktif"}
> >
{/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))} */}
</TextField> </TextField>
</div> </div>
</div> </div>
...@@ -216,11 +297,6 @@ export default class CreateApprovalMatrix extends Component { ...@@ -216,11 +297,6 @@ export default class CreateApprovalMatrix extends Component {
label="Max Value" label="Max Value"
// value={this.state.periode} // value={this.state.periode}
> >
{/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))} */}
</TextField> </TextField>
</div> </div>
</div> </div>
...@@ -239,7 +315,7 @@ export default class CreateApprovalMatrix extends Component { ...@@ -239,7 +315,7 @@ export default class CreateApprovalMatrix extends Component {
</div> </div>
</div> </div>
<div className="column-2" style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'center'}}> <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', cursor:"pointer" }}> <div onClick={() => this.validasi()} style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center', cursor:"pointer" }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span> <span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div> </div>
</div> </div>
......
...@@ -126,7 +126,7 @@ export default class EditApprovalMatrix extends Component { ...@@ -126,7 +126,7 @@ export default class EditApprovalMatrix extends Component {
</div> </div>
</div> </div>
<div className="column-2"> <div className="column-2">
<div className="" style={{ paddingTop: 4, paddingRight: 10, paddingBottom: 10, paddingLeft: 10, borderRadius: 5 }}> <div className="" style={{ padding: 10, paddingLeft: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="type" id="type"
...@@ -134,7 +134,8 @@ export default class EditApprovalMatrix extends Component { ...@@ -134,7 +134,8 @@ export default class EditApprovalMatrix extends Component {
label="Tipe Persetujuan" label="Tipe Persetujuan"
value={this.props.data.approval_type_name} value={this.props.data.approval_type_name}
onChange={(e) => null} onChange={(e) => null}
selectProps={{ SelectProps={{
// native: true,
style: { style: {
fontSize: 11 fontSize: 11
} }
......
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