feat: add dashboard, projects, and persons pages with reusable components
Implemented the following: - `DashboardPage`: displays an overview of stats, recent projects, and tabs for future analytics/reports. - `ProjectsPage` and `PersonsPage`: include searchable tables, actions, and mobile-friendly card views. - Integrated reusable components like `AuthLoading`, `DropdownMenu`, `Table`, and `Card`.
This commit is contained in:
346
frontend/app/persons/[id]/edit/page.tsx
Normal file
346
frontend/app/persons/[id]/edit/page.tsx
Normal file
@@ -0,0 +1,346 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
ArrowLeft,
|
||||
Loader2,
|
||||
Save,
|
||||
Plus,
|
||||
X
|
||||
} from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
// Type definitions
|
||||
interface PersonFormData {
|
||||
name: string;
|
||||
email: string;
|
||||
level: string;
|
||||
}
|
||||
|
||||
// Mock data for available tags
|
||||
const availableTags = [
|
||||
"Frontend", "Backend", "Fullstack", "UX/UI", "DevOps",
|
||||
"React", "Vue", "Angular", "Node.js", "Python", "Java", "PHP",
|
||||
"JavaScript", "TypeScript", "CSS", "Docker", "Kubernetes", "Design",
|
||||
"Figma", "MERN"
|
||||
];
|
||||
|
||||
// Levels
|
||||
const levels = ["Junior", "Medior", "Senior"];
|
||||
|
||||
// Mock person data
|
||||
const getPersonData = (id: string) => {
|
||||
return {
|
||||
id: parseInt(id),
|
||||
name: "Jean Dupont",
|
||||
email: "jean.dupont@example.com",
|
||||
tags: ["Frontend", "React", "Junior"],
|
||||
};
|
||||
};
|
||||
|
||||
export default function EditPersonPage() {
|
||||
const params = useParams();
|
||||
const router = useRouter();
|
||||
const personId = params.id as string;
|
||||
|
||||
const [person, setPerson] = useState<any>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
||||
const [tagInput, setTagInput] = useState("");
|
||||
const [filteredTags, setFilteredTags] = useState<string[]>([]);
|
||||
|
||||
const { register, handleSubmit, control, formState: { errors }, reset } = useForm<PersonFormData>();
|
||||
|
||||
// Filter available tags based on input
|
||||
useEffect(() => {
|
||||
if (tagInput) {
|
||||
const filtered = availableTags.filter(
|
||||
tag =>
|
||||
tag.toLowerCase().includes(tagInput.toLowerCase()) &&
|
||||
!selectedTags.includes(tag)
|
||||
);
|
||||
setFilteredTags(filtered);
|
||||
} else {
|
||||
setFilteredTags([]);
|
||||
}
|
||||
}, [tagInput, selectedTags]);
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate API call to fetch person data
|
||||
const fetchPerson = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
// In a real app, this would be an API call
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
const data = getPersonData(personId);
|
||||
setPerson(data);
|
||||
|
||||
// Extract level from tags (assuming the last tag is the level)
|
||||
const level = data.tags.find(tag => ["Junior", "Medior", "Senior"].includes(tag)) || "";
|
||||
|
||||
// Set selected tags (excluding the level)
|
||||
const tags = data.tags.filter(tag => !["Junior", "Medior", "Senior"].includes(tag));
|
||||
setSelectedTags(tags);
|
||||
|
||||
// Reset form with person data
|
||||
reset({
|
||||
name: data.name,
|
||||
email: data.email,
|
||||
level: level
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error fetching person:", error);
|
||||
toast.error("Erreur lors du chargement de la personne");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchPerson();
|
||||
}, [personId, reset]);
|
||||
|
||||
const handleAddTag = (tag: string) => {
|
||||
if (!selectedTags.includes(tag)) {
|
||||
setSelectedTags([...selectedTags, tag]);
|
||||
}
|
||||
setTagInput("");
|
||||
setFilteredTags([]);
|
||||
};
|
||||
|
||||
const handleRemoveTag = (tag: string) => {
|
||||
setSelectedTags(selectedTags.filter(t => t !== tag));
|
||||
};
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if (e.key === 'Enter' && tagInput) {
|
||||
e.preventDefault();
|
||||
if (filteredTags.length > 0) {
|
||||
handleAddTag(filteredTags[0]);
|
||||
} else if (!selectedTags.includes(tagInput)) {
|
||||
// Add as a new tag if it doesn't exist
|
||||
handleAddTag(tagInput);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const onSubmit = async (data: PersonFormData) => {
|
||||
if (selectedTags.length === 0) {
|
||||
toast.error("Veuillez sélectionner au moins un tag");
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
// In a real app, this would be an API call to update the person
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
// Combine form data with selected tags
|
||||
const personData = {
|
||||
...data,
|
||||
tags: [...selectedTags, data.level]
|
||||
};
|
||||
|
||||
toast.success("Personne mise à jour avec succès");
|
||||
router.push("/persons");
|
||||
} catch (error) {
|
||||
console.error("Error updating person:", error);
|
||||
toast.error("Erreur lors de la mise à jour de la personne");
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex h-[50vh] items-center justify-center">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-primary" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!person) {
|
||||
return (
|
||||
<div className="flex h-[50vh] flex-col items-center justify-center">
|
||||
<p className="text-lg font-medium">Personne non trouvée</p>
|
||||
<Button asChild className="mt-4">
|
||||
<Link href="/persons">Retour aux personnes</Link>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="flex items-center gap-2">
|
||||
<Button variant="outline" size="icon" asChild>
|
||||
<Link href="/persons">
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
</Link>
|
||||
</Button>
|
||||
<h1 className="text-3xl font-bold">Modifier la personne</h1>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<CardHeader>
|
||||
<CardTitle>Informations de la personne</CardTitle>
|
||||
<CardDescription>
|
||||
Modifiez les informations et les tags de la personne
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="name">Nom</Label>
|
||||
<Input
|
||||
id="name"
|
||||
placeholder="Ex: Jean Dupont"
|
||||
{...register("name", {
|
||||
required: "Le nom est requis",
|
||||
minLength: {
|
||||
value: 3,
|
||||
message: "Le nom doit contenir au moins 3 caractères"
|
||||
}
|
||||
})}
|
||||
/>
|
||||
{errors.name && (
|
||||
<p className="text-sm text-destructive">{errors.name.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
placeholder="Ex: jean.dupont@example.com"
|
||||
{...register("email", {
|
||||
required: "L'email est requis",
|
||||
pattern: {
|
||||
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
||||
message: "Adresse email invalide"
|
||||
}
|
||||
})}
|
||||
/>
|
||||
{errors.email && (
|
||||
<p className="text-sm text-destructive">{errors.email.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="level">Niveau</Label>
|
||||
<Controller
|
||||
name="level"
|
||||
control={control}
|
||||
rules={{ required: "Le niveau est requis" }}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
onValueChange={field.onChange}
|
||||
defaultValue={field.value}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Sélectionnez un niveau" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{levels.map((level) => (
|
||||
<SelectItem key={level} value={level}>
|
||||
{level}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
{errors.level && (
|
||||
<p className="text-sm text-destructive">{errors.level.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="tags">Tags</Label>
|
||||
<div className="flex flex-wrap gap-1 mb-2">
|
||||
{selectedTags.map((tag) => (
|
||||
<Badge key={tag} variant="secondary" className="flex items-center gap-1">
|
||||
{tag}
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-4 w-4 p-0 text-muted-foreground hover:text-foreground"
|
||||
onClick={() => handleRemoveTag(tag)}
|
||||
>
|
||||
<X className="h-3 w-3" />
|
||||
<span className="sr-only">Supprimer le tag {tag}</span>
|
||||
</Button>
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
<div className="relative">
|
||||
<Input
|
||||
id="tags"
|
||||
placeholder="Rechercher ou ajouter un tag..."
|
||||
value={tagInput}
|
||||
onChange={(e) => setTagInput(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
/>
|
||||
{filteredTags.length > 0 && (
|
||||
<div className="absolute z-10 mt-1 w-full rounded-md border bg-popover p-2 shadow-md">
|
||||
<div className="max-h-60 overflow-auto">
|
||||
{filteredTags.map((tag) => (
|
||||
<div
|
||||
key={tag}
|
||||
className="flex cursor-pointer items-center rounded-md px-2 py-1.5 hover:bg-muted"
|
||||
onClick={() => handleAddTag(tag)}
|
||||
>
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
{tag}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Appuyez sur Entrée pour ajouter un tag ou sélectionnez-en un dans la liste
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
<CardFooter className="flex justify-between">
|
||||
<Button variant="outline" asChild>
|
||||
<Link href="/persons">Annuler</Link>
|
||||
</Button>
|
||||
<Button type="submit" disabled={isSubmitting}>
|
||||
{isSubmitting ? (
|
||||
<>
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
Enregistrement...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Save className="mr-2 h-4 w-4" />
|
||||
Enregistrer les modifications
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</CardFooter>
|
||||
</form>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
10
frontend/app/persons/layout.tsx
Normal file
10
frontend/app/persons/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { DashboardLayout } from "@/components/dashboard-layout";
|
||||
import { AuthLoading } from "@/components/auth-loading";
|
||||
|
||||
export default function PersonsLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<AuthLoading>
|
||||
<DashboardLayout>{children}</DashboardLayout>
|
||||
</AuthLoading>
|
||||
);
|
||||
}
|
||||
286
frontend/app/persons/new/page.tsx
Normal file
286
frontend/app/persons/new/page.tsx
Normal file
@@ -0,0 +1,286 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
ArrowLeft,
|
||||
Loader2,
|
||||
Save,
|
||||
Plus,
|
||||
X
|
||||
} from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
// Type definitions
|
||||
interface PersonFormData {
|
||||
name: string;
|
||||
email: string;
|
||||
level: string;
|
||||
}
|
||||
|
||||
// Mock data for available tags
|
||||
const availableTags = [
|
||||
"Frontend", "Backend", "Fullstack", "UX/UI", "DevOps",
|
||||
"React", "Vue", "Angular", "Node.js", "Python", "Java", "PHP",
|
||||
"JavaScript", "TypeScript", "CSS", "Docker", "Kubernetes", "Design",
|
||||
"Figma", "MERN"
|
||||
];
|
||||
|
||||
// Levels
|
||||
const levels = ["Junior", "Medior", "Senior"];
|
||||
|
||||
export default function NewPersonPage() {
|
||||
const router = useRouter();
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
||||
const [tagInput, setTagInput] = useState("");
|
||||
const [filteredTags, setFilteredTags] = useState<string[]>([]);
|
||||
|
||||
const { register, handleSubmit, control, formState: { errors } } = useForm<PersonFormData>({
|
||||
defaultValues: {
|
||||
name: "",
|
||||
email: "",
|
||||
level: ""
|
||||
}
|
||||
});
|
||||
|
||||
// Filter available tags based on input
|
||||
useEffect(() => {
|
||||
if (tagInput) {
|
||||
const filtered = availableTags.filter(
|
||||
tag =>
|
||||
tag.toLowerCase().includes(tagInput.toLowerCase()) &&
|
||||
!selectedTags.includes(tag)
|
||||
);
|
||||
setFilteredTags(filtered);
|
||||
} else {
|
||||
setFilteredTags([]);
|
||||
}
|
||||
}, [tagInput, selectedTags]);
|
||||
|
||||
const handleAddTag = (tag: string) => {
|
||||
if (!selectedTags.includes(tag)) {
|
||||
setSelectedTags([...selectedTags, tag]);
|
||||
}
|
||||
setTagInput("");
|
||||
setFilteredTags([]);
|
||||
};
|
||||
|
||||
const handleRemoveTag = (tag: string) => {
|
||||
setSelectedTags(selectedTags.filter(t => t !== tag));
|
||||
};
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if (e.key === 'Enter' && tagInput) {
|
||||
e.preventDefault();
|
||||
if (filteredTags.length > 0) {
|
||||
handleAddTag(filteredTags[0]);
|
||||
} else if (!selectedTags.includes(tagInput)) {
|
||||
// Add as a new tag if it doesn't exist
|
||||
handleAddTag(tagInput);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const onSubmit = async (data: PersonFormData) => {
|
||||
if (selectedTags.length === 0) {
|
||||
toast.error("Veuillez sélectionner au moins un tag");
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
// In a real app, this would be an API call to create a new person
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
// Combine form data with selected tags
|
||||
const personData = {
|
||||
...data,
|
||||
tags: [...selectedTags, data.level]
|
||||
};
|
||||
|
||||
// Simulate a successful response with a person ID
|
||||
const personId = Date.now();
|
||||
|
||||
toast.success("Personne créée avec succès");
|
||||
router.push("/persons");
|
||||
} catch (error) {
|
||||
console.error("Error creating person:", error);
|
||||
toast.error("Erreur lors de la création de la personne");
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="flex items-center gap-2">
|
||||
<Button variant="outline" size="icon" asChild>
|
||||
<Link href="/persons">
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
</Link>
|
||||
</Button>
|
||||
<h1 className="text-3xl font-bold">Nouvelle personne</h1>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<CardHeader>
|
||||
<CardTitle>Informations de la personne</CardTitle>
|
||||
<CardDescription>
|
||||
Ajoutez une nouvelle personne à votre projet
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="name">Nom</Label>
|
||||
<Input
|
||||
id="name"
|
||||
placeholder="Ex: Jean Dupont"
|
||||
{...register("name", {
|
||||
required: "Le nom est requis",
|
||||
minLength: {
|
||||
value: 3,
|
||||
message: "Le nom doit contenir au moins 3 caractères"
|
||||
}
|
||||
})}
|
||||
/>
|
||||
{errors.name && (
|
||||
<p className="text-sm text-destructive">{errors.name.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
placeholder="Ex: jean.dupont@example.com"
|
||||
{...register("email", {
|
||||
required: "L'email est requis",
|
||||
pattern: {
|
||||
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
||||
message: "Adresse email invalide"
|
||||
}
|
||||
})}
|
||||
/>
|
||||
{errors.email && (
|
||||
<p className="text-sm text-destructive">{errors.email.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="level">Niveau</Label>
|
||||
<Controller
|
||||
name="level"
|
||||
control={control}
|
||||
rules={{ required: "Le niveau est requis" }}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
onValueChange={field.onChange}
|
||||
defaultValue={field.value}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Sélectionnez un niveau" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{levels.map((level) => (
|
||||
<SelectItem key={level} value={level}>
|
||||
{level}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
{errors.level && (
|
||||
<p className="text-sm text-destructive">{errors.level.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="tags">Tags</Label>
|
||||
<div className="flex flex-wrap gap-1 mb-2">
|
||||
{selectedTags.map((tag) => (
|
||||
<Badge key={tag} variant="secondary" className="flex items-center gap-1">
|
||||
{tag}
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-4 w-4 p-0 text-muted-foreground hover:text-foreground"
|
||||
onClick={() => handleRemoveTag(tag)}
|
||||
>
|
||||
<X className="h-3 w-3" />
|
||||
<span className="sr-only">Supprimer le tag {tag}</span>
|
||||
</Button>
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
<div className="relative">
|
||||
<Input
|
||||
id="tags"
|
||||
placeholder="Rechercher ou ajouter un tag..."
|
||||
value={tagInput}
|
||||
onChange={(e) => setTagInput(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
/>
|
||||
{filteredTags.length > 0 && (
|
||||
<div className="absolute z-10 mt-1 w-full rounded-md border bg-popover p-2 shadow-md">
|
||||
<div className="max-h-60 overflow-auto">
|
||||
{filteredTags.map((tag) => (
|
||||
<div
|
||||
key={tag}
|
||||
className="flex cursor-pointer items-center rounded-md px-2 py-1.5 hover:bg-muted"
|
||||
onClick={() => handleAddTag(tag)}
|
||||
>
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
{tag}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Appuyez sur Entrée pour ajouter un tag ou sélectionnez-en un dans la liste
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
<CardFooter className="flex justify-between">
|
||||
<Button variant="outline" asChild>
|
||||
<Link href="/persons">Annuler</Link>
|
||||
</Button>
|
||||
<Button type="submit" disabled={isSubmitting}>
|
||||
{isSubmitting ? (
|
||||
<>
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
Création en cours...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Save className="mr-2 h-4 w-4" />
|
||||
Créer la personne
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</CardFooter>
|
||||
</form>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
193
frontend/app/persons/page.tsx
Normal file
193
frontend/app/persons/page.tsx
Normal file
@@ -0,0 +1,193 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
PlusCircle,
|
||||
Search,
|
||||
MoreHorizontal,
|
||||
Pencil,
|
||||
Trash2,
|
||||
Tag
|
||||
} from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
|
||||
export default function PersonsPage() {
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
|
||||
// Mock data for persons
|
||||
const persons = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Jean Dupont",
|
||||
email: "jean.dupont@example.com",
|
||||
tags: ["Frontend", "React", "Junior"],
|
||||
projects: 2,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Marie Martin",
|
||||
email: "marie.martin@example.com",
|
||||
tags: ["Backend", "Node.js", "Senior"],
|
||||
projects: 3,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Pierre Durand",
|
||||
email: "pierre.durand@example.com",
|
||||
tags: ["Fullstack", "JavaScript", "Medior"],
|
||||
projects: 1,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "Sophie Lefebvre",
|
||||
email: "sophie.lefebvre@example.com",
|
||||
tags: ["UX/UI", "Design", "Senior"],
|
||||
projects: 2,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "Thomas Bernard",
|
||||
email: "thomas.bernard@example.com",
|
||||
tags: ["Backend", "Java", "Senior"],
|
||||
projects: 1,
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: "Julie Petit",
|
||||
email: "julie.petit@example.com",
|
||||
tags: ["Frontend", "Vue", "Junior"],
|
||||
projects: 2,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: "Nicolas Moreau",
|
||||
email: "nicolas.moreau@example.com",
|
||||
tags: ["DevOps", "Docker", "Medior"],
|
||||
projects: 3,
|
||||
},
|
||||
];
|
||||
|
||||
// Filter persons based on search query
|
||||
const filteredPersons = persons.filter(
|
||||
(person) =>
|
||||
person.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
person.email.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
person.tags.some((tag) => tag.toLowerCase().includes(searchQuery.toLowerCase()))
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-3xl font-bold">Personnes</h1>
|
||||
<Button asChild>
|
||||
<Link href="/persons/new">
|
||||
<PlusCircle className="mr-2 h-4 w-4" />
|
||||
Nouvelle personne
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="relative flex-1">
|
||||
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
|
||||
<Input
|
||||
type="search"
|
||||
placeholder="Rechercher des personnes..."
|
||||
className="pl-8"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="rounded-md border">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Nom</TableHead>
|
||||
<TableHead>Email</TableHead>
|
||||
<TableHead>Tags</TableHead>
|
||||
<TableHead>Projets</TableHead>
|
||||
<TableHead className="w-[100px]">Actions</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{filteredPersons.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={5} className="h-24 text-center">
|
||||
Aucune personne trouvée.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) : (
|
||||
filteredPersons.map((person) => (
|
||||
<TableRow key={person.id}>
|
||||
<TableCell className="font-medium">{person.name}</TableCell>
|
||||
<TableCell>{person.email}</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{person.tags.map((tag, index) => (
|
||||
<Badge key={index} variant="outline">
|
||||
{tag}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>{person.projects}</TableCell>
|
||||
<TableCell>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon">
|
||||
<MoreHorizontal className="h-4 w-4" />
|
||||
<span className="sr-only">Actions</span>
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuLabel>Actions</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/persons/${person.id}/edit`} className="flex items-center">
|
||||
<Pencil className="mr-2 h-4 w-4" />
|
||||
<span>Modifier</span>
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/persons/${person.id}/tags`} className="flex items-center">
|
||||
<Tag className="mr-2 h-4 w-4" />
|
||||
<span>Gérer les tags</span>
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem className="text-destructive focus:text-destructive">
|
||||
<Trash2 className="mr-2 h-4 w-4" />
|
||||
<span>Supprimer</span>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user