[FA-misc] Refresh button, UI mostly gold
This commit is contained in:
@@ -4,12 +4,14 @@ export interface NovelFilters {
|
||||
search: string;
|
||||
statuses: NovelStatus[];
|
||||
tags: string[];
|
||||
authorName: string;
|
||||
}
|
||||
|
||||
export const EMPTY_FILTERS: NovelFilters = {
|
||||
search: '',
|
||||
statuses: [],
|
||||
tags: []
|
||||
tags: [],
|
||||
authorName: ''
|
||||
};
|
||||
|
||||
const VALID_STATUSES: NovelStatus[] = ['ABANDONED', 'COMPLETED', 'HIATUS', 'IN_PROGRESS', 'UNKNOWN'];
|
||||
@@ -30,7 +32,9 @@ export function parseFiltersFromURL(searchParams?: URLSearchParams): NovelFilter
|
||||
const tagsParam = params.get('tags') ?? '';
|
||||
const tags = tagsParam.split(',').filter((t) => t.length > 0);
|
||||
|
||||
return { search, statuses, tags };
|
||||
const authorName = params.get('author') ?? '';
|
||||
|
||||
return { search, statuses, tags, authorName };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,6 +55,10 @@ export function filtersToURLParams(filters: NovelFilters): string {
|
||||
params.set('tags', filters.tags.join(','));
|
||||
}
|
||||
|
||||
if (filters.authorName.trim()) {
|
||||
params.set('author', filters.authorName.trim());
|
||||
}
|
||||
|
||||
return params.toString();
|
||||
}
|
||||
|
||||
@@ -95,6 +103,15 @@ export function filtersToGraphQLWhere(filters: NovelFilters): NovelDtoFilterInpu
|
||||
});
|
||||
}
|
||||
|
||||
// Author filter (exact match on author name)
|
||||
if (filters.authorName.trim()) {
|
||||
conditions.push({
|
||||
author: {
|
||||
name: { eq: filters.authorName.trim() }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Return null if no filters, single condition if one filter, AND for multiple
|
||||
if (conditions.length === 0) {
|
||||
return null;
|
||||
@@ -111,5 +128,10 @@ export function filtersToGraphQLWhere(filters: NovelFilters): NovelDtoFilterInpu
|
||||
* Check if any filters are active
|
||||
*/
|
||||
export function hasActiveFilters(filters: NovelFilters): boolean {
|
||||
return filters.search.trim().length > 0 || filters.statuses.length > 0 || filters.tags.length > 0;
|
||||
return (
|
||||
filters.search.trim().length > 0 ||
|
||||
filters.statuses.length > 0 ||
|
||||
filters.tags.length > 0 ||
|
||||
filters.authorName.trim().length > 0
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user