|
|
|
|
@ -55,6 +55,7 @@ const ArticleHistory: Component = () => {
|
|
|
|
|
const [filterStatus, setFilterStatus] = createSignal('');
|
|
|
|
|
const [filterSourceType, setFilterSourceType] = createSignal('');
|
|
|
|
|
const [page, setPage] = createSignal(0);
|
|
|
|
|
const [confirming, setConfirming] = createSignal(false);
|
|
|
|
|
|
|
|
|
|
const totalPages = () => Math.max(1, Math.ceil(total() / PAGE_SIZE));
|
|
|
|
|
|
|
|
|
|
@ -88,6 +89,22 @@ const ArticleHistory: Component = () => {
|
|
|
|
|
// Skip the initial run which is handled by onMount
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const handleClear = async () => {
|
|
|
|
|
if (!confirming()) {
|
|
|
|
|
setConfirming(true);
|
|
|
|
|
setTimeout(() => setConfirming(false), 3000);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
await articleHistoryApi.clearAll();
|
|
|
|
|
setConfirming(false);
|
|
|
|
|
setPage(0);
|
|
|
|
|
fetchHistory();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error('Failed to clear history', err);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleFilterChange = () => {
|
|
|
|
|
setPage(0);
|
|
|
|
|
fetchHistory();
|
|
|
|
|
@ -101,10 +118,20 @@ const ArticleHistory: Component = () => {
|
|
|
|
|
return (
|
|
|
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
|
|
|
{/* Page header */}
|
|
|
|
|
<div class="mb-6">
|
|
|
|
|
<div class="mb-6 flex items-center justify-between">
|
|
|
|
|
<h1 class="text-3xl font-bold text-gray-900">
|
|
|
|
|
{t('articleHistory.title')}
|
|
|
|
|
</h1>
|
|
|
|
|
<button
|
|
|
|
|
onClick={handleClear}
|
|
|
|
|
class={`px-3 py-1.5 text-sm rounded-md border ${
|
|
|
|
|
confirming()
|
|
|
|
|
? 'bg-red-600 text-white border-red-600'
|
|
|
|
|
: 'bg-white text-red-600 border-red-300 hover:bg-red-50'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{confirming() ? 'Confirmer' : t('articleHistory.clearAll')}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Filters */}
|
|
|
|
|
|