From f5417040fd26b57ebbc5d4acf1397bc008597225 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Tue, 23 Sep 2025 10:25:41 +0200 Subject: [PATCH] feat: complete Phase 4 of service refactoring - Marked tasks in `TODO.md` as completed for moving task-related files to the `task-management` directory and correcting imports across the codebase. - Updated imports in `seed-data.ts`, `seed-tags.ts`, API routes, and various components to reflect the new structure. - Removed obsolete `daily.ts`, `tags.ts`, and `tasks.ts` files to streamline the codebase. - Added new tasks in `TODO.md` for future cleaning and organization of service imports. --- TODO.md | 21 +++++++++++-------- scripts/seed-data.ts | 2 +- scripts/seed-tags.ts | 2 +- src/actions/daily.ts | 2 +- src/actions/tags.ts | 2 +- src/actions/tasks.ts | 2 +- .../daily/checkboxes/[id]/archive/route.ts | 2 +- src/app/api/daily/dates/route.ts | 2 +- src/app/api/daily/pending/route.ts | 2 +- src/app/api/daily/route.ts | 2 +- src/app/api/tags/[id]/route.ts | 2 +- src/app/api/tags/route.ts | 2 +- src/app/api/tasks/[id]/checkboxes/route.ts | 2 +- src/app/api/tasks/route.ts | 2 +- src/app/daily/page.tsx | 2 +- src/app/kanban/page.tsx | 4 ++-- src/app/page.tsx | 4 ++-- src/app/settings/advanced/page.tsx | 4 ++-- src/app/settings/general/page.tsx | 2 +- src/app/weekly-manager/page.tsx | 4 ++-- src/services/{ => task-management}/daily.ts | 2 +- src/services/{ => task-management}/tags.ts | 2 +- src/services/{ => task-management}/tasks.ts | 2 +- 23 files changed, 38 insertions(+), 35 deletions(-) rename src/services/{ => task-management}/daily.ts (99%) rename src/services/{ => task-management}/tags.ts (99%) rename src/services/{ => task-management}/tasks.ts (99%) diff --git a/TODO.md b/TODO.md index 8531790..1426d5f 100644 --- a/TODO.md +++ b/TODO.md @@ -126,13 +126,16 @@ src/services/ - [x] Corriger import dans script backup-manager.ts - [x] Corriger imports relatifs entre services -### Phase 4: Task Management -- [ ] **Déplacer `tasks.ts`** → `task-management/tasks.ts` - - [ ] Corriger imports dans actions/tasks, hooks/useTasks -- [ ] **Déplacer `tags.ts`** → `task-management/tags.ts` - - [ ] Corriger import dans `actions/tags.ts` -- [ ] **Déplacer `daily.ts`** → `task-management/daily.ts` - - [ ] Corriger imports dans hooks/useDaily, actions/daily +### Phase 4: Task Management ✅ +- [x] **Déplacer `tasks.ts`** → `task-management/tasks.ts` + - [x] Corriger 7 imports externes (pages, API routes, actions) + - [x] Corriger import dans script seed-data.ts +- [x] **Déplacer `tags.ts`** → `task-management/tags.ts` + - [x] Corriger 8 imports externes (pages, API routes, actions) + - [x] Corriger import dans script seed-tags.ts +- [x] **Déplacer `daily.ts`** → `task-management/daily.ts` + - [x] Corriger 6 imports externes (pages, API routes, actions) + - [x] Corriger imports relatifs vers ../core/database ### Phase 5: Intégrations (déjà partiellement fait) - [ ] **Déplacer `tfs.ts`** → `integrations/tfs.ts` @@ -147,8 +150,8 @@ src/services/ - [ ] Corriger tous les imports Jira dans actions, API routes, hooks ## phase 6: cleaning -- [ ] Les imports des services dans les services : pourquoi ne pas utiliser @services/... ? -- [ ] Les types & interfaces dans services : j'aimerai isoler les types et revoir les imports; par dossier un par un. +- [ ] Les imports des services dans les services : pourquoi ne pas utiliser @/services/... ? +- [ ] Les types & interfaces dans services : j'aimerai isoler les types dans des fihiers séparés et revoir les imports; par dossier un par un. Tant qu'à faire, il faudrait qu'on fasse toujours des "import type {} from ..." (ajouter le mot type sur l'import des types) ### Points d'attention pour chaque service: 1. **Identifier tous les imports du service** (grep) diff --git a/scripts/seed-data.ts b/scripts/seed-data.ts index a5e44a9..98f31b9 100644 --- a/scripts/seed-data.ts +++ b/scripts/seed-data.ts @@ -1,4 +1,4 @@ -import { tasksService } from '../src/services/tasks'; +import { tasksService } from '../src/services/task-management/tasks'; import { TaskStatus, TaskPriority } from '../src/lib/types'; /** diff --git a/scripts/seed-tags.ts b/scripts/seed-tags.ts index 0ab849a..07abf9e 100644 --- a/scripts/seed-tags.ts +++ b/scripts/seed-tags.ts @@ -1,4 +1,4 @@ -import { tagsService } from '../src/services/tags'; +import { tagsService } from '../src/services/task-management/tags'; async function seedTags() { console.log('🏷️ Création des tags de test...'); diff --git a/src/actions/daily.ts b/src/actions/daily.ts index 6281680..f5e0801 100644 --- a/src/actions/daily.ts +++ b/src/actions/daily.ts @@ -1,6 +1,6 @@ 'use server'; -import { dailyService } from '@/services/daily'; +import { dailyService } from '@/services/task-management/daily'; import { UpdateDailyCheckboxData, DailyCheckbox, CreateDailyCheckboxData } from '@/lib/types'; import { revalidatePath } from 'next/cache'; import { getToday, getPreviousWorkday, parseDate, normalizeDate } from '@/lib/date-utils'; diff --git a/src/actions/tags.ts b/src/actions/tags.ts index 7b04214..6882117 100644 --- a/src/actions/tags.ts +++ b/src/actions/tags.ts @@ -1,6 +1,6 @@ 'use server'; -import { tagsService } from '@/services/tags'; +import { tagsService } from '@/services/task-management/tags'; import { revalidatePath } from 'next/cache'; import { Tag } from '@/lib/types'; diff --git a/src/actions/tasks.ts b/src/actions/tasks.ts index 59e8903..221c6cf 100644 --- a/src/actions/tasks.ts +++ b/src/actions/tasks.ts @@ -1,6 +1,6 @@ 'use server' -import { tasksService } from '@/services/tasks'; +import { tasksService } from '@/services/task-management/tasks'; import { revalidatePath } from 'next/cache'; import { TaskStatus, TaskPriority } from '@/lib/types'; diff --git a/src/app/api/daily/checkboxes/[id]/archive/route.ts b/src/app/api/daily/checkboxes/[id]/archive/route.ts index df33251..c25b98e 100644 --- a/src/app/api/daily/checkboxes/[id]/archive/route.ts +++ b/src/app/api/daily/checkboxes/[id]/archive/route.ts @@ -1,5 +1,5 @@ import { NextRequest, NextResponse } from 'next/server'; -import { dailyService } from '@/services/daily'; +import { dailyService } from '@/services/task-management/daily'; export async function PATCH( request: NextRequest, diff --git a/src/app/api/daily/dates/route.ts b/src/app/api/daily/dates/route.ts index 115bbd0..36c426a 100644 --- a/src/app/api/daily/dates/route.ts +++ b/src/app/api/daily/dates/route.ts @@ -1,5 +1,5 @@ import { NextResponse } from 'next/server'; -import { dailyService } from '@/services/daily'; +import { dailyService } from '@/services/task-management/daily'; /** * API route pour récupérer toutes les dates avec des dailies diff --git a/src/app/api/daily/pending/route.ts b/src/app/api/daily/pending/route.ts index 3164d43..c0b8383 100644 --- a/src/app/api/daily/pending/route.ts +++ b/src/app/api/daily/pending/route.ts @@ -1,5 +1,5 @@ import { NextRequest, NextResponse } from 'next/server'; -import { dailyService } from '@/services/daily'; +import { dailyService } from '@/services/task-management/daily'; import { DailyCheckboxType } from '@/lib/types'; export async function GET(request: NextRequest) { diff --git a/src/app/api/daily/route.ts b/src/app/api/daily/route.ts index 8500ef9..221ac80 100644 --- a/src/app/api/daily/route.ts +++ b/src/app/api/daily/route.ts @@ -1,5 +1,5 @@ import { NextResponse } from 'next/server'; -import { dailyService } from '@/services/daily'; +import { dailyService } from '@/services/task-management/daily'; import { getToday, parseDate, isValidAPIDate, createDateFromParts } from '@/lib/date-utils'; /** diff --git a/src/app/api/tags/[id]/route.ts b/src/app/api/tags/[id]/route.ts index bf5e412..4e840ac 100644 --- a/src/app/api/tags/[id]/route.ts +++ b/src/app/api/tags/[id]/route.ts @@ -1,5 +1,5 @@ import { NextRequest, NextResponse } from 'next/server'; -import { tagsService } from '@/services/tags'; +import { tagsService } from '@/services/task-management/tags'; /** * GET /api/tags/[id] - Récupère un tag par son ID diff --git a/src/app/api/tags/route.ts b/src/app/api/tags/route.ts index 846899f..5f9c751 100644 --- a/src/app/api/tags/route.ts +++ b/src/app/api/tags/route.ts @@ -1,5 +1,5 @@ import { NextRequest, NextResponse } from 'next/server'; -import { tagsService } from '@/services/tags'; +import { tagsService } from '@/services/task-management/tags'; /** * GET /api/tags - Récupère tous les tags ou recherche par query diff --git a/src/app/api/tasks/[id]/checkboxes/route.ts b/src/app/api/tasks/[id]/checkboxes/route.ts index 01745ad..85c38b3 100644 --- a/src/app/api/tasks/[id]/checkboxes/route.ts +++ b/src/app/api/tasks/[id]/checkboxes/route.ts @@ -1,5 +1,5 @@ import { NextRequest, NextResponse } from 'next/server'; -import { tasksService } from '@/services/tasks'; +import { tasksService } from '@/services/task-management/tasks'; export async function GET( request: NextRequest, diff --git a/src/app/api/tasks/route.ts b/src/app/api/tasks/route.ts index 041b3f5..2240b0b 100644 --- a/src/app/api/tasks/route.ts +++ b/src/app/api/tasks/route.ts @@ -1,5 +1,5 @@ import { NextResponse } from 'next/server'; -import { tasksService } from '@/services/tasks'; +import { tasksService } from '@/services/task-management/tasks'; import { TaskStatus } from '@/lib/types'; /** diff --git a/src/app/daily/page.tsx b/src/app/daily/page.tsx index 61a6bec..1d2df8c 100644 --- a/src/app/daily/page.tsx +++ b/src/app/daily/page.tsx @@ -1,6 +1,6 @@ import { Metadata } from 'next'; import { DailyPageClient } from './DailyPageClient'; -import { dailyService } from '@/services/daily'; +import { dailyService } from '@/services/task-management/daily'; import { getToday } from '@/lib/date-utils'; // Force dynamic rendering (no static generation) diff --git a/src/app/kanban/page.tsx b/src/app/kanban/page.tsx index 1f6f4ea..fbf21b4 100644 --- a/src/app/kanban/page.tsx +++ b/src/app/kanban/page.tsx @@ -1,5 +1,5 @@ -import { tasksService } from '@/services/tasks'; -import { tagsService } from '@/services/tags'; +import { tasksService } from '@/services/task-management/tasks'; +import { tagsService } from '@/services/task-management/tags'; import { KanbanPageClient } from './KanbanPageClient'; // Force dynamic rendering (no static generation) diff --git a/src/app/page.tsx b/src/app/page.tsx index 75d3491..9df933f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,5 +1,5 @@ -import { tasksService } from '@/services/tasks'; -import { tagsService } from '@/services/tags'; +import { tasksService } from '@/services/task-management/tasks'; +import { tagsService } from '@/services/task-management/tags'; import { HomePageClient } from '@/components/HomePageClient'; // Force dynamic rendering (no static generation) diff --git a/src/app/settings/advanced/page.tsx b/src/app/settings/advanced/page.tsx index 584a937..12ff529 100644 --- a/src/app/settings/advanced/page.tsx +++ b/src/app/settings/advanced/page.tsx @@ -1,5 +1,5 @@ -import { tasksService } from '@/services/tasks'; -import { tagsService } from '@/services/tags'; +import { tasksService } from '@/services/task-management/tasks'; +import { tagsService } from '@/services/task-management/tags'; import { backupService } from '@/services/data-management/backup'; import { backupScheduler } from '@/services/data-management/backup-scheduler'; import { AdvancedSettingsPageClient } from '@/components/settings/AdvancedSettingsPageClient'; diff --git a/src/app/settings/general/page.tsx b/src/app/settings/general/page.tsx index 41051a1..7fd2e08 100644 --- a/src/app/settings/general/page.tsx +++ b/src/app/settings/general/page.tsx @@ -1,4 +1,4 @@ -import { tagsService } from '@/services/tags'; +import { tagsService } from '@/services/task-management/tags'; import { GeneralSettingsPageClient } from '@/components/settings/GeneralSettingsPageClient'; // Force dynamic rendering for real-time data diff --git a/src/app/weekly-manager/page.tsx b/src/app/weekly-manager/page.tsx index b9ddd57..715a37f 100644 --- a/src/app/weekly-manager/page.tsx +++ b/src/app/weekly-manager/page.tsx @@ -1,7 +1,7 @@ import { Header } from '@/components/ui/Header'; import { ManagerSummaryService } from '@/services/analytics/manager-summary'; -import { tasksService } from '@/services/tasks'; -import { tagsService } from '@/services/tags'; +import { tasksService } from '@/services/task-management/tasks'; +import { tagsService } from '@/services/task-management/tags'; import { WeeklyManagerPageClient } from './WeeklyManagerPageClient'; // Force dynamic rendering (no static generation) diff --git a/src/services/daily.ts b/src/services/task-management/daily.ts similarity index 99% rename from src/services/daily.ts rename to src/services/task-management/daily.ts index 48e0aa8..06fd3b4 100644 --- a/src/services/daily.ts +++ b/src/services/task-management/daily.ts @@ -1,4 +1,4 @@ -import { prisma } from './core/database'; +import { prisma } from '../core/database'; import { Prisma } from '@prisma/client'; import { DailyCheckbox, DailyView, CreateDailyCheckboxData, UpdateDailyCheckboxData, BusinessError, DailyCheckboxType, TaskStatus, TaskPriority, TaskSource } from '@/lib/types'; import { getPreviousWorkday, normalizeDate, formatDateForAPI, getToday, getYesterday } from '@/lib/date-utils'; diff --git a/src/services/tags.ts b/src/services/task-management/tags.ts similarity index 99% rename from src/services/tags.ts rename to src/services/task-management/tags.ts index a732a33..8960e16 100644 --- a/src/services/tags.ts +++ b/src/services/task-management/tags.ts @@ -1,4 +1,4 @@ -import { prisma } from './core/database'; +import { prisma } from '../core/database'; import { Prisma } from '@prisma/client'; import { Tag } from '@/lib/types'; diff --git a/src/services/tasks.ts b/src/services/task-management/tasks.ts similarity index 99% rename from src/services/tasks.ts rename to src/services/task-management/tasks.ts index 20a32d9..f858f47 100644 --- a/src/services/tasks.ts +++ b/src/services/task-management/tasks.ts @@ -1,4 +1,4 @@ -import { prisma } from './core/database'; +import { prisma } from '../core/database'; import { Task, TaskStatus, TaskPriority, TaskSource, BusinessError, DailyCheckbox, DailyCheckboxType } from '@/lib/types'; import { Prisma } from '@prisma/client'; import { getToday } from '@/lib/date-utils';