refactor: update tag data structure and improve tag handling
- Changed `TagsResponse` and `UseTagsState` to include `usage` count in the tag data structure for better tracking. - Simplified tag initialization in `useTags` to directly use `initialData`. - Enhanced `TagsPageClient` to filter and sort tags based on usage, improving user experience in tag management. - Removed unused variables and streamlined the search functionality for better performance.
This commit is contained in:
@@ -5,7 +5,7 @@ import { tagsClient, TagFilters, CreateTagData, UpdateTagData, TagsClient } from
|
||||
import { Tag } from '@/lib/types';
|
||||
|
||||
interface UseTagsState {
|
||||
tags: Tag[];
|
||||
tags: Array<Tag & { usage: number }>;
|
||||
popularTags: Array<Tag & { usage: number }>;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
@@ -29,7 +29,7 @@ export function useTags(
|
||||
initialFilters?: TagFilters
|
||||
): UseTagsState & UseTagsActions {
|
||||
const [state, setState] = useState<UseTagsState>({
|
||||
tags: initialData?.map(tag => ({ id: tag.id, name: tag.name, color: tag.color, isPinned: tag.isPinned })) || [],
|
||||
tags: initialData || [],
|
||||
popularTags: initialData || [],
|
||||
loading: !initialData,
|
||||
error: null
|
||||
|
||||
Reference in New Issue
Block a user