Initial commit with contrats and domaines modules

This commit is contained in:
mrKamoo
2026-04-08 18:07:08 +02:00
commit 092a6a0484
191 changed files with 24639 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<script setup>
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
import { Head, Link, useForm } from '@inertiajs/vue3'
const props = defineProps({ user: Object, services: Array, roles: Array })
const form = useForm({
name: props.user.name, email: props.user.email,
service_id: props.user.service_id ?? '', telephone: props.user.telephone ?? '',
role: props.user.roles?.[0]?.name ?? 'lecteur',
password: '', password_confirmation: '',
})
function submit() { form.put(route('users.update', props.user.id)) }
const roleLabels = { admin: 'Administrateur', responsable: 'Responsable', acheteur: 'Acheteur', lecteur: 'Lecteur' }
</script>
<template>
<Head :title="`Modifier — ${user.name}`" />
<AuthenticatedLayout>
<template #header>
<div class="flex items-center gap-3">
<Link :href="route('users.index')" class="text-gray-400 hover:text-gray-600"><svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" /></svg></Link>
<h1 class="text-xl font-semibold text-gray-900">Modifier {{ user.name }}</h1>
</div>
</template>
<form @submit.prevent="submit" class="max-w-xl space-y-6">
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
<div class="grid gap-4 sm:grid-cols-2">
<div class="sm:col-span-2"><label class="block text-sm font-medium text-gray-700">Nom *</label><input v-model="form.name" type="text" required class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
<div class="sm:col-span-2"><label class="block text-sm font-medium text-gray-700">Email *</label><input v-model="form.email" type="email" required class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
<div><label class="block text-sm font-medium text-gray-700">Service</label><select v-model="form.service_id" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"><option value="">—</option><option v-for="s in services" :key="s.id" :value="s.id">{{ s.nom }}</option></select></div>
<div><label class="block text-sm font-medium text-gray-700">Téléphone</label><input v-model="form.telephone" type="text" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
<div class="sm:col-span-2"><label class="block text-sm font-medium text-gray-700">Rôle *</label>
<select v-model="form.role" required class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none">
<option v-for="r in roles" :key="r.name" :value="r.name">{{ roleLabels[r.name] ?? r.name }}</option>
</select>
</div>
<div><label class="block text-sm font-medium text-gray-700">Nouveau mot de passe</label><input v-model="form.password" type="password" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
<div><label class="block text-sm font-medium text-gray-700">Confirmation</label><input v-model="form.password_confirmation" type="password" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
</div>
</div>
<div class="flex justify-end gap-3">
<Link :href="route('users.index')" class="rounded-lg border border-gray-300 px-5 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 transition-colors">Annuler</Link>
<button type="submit" :disabled="form.processing" class="rounded-lg bg-blue-600 px-5 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50 transition-colors">{{ form.processing ? '...' : 'Enregistrer' }}</button>
</div>
</form>
</AuthenticatedLayout>
</template>

View File

@@ -0,0 +1,63 @@
<script setup>
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
import Pagination from '@/Components/Pagination.vue'
import { Head, Link, router } from '@inertiajs/vue3'
defineProps({ users: Object, services: Array, roles: Array })
const roleLabels = { admin: 'Administrateur', responsable: 'Responsable', acheteur: 'Acheteur', lecteur: 'Lecteur' }
function toggleActive(user) {
router.patch(route('users.toggle-active', user.id))
}
</script>
<template>
<Head title="Utilisateurs" />
<AuthenticatedLayout>
<template #header>
<h1 class="text-xl font-semibold text-gray-900">Utilisateurs</h1>
</template>
<div class="rounded-xl bg-white shadow-sm border border-gray-100 overflow-hidden">
<table class="min-w-full divide-y divide-gray-100 text-sm">
<thead class="bg-gray-50">
<tr>
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Nom</th>
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Email</th>
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Service</th>
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Rôle</th>
<th class="px-5 py-3 text-center text-xs font-medium text-gray-500 uppercase">Statut</th>
<th class="px-5 py-3 text-center text-xs font-medium text-gray-500 uppercase">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-50">
<tr v-for="u in users.data" :key="u.id" :class="['hover:bg-gray-50', !u.active ? 'opacity-60' : '']">
<td class="px-5 py-3 font-medium text-gray-900">{{ u.name }}</td>
<td class="px-5 py-3 text-gray-500">{{ u.email }}</td>
<td class="px-5 py-3 text-gray-500">{{ u.service?.nom ?? '—' }}</td>
<td class="px-5 py-3">
<span class="rounded-full bg-blue-100 px-2.5 py-1 text-xs font-medium text-blue-700">
{{ roleLabels[u.roles?.[0]?.name] ?? u.roles?.[0]?.name ?? 'Aucun' }}
</span>
</td>
<td class="px-5 py-3 text-center">
<button @click="toggleActive(u)"
:class="['rounded-full px-2.5 py-1 text-xs font-medium transition-colors', u.active ? 'bg-green-100 text-green-700 hover:bg-green-200' : 'bg-gray-100 text-gray-600 hover:bg-gray-200']">
{{ u.active ? 'Actif' : 'Inactif' }}
</button>
</td>
<td class="px-5 py-3 text-center">
<Link :href="route('users.edit', u.id)" class="text-gray-400 hover:text-indigo-600 transition-colors">
<svg class="h-4 w-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" /></svg>
</Link>
</td>
</tr>
</tbody>
</table>
<div class="border-t border-gray-100 px-5 py-3">
<Pagination :links="users.links" :meta="users.meta" />
</div>
</div>
</AuthenticatedLayout>
</template>