Choose / Edit / Create customers during billing.
This commit is contained in:
@ -1,12 +0,0 @@
|
||||
export class Customer {
|
||||
name: string;
|
||||
phone: string;
|
||||
address: string;
|
||||
|
||||
public constructor(init?: Partial<Customer>) {
|
||||
this.name = '';
|
||||
this.phone = '';
|
||||
this.address = '';
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
@ -5,8 +5,9 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { Customer } from '../../core/customer';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { Customer } from '../customer';
|
||||
import { CustomerService } from '../../customers/customer.service';
|
||||
import { GuestBook } from '../guest-book';
|
||||
import { GuestBookService } from '../guest-book.service';
|
||||
|
||||
@ -27,6 +28,7 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
private router: Router,
|
||||
private toaster: ToasterService,
|
||||
private ser: GuestBookService,
|
||||
private customerService: CustomerService,
|
||||
) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
@ -41,7 +43,7 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) => (x === null ? observableOf([]) : this.ser.autocomplete(x))),
|
||||
switchMap((x) => (x === null ? observableOf([]) : this.customerService.autocomplete(x))),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { Customer } from './customer';
|
||||
import { GuestBook } from './guest-book';
|
||||
import { GuestBookList } from './guest-book-list';
|
||||
|
||||
@ -59,13 +58,4 @@ export class GuestBookService {
|
||||
.delete<GuestBook>(`${url}/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<GuestBook>;
|
||||
}
|
||||
|
||||
autocomplete(query: string): Observable<Customer[]> {
|
||||
const options = { params: new HttpParams().set('q', query) };
|
||||
return this.http
|
||||
.get<Customer[]>(`${customerUrl}/query`, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'autocomplete'))) as Observable<
|
||||
Customer[]
|
||||
>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user