fix
This commit is contained in:
@@ -24,14 +24,13 @@ export class ErrorInterceptor implements HttpInterceptor {
|
||||
this.authenticationService.logout();
|
||||
location.reload();
|
||||
}
|
||||
let error = err.message || err.statusText;
|
||||
error = !err.error ? error : err.error.message || err.error.title;
|
||||
|
||||
let error = err.error || err.message || err.statusText;
|
||||
|
||||
if (!error) {
|
||||
console.log('not parsed error', err);
|
||||
}
|
||||
return throwError(error);
|
||||
//return throwError(err.error || err);
|
||||
return throwError(() => error);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@
|
||||
<div class="text-inside">
|
||||
<mat-form-field class="example-full-width" appearance="fill">
|
||||
<mat-label>Rate</mat-label>
|
||||
<input matInput [value]="currency.rate | number:'0.2-2'" formControlName="rate" currencyMask [options]="{ prefix: '', precision: 4, inputMode: 1 }" required>
|
||||
<input matInput [value]="currency.rate | number:'0.2-2'" formControlName="rate" currencyMask
|
||||
[options]="{ prefix: '', precision: 4, inputMode: 1 }" required>
|
||||
<mat-error *ngIf="addForm.controls?.['rate']?.hasError('required')">
|
||||
Please enter rate
|
||||
</mat-error>
|
||||
@@ -52,7 +53,8 @@
|
||||
<div class="text-inside">
|
||||
<mat-form-field class="example-full-width" appearance="fill">
|
||||
<mat-label>Quantity</mat-label>
|
||||
<input matInput [value]="currency.rate | number:'0.0-0'" formControlName="quantity" currencyMask [options]="{ prefix: '', precision: 0 }" required>
|
||||
<input matInput [value]="currency.rate | number:'0.0-0'" formControlName="quantity"
|
||||
currencyMask [options]="{ prefix: '', precision: 0 }" required>
|
||||
<mat-error *ngIf="addForm.controls?.['rate']?.hasError('required')">
|
||||
Please enter rate
|
||||
</mat-error>
|
||||
@@ -63,7 +65,8 @@
|
||||
<div class="text-inside">
|
||||
<mat-form-field class="example-full-width">
|
||||
<mat-label>Rate Date</mat-label>
|
||||
<input matInput [matDatepicker]="picker3" (focus)="picker3.open()" value={{currency.rateDate}} formControlName="rateDate" required>
|
||||
<input matInput [matDatepicker]="picker3" (focus)="picker3.open()"
|
||||
value={{currency.rateDate}} formControlName="rateDate" required>
|
||||
<mat-hint>DD/MM/YYYY</mat-hint>
|
||||
<mat-datepicker-toggle matSuffix [for]="picker3"></mat-datepicker-toggle>
|
||||
<mat-datepicker #picker3></mat-datepicker>
|
||||
@@ -85,8 +88,11 @@
|
||||
</div>
|
||||
<mat-dialog-actions class="mat-dialog-actions">
|
||||
<div class="mat-dialog-left">
|
||||
<div class="alert alert-danger mat-dialog-error" *ngIf="errorMessage">
|
||||
{{errorMessage}}
|
||||
<div class="alert alert-danger mat-dialog-error" *ngIf="error">
|
||||
<p *ngIf="error.title">{{error.title}}</p>
|
||||
<ul *ngIf="error.errors">
|
||||
<li *ngFor="let error of error.errors | keyvalue">{{error.value}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mat-dialog-right">
|
||||
@@ -98,4 +104,4 @@
|
||||
</mat-dialog-actions>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -21,7 +21,7 @@ import { CurrencyModel } from '../../../model/currency.model';
|
||||
})
|
||||
export class SettingsRateCurrencyComponent {
|
||||
public addForm!: UntypedFormGroup;
|
||||
public errorMessage?: string;
|
||||
public error?: any;
|
||||
|
||||
constructor(
|
||||
private fb: UntypedFormBuilder,
|
||||
@@ -71,20 +71,26 @@ export class SettingsRateCurrencyComponent {
|
||||
}
|
||||
|
||||
onSubmitClick() {
|
||||
this.error = undefined;
|
||||
if (this.addForm.valid) {
|
||||
this.errorMessage = undefined;
|
||||
this.httpClient
|
||||
.put<CurrencyModel>(ApiRoutes.SettingsCurrency.replace(':id', this.addForm.value.id), this.addForm.value)
|
||||
.subscribe(response => {
|
||||
this.httpClient
|
||||
.post<CurrencyModel[]>(ApiRoutes.SettingsCurrenciesRate.replace(':id', this.addForm.value.id), this.addForm.value)
|
||||
.subscribe(response => {
|
||||
this.dialogRef.close({ refresh: true });
|
||||
}, error => {
|
||||
this.errorMessage = error.detail;
|
||||
});
|
||||
}, error => {
|
||||
this.errorMessage = error.detail;
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
this.httpClient
|
||||
.post<CurrencyModel[]>(ApiRoutes.SettingsCurrenciesRate.replace(':id', this.addForm.value.id), this.addForm.value)
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
this.dialogRef.close({ refresh: true });
|
||||
},
|
||||
error: (error) => {
|
||||
this.error = error;
|
||||
},
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
this.error = error;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user