Compare commits

21 Commits

Author SHA1 Message Date
jeremy bayse
589e9956f9 UI: lock application to light mode globally (disabled dark mode detection) 2026-04-16 19:16:48 +02:00
jeremy bayse
d6e5b44e47 Admin: implementation of the 'is_selected' feature for candidates for interviews 2026-04-16 19:08:52 +02:00
jeremy bayse
c4ab5c97b2 Admin: Super Admin can bypass the 7-day AI analysis restriction 2026-04-16 18:55:53 +02:00
jeremy bayse
84a9c6bb14 Fix: New registered candidates visibility (profile creation and tenant scope adjustment) 2026-04-16 18:31:23 +02:00
jeremy bayse
957947cc0b fix: quiz questions not showing - reload quiz freshly in show(), fix v-if guard in QuizInterface 2026-04-14 19:55:05 +02:00
jeremy bayse
6e4eb62553 fix: bypass tenant scope in AttemptController::destroy - null quiz title caused 500 when admin deletes attempt 2026-04-14 19:51:06 +02:00
jeremy bayse
c74d8e14ec fix: null quiz crash in admin candidate show - load attempts.quiz withoutGlobalScopes + null guard in Vue template 2026-04-14 19:49:12 +02:00
jeremy bayse
e93a17f324 refactor: fix BelongsToTenant trait to exempt candidates globally - removes all withoutGlobalScopes() workarounds 2026-04-14 19:38:42 +02:00
jeremy bayse
49ee91c601 fix: bypass tenant scope in recalculateScore - null quiz when candidate finishes quiz 2026-04-14 19:35:26 +02:00
jeremy bayse
479a7e35d1 fix: bypass tenant scope in AttemptController::show - candidates (no tenant_id) were getting 404 on quiz start 2026-04-14 19:24:29 +02:00
jeremy bayse
de6938d2e6 fix: bypass BelongsToTenant global scope when loading candidate quizzes on dashboard - candidates have no tenant_id 2026-04-14 19:20:20 +02:00
jeremy bayse
91213cc371 fix: sync quizzes unconditionally - was not removing quizzes when quiz_ids was empty 2026-04-14 19:15:15 +02:00
jeremy bayse
af4502859b fix: QuizInterface crash on undefined text_content - add null guards and safe optional chaining 2026-04-14 19:09:58 +02:00
jeremy bayse
107e2d0a1d design: darken nav bar elements for high contrast - Dashboard and NavLink text fix 2026-04-14 19:08:06 +02:00
jeremy bayse
71672509b6 design: fix candidate layout with full light theme, no dark mode dependencies, high contrast throughout 2026-04-14 19:06:17 +02:00
jeremy bayse
351bdda2a1 design: complete UI harmonization with full dark mode support and high contrast for candidate dashboard 2026-04-14 19:02:38 +02:00
jeremy bayse
21d4aaee59 design: premium candidate dashboard with high contrast and better layout 2026-04-14 18:59:09 +02:00
jeremy bayse
ec1fe91b35 feat: link quizzes to job positions and filter candidate dashboard accordingly 2026-04-14 18:30:13 +02:00
jeremy bayse
8c577cfaa7 fix: display flash messages on admin users index to show generated passwords 2026-04-14 18:24:44 +02:00
jeremy bayse
4a137fc511 feat: implement admin user management interface and routes for CRUD operations and password resets 2026-04-14 18:17:33 +02:00
jeremy bayse
e68108a2b1 feat: implement candidate details page with Chart.js radar visualization and AI analysis integration 2026-04-14 18:13:17 +02:00
25 changed files with 646 additions and 83 deletions

View File

@@ -23,7 +23,10 @@ class AIAnalysisController extends Controller
}
// Restriction: Une analyse tous les 7 jours maximum par candidat
if ($candidate->ai_analysis && isset($candidate->ai_analysis['analyzed_at'])) {
// Le super_admin peut outrepasser cette restriction via le paramètre 'force'
$shouldCheckRestriction = !($request->force && auth()->user()->isSuperAdmin());
if ($shouldCheckRestriction && $candidate->ai_analysis && isset($candidate->ai_analysis['analyzed_at'])) {
$lastAnalysis = Carbon::parse($candidate->ai_analysis['analyzed_at']);
if ($lastAnalysis->diffInDays(now()) < 7) {
return response()->json([

View File

@@ -19,7 +19,9 @@ class AttemptController extends Controller
$this->authorizeAdmin();
$candidateName = $attempt->candidate->user->name;
$quizTitle = $attempt->quiz->title;
// Bypass tenant scope: admin may delete attempts for cross-tenant quizzes
$quiz = Quiz::withoutGlobalScopes()->find($attempt->quiz_id);
$quizTitle = $quiz?->title ?? "Quiz #{$attempt->quiz_id}";
DB::transaction(function () use ($attempt, $candidateName, $quizTitle) {
// Log the action
@@ -74,11 +76,15 @@ class AttemptController extends Controller
$candidate->update(['status' => 'en_cours']);
}
$quiz->load(['questions.options']);
// Reload quiz with questions FRESHLY (avoid any cached state from model binding)
$quizData = Quiz::with(['questions' => function($q) {
$q->orderBy('id')->with('options');
}])
->find($quiz->id);
return Inertia::render('Candidate/QuizInterface', [
'quiz' => $quiz,
'attempt' => $attempt->load('answers')
'quiz' => $quizData,
'attempt' => $attempt->load('answers'),
]);
}

View File

@@ -41,6 +41,12 @@ class RegisteredUserController extends Controller
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
'role' => 'candidate',
]);
// Create the associated candidate record so they appear in the lists
$user->candidate()->create([
'status' => 'en_attente',
]);
event(new Registered($user));

View File

@@ -81,13 +81,23 @@ class CandidateController extends Controller
$candidate->load([
'user',
'documents',
'attempts.quiz',
'attempts.answers.question',
'attempts.answers.option',
'jobPosition',
'tenant'
]);
// Load attempts with quiz bypassing tenant scope
// (admin may view candidates whose quizzes belong to other tenants)
$candidate->setRelation(
'attempts',
$candidate->attempts()
->with([
'quiz' => fn($q) => $q->withoutGlobalScopes(),
'answers.question',
'answers.option',
])
->get()
);
$data = [
'candidate' => $candidate,
'jobPositions' => \App\Models\JobPosition::all(),
@@ -227,6 +237,15 @@ class CandidateController extends Controller
$this->storeDocument($candidate, $file, $type);
}
public function toggleSelection(Candidate $candidate)
{
$candidate->update([
'is_selected' => !$candidate->is_selected
]);
return back()->with('success', 'Statut de sélection mis à jour.');
}
private function storeDocument(Candidate $candidate, $file, string $type)
{
if (!$file) {

View File

@@ -13,8 +13,9 @@ class JobPositionController extends Controller
$this->authorizeAdmin();
return Inertia::render('Admin/JobPositions/Index', [
'jobPositions' => JobPosition::with('tenant')->get(),
'tenants' => \App\Models\Tenant::orderBy('name')->get()
'jobPositions' => JobPosition::with(['tenant', 'quizzes'])->get(),
'tenants' => \App\Models\Tenant::orderBy('name')->get(),
'quizzes' => \App\Models\Quiz::all()
]);
}
@@ -28,9 +29,11 @@ class JobPositionController extends Controller
'requirements' => 'nullable|array',
'ai_prompt' => 'nullable|string',
'tenant_id' => 'nullable|exists:tenants,id',
'quiz_ids' => 'nullable|array',
'quiz_ids.*' => 'exists:quizzes,id',
]);
JobPosition::create([
$jobPosition = JobPosition::create([
'title' => $request->title,
'description' => $request->description,
'requirements' => $request->requirements,
@@ -38,6 +41,8 @@ class JobPositionController extends Controller
'tenant_id' => auth()->user()->isSuperAdmin() ? $request->tenant_id : auth()->user()->tenant_id,
]);
$jobPosition->quizzes()->sync($request->input('quiz_ids', []));
return back()->with('success', 'Fiche de poste créée avec succès.');
}
@@ -51,6 +56,8 @@ class JobPositionController extends Controller
'requirements' => 'nullable|array',
'ai_prompt' => 'nullable|string',
'tenant_id' => 'nullable|exists:tenants,id',
'quiz_ids' => 'nullable|array',
'quiz_ids.*' => 'exists:quizzes,id',
]);
$jobPosition->update([
@@ -61,6 +68,8 @@ class JobPositionController extends Controller
'tenant_id' => auth()->user()->isSuperAdmin() ? $request->tenant_id : auth()->user()->tenant_id,
]);
$jobPosition->quizzes()->sync($request->input('quiz_ids', []));
return back()->with('success', 'Fiche de poste mise à jour.');
}

