2026-03-11 23:33:10 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { Head, Link, router } from '@inertiajs/vue3';
|
|
|
|
|
import { Building2 } from 'lucide-vue-next';
|
|
|
|
|
import Heading from '@/components/Heading.vue';
|
|
|
|
|
import Pagination from '@/components/Pagination.vue';
|
|
|
|
|
import { Button } from '@/components/ui/button';
|
2026-03-18 00:12:50 +00:00
|
|
|
import AppLayout from '@/layouts/AppLayout.vue';
|
2026-03-11 23:33:10 +00:00
|
|
|
|
|
|
|
|
type Client = {
|
|
|
|
|
id: number;
|
|
|
|
|
company_name: string;
|
|
|
|
|
legal_form: string;
|
|
|
|
|
ice: string | null;
|
|
|
|
|
status: string | null;
|
|
|
|
|
showUrl: string;
|
|
|
|
|
editUrl: string;
|
|
|
|
|
destroyUrl: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type PaginatedData<T> = {
|
|
|
|
|
data: T[];
|
|
|
|
|
from: number | null;
|
|
|
|
|
to: number | null;
|
|
|
|
|
total: number;
|
|
|
|
|
current_page: number;
|
|
|
|
|
last_page: number;
|
|
|
|
|
per_page: number;
|
|
|
|
|
path: string;
|
|
|
|
|
first_page_url: string;
|
|
|
|
|
prev_page_url: string | null;
|
|
|
|
|
next_page_url: string | null;
|
|
|
|
|
last_page_url: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
clients: PaginatedData<Client>;
|
|
|
|
|
createUrl: string;
|
|
|
|
|
workspaceName: string;
|
2026-03-18 00:12:50 +00:00
|
|
|
canCreate: boolean;
|
|
|
|
|
canEdit: boolean;
|
|
|
|
|
canDelete: boolean;
|
2026-03-11 23:33:10 +00:00
|
|
|
};
|
|
|
|
|
|
2026-03-18 00:12:50 +00:00
|
|
|
const props = defineProps<Props>();
|
2026-03-11 23:33:10 +00:00
|
|
|
|
|
|
|
|
function destroy(client: Client) {
|
|
|
|
|
if (
|
|
|
|
|
window.confirm(
|
|
|
|
|
`Êtes-vous sûr de vouloir supprimer « ${client.company_name} » ?`,
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
router.delete(client.destroyUrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const statusLabels: Record<string, string> = {
|
|
|
|
|
actif: 'Actif',
|
|
|
|
|
inactif: 'Inactif',
|
|
|
|
|
suspendu: 'Suspendu',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function getLegalFormLabel(legalForm: string): string {
|
|
|
|
|
const labels: Record<string, string> = {
|
|
|
|
|
sarl: 'SARL',
|
|
|
|
|
sa: 'SA',
|
|
|
|
|
snc: 'SNC',
|
|
|
|
|
scs: 'SCS',
|
|
|
|
|
eurl: 'EURL',
|
|
|
|
|
sel: 'SEL',
|
|
|
|
|
auto_entrepreneur: 'Auto-entrepreneur',
|
|
|
|
|
entreprise_individuelle: 'Entreprise individuelle',
|
|
|
|
|
other: 'Autre',
|
|
|
|
|
};
|
|
|
|
|
return labels[legalForm] ?? legalForm;
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-03-18 00:12:50 +00:00
|
|
|
<AppLayout :breadcrumbs="[{ title: 'Clients' }]">
|
2026-03-11 23:33:10 +00:00
|
|
|
<Head title="Clients" />
|
|
|
|
|
|
|
|
|
|
<div class="flex flex-col space-y-6 p-4">
|
|
|
|
|
<div class="flex items-center justify-between">
|
|
|
|
|
<Heading
|
|
|
|
|
variant="small"
|
|
|
|
|
title="Clients"
|
|
|
|
|
:description="`Gérer les clients du workspace « ${workspaceName} »`"
|
|
|
|
|
/>
|
2026-03-18 00:12:50 +00:00
|
|
|
<Button v-if="props.canCreate" as-child>
|
2026-03-11 23:33:10 +00:00
|
|
|
<Link :href="createUrl">Ajouter un client</Link>
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
2026-03-18 00:12:50 +00:00
|
|
|
class="overflow-hidden rounded-xl border border-sidebar-border/70 dark:border-sidebar-border"
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
<div class="overflow-x-auto">
|
|
|
|
|
<table class="w-full text-sm">
|
2026-03-18 00:12:50 +00:00
|
|
|
<thead
|
|
|
|
|
class="border-b border-sidebar-border/70 bg-muted/50"
|
|
|
|
|
>
|
2026-03-11 23:33:10 +00:00
|
|
|
<tr>
|
|
|
|
|
<th
|
2026-03-18 00:12:50 +00:00
|
|
|
class="h-10 px-4 text-left align-middle font-medium"
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
Raison sociale
|
|
|
|
|
</th>
|
|
|
|
|
<th
|
2026-03-18 00:12:50 +00:00
|
|
|
class="h-10 px-4 text-left align-middle font-medium"
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
Forme juridique
|
|
|
|
|
</th>
|
|
|
|
|
<th
|
2026-03-18 00:12:50 +00:00
|
|
|
class="h-10 px-4 text-left align-middle font-medium"
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
ICE
|
|
|
|
|
</th>
|
|
|
|
|
<th
|
2026-03-18 00:12:50 +00:00
|
|
|
class="h-10 px-4 text-left align-middle font-medium"
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
Statut
|
|
|
|
|
</th>
|
|
|
|
|
<th
|
2026-03-18 00:12:50 +00:00
|
|
|
class="h-10 px-4 text-right align-middle font-medium"
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
Actions
|
|
|
|
|
</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr
|
|
|
|
|
v-for="client in clients.data"
|
|
|
|
|
:key="client.id"
|
|
|
|
|
class="border-b border-sidebar-border/50 last:border-0"
|
|
|
|
|
>
|
|
|
|
|
<td class="px-4 py-3 font-medium">
|
|
|
|
|
<Link
|
|
|
|
|
:href="client.showUrl"
|
|
|
|
|
class="hover:underline"
|
|
|
|
|
>
|
|
|
|
|
{{ client.company_name }}
|
|
|
|
|
</Link>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="px-4 py-3 text-muted-foreground">
|
|
|
|
|
{{ getLegalFormLabel(client.legal_form) }}
|
|
|
|
|
</td>
|
|
|
|
|
<td class="px-4 py-3 text-muted-foreground">
|
|
|
|
|
{{ client.ice || '—' }}
|
|
|
|
|
</td>
|
|
|
|
|
<td class="px-4 py-3 text-muted-foreground">
|
2026-03-18 00:12:50 +00:00
|
|
|
{{
|
|
|
|
|
client.status
|
|
|
|
|
? (statusLabels[client.status] ??
|
|
|
|
|
client.status)
|
|
|
|
|
: '—'
|
|
|
|
|
}}
|
2026-03-11 23:33:10 +00:00
|
|
|
</td>
|
2026-03-18 00:12:50 +00:00
|
|
|
<td class="space-x-2 px-4 py-3 text-right">
|
|
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
|
|
|
|
size="sm"
|
|
|
|
|
as-child
|
|
|
|
|
>
|
|
|
|
|
<Link :href="client.showUrl">Voir</Link>
|
2026-03-11 23:33:10 +00:00
|
|
|
</Button>
|
2026-03-18 00:12:50 +00:00
|
|
|
<Button
|
|
|
|
|
v-if="props.canEdit"
|
|
|
|
|
variant="outline"
|
|
|
|
|
size="sm"
|
|
|
|
|
as-child
|
|
|
|
|
>
|
2026-03-11 23:33:10 +00:00
|
|
|
<Link :href="client.editUrl"
|
|
|
|
|
>Modifier</Link
|
|
|
|
|
>
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
2026-03-18 00:12:50 +00:00
|
|
|
v-if="props.canDelete"
|
2026-03-11 23:33:10 +00:00
|
|
|
variant="destructive"
|
|
|
|
|
size="sm"
|
|
|
|
|
@click="destroy(client)"
|
|
|
|
|
>
|
|
|
|
|
Supprimer
|
|
|
|
|
</Button>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr v-if="!clients.data.length">
|
|
|
|
|
<td
|
|
|
|
|
colspan="5"
|
|
|
|
|
class="px-4 py-8 text-center text-muted-foreground"
|
|
|
|
|
>
|
2026-03-18 00:12:50 +00:00
|
|
|
<div
|
|
|
|
|
class="flex flex-col items-center gap-2"
|
|
|
|
|
>
|
2026-03-11 23:33:10 +00:00
|
|
|
<Building2 class="h-10 w-10" />
|
|
|
|
|
<p>Aucun client pour le moment.</p>
|
2026-03-18 00:12:50 +00:00
|
|
|
<Button v-if="props.canCreate" as-child>
|
2026-03-11 23:33:10 +00:00
|
|
|
<Link :href="createUrl"
|
|
|
|
|
>Ajouter votre premier
|
|
|
|
|
client</Link
|
|
|
|
|
>
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<Pagination
|
|
|
|
|
:pagination="{
|
|
|
|
|
from: clients.from ?? 0,
|
|
|
|
|
to: clients.to ?? 0,
|
|
|
|
|
total: clients.total,
|
|
|
|
|
current_page: clients.current_page,
|
|
|
|
|
last_page: clients.last_page,
|
|
|
|
|
per_page: clients.per_page,
|
|
|
|
|
}"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</AppLayout>
|
|
|
|
|
</template>
|