+5
-1
@@ -6,6 +6,10 @@
|
||||
<label>{{ t('authorNameLabel') }}</label>
|
||||
<input pInputText type="text" [(ngModel)]="searchQuery" [placeholder]="t('authorNamePlaceholder')" class="search-input"/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{ t('asinLabel') }}</label>
|
||||
<input pInputText type="text" [(ngModel)]="asinQuery" [placeholder]="t('asinPlaceholder')" class="search-input"/>
|
||||
</div>
|
||||
<div class="field region-field">
|
||||
<label>{{ t('regionLabel') }}</label>
|
||||
<p-select
|
||||
@@ -22,7 +26,7 @@
|
||||
icon="pi pi-search"
|
||||
(onClick)="search()"
|
||||
[loading]="searching"
|
||||
[disabled]="!searchQuery.trim()">
|
||||
[disabled]="!canSearch">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+9
-2
@@ -39,6 +39,7 @@ export class AuthorMatchComponent implements OnInit {
|
||||
private t = inject(TranslocoService);
|
||||
|
||||
searchQuery = '';
|
||||
asinQuery = '';
|
||||
selectedRegion = 'us';
|
||||
searching = false;
|
||||
matching = false;
|
||||
@@ -62,13 +63,19 @@ export class AuthorMatchComponent implements OnInit {
|
||||
this.searchQuery = this.authorName;
|
||||
}
|
||||
|
||||
get canSearch(): boolean {
|
||||
return !!this.searchQuery.trim() || !!this.asinQuery.trim();
|
||||
}
|
||||
|
||||
search(): void {
|
||||
if (!this.searchQuery.trim()) return;
|
||||
const asin = this.asinQuery.trim();
|
||||
const query = this.searchQuery.trim();
|
||||
if (!query && !asin) return;
|
||||
this.searching = true;
|
||||
this.results = [];
|
||||
this.hasSearched = true;
|
||||
|
||||
this.authorService.searchAuthorMetadata(this.authorId, this.searchQuery.trim(), this.selectedRegion)
|
||||
this.authorService.searchAuthorMetadata(this.authorId, query, this.selectedRegion, asin || undefined)
|
||||
.subscribe({
|
||||
next: (results) => {
|
||||
this.results = results;
|
||||
|
||||
@@ -35,10 +35,14 @@ export class AuthorService {
|
||||
return this.http.get<AuthorDetails>(`${this.baseUrl}/by-name`, {params: {name}});
|
||||
}
|
||||
|
||||
searchAuthorMetadata(authorId: number, query: string, region: string): Observable<AuthorSearchResult[]> {
|
||||
return this.http.get<AuthorSearchResult[]>(`${this.baseUrl}/${authorId}/search-metadata`, {
|
||||
params: {q: query, region}
|
||||
});
|
||||
searchAuthorMetadata(authorId: number, query: string, region: string, asin?: string): Observable<AuthorSearchResult[]> {
|
||||
const params: Record<string, string> = {region};
|
||||
if (asin) {
|
||||
params['asin'] = asin;
|
||||
} else {
|
||||
params['q'] = query;
|
||||
}
|
||||
return this.http.get<AuthorSearchResult[]>(`${this.baseUrl}/${authorId}/search-metadata`, {params});
|
||||
}
|
||||
|
||||
matchAuthor(authorId: number, request: AuthorMatchRequest): Observable<AuthorDetails> {
|
||||
|
||||
Reference in New Issue
Block a user