Commit a0d7c716 authored by Riri Novita's avatar Riri Novita

Merge branch 'ENV-DEV' into 'ENV-DEPLOYMENT'

email recipient

See merge request !2259
parents e05d96a6 c2c53026
...@@ -60,14 +60,27 @@ export default class AddUser extends Component { ...@@ -60,14 +60,27 @@ export default class AddUser extends Component {
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorNotification: false,
msgErrorFN: '', msgErrorFN: '',
msgErrorEM: '', msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
msgErrorNotification: '',
alert: false, alert: false,
tipeAlert: '', tipeAlert: '',
messageAlert: '' messageAlert: '',
notification: null,
listNotification: [
{
"id": 0,
"value": "No"
},
{
"id": 1,
"value": "Yes"
}
],
} }
} }
...@@ -101,11 +114,13 @@ export default class AddUser extends Component { ...@@ -101,11 +114,13 @@ export default class AddUser extends Component {
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorNotification: false,
msgErrorFN: '', msgErrorFN: '',
msgErrorEM: '', msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
msgErrorNotification: '',
}) })
} else if (isDate && type === 'end_date') { } else if (isDate && type === 'end_date') {
this.setState({ this.setState({
...@@ -115,11 +130,13 @@ export default class AddUser extends Component { ...@@ -115,11 +130,13 @@ export default class AddUser extends Component {
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorNotification: false,
msgErrorFN: '', msgErrorFN: '',
msgErrorEM: '', msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
msgErrorNotification: '',
}) })
} else { } else {
this.setState({ this.setState({
...@@ -129,11 +146,13 @@ export default class AddUser extends Component { ...@@ -129,11 +146,13 @@ export default class AddUser extends Component {
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorNotification: false,
msgErrorFN: '', msgErrorFN: '',
msgErrorEM: '', msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
msgErrorNotification: '',
}) })
} }
} }
...@@ -148,7 +167,7 @@ export default class AddUser extends Component { ...@@ -148,7 +167,7 @@ export default class AddUser extends Component {
} }
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) => {
handlePushChild(items) handlePushChild(items)
}) })
} }
...@@ -161,22 +180,24 @@ export default class AddUser extends Component { ...@@ -161,22 +180,24 @@ export default class AddUser extends Component {
}) })
let uniqueCompany = company.filter((val, id, array) => { let uniqueCompany = company.filter((val, id, array) => {
return array.indexOf(val) == id; return array.indexOf(val) == id;
}); });
company = this.state.role == null? [] : this.state.role.role_id === 1? uniqueCompany : [] company = this.state.role == null ? [] : this.state.role.role_id === 1 ? uniqueCompany : []
// console.log(uniqueCompany) // console.log(uniqueCompany)
this.setState({ this.setState({
errorFullname: false, errorFullname: false,
errorEmail: false, errorEmail: false,
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorNotification: false,
msgErrorFN: '', msgErrorFN: '',
msgErrorEM: '', msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
msgErrorNotification: '',
company company
}, () => { }, () => {
// console.log(this.state.company) // console.log(this.state.company)
...@@ -205,6 +226,8 @@ export default class AddUser extends Component { ...@@ -205,6 +226,8 @@ export default class AddUser extends Component {
this.setState({ errorEndDate: true, msgErrorED: 'Valid To Cannot be Empty' }) this.setState({ errorEndDate: true, msgErrorED: 'Valid To Cannot be Empty' })
} else if (this.state.company.length < 1) { } else if (this.state.company.length < 1) {
this.setState({ alert: true, messageAlert: 'Authorization company cannot be empty', tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: 'Authorization company cannot be empty', tipeAlert: 'warning' })
} else if (R.isNil(this.state.notification)) {
this.setState({ errorNotification: true, msgErrorNotification: 'Email Notification Maintenance Cannot be Empty' })
} }
// else if (this.state.privileges.length < 1) { // else if (this.state.privileges.length < 1) {
// alert('Hak Akses belum di pilih !!') // alert('Hak Akses belum di pilih !!')
...@@ -217,8 +240,10 @@ export default class AddUser extends Component { ...@@ -217,8 +240,10 @@ export default class AddUser extends Component {
"password": this.state.fullname, "password": this.state.fullname,
"company": this.state.company, "company": this.state.company,
"start_date": this.state.startDate, "start_date": this.state.startDate,
"end_date": this.state.endDate "end_date": this.state.endDate,
"mail_notif": this.state.notification.id
} }
// console.log(payload);
this.props.createUser(payload) this.props.createUser(payload)
} }
} }
...@@ -300,7 +325,7 @@ export default class AddUser extends Component { ...@@ -300,7 +325,7 @@ export default class AddUser extends Component {
} }
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) => {
handlePushChild(items) handlePushChild(items)
}) })
} }
...@@ -314,7 +339,7 @@ export default class AddUser extends Component { ...@@ -314,7 +339,7 @@ export default class AddUser extends Component {
} }
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) => {
handleSpliceChild(items) handleSpliceChild(items)
}) })
} }
...@@ -325,7 +350,7 @@ export default class AddUser extends Component { ...@@ -325,7 +350,7 @@ export default class AddUser extends Component {
company.push(item.id) 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) => {
handlePushChild(items) handlePushChild(items)
}) })
} }
...@@ -335,15 +360,15 @@ export default class AddUser extends Component { ...@@ -335,15 +360,15 @@ export default class AddUser extends Component {
company.splice(indexID, 1) 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) => {
handleSpliceChild(items) handleSpliceChild(items)
}) })
} }
} }
} }
// console.log(company) // console.log(company)
this.setState({ company}) this.setState({ company })
} }
renderChildren = (item, pad) => { renderChildren = (item, pad) => {
...@@ -679,6 +704,37 @@ export default class AddUser extends Component { ...@@ -679,6 +704,37 @@ export default class AddUser extends Component {
</div> </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-bottom-20px">
<Autocomplete
debug
id="tipe"
options={this.state.listNotification}
getOptionLabel={(option) => option.value}
onChange={(event, newInputValue) => this.setState({ notification: newInputValue }, () => this.clearError())}
renderInput={(params) =>
<TextField
{...params}
label="Email Notification Maintenance"
margin="normal"
style={{ marginTop: 7 }}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
error={this.state.errorNotification}
helperText={this.state.msgErrorNotification}
/>
}
/>
</div>
</div>
<div className="column-2">
</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-bottom-20px"> <div className="margin-bottom-20px">
......
...@@ -54,14 +54,27 @@ export default class EditUser extends Component { ...@@ -54,14 +54,27 @@ export default class EditUser extends Component {
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorNotification: false,
msgErrorFN: '', msgErrorFN: '',
msgErrorEM: '', msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
msgErrorNotification: '',
alert: false, alert: false,
tipeAlert: '', tipeAlert: '',
messageAlert: '' messageAlert: '',
notification: null,
listNotification: [
{
"id": 0,
"value": "No"
},
{
"id": 1,
"value": "Yes"
}
],
} }
} }
...@@ -85,11 +98,13 @@ export default class EditUser extends Component { ...@@ -85,11 +98,13 @@ export default class EditUser extends Component {
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorNotification: false,
msgErrorFN: '', msgErrorFN: '',
msgErrorEM: '', msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
msgErrorNotification: '',
}) })
} else if (isDate && type === 'end_date') { } else if (isDate && type === 'end_date') {
this.setState({ this.setState({
...@@ -99,11 +114,13 @@ export default class EditUser extends Component { ...@@ -99,11 +114,13 @@ export default class EditUser extends Component {
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorNotification: false,
msgErrorFN: '', msgErrorFN: '',
msgErrorEM: '', msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
msgErrorNotification: '',
}) })
} else { } else {
this.setState({ this.setState({
...@@ -113,11 +130,13 @@ export default class EditUser extends Component { ...@@ -113,11 +130,13 @@ export default class EditUser extends Component {
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorNotification: false,
msgErrorFN: '', msgErrorFN: '',
msgErrorEM: '', msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
msgErrorNotification: '',
}) })
} }
} }
...@@ -132,7 +151,7 @@ export default class EditUser extends Component { ...@@ -132,7 +151,7 @@ export default class EditUser extends Component {
} }
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) => {
handlePushChild(items) handlePushChild(items)
}) })
} }
...@@ -145,34 +164,37 @@ export default class EditUser extends Component { ...@@ -145,34 +164,37 @@ export default class EditUser extends Component {
}) })
let uniqueCompany = company.filter((val, id, array) => { let uniqueCompany = company.filter((val, id, array) => {
return array.indexOf(val) == id; return array.indexOf(val) == id;
}); });
company = this.state.role == null? [] : this.state.role.role_id === 1? uniqueCompany : [] company = this.state.role == null ? [] : this.state.role.role_id === 1 ? uniqueCompany : []
// console.log(uniqueCompany) // console.log(uniqueCompany)
this.setState({ this.setState({
errorFullname: false, errorFullname: false,
errorEmail: false, errorEmail: false,
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorNotification: false,
msgErrorFN: '', msgErrorFN: '',
msgErrorEM: '', msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
msgErrorNotification: '',
company company
}) })
} }
getDetailUser() { getDetailUser() {
api.create().getDetailUser(this.state.paramsId).then((response) => { api.create().getDetailUser(this.state.paramsId).then((response) => {
// console.log(response);
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ tempData: response.data.data, company: response.data.data.company }, ()=> let index = this.state.listNotification.findIndex((val) => val.id === response.data.data.mail_notif)
this.getRole(response.data.data.role_id)) this.setState({ tempData: response.data.data, company: response.data.data.company, notification: index === -1 ? null : this.state.listNotification[index] }, () =>
// console.log(response.data.data) this.getRole(response.data.data.role_id))
} 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("Someone Logged In") || response.data.message.includes("Token Expired")) { if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
...@@ -215,6 +237,8 @@ export default class EditUser extends Component { ...@@ -215,6 +237,8 @@ export default class EditUser extends Component {
this.setState({ errorEndDate: true, msgErrorED: 'Valid To Cannot be Empty' }) this.setState({ errorEndDate: true, msgErrorED: 'Valid To Cannot be Empty' })
} else if (this.state.company.length < 1) { } else if (this.state.company.length < 1) {
this.setState({ alert: true, messageAlert: 'Authorization company cannot be empty', tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: 'Authorization company cannot be empty', tipeAlert: 'warning' })
} else if (R.isNil(this.state.notification)) {
this.setState({ errorNotification: true, msgErrorNotification: 'Email Notification Maintenance Cannot be Empty' })
} }
// else if (this.state.privileges.length < 1) { // else if (this.state.privileges.length < 1) {
// alert('Hak Akses belum di pilih !!') // alert('Hak Akses belum di pilih !!')
...@@ -224,7 +248,7 @@ export default class EditUser extends Component { ...@@ -224,7 +248,7 @@ export default class EditUser extends Component {
} }
} }
updateUser(){ updateUser() {
let payload = { let payload = {
"user_id": this.state.tempData.user_id, "user_id": this.state.tempData.user_id,
"role_id": this.state.role.role_id, "role_id": this.state.role.role_id,
...@@ -232,7 +256,8 @@ export default class EditUser extends Component { ...@@ -232,7 +256,8 @@ export default class EditUser extends Component {
"fullname": this.state.tempData.fullname, "fullname": this.state.tempData.fullname,
"company": this.state.company, "company": this.state.company,
"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,
"mail_notif": this.state.notification.id
} }
this.props.updateUser(payload) this.props.updateUser(payload)
} }
...@@ -281,8 +306,8 @@ export default class EditUser extends Component { ...@@ -281,8 +306,8 @@ 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') {
let dataBaru = response.data.data.map((item,index) => { let dataBaru = response.data.data.map((item, index) => {
return {...item, check: false} return { ...item, check: false }
}) })
this.setState({ listCompany: dataBaru }) this.setState({ listCompany: dataBaru })
} else { } else {
...@@ -319,7 +344,7 @@ export default class EditUser extends Component { ...@@ -319,7 +344,7 @@ export default class EditUser extends Component {
} }
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) => {
handlePushChild(items) handlePushChild(items)
}) })
} }
...@@ -333,7 +358,7 @@ export default class EditUser extends Component { ...@@ -333,7 +358,7 @@ export default class EditUser extends Component {
} }
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) => {
handleSpliceChild(items) handleSpliceChild(items)
}) })
} }
...@@ -344,7 +369,7 @@ export default class EditUser extends Component { ...@@ -344,7 +369,7 @@ export default class EditUser extends Component {
company.push(item.id) 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) => {
handlePushChild(items) handlePushChild(items)
}) })
} }
...@@ -354,15 +379,15 @@ export default class EditUser extends Component { ...@@ -354,15 +379,15 @@ export default class EditUser extends Component {
company.splice(indexID, 1) 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) => {
handleSpliceChild(items) handleSpliceChild(items)
}) })
} }
} }
} }
// console.log(company) // console.log(company)
this.setState({ company}) this.setState({ company })
} }
renderChildren = (item, pad) => { renderChildren = (item, pad) => {
...@@ -380,7 +405,7 @@ export default class EditUser extends Component { ...@@ -380,7 +405,7 @@ export default class EditUser extends Component {
return ( return (
// <li> // <li>
<Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}> <Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: !R.isNil(data.children)? (data.children.length > 0? padding : padding + 30) : padding + 30}}> <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: !R.isNil(data.children) ? (data.children.length > 0 ? padding : padding + 30) : padding + 30 }}>
{R.isNil(data.children) ? {R.isNil(data.children) ?
null null
: :
...@@ -472,7 +497,7 @@ export default class EditUser extends Component { ...@@ -472,7 +497,7 @@ export default class EditUser extends Component {
}; };
closeAlert() { closeAlert() {
this.setState({ alert: false }) this.setState({ alert: false })
} }
render() { render() {
...@@ -600,14 +625,14 @@ export default class EditUser extends Component { ...@@ -600,14 +625,14 @@ export default class EditUser extends Component {
<Autocomplete <Autocomplete
{...this.state.listRole} {...this.state.listRole}
id="role" id="role"
onChange={(event, newInputValue) => this.setState({ role: newInputValue }, ()=> this.clearError())} onChange={(event, newInputValue) => this.setState({ role: newInputValue }, () => this.clearError())}
debug debug
renderInput={(params) => <TextField renderInput={(params) => <TextField
{...params} {...params}
label="Role" label="Role"
margin="normal" margin="normal"
style={{ marginTop: 7 }} style={{ marginTop: 7 }}
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
error={this.state.errorRoleName} error={this.state.errorRoleName}
helperText={this.state.msgErrorRN} helperText={this.state.msgErrorRN}
...@@ -619,7 +644,7 @@ export default class EditUser extends Component { ...@@ -619,7 +644,7 @@ export default class EditUser extends Component {
} }
}} }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }} InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>} />}
value={this.state.role} value={this.state.role}
/> />
</div> </div>
...@@ -693,6 +718,38 @@ export default class EditUser extends Component { ...@@ -693,6 +718,38 @@ export default class EditUser extends Component {
</div> </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 }}>
<Autocomplete
debug
id="tipe"
options={this.state.listNotification}
getOptionLabel={(option) => option.value}
value={this.state.notification}
onChange={(event, newInputValue) => this.setState({ notification: newInputValue }, () => this.clearError())}
renderInput={(params) =>
<TextField
{...params}
label="Email Notification Maintenance"
margin="normal"
style={{ marginTop: 7 }}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
error={this.state.errorNotification}
helperText={this.state.msgErrorNotification}
/>
}
/>
</div>
</div>
<div className="column-2">
</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-bottom-20px"> <div className="margin-bottom-20px">
......
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