Fix: Login deleting old clients was conflicting with login history
Chore: Moved to angular linting using the recommended plugins / settings
This commit is contained in:
@ -6,10 +6,6 @@ import { catchError } from 'rxjs/operators';
|
||||
import { ErrorLoggerService } from './error-logger.service';
|
||||
import { Voucher } from './voucher';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||
};
|
||||
|
||||
const url = '/api';
|
||||
const serviceName = 'VoucherService';
|
||||
|
||||
@ -36,11 +32,9 @@ export class VoucherService {
|
||||
|
||||
get(id: string, type: string): Observable<Voucher> {
|
||||
const endpoint = type.replace(/ /g, '-').toLowerCase();
|
||||
return <Observable<Voucher>>(
|
||||
this.http
|
||||
.get<Voucher>(`${url}/${endpoint}/${id}`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Get Voucher')))
|
||||
);
|
||||
return this.http
|
||||
.get<Voucher>(`${url}/${endpoint}/${id}`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Get Voucher'))) as Observable<Voucher>;
|
||||
}
|
||||
|
||||
getOfType(type: string, account?: string): Observable<Voucher> {
|
||||
@ -50,36 +44,30 @@ export class VoucherService {
|
||||
// eslint-disable-next-line @typescript-eslint/dot-notation
|
||||
options = { params: new HttpParams().set('a', account) };
|
||||
}
|
||||
return <Observable<Voucher>>(
|
||||
this.http
|
||||
.get<Voucher>(`${url}/${endpoint}`, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Get Voucher of Type')))
|
||||
);
|
||||
return this.http
|
||||
.get<Voucher>(`${url}/${endpoint}`, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'Get Voucher of Type')),
|
||||
) as Observable<Voucher>;
|
||||
}
|
||||
|
||||
getIncentive(date: string): Observable<Voucher> {
|
||||
const options = { params: new HttpParams().set('d', date) };
|
||||
return <Observable<Voucher>>(
|
||||
this.http
|
||||
.get<Voucher>(`${url}/incentive`, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Get Incentive')))
|
||||
);
|
||||
return this.http
|
||||
.get<Voucher>(`${url}/incentive`, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Get Incentive'))) as Observable<Voucher>;
|
||||
}
|
||||
|
||||
post(id: string): Observable<Voucher> {
|
||||
return <Observable<Voucher>>(
|
||||
this.http
|
||||
.post<Voucher>(`${url}/post-voucher/${id}`, {})
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Post Voucher')))
|
||||
);
|
||||
return this.http
|
||||
.post<Voucher>(`${url}/post as Observable<Voucher>-voucher/${id}`, {})
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Post Voucher'))) as Observable<Voucher>;
|
||||
}
|
||||
|
||||
delete(id: string): Observable<Voucher> {
|
||||
return <Observable<Voucher>>(
|
||||
this.http
|
||||
.delete<Voucher>(`${url}/delete/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Delete Voucher')))
|
||||
);
|
||||
return this.http
|
||||
.delete<Voucher>(`${url}/delete/${id}`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Delete Voucher'))) as Observable<Voucher>;
|
||||
}
|
||||
|
||||
saveOrUpdate(voucher: Voucher): Observable<Voucher> {
|
||||
@ -100,11 +88,9 @@ export class VoucherService {
|
||||
});
|
||||
voucher.files = voucher.files.filter((x) => x.id);
|
||||
fd.append('data', JSON.stringify(voucher));
|
||||
return <Observable<Voucher>>(
|
||||
this.http
|
||||
.post<Voucher>(`${url}/${endpoint}`, fd)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Save Voucher')))
|
||||
);
|
||||
return this.http
|
||||
.post<Voucher>(`${url}/${endpoint}`, fd)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Save Voucher'))) as Observable<Voucher>;
|
||||
}
|
||||
|
||||
update(voucher: Voucher, endpoint: string): Observable<Voucher> {
|
||||
@ -117,10 +103,8 @@ export class VoucherService {
|
||||
});
|
||||
voucher.files = voucher.files.filter((x) => x.id);
|
||||
fd.append('data', JSON.stringify(voucher));
|
||||
return <Observable<Voucher>>(
|
||||
this.http
|
||||
.put<Voucher>(`${url}/${endpoint}/${voucher.id}`, fd)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Update Voucher')))
|
||||
);
|
||||
return this.http
|
||||
.put<Voucher>(`${url}/${endpoint}/${voucher.id}`, fd)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Update Voucher'))) as Observable<Voucher>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user