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 @@
"@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": {
"version": "3.2.10",
"resolved": "https://registry.npmjs.org/@material-ui/pickers/-/pickers-3.2.10.tgz",
......
......@@ -8,6 +8,7 @@
"@date-io/moment": "^2.8.0",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@material-ui/pickers": "^3.2.10",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
......
......@@ -91,6 +91,10 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
// 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
......@@ -126,6 +130,9 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
getPerusahaan,
createPerusahaan,
updatePerusahaan
getApprovedByAM,
createAM,
updateAM
}
}
......
......@@ -78,12 +78,6 @@ export default class ApprovalMatrix extends Component {
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)
}
......@@ -127,6 +121,17 @@ export default class ApprovalMatrix extends Component {
// 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() {
const columns = [{
name: "Action",
......@@ -366,6 +371,7 @@ export default class ApprovalMatrix extends Component {
<CreateApprovalMatrix
onClickClose={() => this.setState({ visibleCreate: false })}
data={this.state.listData}
createAM={this.createAM.bind(this)}
/>
)}
{this.state.visibleEdit && (
......
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 * as R from 'ramda'
import format from "date-fns/format";
import api from "../../api";
import Autocomplete from '@material-ui/lab/Autocomplete';
const type = [
{
value: 'KPI',
label: 'KPI',
value: '1',
label: 'YEARLY',
},
{
value: 'Gatau',
label: 'Gatau',
value: '2',
label: 'MONTHLY',
},
];
{
value: '3',
label: 'DAILY',
},
];
const approve_by = [
{
value: '1',
label: 'John Doe',
user_id: '1',
fullname: 'John Doe',
},
{
value: '2',
label: 'John Doe lagi',
user_id: '2',
fullname: 'John Doe lagi',
},
];
const operator = [
......@@ -38,6 +47,91 @@ const operator = [
];
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() {
return (
<div className="test app-popup-show" style={{ paddingTop: 100 }}>
......@@ -68,6 +162,7 @@ export default class CreateApprovalMatrix extends Component {
id="id"
variant="filled"
label="ID"
disabled
// value={this.state.periode}
>
{/* {periode.map((option) => (
......@@ -85,7 +180,7 @@ export default class CreateApprovalMatrix extends Component {
id="type"
select
label="Tipe Persetujuan"
// value={this.state.periode}
value={this.state.type}
onChange={(e) => null}
>
{type.map((option) => (
......@@ -104,32 +199,21 @@ export default class CreateApprovalMatrix extends Component {
style={{ width: '100%' }}
id="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>
</div>
</div>
<div className="column-2">
<div className="margin-bottom-20px">
<TextField
style={{ width: '100%' }}
id="approve-by"
select
label="Pemberi Persetujuan"
// value={this.state.periode}
onChange={(e) => null}
>
{approve_by.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))}
</TextField>
<Autocomplete
{...this.state.approvedBy}
id="debug"
onChange={(event, newInputValue) => this.setState({userId:newInputValue.user_id}, () => console.log(this.state.userId))}
debug
renderInput={(params) => <TextField {...params} label="debug" margin="normal" />}
/>
</div>
</div>
</div>
......@@ -141,7 +225,7 @@ export default class CreateApprovalMatrix extends Component {
id="operator"
select
label="Operator"
// value={this.state.periode}
value={this.state.operator}
onChange={(e) => null}
>
{operator.map((option) => (
......@@ -159,34 +243,35 @@ export default class CreateApprovalMatrix extends Component {
<div className="grid grid-2x grid-mobile-none gap-15px">
<div className="column-1">
<div className="margin-bottom-20px">
<TextField
style={{ width: '100%' }}
id="start-period"
<DatePicker
margin="normal"
id="startDate"
label="Berlaku Mulai"
// value={this.state.periode}
>
{/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))} */}
</TextField>
format="dd MMMM yyyy"
value={this.state.startDate == "" ? null : this.state.startDate}
onChange={(e) => this.handleChange(e, 'start_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
<div className="column-2">
<div className="margin-bottom-20px">
<TextField
style={{ width: '100%' }}
id="end-period"
<DatePicker
margin="normal"
id="endDate"
label="Berlaku Hingga"
// value={this.state.periode}
>
{/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))} */}
</TextField>
format="dd MMMM yyyy"
value={this.state.endDate == "" ? null : this.state.endDate}
onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
</div>
......@@ -195,16 +280,12 @@ export default class CreateApprovalMatrix extends Component {
<div className="margin-bottom-20px">
<TextField
style={{ width: '100%' }}
id="status"
variant="filled"
label="Aktif"
// value={this.state.periode}
id="status"
label="Status"
disabled
defaultValue={"Aktif"}
>
{/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))} */}
</TextField>
</div>
</div>
......@@ -216,11 +297,6 @@ export default class CreateApprovalMatrix extends Component {
label="Max Value"
// value={this.state.periode}
>
{/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))} */}
</TextField>
</div>
</div>
......@@ -239,7 +315,7 @@ export default class CreateApprovalMatrix extends Component {
</div>
</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', 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>
</div>
</div>
......
......@@ -126,7 +126,7 @@ export default class EditApprovalMatrix extends Component {
</div>
</div>
<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
style={{ width: '100%' }}
id="type"
......@@ -134,7 +134,8 @@ export default class EditApprovalMatrix extends Component {
label="Tipe Persetujuan"
value={this.props.data.approval_type_name}
onChange={(e) => null}
selectProps={{
SelectProps={{
// native: true,
style: {
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