"use client"; import { useState } from "react"; import { createSkillAction, updateSkillAction } from "./actions"; import { useRouter } from "@/i18n/routing"; import { Loader2, ArrowLeft, Save, PlusCircle } from "lucide-react"; const CATEGORIES = [ { value: "backend", label: "Enterprise Backend" }, { value: "infra", label: "Database & Infrastructure" }, { value: "frontend", label: "Frontend Development" }, { value: "mobile", label: "Mobile Development" }, ]; const DEVICON_SUGGESTIONS = [ "java", "spring", "oracle", "docker", "postgresql", "redis", "kubernetes", "react", "nextjs", "typescript", "tailwindcss", "angular", "flutter", "swift", "kafka", "nginx", "jenkins", "github", ]; export function SkillForm({ initialData, skillId }: { initialData?: any; skillId?: string }) { const router = useRouter(); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [iconPreview, setIconPreview] = useState(initialData?.iconName || ""); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(null); setLoading(true); const formData = new FormData(e.currentTarget); let result; if (skillId) { result = await updateSkillAction(skillId, null, formData); } else { result = await createSkillAction(null, formData); } if (!result.success) { setError(result.message || "An error occurred"); setLoading(false); } else { router.push("/admin/dashboard/skills"); router.refresh(); } } return (

{skillId ? "Edit Skill" : "Add New Skill"}

{skillId ? "Update tech stack item" : "Add a new technology to your arsenal"}

{error && (
{error}
)}
setIconPreview(e.target.value.trim())} className="w-full px-4 py-3 rounded-xl bg-muted/30 border border-border text-sm focus:outline-none focus:ring-2 focus:ring-emerald-500/50 transition-all font-mono" /> {/* Icon Preview */} {iconPreview && (
{iconPreview} { (e.target as HTMLImageElement).style.display = 'none'; }} /> {iconPreview}
)} {/* Quick suggestions */}
{DEVICON_SUGGESTIONS.map((s) => ( ))}
); }