feat: migrate tag management to server actions

- Completed migration of tag management to server actions by creating `actions/tags.ts` for CRUD operations.
- Removed obsolete API routes for tags (`/api/tags`, `/api/tags/[id]`) and updated related components to utilize new server actions.
- Updated `TagForm` and `useTags` hook to handle tag creation, updating, and deletion through server actions, improving performance and simplifying client-side logic.
- Cleaned up `tags-client.ts` by removing unused types and methods, focusing on validation only.
- Marked related TODO items as complete in `TODO.md`.
This commit is contained in:
Julien Froidefond
2025-09-18 21:00:28 +02:00
parent 8b98c467d0
commit b12dd4f8dc
8 changed files with 253 additions and 317 deletions

View File

@@ -1,17 +1,7 @@
import { HttpClient } from './base/http-client';
import { Tag, ApiResponse } from '@/lib/types';
// Types pour les requêtes
export interface CreateTagData {
name: string;
color: string;
}
export interface UpdateTagData {
tagId: string;
name?: string;
color?: string;
}
// Types pour les requêtes (now only used for validation - CRUD operations moved to server actions)
export interface TagFilters {
q?: string; // Recherche par nom
@@ -89,27 +79,7 @@ export class TagsClient extends HttpClient {
return this.get<TagResponse>(`/${id}`);
}
/**
* Crée un nouveau tag
*/
async createTag(data: CreateTagData): Promise<TagResponse> {
return this.post<TagResponse>('', data);
}
/**
* Met à jour un tag
*/
async updateTag(data: UpdateTagData): Promise<TagResponse> {
const { tagId, ...updates } = data;
return this.patch<TagResponse>(`/${tagId}`, updates);
}
/**
* Supprime un tag
*/
async deleteTag(id: string): Promise<ApiResponse<void>> {
return this.delete<ApiResponse<void>>(`/${id}`);
}
// CRUD operations removed - now handled by server actions in /actions/tags.ts
/**
* Valide le format d'une couleur hexadécimale
@@ -139,9 +109,9 @@ export class TagsClient extends HttpClient {
}
/**
* Valide les données d'un tag
* Valide les données d'un tag (utilisé par les formulaires avant server actions)
*/
static validateTagData(data: Partial<CreateTagData>): string[] {
static validateTagData(data: { name?: string; color?: string }): string[] {
const errors: string[] = [];
if (!data.name || typeof data.name !== 'string') {