View File

@@ -94,4 +94,18 @@ class UserController extends Controller
return back()->with('success', 'Administrateur supprimé.');
}
public function resetPassword(User $user)
{
if (!auth()->user()->isSuperAdmin()) {
abort(403, 'Unauthorized action.');
}
$password = Str::random(10);
$user->update([
'password' => Hash::make($password)
]);
return back()->with('success', 'Nouveau mot de passe généré pour ' . $user->name . ' : ' . $password);
}
}

View File

@@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Traits\BelongsToTenant;
#[Fillable(['user_id', 'job_position_id', 'phone', 'linkedin_url', 'status', 'notes', 'cv_score', 'motivation_score', 'interview_score', 'ai_analysis', 'tenant_id'])]
#[Fillable(['user_id', 'job_position_id', 'phone', 'linkedin_url', 'status', 'is_selected', 'notes', 'cv_score', 'motivation_score', 'interview_score', 'ai_analysis', 'tenant_id'])]
class Candidate extends Model
{
use HasFactory, BelongsToTenant;
@@ -30,6 +30,7 @@ class Candidate extends Model
protected $casts = [
'ai_analysis' => 'array',
'is_selected' => 'boolean',
];
public function jobPosition(): BelongsTo

View File

@@ -22,4 +22,9 @@ class JobPosition extends Model
{
return $this->hasMany(Candidate::class);
}
public function quizzes()
{
return $this->belongsToMany(Quiz::class);
}
}

View File

@@ -19,4 +19,9 @@ class Quiz extends Model
{
return $this->hasMany(Question::class);
}
public function jobPositions()
{
return $this->belongsToMany(JobPosition::class);
}
}

View File

@@ -13,13 +13,22 @@ trait BelongsToTenant
if (Auth::check()) {
$user = Auth::user();
// Super admins see everything
if ($user->role === 'super_admin') {
// Super admins see everything
return;
}
// Candidates don't have a tenant_id but must access
// quizzes/job positions linked to their position
if ($user->role === 'candidate') {
return;
}
if ($user->tenant_id) {
$builder->where('tenant_id', $user->tenant_id);
$builder->where(function ($query) use ($user) {
$query->where('tenant_id', $user->tenant_id)
->orWhereNull('tenant_id');
});
}
}
});

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('job_position_quiz', function (Blueprint $table) {
$table->id();
$table->foreignId('job_position_id')->constrained()->cascadeOnDelete();
$table->foreignId('quiz_id')->constrained()->cascadeOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('job_position_quiz');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('candidates', function (Blueprint $table) {
$table->boolean('is_selected')->default(false)->after('status');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('candidates', function (Blueprint $table) {
$table->dropColumn('is_selected');
});
}
};

19
package-lock.json generated
View File

@@ -6,6 +6,7 @@
"": {
"dependencies": {
"@tailwindcss/typography": "^0.5.19",
"chart.js": "^4.5.1",
"marked": "^17.0.4"
},
"devDependencies": {
@@ -195,6 +196,12 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/@kurkle/color": {
"version": "0.3.4",
"resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.4.tgz",
"integrity": "sha512-M5UknZPHRu3DEDWoipU6sE8PdkZ6Z/S+v4dD+Ke8IaNlpdSQah50lz1KtcFBa2vsdOnwbbnxJwVM4wty6udA5w==",
"license": "MIT"
},
"node_modules/@napi-rs/wasm-runtime": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.1.tgz",
@@ -1266,6 +1273,18 @@
"node": ">=8"
}
},
"node_modules/chart.js": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.5.1.tgz",
"integrity": "sha512-GIjfiT9dbmHRiYi6Nl2yFCq7kkwdkp1W/lp2J99rX0yo9tgJGn3lKQATztIjb5tVtevcBtIdICNWqlq5+E8/Pw==",
"license": "MIT",
"dependencies": {
"@kurkle/color": "^0.3.0"
},
"engines": {
"pnpm": ">=8"
}
},
"node_modules/chokidar": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",

View File

@@ -22,6 +22,7 @@
},
"dependencies": {
"@tailwindcss/typography": "^0.5.19",
"chart.js": "^4.5.1",
"marked": "^17.0.4"
}
}

View File

