[FA-misc] Refresh button, UI mostly gold
All checks were successful
CI / build-backend (pull_request) Successful in 1m45s
CI / build-frontend (pull_request) Successful in 39s

This commit is contained in:
gamer147
2025-12-09 09:11:39 -05:00
parent 81e4e88ad4
commit e70c39ea75
12 changed files with 476 additions and 26 deletions

View File

@@ -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
);
}