Commit ce90c26c authored by ari_darmawan's avatar ari_darmawan

fix button edit customer type

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