feat: multi-tenant SaaS implementation - admin interface, tenant isolation, and UI updates

This commit is contained in:
jeremy bayse
2026-03-28 18:38:22 +01:00
parent 7d94be7a8c
commit f53d5770df
20 changed files with 757 additions and 34 deletions

View File

@@ -13,7 +13,9 @@ import SecondaryButton from '@/Components/SecondaryButton.vue';
import InputError from '@/Components/InputError.vue';
const props = defineProps({
candidates: Array
candidates: Array,
jobPositions: Array,
tenants: Array
});
const isModalOpen = ref(false);
@@ -23,9 +25,11 @@ const form = useForm({
name: '',
email: '',
phone: '',
linkedin_url: '',
linkedin_url: '',
cv: null,
cover_letter: null,
tenant_id: '',
job_position_id: '',
});
const submit = () => {
@@ -64,8 +68,16 @@ const getNestedValue = (obj, path) => {
return path.split('.').reduce((o, i) => (o ? o[i] : null), obj);
};
const selectedJobPosition = ref('');
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);
});
const sortedCandidates = computed(() => {
return [...props.candidates].sort((a, b) => {
return [...filteredCandidates.value].sort((a, b) => {
let valA = getNestedValue(a, sortKey.value);
let valB = getNestedValue(b, sortKey.value);
@@ -87,8 +99,23 @@ const sortedCandidates = computed(() => {
Gestion des Candidats
</template>
<div class="flex justify-between items-center mb-8">
<h3 class="text-2xl font-bold">Liste des Candidats</h3>
<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>
</div>
<PrimaryButton @click="isModalOpen = true">
Ajouter un Candidat
</PrimaryButton>
@@ -128,6 +155,22 @@ const sortedCandidates = computed(() => {
</svg>
</div>
</th>
<th @click="sortBy('tenant.name')" v-if="$page.props.auth.user.role === 'super_admin'" 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">
Structure
<svg v-show="sortKey === 'tenant.name'" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" :class="{ 'rotate-180': sortOrder === -1 }" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
</div>
</th>
<th @click="sortBy('job_position.title')" 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">
Fiche de Poste
<svg v-show="sortKey === 'job_position.title'" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" :class="{ 'rotate-180': sortOrder === -1 }" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
</div>
</th>
<th @click="sortBy('status')" 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">
Statut
@@ -165,6 +208,12 @@ const sortedCandidates = computed(() => {
<td class="px-6 py-4 text-sm text-slate-600 dark:text-slate-400">
{{ candidate.user.email }}
</td>
<td class="px-6 py-4 text-xs font-bold uppercase tracking-widest text-indigo-600 dark:text-indigo-400" v-if="$page.props.auth.user.role === 'super_admin'">
{{ candidate.tenant ? candidate.tenant.name : 'Aucun' }}
</td>
<td class="px-6 py-4 text-sm font-semibold text-slate-700 dark:text-slate-300">
{{ candidate.job_position ? candidate.job_position.title : 'Non assigné' }}
</td>
<td class="px-6 py-4 text-xs font-bold uppercase tracking-widest">
<span
class="px-3 py-1 rounded-lg"
@@ -245,7 +294,7 @@ const sortedCandidates = computed(() => {
</td>
</tr>
<tr v-if="candidates.length === 0">
<td colspan="5" class="px-6 py-12 text-center text-slate-500 italic">
<td colspan="7" class="px-6 py-12 text-center text-slate-500 italic">
Aucun candidat trouvé.
</td>
</tr>
@@ -285,6 +334,25 @@ const sortedCandidates = computed(() => {
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div v-if="$page.props.auth.user.role === 'super_admin'">
<InputLabel for="tenant_id" value="Structure de rattachement" />
<select id="tenant_id" v-model="form.tenant_id" class="mt-1 block w-full rounded-md border-slate-300 dark:border-slate-700 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm dark:bg-slate-900">
<option value="">Aucune</option>
<option v-for="t in tenants" :key="t.id" :value="t.id">{{ t.name }}</option>
</select>
<InputError class="mt-2" :message="form.errors.tenant_id" />
</div>
<div :class="{ 'md:col-span-2': $page.props.auth.user.role !== 'super_admin' }">
<InputLabel for="job_position_id" value="Rattacher à une Fiche de poste" />
<select id="job_position_id" v-model="form.job_position_id" class="mt-1 block w-full rounded-md border-slate-300 dark:border-slate-700 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm dark:bg-slate-900">
<option value="">Aucune (Candidature spontanée)</option>
<option v-for="jp in jobPositions" :key="jp.id" :value="jp.id">{{ jp.title }}</option>
</select>
<InputError class="mt-2" :message="form.errors.job_position_id" />
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<InputLabel value="CV (PDF)" />