@@ -12,7 +12,8 @@ defineProps({
<template>
<Link
:href="href"
class="block w-full px-4 py-2 text-start text-sm leading-5 text-gray-700 transition duration-150 ease-in-out hover:bg-gray-100 focus:bg-gray-100 focus:outline-none"
class="block w-full px-4 py-2 text-start text-sm font-semibold leading-5 transition duration-150 ease-in-out focus:outline-none"
style="color:#1e293b;"
>
<slot />
</Link>

View File

@@ -14,8 +14,8 @@ const props = defineProps({
const classes = computed(() =>
props.active
? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 text-sm font-medium leading-5 text-gray-900 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out'
: 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out',
? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-600 text-sm font-bold leading-5 text-indigo-700 focus:outline-none transition duration-150 ease-in-out'
: 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-bold leading-5 text-slate-700 hover:text-indigo-600 hover:border-indigo-400 focus:outline-none transition duration-150 ease-in-out',
);
</script>

View File

@@ -14,10 +14,8 @@ const showingNavigationDropdown = ref(false);
<template>
<EnvironmentBanner />
<div>
<div class="min-h-screen bg-gray-100">
<nav
class="border-b border-gray-100 bg-white"
>
<div class="min-h-screen" style="background:#f8fafc;">
<nav style="border-bottom:1px solid #e2e8f0; background:white; box-shadow:0 1px 3px rgba(0,0,0,0.04);">
<!-- Primary Navigation Menu -->
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<div class="flex h-16 justify-between">
@@ -26,7 +24,7 @@ const showingNavigationDropdown = ref(false);
<div class="flex shrink-0 items-center">
<Link :href="route('dashboard')">
<ApplicationLogo
class="block h-9 w-auto fill-current text-gray-800"
class="block h-9 w-auto fill-indigo-600"
/>
</Link>
</div>
@@ -52,7 +50,7 @@ const showingNavigationDropdown = ref(false);
<span class="inline-flex rounded-md">
<button
type="button"
class="inline-flex items-center rounded-md border border-transparent bg-white px-3 py-2 text-sm font-medium leading-4 text-gray-500 transition duration-150 ease-in-out hover:text-gray-700 focus:outline-none"
style="display:inline-flex; align-items:center; border-radius:0.75rem; border:1.5px solid #e2e8f0; background:#f1f5f9; padding:0.5rem 1rem; font-size:0.875rem; font-weight:700; color:#0f172a; transition:all 0.15s ease;"
>
{{ $page.props.auth.user.name }}
@@ -183,7 +181,7 @@ const showingNavigationDropdown = ref(false);
<!-- Page Heading -->
<header
class="bg-white shadow"
style="background:white; border-bottom:1px solid #f1f5f9; box-shadow:none;"
v-if="$slots.header"
>
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
@@ -196,8 +194,8 @@ const showingNavigationDropdown = ref(false);
<slot />
</main>
<footer class="pb-8 pt-4 text-center">
<span class="text-[10px] text-gray-400 font-mono">v{{ $page.props.app_version }}</span>
<footer class="pb-8 pt-4 text-center" style="background:#f8fafc;">
<span class="text-[10px] font-mono" style="color:#9ca3af;">v{{ $page.props.app_version }}</span>
</footer>
</div>
</div>

View File

@@ -43,10 +43,14 @@ const submit = () => {
const deleteCandidate = (id) => {
if (confirm('Voulez-vous vraiment supprimer ce candidat ?')) {
router.delete(route('admin.candidates.destroy', id));
router.delete(route('admin.candidates.destroy', id), { preserveScroll: true });
}
};
const toggleSelection = (id) => {
router.patch(route('admin.candidates.toggle-selection', id), {}, { preserveScroll: true });
};
const openPreview = (doc) => {
selectedDocument.value = doc;
};
@@ -69,11 +73,24 @@ const getNestedValue = (obj, path) => {
};
const selectedJobPosition = ref('');
const showOnlySelected = ref(false);
const filteredCandidates = computed(() => {
if (selectedJobPosition.value === '') return props.candidates;
if (selectedJobPosition.value === 'none') return props.candidates.filter(c => !c.job_position_id);
return props.candidates.filter(c => c.job_position_id === selectedJobPosition.value);
let result = props.candidates;
if (showOnlySelected.value) {
result = result.filter(c => c.is_selected);
}
if (selectedJobPosition.value !== '') {
if (selectedJobPosition.value === 'none') {
result = result.filter(c => !c.job_position_id);
} else {
result = result.filter(c => c.job_position_id === selectedJobPosition.value);
}
}
return result;
});
const sortedCandidates = computed(() => {
@@ -102,18 +119,26 @@ const sortedCandidates = computed(() => {
<div class="flex justify-between items-end mb-8">
<div class="space-y-4">
<h3 class="text-2xl font-bold">Liste des Candidats</h3>
<div class="flex items-center gap-3">
<label class="text-sm font-medium text-slate-700 dark:text-slate-300">Filtrer par fiche de poste :</label>
<select
v-model="selectedJobPosition"
class="block w-64 rounded-xl border-slate-300 dark:border-slate-700 dark:bg-slate-900 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
>
<option value="">Toutes les fiches de poste</option>
<option value="none"> Non assigné (Candidature Spontanée)</option>
<option v-for="jp in jobPositions" :key="jp.id" :value="jp.id">
{{ jp.title }}
</option>
</select>
<div class="flex items-center gap-6">
<div class="flex items-center gap-3 bg-white dark:bg-slate-800 p-2 rounded-xl border border-slate-200 dark:border-slate-700 shadow-sm">
<label class="flex items-center gap-2 cursor-pointer px-2">
<input type="checkbox" v-model="showOnlySelected" class="rounded border-amber-300 text-amber-500 focus:ring-amber-500/20 cursor-pointer">
<span class="text-sm font-bold text-slate-700 dark:text-slate-300">Retenus uniquement</span>
</label>
</div>
<div class="flex items-center gap-3">
<label class="text-sm font-medium text-slate-700 dark:text-slate-300">Filtrer par fiche de poste :</label>
<select
v-model="selectedJobPosition"
class="block w-64 rounded-xl border-slate-300 dark:border-slate-700 dark:bg-slate-900 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
>
<option value="">Toutes les fiches de poste</option>
<option value="none"> Non assigné (Candidature Spontanée)</option>
<option v-for="jp in jobPositions" :key="jp.id" :value="jp.id">
{{ jp.title }}
</option>
</select>
</div>
</div>
</div>
<PrimaryButton @click="isModalOpen = true">
@@ -139,6 +164,7 @@ const sortedCandidates = computed(() => {
<table class="w-full text-left">
<thead class="bg-slate-50 dark:bg-slate-700/50 border-b border-slate-200 dark:border-slate-700">
<tr>
<th class="w-12 px-6 py-4"></th>
<th @click="sortBy('user.name')" class="px-6 py-4 font-semibold text-slate-700 dark:text-slate-300 cursor-pointer hover:bg-slate-100 dark:hover:bg-slate-700/50 transition-colors">
<div class="flex items-center gap-2">
Nom
@@ -201,6 +227,16 @@ const sortedCandidates = computed(() => {
</thead>
<tbody class="divide-y divide-slate-200 dark:divide-slate-700">
<tr v-for="candidate in sortedCandidates" :key="candidate.id" class="hover:bg-slate-50/50 dark:hover:bg-slate-700/30 transition-colors">
<td class="px-6 py-4">
<button @click="toggleSelection(candidate.id)" class="text-amber-400 hover:text-amber-500 hover:scale-110 transition-transform focus:outline-none" :title="candidate.is_selected ? 'Retirer des retenus' : 'Marquer comme retenu'">
<svg v-if="candidate.is_selected" xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" viewBox="0 0 20 20" fill="currentColor">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
</svg>
<svg v-else xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-slate-300 hover:text-amber-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z" />
</svg>
</button>
</td>
<td class="px-6 py-4">
<div class="font-bold text-slate-900 dark:text-white">{{ candidate.user.name }}</div>
<div class="text-[10px] text-slate-500 font-bold uppercase tracking-tight">{{ candidate.phone }}</div>
@@ -294,7 +330,7 @@ const sortedCandidates = computed(() => {
</td>
</tr>
<tr v-if="candidates.length === 0">
<td colspan="7" class="px-6 py-12 text-center text-slate-500 italic">
<td colspan="8" class="px-6 py-12 text-center text-slate-500 italic">
Aucun candidat trouvé.
</td>
</tr>

View File

@@ -2,13 +2,14 @@
import AdminLayout from '@/Layouts/AdminLayout.vue';
import axios from 'axios';
import { Head, Link, router, useForm, usePage } from '@inertiajs/vue3';
import { ref, computed } from 'vue';
import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue';
import { marked } from 'marked';
import Modal from '@/Components/Modal.vue';
import SecondaryButton from '@/Components/SecondaryButton.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import DangerButton from '@/Components/DangerButton.vue';
import InputError from '@/Components/InputError.vue';
import Chart from 'chart.js/auto';
const props = defineProps({
candidate: Object,
@@ -40,6 +41,10 @@ const updateTenant = () => {
});
};
const toggleSelection = () => {
router.patch(route('admin.candidates.toggle-selection', props.candidate.id), {}, { preserveScroll: true });
};
const selectedDocument = ref(null);
const docForm = useForm({
@@ -133,9 +138,121 @@ const updateAnswerScore = (answerId, score) => {
});
};
// ─── Radar Chart ──────────────────────────────────────────────────────────────
const radarCanvasRef = ref(null);
let radarChartInstance = null;
// Calcul du score test (meilleure tentative ramenée sur 20)
const bestTestScore = computed(() => {
if (!props.candidate.attempts || props.candidate.attempts.length === 0) return 0;
const finished = props.candidate.attempts.filter(a => a.finished_at && a.max_score > 0);
if (finished.length === 0) return 0;
return Math.max(...finished.map(a => (a.score / a.max_score) * 20));
});
// Données radar normalisées en % (chaque axe / son max)
const radarData = computed(() => ([
Math.round((parseFloat(scoreForm.cv_score) / 20) * 100),
Math.round((parseFloat(scoreForm.motivation_score) / 10) * 100),
Math.round((parseFloat(scoreForm.interview_score) / 30) * 100),
Math.round((bestTestScore.value / 20) * 100),
]));
const buildRadarChart = () => {
if (!radarCanvasRef.value) return;
if (radarChartInstance) {
radarChartInstance.destroy();
radarChartInstance = null;
}
const isDark = false; // Désactivation forcée du mode sombre
const gridColor = isDark ? 'rgba(148,163,184,0.15)' : 'rgba(100,116,139,0.15)';
const labelColor = isDark ? '#94a3b8' : '#64748b';
radarChartInstance = new Chart(radarCanvasRef.value, {
type: 'radar',
data: {
labels: ['Analyse CV', 'Lettre Motiv.', 'Entretien', 'Test Technique'],
datasets: [{
label: 'Profil Candidat (%)',
data: radarData.value,
backgroundColor: 'rgba(99,102,241,0.15)',
borderColor: 'rgba(99,102,241,0.9)',
borderWidth: 2.5,
pointBackgroundColor: 'rgba(99,102,241,1)',
pointBorderColor: '#fff',
pointBorderWidth: 2,
pointRadius: 5,
pointHoverRadius: 7,
pointHoverBackgroundColor: 'rgba(139,92,246,1)',
}]
},
options: {
responsive: true,
maintainAspectRatio: true,
animation: { duration: 700, easing: 'easeInOutQuart' },
plugins: {
legend: { display: false },
tooltip: {
callbacks: {
label: (ctx) => ` ${ctx.raw}%`,
},
backgroundColor: isDark ? '#1e293b' : '#fff',
titleColor: isDark ? '#e2e8f0' : '#0f172a',
bodyColor: isDark ? '#94a3b8' : '#475569',
borderColor: isDark ? '#334155' : '#e2e8f0',
borderWidth: 1,
padding: 10,
cornerRadius: 10,
}
},
scales: {
r: {
min: 0,
max: 100,
ticks: {
stepSize: 25,
color: labelColor,
backdropColor: 'transparent',
font: { size: 9, weight: 'bold' },
callback: (v) => v + '%',
},
grid: { color: gridColor },
angleLines: { color: gridColor },
pointLabels: {
color: labelColor,
font: { size: 11, weight: 'bold' },
}
}
}
}
});
};
onMounted(() => {
nextTick(() => buildRadarChart());
});
onUnmounted(() => {
if (radarChartInstance) radarChartInstance.destroy();
});
// Mise à jour du radar quand les scores changent
watch(
() => [scoreForm.cv_score, scoreForm.motivation_score, scoreForm.interview_score, bestTestScore.value],
() => {
if (radarChartInstance) {
radarChartInstance.data.datasets[0].data = radarData.value;
radarChartInstance.update();
}
}
);
// ──────────────────────────────────────────────────────────────────────────────
const aiAnalysis = ref(props.candidate.ai_analysis || null);
const isAnalyzing = ref(false);
const selectedProvider = ref(props.ai_config?.default || 'ollama');
const forceAnalysis = ref(false);
// Error Modal state
const showErrorModal = ref(false);
@@ -151,7 +268,8 @@ const runAI = async () => {
isAnalyzing.value = true;
try {
const response = await axios.post(route('admin.candidates.analyze', props.candidate.id), {
provider: selectedProvider.value
provider: selectedProvider.value,
force: forceAnalysis.value
});
aiAnalysis.value = response.data;
} catch (error) {
@@ -198,7 +316,27 @@ const runAI = async () => {
<!-- Profile Card -->
<div class="bg-white dark:bg-slate-800 rounded-2xl shadow-sm border border-slate-200 dark:border-slate-700 overflow-hidden">
<div class="h-24 bg-gradient-to-r from-indigo-500 to-purple-600"></div>
<div class="px-6 pb-6 text-center -mt-12">
<div class="px-6 pb-6 text-center -mt-12 relative">
<div class="absolute right-6 top-16 right-0 text-center w-full max-w-[50px] ml-auto mr-auto sm:right-6 sm:top-14 sm:w-auto">
<button
@click="toggleSelection"
class="flex flex-col items-center gap-1 group focus:outline-none"
:title="candidate.is_selected ? 'Retirer des retenus' : 'Marquer pour entretien'"
>
<div
class="p-2 rounded-full transition-all"
:class="candidate.is_selected ? 'bg-amber-100 text-amber-500 shadow-sm' : 'bg-slate-100 text-slate-400 group-hover:bg-amber-50 group-hover:text-amber-400'"
>
<svg v-if="candidate.is_selected" xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" viewBox="0 0 20 20" fill="currentColor">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
</svg>
<svg v-else xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z" />
</svg>
</div>
<span class="text-[9px] font-black uppercase tracking-widest hidden sm:block" :class="candidate.is_selected ? 'text-amber-500' : 'text-slate-400 group-hover:text-amber-400'">Retenu</span>
</button>
</div>
<div class="w-24 h-24 bg-white dark:bg-slate-900 rounded-2xl shadow-xl border-4 border-white dark:border-slate-800 flex items-center justify-center text-4xl font-black text-indigo-600 mx-auto mb-4">
{{ candidate.user.name.charAt(0) }}
</div>
@@ -395,6 +533,94 @@ const runAI = async () => {
</div>
</div>
<!-- Radar Chart Section -->
<div class="bg-white dark:bg-slate-800 rounded-2xl shadow-sm border border-slate-200 dark:border-slate-700 p-8">
<div class="flex items-center justify-between mb-6">
<h4 class="text-xl font-bold flex items-center gap-3">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-indigo-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.488 9H15V3.512A9.025 9.025 0 0120.488 9z" />
</svg>
Profil de Compétences
</h4>
<div class="flex flex-col items-end gap-1">
<span class="text-[10px] font-black uppercase tracking-widest text-slate-400">Score global</span>
<span class="text-2xl font-black text-indigo-600">{{ candidate.weighted_score }}<span class="text-sm text-slate-300 font-normal ml-1">/20</span></span>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 items-center">
<!-- Radar Canvas -->
<div class="relative flex items-center justify-center">
<canvas ref="radarCanvasRef" class="max-h-72"></canvas>
</div>
<!-- Score Breakdown Legend -->
<div class="space-y-4">
<!-- CV -->
<div class="group">
<div class="flex justify-between items-center mb-1.5">
<span class="text-xs font-black uppercase tracking-widest text-slate-500">Analyse CV</span>
<span class="text-sm font-black text-indigo-600">{{ scoreForm.cv_score }} <span class="text-slate-300 font-normal">/ 20</span></span>
</div>
<div class="h-2 bg-slate-100 dark:bg-slate-700 rounded-full overflow-hidden">
<div
class="h-full bg-gradient-to-r from-indigo-400 to-indigo-600 rounded-full transition-all duration-700"
:style="{ width: (scoreForm.cv_score / 20 * 100) + '%' }"
></div>
</div>
</div>
<!-- Motivation -->
<div class="group">
<div class="flex justify-between items-center mb-1.5">
<span class="text-xs font-black uppercase tracking-widest text-slate-500">Lettre de Motivation</span>
<span class="text-sm font-black text-emerald-600">{{ scoreForm.motivation_score }} <span class="text-slate-300 font-normal">/ 10</span></span>
</div>
<div class="h-2 bg-slate-100 dark:bg-slate-700 rounded-full overflow-hidden">
<div
class="h-full bg-gradient-to-r from-emerald-400 to-emerald-600 rounded-full transition-all duration-700"
:style="{ width: (scoreForm.motivation_score / 10 * 100) + '%' }"
></div>
</div>
</div>
<!-- Entretien -->
<div class="group">
<div class="flex justify-between items-center mb-1.5">
<span class="text-xs font-black uppercase tracking-widest text-slate-500">Entretien</span>
<span class="text-sm font-black text-purple-600">{{ scoreForm.interview_score }} <span class="text-slate-300 font-normal">/ 30</span></span>
</div>
<div class="h-2 bg-slate-100 dark:bg-slate-700 rounded-full overflow-hidden">
<div
class="h-full bg-gradient-to-r from-purple-400 to-purple-600 rounded-full transition-all duration-700"
:style="{ width: (scoreForm.interview_score / 30 * 100) + '%' }"
></div>
</div>
</div>
<!-- Test Technique -->
<div class="group">
<div class="flex justify-between items-center mb-1.5">
<span class="text-xs font-black uppercase tracking-widest text-slate-500">Test Technique</span>
<span class="text-sm font-black text-amber-600">{{ bestTestScore.toFixed(2) }} <span class="text-slate-300 font-normal">/ 20</span></span>
</div>
<div class="h-2 bg-slate-100 dark:bg-slate-700 rounded-full overflow-hidden">
<div
class="h-full bg-gradient-to-r from-amber-400 to-amber-600 rounded-full transition-all duration-700"
:style="{ width: (bestTestScore / 20 * 100) + '%' }"
></div>
</div>
</div>
<!-- Score footer note -->
<p class="text-[10px] text-slate-400 italic pt-2 border-t border-slate-100 dark:border-slate-700">
Chaque axe est normalisé sur 100% par rapport à son barème maximum.
</p>
</div>
</div>
</div>
<!-- AI Analysis Section -->
<div class="bg-white dark:bg-slate-800 rounded-2xl shadow-sm border border-slate-200 dark:border-slate-700 p-8 overflow-hidden relative">
<div class="flex flex-col md:flex-row md:items-center justify-between gap-6 mb-8">
@@ -430,6 +656,19 @@ const runAI = async () => {
</button>
</div>
<!-- Force option for Super Admin -->
<div v-if="$page.props.auth.user.role === 'super_admin'" class="flex items-center gap-2 px-4 py-2 bg-red-50 dark:bg-red-900/20 border border-red-100 dark:border-red-900/50 rounded-xl">
<input
type="checkbox"
id="forceAnalysis"
v-model="forceAnalysis"
class="rounded border-red-300 text-red-600 focus:ring-red-500/20 w-4 h-4 cursor-pointer"
/>
<label for="forceAnalysis" class="text-[10px] font-black uppercase tracking-widest text-red-600 cursor-pointer select-none">
Forcer (Bypass 7 jours)
</label>
</div>
<PrimaryButton
@click="runAI"
:disabled="isAnalyzing"
@@ -618,7 +857,7 @@ const runAI = async () => {
</div>
</div>
<div>
<h4 class="text-xl font-black uppercase tracking-tight">{{ attempt.quiz.title }}</h4>
<h4 class="text-xl font-black uppercase tracking-tight">{{ attempt.quiz?.title ?? 'Quiz supprimé' }}</h4>
<div class="text-xs text-slate-400 mt-1 uppercase font-bold tracking-widest">
Fini le {{ formatDateTime(attempt.finished_at) }}
</div>

View File

@@ -10,7 +10,8 @@ import InputError from '@/Components/InputError.vue';
const props = defineProps({
jobPositions: Array,
tenants: Array
tenants: Array,
quizzes: Array
});
const showingModal = ref(false);
@@ -22,6 +23,7 @@ const form = useForm({
requirements: [],
ai_prompt: '',
tenant_id: '',
quiz_ids: [],
});
const openModal = (position = null) => {
@@ -32,6 +34,7 @@ const openModal = (position = null) => {
form.requirements = position.requirements || [];
form.ai_prompt = position.ai_prompt || '';
form.tenant_id = position.tenant_id || '';
form.quiz_ids = position.quizzes ? position.quizzes.map(q => q.id) : [];
} else {
form.reset();
}
@@ -203,6 +206,32 @@ const removeRequirement = (index) => {
<InputError :message="form.errors.ai_prompt" />
</div>
<div v-if="quizzes && quizzes.length > 0">
<label class="block text-xs font-black uppercase tracking-widest text-slate-400 mb-4">Tests techniques associés</label>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div
v-for="quiz in quizzes"
:key="quiz.id"
class="flex items-center p-3 bg-slate-50 dark:bg-slate-900 rounded-2xl cursor-pointer hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors"
@click="form.quiz_ids.includes(quiz.id) ? form.quiz_ids = form.quiz_ids.filter(id => id !== quiz.id) : form.quiz_ids.push(quiz.id)"
>
<div
class="w-5 h-5 rounded-md border-2 mr-3 flex items-center justify-center transition-all"
:class="form.quiz_ids.includes(quiz.id) ? 'bg-indigo-600 border-indigo-600' : 'border-slate-300 dark:border-slate-600'"
>
<svg v-if="form.quiz_ids.includes(quiz.id)" xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M5 13l4 4L19 7" />
</svg>
</div>
<div>
<div class="text-xs font-bold leading-tight">{{ quiz.title }}</div>
<div class="text-[9px] text-slate-400 uppercase tracking-tighter">{{ quiz.duration_minutes }} min</div>
</div>
</div>
</div>
<InputError :message="form.errors.quiz_ids" />
</div>
<div>
<div class="flex justify-between items-center mb-4">
<label class="text-xs font-black uppercase tracking-widest text-slate-400">Compétences clés / Pré-requis</label>

View File

@@ -1,8 +1,11 @@
<script setup>
import { Head, useForm, Link } from '@inertiajs/vue3';
import { ref } from 'vue';
import { Head, useForm, Link, usePage } from '@inertiajs/vue3';
import { ref, computed } from 'vue';
import AdminLayout from '@/Layouts/AdminLayout.vue';
const page = usePage();
const flashSuccess = computed(() => page.props.flash?.success);
const props = defineProps({
users: Array,
tenants: Array
@@ -51,6 +54,12 @@ const deleteUser = (user) => {
}
};
const resetPassword = (user) => {
if (confirm(`Êtes-vous sûr de vouloir réinitialiser le mot de passe de ${user.name} ? Un nouveau mot de passe sera généré aléatoirement.`)) {
form.post(route('admin.users.reset-password', user.id));
}
};
const cancel = () => {
isCreating.value = false;
editingUser.value = null;
@@ -63,6 +72,19 @@ const cancel = () => {
<AdminLayout>
<template #header>Équipe / Utilisateurs Admin</template>
<!-- Flash Messages -->
<div v-if="flashSuccess" class="mb-8 p-6 bg-emerald-50 dark:bg-emerald-900/20 border border-emerald-200 dark:border-emerald-800 rounded-xl flex items-center gap-4 animate-in fade-in slide-in-from-top-4 duration-500">
<div class="p-2 bg-emerald-500 rounded-lg text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
</div>
<div class="flex-1">
<p class="font-bold text-emerald-800 dark:text-emerald-400">Action réussie !</p>
<p class="text-emerald-700 dark:text-emerald-500 text-sm">{{ flashSuccess }}</p>
</div>
</div>
<div class="mb-6 flex justify-between items-center">
<h1 class="text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-blue-500 to-indigo-500">
Administrateurs Plateforme
@@ -136,6 +158,9 @@ const cancel = () => {
{{ user.tenant ? user.tenant.name : (user.role === 'super_admin' ? 'Toutes les structures' : 'Aucun rattachement') }}
</td>
<td class="py-3 px-6 text-right space-x-2">
<button v-if="page.props.auth.user.role === 'super_admin'" @click="resetPassword(user)" class="text-orange-600 hover:text-orange-900 px-3 py-1 rounded bg-orange-50 hover:bg-orange-100 transition-colors" title="Réinitialiser le mot de passe">
MDP
</button>
<button @click="editUser(user)" class="text-indigo-600 hover:text-indigo-900 px-3 py-1 rounded bg-indigo-50 hover:bg-indigo-100 transition-colors">Modifier</button>
<button @click="deleteUser(user)" class="text-red-600 hover:text-red-900 px-3 py-1 rounded bg-red-50 hover:bg-red-100 transition-colors">Supprimer</button>
</td>

View File

@@ -10,7 +10,7 @@ const props = defineProps({
const currentQuestionIndex = ref(0);
const answers = ref({});
const timeLeft = ref(props.quiz.duration_minutes * 60);
const timeLeft = ref(props.quiz?.duration_minutes ? props.quiz.duration_minutes * 60 : 0);
let timer = null;
// Initialize answers from existing attempt answers if any
@@ -58,8 +58,8 @@ const formatTime = (seconds) => {
return `${mins}:${secs.toString().padStart(2, '0')}`;
};
const currentQuestion = computed(() => props.quiz.questions[currentQuestionIndex.value]);
const progress = computed(() => ((currentQuestionIndex.value + 1) / props.quiz.questions.length) * 100);
const currentQuestion = computed(() => props.quiz.questions?.[currentQuestionIndex.value] ?? null);
const progress = computed(() => props.quiz.questions?.length ? ((currentQuestionIndex.value + 1) / props.quiz.questions.length) * 100 : 0);
const saveAnswer = async () => {
const qid = currentQuestion.value.id;
@@ -150,8 +150,13 @@ const finishQuiz = () => {
<!-- Main Content -->
<main class="flex-1 flex flex-col items-center justify-center p-8">
<div class="w-full max-w-3xl">
<!-- Guard: only render if quiz has questions -->
<div v-if="!quiz.questions || !quiz.questions.length" class="text-center py-12">
<p class="text-slate-400 italic">Aucune question disponible pour ce test.</p>
</div>
<!-- Question Card -->
<div class="bg-slate-800/50 backdrop-blur-xl rounded-3xl p-8 sm:p-12 border border-slate-700 shadow-2xl relative overflow-hidden group">
<div v-else class="bg-slate-800/50 backdrop-blur-xl rounded-3xl p-8 sm:p-12 border border-slate-700 shadow-2xl relative overflow-hidden group">
<!-- Subtle background glow -->
<div class="absolute -top-24 -right-24 w-64 h-64 bg-indigo-600/10 blur-[100px] rounded-full group-hover:bg-indigo-600/20 transition-all duration-700"></div>
@@ -202,7 +207,8 @@ const finishQuiz = () => {
<textarea
class="w-full h-48 bg-slate-700/30 border border-slate-600 rounded-2xl p-6 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-all outline-none resize-none text-lg"
placeholder="Saisissez votre réponse ici..."
v-model="answers[currentQuestion.id].text_content"
:value="answers[currentQuestion.id]?.text_content ?? ''"
@input="updateOpenAnswer($event.target.value)"
@blur="saveAnswer"
></textarea>
</div>

View File

@@ -38,7 +38,7 @@ const getStatusColor = (status) => {
<span v-if="user.role === 'super_admin'" class="bg-gradient-to-r from-red-600 to-orange-500 text-white px-3 py-1 rounded-full text-[10px] font-black tracking-widest uppercase shadow-sm">
GOD MODE
</span>
<span v-else-if="user.tenant" class="bg-indigo-100 text-indigo-700 dark:bg-indigo-900/50 dark:text-indigo-400 border border-indigo-200 dark:border-indigo-800 px-3 py-1 rounded-full text-[10px] font-black tracking-widest uppercase">
<span v-else-if="user.tenant" class="bg-indigo-600 text-white dark:bg-indigo-500/20 dark:text-indigo-300 px-3 py-1 rounded-full text-[10px] font-black tracking-widest uppercase border border-indigo-700 dark:border-indigo-400/30">
Structure : {{ user.tenant.name }}
</span>
</div>
@@ -46,11 +46,23 @@ const getStatusColor = (status) => {
<div v-if="isAdmin" class="p-8 space-y-8">
<!-- KPI Cards -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-6">
<div class="bg-white dark:bg-slate-800 p-6 rounded-3xl shadow-sm border border-slate-200 dark:border-slate-700 hover:shadow-xl transition-all duration-300">
<div class="text-slate-500 dark:text-slate-400 text-[10px] font-black uppercase tracking-widest">Total Candidats</div>
<div class="text-4xl font-black mt-2 text-indigo-600 dark:text-indigo-400">{{ stats.total_candidates }}</div>
</div>
<div class="bg-white dark:bg-slate-800 p-6 rounded-3xl shadow-sm border border-slate-200 dark:border-slate-700 hover:shadow-xl transition-all duration-300 relative overflow-hidden group">
<div class="absolute inset-0 bg-gradient-to-br from-amber-50 to-orange-50 dark:from-amber-900/20 dark:to-orange-900/20 opacity-0 group-hover:opacity-100 transition-opacity duration-500"></div>
<div class="relative z-10">
<div class="text-amber-600 dark:text-amber-500 text-[10px] font-black uppercase tracking-widest flex items-center gap-1.5">
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" viewBox="0 0 20 20" fill="currentColor">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
</svg>
Retenus
</div>
<div class="text-4xl font-black mt-2 text-amber-600 dark:text-amber-400">{{ stats.selected_candidates }}</div>
</div>
</div>
<div class="bg-white dark:bg-slate-800 p-6 rounded-3xl shadow-sm border border-slate-200 dark:border-slate-700 hover:shadow-xl transition-all duration-300">
<div class="text-slate-500 dark:text-slate-400 text-[10px] font-black uppercase tracking-widest">Tests terminés</div>
<div class="text-4xl font-black mt-2 text-emerald-600 dark:text-emerald-400">{{ stats.finished_tests }}</div>
@@ -61,7 +73,7 @@ const getStatusColor = (status) => {
</div>
<div class="bg-white dark:bg-slate-800 p-6 rounded-3xl shadow-sm border border-slate-200 dark:border-slate-700 hover:shadow-xl transition-all duration-300">
<div class="text-slate-500 dark:text-slate-400 text-[10px] font-black uppercase tracking-widest">Meilleur Score</div>
<div class="text-4xl font-black mt-2 text-amber-600 dark:text-amber-400">{{ stats.best_score }} / 20</div>
<div class="text-4xl font-black mt-2 text-purple-600 dark:text-purple-400">{{ stats.best_score }} / 20</div>
</div>
</div>
@@ -142,41 +154,91 @@ const getStatusColor = (status) => {
</div>
</div>
<div v-else class="py-12">
<div class="mx-auto max-w-3xl sm:px-6 lg:px-8">
<div class="bg-white dark:bg-slate-800 p-12 rounded-3xl shadow-xl border border-slate-200 dark:border-slate-700 text-center">
<h3 class="text-3xl font-black mb-4">Bienvenue, {{ user.name }} !</h3>
<p class="text-slate-500 dark:text-slate-400 mb-12">
Veuillez sélectionner le test technique auquel vous avez été invité.
Prenez le temps de vous installer confortablement avant de commencer.
</p>
<!-- Candidate Dashboard: LIGHT ONLY, high contrast, no dark: classes -->
<div v-else style="background: linear-gradient(135deg, #f8faff 0%, #eef2ff 100%); min-height: calc(100vh - 4rem);" class="flex flex-col items-center justify-center px-4 py-16">
<div class="w-full max-w-4xl">
<div v-if="quizzes.length > 0" class="space-y-4">
<div v-for="quiz in quizzes" :key="quiz.id" class="p-6 bg-slate-50 dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-2xl flex flex-col sm:flex-row items-center justify-between gap-6 group hover:border-indigo-500 transition-all duration-300">
<div class="text-left flex-1">
<h4 class="text-xl font-bold group-hover:text-indigo-600 transition-colors">{{ quiz.title }}</h4>
<p class="text-sm text-slate-500 mt-1">{{ quiz.duration_minutes }} minutes {{ quiz.description }}</p>
<!-- Welcome Section -->
<div class="mb-12 text-center">
<div class="inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-[10px] font-black uppercase tracking-widest mb-6 border" style="background:#eef2ff; color:#4f46e5; border-color:#c7d2fe;">
Espace Candidat
</div>
<h3 class="font-black mb-5 tracking-tight" style="font-size: clamp(2rem, 5vw, 3.5rem); color: #1e1b4b; line-height: 1.1;">
Bienvenue, <span style="color:#4f46e5;">{{ user.name }}</span> !
</h3>
<p style="color:#6b7280; font-size:1.1rem; max-width:40rem; margin:0 auto; line-height:1.7;">
Voici les tests techniques préparés pour votre candidature. Installez-vous confortablement avant de commencer.
</p>
</div>
<!-- Quizzes Grid -->
<div v-if="quizzes && quizzes.length > 0" class="grid grid-cols-1 md:grid-cols-2 gap-8">
<div
v-for="quiz in quizzes"
:key="quiz.id"
class="group"
style="background: white; border-radius: 2rem; padding: 2.5rem; box-shadow: 0 4px 24px rgba(79,70,229,0.08); border: 1.5px solid #e0e7ff; transition: all 0.4s ease; position: relative; overflow: hidden;"
@mouseenter="$event.currentTarget.style.borderColor='#6366f1'; $event.currentTarget.style.boxShadow='0 12px 40px rgba(79,70,229,0.15)'; $event.currentTarget.style.transform='translateY(-4px)'"
@mouseleave="$event.currentTarget.style.borderColor='#e0e7ff'; $event.currentTarget.style.boxShadow='0 4px 24px rgba(79,70,229,0.08)'; $event.currentTarget.style.transform='translateY(0)'"
>
<!-- Decorative blob -->
<div style="position:absolute; top:-2rem; right:-2rem; width:8rem; height:8rem; background:radial-gradient(circle, #818cf820 0%, transparent 70%); border-radius:50%;"></div>
<!-- Icon badge -->
<div style="display:inline-flex; padding:0.75rem; background:#eef2ff; border-radius:1rem; margin-bottom:1.5rem;">
<svg xmlns="http://www.w3.org/2000/svg" style="width:1.75rem;height:1.75rem;color:#4f46e5;stroke:#4f46e5;" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4" />
</svg>
</div>
<h4 style="font-size:1.25rem; font-weight:800; color:#1e1b4b; margin-bottom:0.75rem; line-height:1.3;">{{ quiz.title }}</h4>
<p style="color:#6b7280; font-size:0.875rem; line-height:1.6; margin-bottom:2rem; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;">
{{ quiz.description }}
</p>
<div style="border-top:1.5px solid #f1f5f9; padding-top:1.5rem; display:flex; align-items:center; justify-content:space-between; gap:1rem;">
<div>
<div style="font-size:0.65rem; font-weight:900; text-transform:uppercase; letter-spacing:0.1em; color:#9ca3af; margin-bottom:0.2rem;">Durée</div>
<div style="font-size:0.95rem; font-weight:800; color:#374151;">{{ quiz.duration_minutes }} min</div>
</div>
<div v-if="quiz.has_finished_attempt" class="flex items-center gap-2 px-6 py-3 bg-emerald-50 dark:bg-emerald-900/20 border border-emerald-200 dark:border-emerald-800 rounded-xl text-emerald-600 dark:text-emerald-400 font-bold whitespace-nowrap">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
<div v-if="quiz.has_finished_attempt" style="display:flex; align-items:center; gap:0.5rem; background:#ecfdf5; color:#059669; font-weight:800; font-size:0.75rem; text-transform:uppercase; letter-spacing:0.08em; padding:0.625rem 1.25rem; border-radius:0.75rem; border:1.5px solid #a7f3d0;">
<svg xmlns="http://www.w3.org/2000/svg" style="width:1rem;height:1rem;" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="3">
<path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
</svg>
Test effectué
Terminé
</div>
<Link
v-else
:href="route('quizzes.take', quiz.id)"
class="bg-indigo-600 text-white px-8 py-3 rounded-xl font-bold hover:bg-slate-900 dark:hover:bg-white dark:hover:text-slate-900 transition-all duration-300 shadow-lg shadow-indigo-600/20 active:scale-95 whitespace-nowrap"
style="display:inline-flex; align-items:center; justify-content:center; padding:0.75rem 2rem; background:#4f46e5; color:white; border-radius:0.875rem; font-weight:800; font-size:0.875rem; text-decoration:none; box-shadow:0 4px 14px rgba(79,70,229,0.35); transition:all 0.2s ease; white-space:nowrap;"
@mouseenter="$event.currentTarget.style.background='#4338ca'; $event.currentTarget.style.transform='scale(0.98)'"
@mouseleave="$event.currentTarget.style.background='#4f46e5'; $event.currentTarget.style.transform='scale(1)'"
>
Démarrer le test
Démarrer
</Link>
</div>
</div>
<div v-else class="py-12 text-slate-500 italic">
Aucun test ne vous est assigné pour le moment.
</div>
</div>
<!-- Empty State -->
<div v-else style="text-align:center; padding:5rem 2rem; background:white; border-radius:2rem; box-shadow:0 4px 24px rgba(0,0,0,0.06); border:1.5px solid #e0e7ff;">
<div style="display:inline-flex; padding:1.5rem; background:#fff7ed; border-radius:9999px; margin-bottom:1.5rem;">
<svg xmlns="http://www.w3.org/2000/svg" style="width:3rem;height:3rem;stroke:#f97316;" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg>
</div>
<h4 style="font-size:1.5rem; font-weight:900; color:#1e1b4b; margin-bottom:0.75rem;">Aucun test assigné</h4>
<p style="color:#6b7280; max-width:28rem; margin:0 auto; line-height:1.7; font-size:0.95rem;">
Votre dossier est en cours de traitement. Un administrateur vous assignera bientôt vos tests techniques.
</p>
</div>
<!-- Footer -->
<div style="margin-top:3rem; text-align:center;">
<p style="font-size:0.65rem; font-weight:900; text-transform:uppercase; letter-spacing:0.15em; color:#d1d5db;">RecruitQuizz Platform v{{ $page.props.app_version }}</p>
</div>
</div>
</div>
</component>

View File

@@ -26,6 +26,7 @@ Route::get('/dashboard', function () {
$allCandidates = Candidate::with(['attempts'])->get();
$stats = [
'total_candidates' => Candidate::count(),
'selected_candidates' => Candidate::where('is_selected', true)->count(),
'finished_tests' => Attempt::whereNotNull('finished_at')->count(),
'average_score' => round($allCandidates->avg('weighted_score') ?? 0, 1),
'best_score' => round($allCandidates->max('weighted_score') ?? 0, 1),
@@ -49,7 +50,16 @@ Route::get('/dashboard', function () {
->all();
} else {
$candidate = auth()->user()->candidate;
$quizzes = \App\Models\Quiz::all()->map(function($quiz) use ($candidate) {
if ($candidate) {
$candidate->load('jobPosition.quizzes');
}
$quizzes = ($candidate && $candidate->jobPosition)
? $candidate->jobPosition->quizzes
: collect();
$quizzes = $quizzes->map(function($quiz) use ($candidate) {
$quiz->has_finished_attempt = $candidate
? $candidate->attempts()->where('quiz_id', $quiz->id)->whereNotNull('finished_at')->exists()
: false;
@@ -77,6 +87,7 @@ Route::middleware('auth')->group(function () {
Route::patch('/candidates/{candidate}/scores', [\App\Http\Controllers\CandidateController::class, 'updateScores'])->name('candidates.update-scores');
Route::patch('/candidates/{candidate}/position', [\App\Http\Controllers\CandidateController::class, 'updatePosition'])->name('candidates.update-position');
Route::patch('/candidates/{candidate}/tenant', [\App\Http\Controllers\CandidateController::class, 'updateTenant'])->name('candidates.update-tenant');
Route::patch('/candidates/{candidate}/toggle-selection', [\App\Http\Controllers\CandidateController::class, 'toggleSelection'])->name('candidates.toggle-selection');
Route::post('/candidates/{candidate}/analyze', [\App\Http\Controllers\AIAnalysisController::class, 'analyze'])->name('candidates.analyze');
Route::post('/candidates/{candidate}/reset-password', [\App\Http\Controllers\CandidateController::class, 'resetPassword'])->name('candidates.reset-password');
Route::get('/documents/{document}', [\App\Http\Controllers\DocumentController::class, 'show'])->name('documents.show');
@@ -86,6 +97,7 @@ Route::middleware('auth')->group(function () {
Route::resource('quizzes.questions', \App\Http\Controllers\QuestionController::class)->only(['store', 'update', 'destroy']);
Route::resource('tenants', \App\Http\Controllers\TenantController::class)->only(['index', 'store', 'update', 'destroy']);
Route::resource('users', \App\Http\Controllers\UserController::class)->except(['show', 'create', 'edit']);
Route::post('/users/{user}/reset-password', [\App\Http\Controllers\UserController::class, 'resetPassword'])->name('users.reset-password');
Route::get('/backup', [\App\Http\Controllers\BackupController::class, 'download'])->name('backup');
Route::delete('/attempts/{attempt}', [\App\Http\Controllers\AttemptController::class, 'destroy'])->name('attempts.destroy');
Route::patch('/answers/{answer}/score', [\App\Http\Controllers\AttemptController::class, 'updateAnswerScore'])->name('answers.update-score');

View File

@@ -10,6 +10,7 @@ export default {
'./resources/views/**/*.blade.php',
'./resources/js/**/*.vue',
],
darkMode: 'class',
theme: {
extend: {