2026-03-11 23:33:10 +00:00
|
|
|
<script setup lang="ts">
|
2026-03-26 14:31:36 +01:00
|
|
|
import { computed, ref, watch } from 'vue';
|
2026-03-11 23:33:10 +00:00
|
|
|
import { Head, Link, router } from '@inertiajs/vue3';
|
|
|
|
|
import { FolderOpen } from 'lucide-vue-next';
|
2026-03-26 14:31:36 +01:00
|
|
|
import BulkActionBar from '@/components/declarations/BulkActionBar.vue';
|
2026-03-26 11:26:22 +01:00
|
|
|
import NudgePopover from '@/components/declarations/NudgePopover.vue';
|
2026-03-11 23:33:10 +00:00
|
|
|
import Heading from '@/components/Heading.vue';
|
|
|
|
|
import Pagination from '@/components/Pagination.vue';
|
|
|
|
|
import { Button } from '@/components/ui/button';
|
2026-03-26 14:31:36 +01:00
|
|
|
import { Checkbox } from '@/components/ui/checkbox';
|
2026-03-12 18:25:32 +00:00
|
|
|
import AppLayout from '@/layouts/AppLayout.vue';
|
2026-03-11 23:33:10 +00:00
|
|
|
|
2026-03-12 18:25:32 +00:00
|
|
|
type Declaration = {
|
2026-03-11 23:33:10 +00:00
|
|
|
id: number;
|
|
|
|
|
title: string;
|
|
|
|
|
type: string;
|
|
|
|
|
client_name: string;
|
2026-03-26 11:26:22 +01:00
|
|
|
assignee_name: string | null;
|
2026-03-11 23:33:10 +00:00
|
|
|
status: string;
|
|
|
|
|
due_date: string | null;
|
|
|
|
|
showUrl: string;
|
|
|
|
|
editUrl: string;
|
|
|
|
|
destroyUrl: string;
|
2026-03-26 11:26:22 +01:00
|
|
|
nudgeUrl: string | null;
|
2026-03-11 23:33:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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 = {
|
2026-03-12 18:25:32 +00:00
|
|
|
declarations: PaginatedData<Declaration>;
|
2026-03-11 23:33:10 +00:00
|
|
|
createUrl: string;
|
|
|
|
|
workspaceName: string;
|
2026-03-18 00:12:50 +00:00
|
|
|
canCreate: boolean;
|
|
|
|
|
canEdit: boolean;
|
|
|
|
|
canDelete: boolean;
|
2026-03-26 11:26:22 +01:00
|
|
|
canNudge: boolean;
|
2026-03-26 14:31:36 +01:00
|
|
|
bulkNotifyUrl?: string;
|
|
|
|
|
canBulkNotify?: 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
|
|
|
|
2026-03-26 14:31:36 +01:00
|
|
|
const selectedIds = ref<number[]>([]);
|
|
|
|
|
|
|
|
|
|
watch(() => props.declarations.data, () => {
|
|
|
|
|
selectedIds.value = [];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const eligibleDeclarations = computed(() =>
|
|
|
|
|
props.declarations.data.filter(
|
|
|
|
|
(d) => d.status === 'en_attente_client',
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const allEligibleSelected = computed(
|
|
|
|
|
() =>
|
|
|
|
|
eligibleDeclarations.value.length > 0 &&
|
|
|
|
|
eligibleDeclarations.value.every((d) =>
|
|
|
|
|
selectedIds.value.includes(d.id),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
function toggleSelectAll(checked: boolean | 'indeterminate') {
|
|
|
|
|
if (checked === true) {
|
|
|
|
|
const eligibleIds = eligibleDeclarations.value.map((d) => d.id);
|
|
|
|
|
const merged = new Set([...selectedIds.value, ...eligibleIds]);
|
|
|
|
|
selectedIds.value = [...merged];
|
|
|
|
|
} else {
|
|
|
|
|
const eligibleIds = new Set(
|
|
|
|
|
eligibleDeclarations.value.map((d) => d.id),
|
|
|
|
|
);
|
|
|
|
|
selectedIds.value = selectedIds.value.filter(
|
|
|
|
|
(id) => !eligibleIds.has(id),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleRow(id: number, checked: boolean | 'indeterminate') {
|
|
|
|
|
if (checked === true) {
|
|
|
|
|
if (!selectedIds.value.includes(id)) {
|
|
|
|
|
selectedIds.value = [...selectedIds.value, id];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
selectedIds.value = selectedIds.value.filter((i) => i !== id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearSelection() {
|
|
|
|
|
selectedIds.value = [];
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-12 18:25:32 +00:00
|
|
|
function destroy(declaration: Declaration) {
|
2026-03-11 23:33:10 +00:00
|
|
|
if (
|
|
|
|
|
window.confirm(
|
2026-03-12 18:25:32 +00:00
|
|
|
`Êtes-vous sûr de vouloir supprimer « ${declaration.title} » ?`,
|
2026-03-11 23:33:10 +00:00
|
|
|
)
|
|
|
|
|
) {
|
2026-03-12 18:25:32 +00:00
|
|
|
router.delete(declaration.destroyUrl);
|
2026-03-11 23:33:10 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const typeLabels: Record<string, string> = {
|
|
|
|
|
vat: 'TVA',
|
|
|
|
|
vat_monthly: 'TVA mensuelle',
|
|
|
|
|
vat_quarterly: 'TVA trimestrielle',
|
|
|
|
|
corporate_tax: 'IS',
|
|
|
|
|
income_tax: 'IR',
|
|
|
|
|
cnss: 'CNSS',
|
|
|
|
|
annual_balance: 'Bilan',
|
|
|
|
|
other: 'Autre',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const statusLabels: Record<string, string> = {
|
|
|
|
|
draft: 'Brouillon',
|
|
|
|
|
waiting_documents: 'En attente documents',
|
|
|
|
|
documents_received: 'Documents reçus',
|
|
|
|
|
processing: 'En cours de traitement',
|
|
|
|
|
additional_documents_requested: 'Pièces complémentaires demandées',
|
|
|
|
|
waiting_client_validation: 'En attente validation client',
|
|
|
|
|
validated: 'Validé',
|
|
|
|
|
closed: 'Clôturé',
|
|
|
|
|
cancelled: 'Annulé',
|
|
|
|
|
};
|
2026-03-26 14:31:36 +01:00
|
|
|
|
|
|
|
|
const columnCount = computed(() => (props.canBulkNotify ? 7 : 6));
|
2026-03-11 23:33:10 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-03-12 18:25:32 +00:00
|
|
|
<AppLayout :breadcrumbs="[{ title: 'Déclarations' }]">
|
|
|
|
|
<Head title="Déclarations" />
|
2026-03-11 23:33:10 +00:00
|
|
|
|
|
|
|
|
<div class="flex flex-col space-y-6 p-4">
|
|
|
|
|
<div class="flex items-center justify-between">
|
|
|
|
|
<Heading
|
|
|
|
|
variant="small"
|
2026-03-12 18:25:32 +00:00
|
|
|
title="Déclarations"
|
|
|
|
|
:description="`Gérer les déclarations du workspace « ${workspaceName} »`"
|
2026-03-11 23:33:10 +00:00
|
|
|
/>
|
2026-03-18 00:12:50 +00:00
|
|
|
<Button v-if="props.canCreate" as-child>
|
2026-03-12 18:25:32 +00:00
|
|
|
<Link :href="createUrl">Nouvelle déclaration</Link>
|
2026-03-11 23:33:10 +00:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
2026-03-12 18:25:32 +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-12 18:25:32 +00:00
|
|
|
<thead
|
|
|
|
|
class="border-b border-sidebar-border/70 bg-muted/50"
|
|
|
|
|
>
|
2026-03-11 23:33:10 +00:00
|
|
|
<tr>
|
2026-03-26 14:31:36 +01:00
|
|
|
<th
|
|
|
|
|
v-if="props.canBulkNotify"
|
|
|
|
|
class="h-10 w-10 px-4 text-center align-middle"
|
|
|
|
|
>
|
|
|
|
|
<Checkbox
|
|
|
|
|
:checked="allEligibleSelected"
|
|
|
|
|
:disabled="
|
|
|
|
|
eligibleDeclarations.length === 0
|
|
|
|
|
"
|
|
|
|
|
@update:checked="toggleSelectAll"
|
|
|
|
|
/>
|
|
|
|
|
</th>
|
2026-03-11 23:33:10 +00:00
|
|
|
<th
|
2026-03-12 18:25:32 +00:00
|
|
|
class="h-10 px-4 text-left align-middle font-medium"
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
Titre
|
|
|
|
|
</th>
|
|
|
|
|
<th
|
2026-03-12 18:25:32 +00:00
|
|
|
class="h-10 px-4 text-left align-middle font-medium"
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
Client
|
|
|
|
|
</th>
|
|
|
|
|
<th
|
2026-03-12 18:25:32 +00:00
|
|
|
class="h-10 px-4 text-left align-middle font-medium"
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
Type
|
|
|
|
|
</th>
|
|
|
|
|
<th
|
2026-03-12 18:25:32 +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-12 18:25:32 +00:00
|
|
|
class="h-10 px-4 text-left align-middle font-medium"
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
Date limite
|
|
|
|
|
</th>
|
|
|
|
|
<th
|
2026-03-12 18:25:32 +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
|
2026-03-12 18:25:32 +00:00
|
|
|
v-for="declaration in declarations.data"
|
|
|
|
|
:key="declaration.id"
|
2026-03-11 23:33:10 +00:00
|
|
|
class="border-b border-sidebar-border/50 last:border-0"
|
|
|
|
|
>
|
2026-03-26 14:31:36 +01:00
|
|
|
<td
|
|
|
|
|
v-if="props.canBulkNotify"
|
|
|
|
|
class="px-4 py-3 text-center"
|
|
|
|
|
>
|
|
|
|
|
<Checkbox
|
|
|
|
|
v-if="
|
|
|
|
|
declaration.status ===
|
|
|
|
|
'en_attente_client'
|
|
|
|
|
"
|
|
|
|
|
:checked="
|
|
|
|
|
selectedIds.includes(
|
|
|
|
|
declaration.id,
|
|
|
|
|
)
|
|
|
|
|
"
|
|
|
|
|
@update:checked="
|
|
|
|
|
(v: boolean | 'indeterminate') =>
|
|
|
|
|
toggleRow(declaration.id, v)
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</td>
|
2026-03-11 23:33:10 +00:00
|
|
|
<td class="px-4 py-3 font-medium">
|
|
|
|
|
<Link
|
2026-03-12 18:25:32 +00:00
|
|
|
:href="declaration.showUrl"
|
2026-03-11 23:33:10 +00:00
|
|
|
class="hover:underline"
|
|
|
|
|
>
|
2026-03-12 18:25:32 +00:00
|
|
|
{{ declaration.title }}
|
2026-03-11 23:33:10 +00:00
|
|
|
</Link>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="px-4 py-3 text-muted-foreground">
|
2026-03-12 18:25:32 +00:00
|
|
|
{{ declaration.client_name }}
|
2026-03-11 23:33:10 +00:00
|
|
|
</td>
|
|
|
|
|
<td class="px-4 py-3 text-muted-foreground">
|
2026-03-12 18:25:32 +00:00
|
|
|
{{
|
|
|
|
|
typeLabels[declaration.type] ??
|
|
|
|
|
declaration.type
|
|
|
|
|
}}
|
2026-03-11 23:33:10 +00:00
|
|
|
</td>
|
|
|
|
|
<td class="px-4 py-3 text-muted-foreground">
|
2026-03-12 18:25:32 +00:00
|
|
|
{{
|
|
|
|
|
statusLabels[declaration.status] ??
|
|
|
|
|
declaration.status
|
|
|
|
|
}}
|
2026-03-11 23:33:10 +00:00
|
|
|
</td>
|
|
|
|
|
<td class="px-4 py-3 text-muted-foreground">
|
2026-03-12 18:25:32 +00:00
|
|
|
{{ declaration.due_date || '—' }}
|
2026-03-11 23:33:10 +00:00
|
|
|
</td>
|
2026-03-26 11:26:22 +01:00
|
|
|
<td
|
|
|
|
|
class="flex items-center gap-2 px-4 py-3 text-right"
|
|
|
|
|
>
|
|
|
|
|
<NudgePopover
|
|
|
|
|
v-if="props.canNudge"
|
|
|
|
|
:assignee-name="
|
|
|
|
|
declaration.assignee_name
|
|
|
|
|
"
|
|
|
|
|
:nudge-url="declaration.nudgeUrl"
|
|
|
|
|
/>
|
2026-03-12 18:25:32 +00:00
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
|
|
|
|
size="sm"
|
|
|
|
|
as-child
|
|
|
|
|
>
|
|
|
|
|
<Link :href="declaration.showUrl"
|
2026-03-11 23:33:10 +00:00
|
|
|
>Voir</Link
|
|
|
|
|
>
|
|
|
|
|
</Button>
|
2026-03-12 18:25:32 +00:00
|
|
|
<Button
|
2026-03-18 00:12:50 +00:00
|
|
|
v-if="props.canEdit"
|
2026-03-12 18:25:32 +00:00
|
|
|
variant="outline"
|
|
|
|
|
size="sm"
|
|
|
|
|
as-child
|
|
|
|
|
>
|
|
|
|
|
<Link :href="declaration.editUrl"
|
2026-03-11 23:33:10 +00:00
|
|
|
>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"
|
2026-03-12 18:25:32 +00:00
|
|
|
@click="destroy(declaration)"
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
Supprimer
|
|
|
|
|
</Button>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
2026-03-12 18:25:32 +00:00
|
|
|
<tr v-if="!declarations.data.length">
|
2026-03-11 23:33:10 +00:00
|
|
|
<td
|
2026-03-26 14:31:36 +01:00
|
|
|
:colspan="columnCount"
|
2026-03-11 23:33:10 +00:00
|
|
|
class="px-4 py-8 text-center text-muted-foreground"
|
|
|
|
|
>
|
2026-03-12 18:25:32 +00:00
|
|
|
<div
|
|
|
|
|
class="flex flex-col items-center gap-2"
|
|
|
|
|
>
|
2026-03-11 23:33:10 +00:00
|
|
|
<FolderOpen class="h-10 w-10" />
|
2026-03-12 18:25:32 +00:00
|
|
|
<p>
|
|
|
|
|
Aucune déclaration 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"
|
2026-03-12 18:25:32 +00:00
|
|
|
>Créer votre première
|
|
|
|
|
déclaration</Link
|
2026-03-11 23:33:10 +00:00
|
|
|
>
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<Pagination
|
|
|
|
|
:pagination="{
|
2026-03-12 18:25:32 +00:00
|
|
|
from: declarations.from ?? 0,
|
|
|
|
|
to: declarations.to ?? 0,
|
|
|
|
|
total: declarations.total,
|
|
|
|
|
current_page: declarations.current_page,
|
|
|
|
|
last_page: declarations.last_page,
|
|
|
|
|
per_page: declarations.per_page,
|
2026-03-11 23:33:10 +00:00
|
|
|
}"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2026-03-26 14:31:36 +01:00
|
|
|
|
|
|
|
|
<BulkActionBar
|
|
|
|
|
v-if="props.canBulkNotify && props.bulkNotifyUrl"
|
|
|
|
|
:selected-ids="selectedIds"
|
|
|
|
|
:bulk-notify-url="props.bulkNotifyUrl"
|
|
|
|
|
@clear="clearSelection"
|
|
|
|
|
/>
|
2026-03-11 23:33:10 +00:00
|
|
|
</AppLayout>
|
|
|
|
|
</template>
|