Commit ce90c26c authored by ari_darmawan's avatar ari_darmawan

fix button edit customer type

parent 073b95aa
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
<div class="form-group" *ngIf="CustomerType != ''" > <div class="form-group" *ngIf="CustomerType != ''" >
<label><small>Customer Type <span class="text-danger">*</span></small></label> <label><small>Customer Type <span class="text-danger">*</span></small></label>
<select type="text" <select type="text"
[disabled]="IsFormDisabled"
class="form-control form-control-sm select-style" class="form-control form-control-sm select-style"
[disabled]="IsFormDisabledCSType"
[(ngModel)]="CustomerType" [(ngModel)]="CustomerType"
(change)="CustomerTypeChange()"> (change)="CustomerTypeChange()">
<ng-container *ngFor="let CustomerType of CustomerTypeData; let i = index"> <ng-container *ngFor="let CustomerType of CustomerTypeData; let i = index">
...@@ -136,13 +136,13 @@ ...@@ -136,13 +136,13 @@
<div class="col-4"> <div class="col-4">
<button class="btn btn-sm btn-block btn-danger" style="border-radius: 3px" (click)="CancelClick()"><i class="fas fa-times"></i> Cancel</button> <button class="btn btn-sm btn-block btn-danger" style="border-radius: 3px" (click)="CancelClick()"><i class="fas fa-times"></i> Cancel</button>
</div> </div>
<div class="col-4" *ngIf="IsFormDisabled == true"> <div class="col-4" *ngIf="IsFormDisabled && !isEditCustomerType">
<button class="btn btn-sm btn-block arataka-btn-default" (click)="EditCsutomerData()"><i class="fas fa-user-edit"></i> Edit Customer</button> <button class="btn btn-sm btn-block arataka-btn-default" (click)="EditCsutomerData()"><i class="fas fa-user-edit"></i> Edit Customer</button>
</div> </div>
<div class="col-8" *ngIf="IsFormDisabledCSType == true"> <div class="col-8" *ngIf="IsFormDisabledCSType && isEditCustomerType">
<button class="btn btn-sm btn-block arataka-btn-default" (click)="EditCsutomerDataSubmit()"><i class="far fa-paper-plane"></i> Edit Customer</button> <button class="btn btn-sm btn-block arataka-btn-default" (click)="EditCsutomerDataSubmit()"><i class="far fa-paper-plane"></i> Save Customer</button>
</div> </div>
<div class="col-4" *ngIf="IsFormDisabledCSType == false"> <div class="col-4" *ngIf="!IsFormDisabledCSType">
<button class="btn btn-sm btn-block arataka-btn-primary" (click)="SubmitNewCustomer()"><i class="fas fa-plus-circle"></i> Add Customer</button> <button class="btn btn-sm btn-block arataka-btn-primary" (click)="SubmitNewCustomer()"><i class="fas fa-plus-circle"></i> Add Customer</button>
</div> </div>
</ng-container> </ng-container>
......
...@@ -34,6 +34,7 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -34,6 +34,7 @@ export class AdminTicketCustomerMdComponent implements OnInit {
@Input() IsFormDisabled : boolean = false @Input() IsFormDisabled : boolean = false
@Input() IsFormDisabledCSType : boolean = false @Input() IsFormDisabledCSType : boolean = false
isEditCustomerType: boolean = false;
public CustomerTypeData = [ public CustomerTypeData = [
...@@ -111,6 +112,7 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -111,6 +112,7 @@ export class AdminTicketCustomerMdComponent implements OnInit {
} }
ngOnInitAfter(_data,_urlParamData){ ngOnInitAfter(_data,_urlParamData){
console.log([_data, _urlParamData])
this.urlParamData = { this.urlParamData = {
value : null, value : null,
...@@ -250,20 +252,20 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -250,20 +252,20 @@ export class AdminTicketCustomerMdComponent implements OnInit {
let that = this let that = this
this.FilterIdentityType() this.FilterIdentityType()
this.FirstName = "" // this.FirstName = ""
this.LastName = "" // this.LastName = ""
this.Email = "" // this.Email = ""
this.MobileNumber = "" // this.MobileNumber = ""
this.MobileNumber2 = "" // this.MobileNumber2 = ""
this.MothersName = "" // this.MothersName = ""
this.IdentityIDNumber = "" // this.IdentityIDNumber = ""
this.CustomerTypeData.forEach(function(item,index) { this.CustomerTypeData.forEach(function(item,index) {
if(item.Active){ if(item.Active){
that.IdentityIDType = that.IdentityIDTypeData[index].ID that.IdentityIDType = that.IdentityIDTypeData[index].ID
return false; return false;
} }
}); });
this.Address = "" // this.Address = ""
var date17 = new Date(); var date17 = new Date();
date17.setFullYear(date17.getFullYear() - 17); date17.setFullYear(date17.getFullYear() - 17);
...@@ -274,9 +276,10 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -274,9 +276,10 @@ export class AdminTicketCustomerMdComponent implements OnInit {
isGet: false, isGet: false,
}) })
this.CustomerID = null // this.CustomerID = null
this.IsFormDisabled = false // this.IsFormDisabled = false
// this.isEditCustomerType = false;
} }
...@@ -341,8 +344,10 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -341,8 +344,10 @@ export class AdminTicketCustomerMdComponent implements OnInit {
CancelClick() { CancelClick() {
if(!this.IsFormDisabledCSType){ if(!this.IsFormDisabledCSType){
this.isEditCustomerType = false;
this.ChildEvent.next(this.CustomerDataLocal) this.ChildEvent.next(this.CustomerDataLocal)
}else{ }else{
this.isEditCustomerType = false;
this.IsFormDisabledCSType = false; this.IsFormDisabledCSType = false;
this.IsFormDisabled = true; this.IsFormDisabled = true;
} }
...@@ -428,6 +433,7 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -428,6 +433,7 @@ export class AdminTicketCustomerMdComponent implements OnInit {
EditCsutomerData(){ EditCsutomerData(){
this.IsFormDisabledCSType = true; this.IsFormDisabledCSType = true;
this.IsFormDisabled = false; this.IsFormDisabled = false;
this.isEditCustomerType = true;
} }
EditCsutomerDataSubmit(){ EditCsutomerDataSubmit(){
...@@ -471,7 +477,7 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -471,7 +477,7 @@ export class AdminTicketCustomerMdComponent implements OnInit {
org_id: 1, org_id: 1,
customer_id : this.CustomerID customer_id : this.CustomerID
} }
console.log(Request)
if(valid){ if(valid){
this.UpdateCustomerAPI(Request) this.UpdateCustomerAPI(Request)
}else{ }else{
...@@ -543,7 +549,7 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -543,7 +549,7 @@ export class AdminTicketCustomerMdComponent implements OnInit {
this.IsFormDisabled = true this.IsFormDisabled = true
}else{ } else {
//this.MobileNumber = "" //this.MobileNumber = ""
// this.FirstName = "" // this.FirstName = ""
...@@ -559,15 +565,12 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -559,15 +565,12 @@ export class AdminTicketCustomerMdComponent implements OnInit {
} }
}else{ } else {
AratakaConfig.Alert.showAlert('Internal Server Error!','alert-danger',2000) AratakaConfig.Alert.showAlert('Internal Server Error!','alert-danger',2000)
this.IsFormDisabled = false this.IsFormDisabled = false
} }
AratakaConfig.LoadingPage.hideLoading() AratakaConfig.LoadingPage.hideLoading()
}, }, (err: HttpErrorResponse) => {
(err: HttpErrorResponse) => {
console.log(this.MobileNumber)
console.log(JSON.stringify(err.error));
//AratakaConfig.Alert.showAlert(err.error.detail,'alert-danger',2000) //AratakaConfig.Alert.showAlert(err.error.detail,'alert-danger',2000)
// this.MobileNumber = this.urlParamData.value // this.MobileNumber = this.urlParamData.value
// this.FirstName = "" // this.FirstName = ""
...@@ -585,41 +588,34 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -585,41 +588,34 @@ export class AdminTicketCustomerMdComponent implements OnInit {
}); });
} }
GettingPersonByIdentityIDNumberListAPI(_Request){ GettingPersonByIdentityIDNumberListAPI(_Request) {
//AratakaConfig.LoadingPage.showLoading('Checking Person by Identity ID Number') //AratakaConfig.LoadingPage.showLoading('Checking Person by Identity ID Number')
this._CustomerService.GetPersonByIdentityIDNumber(_Request) this._CustomerService.GetPersonByIdentityIDNumber(_Request)
.subscribe((result: any) => { .subscribe((result: any) => {
if(result != null){ if (result != null) {
console.log(JSON.stringify(result)) if (result.values != undefined) {
if(result.values != undefined){
this.FilterCustomerType() this.FilterCustomerType()
let CsTypeVal = "" let CsTypeVal = ""
if( if(
this.TeamID == this.Env.Team.CsCabangBranchAgent || this.TeamID == this.Env.Team.CsCabangBranchAgent ||
this.TeamID == this.Env.Team.AgentCallCenter || this.TeamID == this.Env.Team.AgentCallCenter ||
this.TeamID == this.Env.Team.SociomileStaff) this.TeamID == this.Env.Team.SociomileStaff ) {
{ if (result.values[0].customer_type == "Non Nasabah") {
if(result.values[0].customer_type == "Non Nasabah"){
CsTypeVal = "0" CsTypeVal = "0"
}else if(result.values[0].customer_type == "Nasabah"){ } else if (result.values[0].customer_type == "Nasabah") {
CsTypeVal = "1" CsTypeVal = "1"
}else if(result.values[0].customer_type == "Nasabah Perusahaan"){ } else if (result.values[0].customer_type == "Nasabah Perusahaan") {
CsTypeVal = "2" CsTypeVal = "2"
}else{ } else {
CsTypeVal = "" CsTypeVal = ""
} }
} } else {
else if (result.values[0].customer_type == "Non Nasabah") {
{
if(result.values[0].customer_type == "Non Nasabah"){
CsTypeVal = "0" CsTypeVal = "0"
}else if(result.values[0].customer_type == "Nasabah"){ } else if (result.values[0].customer_type == "Nasabah") {
CsTypeVal = "1" CsTypeVal = "1"
}else{ } else {
CsTypeVal = "" CsTypeVal = ""
} }
} }
...@@ -644,11 +640,10 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -644,11 +640,10 @@ export class AdminTicketCustomerMdComponent implements OnInit {
isGet: false, isGet: false,
}) })
this.CustomerID = result.values[0].id this.CustomerID = result.values[0].id;
this.IsFormDisabled = true;
this.IsFormDisabled = true
}else{ } else {
// this.MobileNumber = "" // this.MobileNumber = ""
// this.FirstName = "" // this.FirstName = ""
...@@ -666,14 +661,12 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -666,14 +661,12 @@ export class AdminTicketCustomerMdComponent implements OnInit {
} }
}else{ } else {
AratakaConfig.Alert.showAlert('Internal Server Error!','alert-danger',2000) AratakaConfig.Alert.showAlert('Internal Server Error!','alert-danger',2000)
this.IsFormDisabled = false this.IsFormDisabled = false
} }
AratakaConfig.LoadingPage.hideLoading() AratakaConfig.LoadingPage.hideLoading()
}, }, (err: HttpErrorResponse) => {
(err: HttpErrorResponse) => {
console.log(JSON.stringify(err.error));
//AratakaConfig.Alert.showAlert(err.error.detail,'alert-danger',2000) //AratakaConfig.Alert.showAlert(err.error.detail,'alert-danger',2000)
// this.MobileNumber = "" // this.MobileNumber = ""
...@@ -694,15 +687,12 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -694,15 +687,12 @@ export class AdminTicketCustomerMdComponent implements OnInit {
}); });
} }
InsertNewCustomerAPI(_Request){ InsertNewCustomerAPI(_Request) {
AratakaConfig.LoadingPage.showLoading('Add new Customer') AratakaConfig.LoadingPage.showLoading('Add new Customer')
this._CustomerService.AddNewCustomer(_Request) this._CustomerService.AddNewCustomer(_Request)
.subscribe((result: any) => { .subscribe((result: any) => {
if(result != null){ if (result != null) {
//console.log(JSON.stringify(result)) if (result.values != undefined) {
if(result.values != undefined){
var ObjKey = Object.keys(result.values.objects) var ObjKey = Object.keys(result.values.objects)
...@@ -716,57 +706,47 @@ export class AdminTicketCustomerMdComponent implements OnInit { ...@@ -716,57 +706,47 @@ export class AdminTicketCustomerMdComponent implements OnInit {
} }
this.ChildEvent.next(this.CustomerDataLocal) this.ChildEvent.next(this.CustomerDataLocal)
}else{ } else {
AratakaConfig.Alert.showAlert('Failed to add Customer','alert-danger',2000) AratakaConfig.Alert.showAlert('Failed to add Customer','alert-danger',2000)
} }
} else {
}else{
AratakaConfig.Alert.showAlert('Internal Server Error!','alert-danger',2000) AratakaConfig.Alert.showAlert('Internal Server Error!','alert-danger',2000)
} }
AratakaConfig.LoadingPage.hideLoading() AratakaConfig.LoadingPage.hideLoading()
}, }, (err: HttpErrorResponse) => {
(err: HttpErrorResponse) => {
console.log(JSON.stringify(err.error));
//AratakaConfig.Alert.showAlert(err.error.detail,'alert-danger',2000)
AratakaConfig.LoadingPage.hideLoading() AratakaConfig.LoadingPage.hideLoading()
}); });
} }
UpdateCustomerAPI(_Request){ UpdateCustomerAPI(_Request) {
AratakaConfig.LoadingPage.showLoading('Update Customer') AratakaConfig.LoadingPage.showLoading('Update Customer')
this._CustomerService.UpdateCustomer(_Request) this._CustomerService.UpdateCustomer(_Request)
.subscribe((result: any) => { .subscribe((result: any) => {
if(result != null){ if (result != null) {
//console.log(JSON.stringify(result)) if (result.values != undefined) {
if(result.values != undefined){
var ObjKey = Object.keys(result.values.objects) var ObjKey = Object.keys(result.values.objects)
if(result.values.objects[ObjKey[0]].key != undefined){ if (result.values.objects[ObjKey[0]].key != undefined) {
AratakaConfig.Alert.showAlert('Customer data updated successfully','alert-success',2000) AratakaConfig.Alert.showAlert('Customer data updated successfully','alert-success',2000)
this.IsFormDisabledCSType = false; this.IsFormDisabledCSType = false;
this.IsFormDisabled = true; this.IsFormDisabled = true;
this.isEditCustomerType = false;
} }
}else{ } else {
this.isEditCustomerType = false;
AratakaConfig.Alert.showAlert('Failed to Update Customer','alert-danger',2000) AratakaConfig.Alert.showAlert('Failed to Update Customer','alert-danger',2000)
} }
} else {
}else{ this.isEditCustomerType = false;
AratakaConfig.Alert.showAlert('Internal Server Error!','alert-danger',2000) AratakaConfig.Alert.showAlert('Internal Server Error!','alert-danger',2000)
} }
AratakaConfig.LoadingPage.hideLoading() AratakaConfig.LoadingPage.hideLoading()
}, }, (err: HttpErrorResponse) => {
(err: HttpErrorResponse) => { this.isEditCustomerType = false;
console.log(JSON.stringify(err.error));
//AratakaConfig.Alert.showAlert(err.error.detail,'alert-danger',2000)
AratakaConfig.LoadingPage.hideLoading() AratakaConfig.LoadingPage.hideLoading()
}); });
} }
} }
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