From a440c0729f4745ada3cc57828e522e05db33f31b Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Mon, 25 Aug 2025 19:31:17 +0200 Subject: [PATCH] refactor: remove unused components and clean up evaluation client - Deleted CreateSkillForm and ProfileForm components as they are no longer needed. - Removed the initializeEmptyEvaluation method from EvaluationClient, as the backend handles evaluation creation. - Updated exports in evaluation index to reflect the removal of WelcomeEvaluationScreen. --- clients/domains/evaluation-client.ts | 17 -- components/create-skill-form.tsx | 226 ----------------------- components/evaluation/index.ts | 2 +- components/evaluation/welcome-screen.tsx | 73 -------- components/login/index.ts | 1 - components/login/login-form-wrapper.tsx | 213 --------------------- components/profile-form.tsx | 226 ----------------------- 7 files changed, 1 insertion(+), 757 deletions(-) delete mode 100644 components/create-skill-form.tsx delete mode 100644 components/evaluation/welcome-screen.tsx delete mode 100644 components/login/login-form-wrapper.tsx delete mode 100644 components/profile-form.tsx diff --git a/clients/domains/evaluation-client.ts b/clients/domains/evaluation-client.ts index 39a29da..2638178 100644 --- a/clients/domains/evaluation-client.ts +++ b/clients/domains/evaluation-client.ts @@ -102,21 +102,4 @@ export class EvaluationClient extends BaseHttpClient { throw error; } }; - - /** - * Initialise une évaluation vide pour un profil - */ - initializeEmptyEvaluation = async ( - profile: import("../../lib/types").UserProfile - ): Promise => { - try { - // Simplement créer le profil via l'auth, pas besoin de créer une évaluation vide - // Le backend créera automatiquement l'évaluation lors du premier accès - const { authClient } = await import("../index"); - await authClient.login(profile); - } catch (error) { - console.error("Failed to initialize evaluation:", error); - throw error; - } - }; } diff --git a/components/create-skill-form.tsx b/components/create-skill-form.tsx deleted file mode 100644 index 908d517..0000000 --- a/components/create-skill-form.tsx +++ /dev/null @@ -1,226 +0,0 @@ -"use client"; - -import { useState } from "react"; -import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; -import { Textarea } from "@/components/ui/textarea"; -import { Label } from "@/components/ui/label"; -import { Plus, X, Link as LinkIcon, Loader2 } from "lucide-react"; -import { skillsClient } from "@/clients"; - -interface CreateSkillFormProps { - categoryName: string; - onSuccess: (skillId: string) => void; - onCancel: () => void; -} - -export function CreateSkillForm({ - categoryName, - onSuccess, - onCancel, -}: CreateSkillFormProps) { - const [formData, setFormData] = useState({ - name: "", - description: "", - icon: "", - links: [""], - }); - const [isLoading, setIsLoading] = useState(false); - const [error, setError] = useState(""); - - const addLink = () => { - setFormData((prev) => ({ - ...prev, - links: [...prev.links, ""], - })); - }; - - const removeLink = (index: number) => { - setFormData((prev) => ({ - ...prev, - links: prev.links.filter((_, i) => i !== index), - })); - }; - - const updateLink = (index: number, value: string) => { - setFormData((prev) => ({ - ...prev, - links: prev.links.map((link, i) => (i === index ? value : link)), - })); - }; - - const generateSkillId = (name: string) => { - return name - .toLowerCase() - .replace(/[^a-z0-9\s]/g, "") - .replace(/\s+/g, "-") - .trim(); - }; - - const getCategoryId = (categoryName: string) => { - // Convertir le nom de catégorie en ID (ex: "Cloud" -> "cloud") - return categoryName.toLowerCase(); - }; - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - setError(""); - setIsLoading(true); - - try { - // Validation - if (!formData.name.trim()) { - throw new Error("Le nom de la compétence est requis"); - } - if (!formData.description.trim()) { - throw new Error("La description est requise"); - } - - const skillId = generateSkillId(formData.name); - const categoryId = getCategoryId(categoryName); - - // Filtrer les liens vides - const validLinks = formData.links.filter((link) => link.trim()); - - const skillData = { - id: skillId, - name: formData.name.trim(), - description: formData.description.trim(), - icon: formData.icon.trim() || "fas-cog", - links: validLinks, - }; - - const success = await skillsClient.createSkill(categoryId, skillData); - - if (success) { - onSuccess(skillId); - } else { - throw new Error("Erreur lors de la création de la compétence"); - } - } catch (err) { - setError(err instanceof Error ? err.message : "Une erreur est survenue"); - } finally { - setIsLoading(false); - } - }; - - return ( -
- {error && ( -
- {error} -
- )} - -
- - - setFormData((prev) => ({ ...prev, name: e.target.value })) - } - disabled={isLoading} - /> -
- -
- -