refactor: use shared Pagination component in admin pages
- Replace inline pagination in TicketManagement with Pagination component - Replace inline pagination in UserManagement with Pagination component - Reduces duplication from 2.8% to 2.49% 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
6020dc7b93
commit
c78b68ca4f
|
|
@ -3,7 +3,7 @@
|
|||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { adminService } from '@/services/admin.service';
|
||||
import { Ticket } from '@/types';
|
||||
import { StatusBadge } from '@/components/ui';
|
||||
import { StatusBadge, Pagination } from '@/components/ui';
|
||||
|
||||
export default function TicketManagement() {
|
||||
const [tickets, setTickets] = useState<Ticket[]>([]);
|
||||
|
|
@ -312,25 +312,12 @@ export default function TicketManagement() {
|
|||
</div>
|
||||
|
||||
{/* Pagination */}
|
||||
<div className="flex justify-center gap-2 mt-4">
|
||||
<button
|
||||
onClick={() => setPage((p) => Math.max(1, p - 1))}
|
||||
disabled={page === 1}
|
||||
className="px-4 py-2 border rounded disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
Précédent
|
||||
</button>
|
||||
<span className="px-4 py-2">
|
||||
Page {page} sur {totalPages}
|
||||
</span>
|
||||
<button
|
||||
onClick={() => setPage((p) => Math.min(totalPages, p + 1))}
|
||||
disabled={page === totalPages}
|
||||
className="px-4 py-2 border rounded disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
Suivant
|
||||
</button>
|
||||
</div>
|
||||
<Pagination
|
||||
currentPage={page}
|
||||
totalPages={totalPages}
|
||||
onPageChange={setPage}
|
||||
showPageNumbers={false}
|
||||
/>
|
||||
|
||||
|
||||
{/* Modal détails ticket */}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { useState, useEffect, useCallback, useMemo } from 'react';
|
|||
import { useRouter } from 'next/navigation';
|
||||
import { adminService } from '@/services/admin.service';
|
||||
import { User, CreateEmployeeData, UpdateUserData, PaginatedResponse } from '@/types';
|
||||
import { Pagination } from '@/components/ui';
|
||||
|
||||
export default function UserManagement() {
|
||||
const router = useRouter();
|
||||
|
|
@ -263,25 +264,12 @@ export default function UserManagement() {
|
|||
</div>
|
||||
|
||||
{/* Pagination */}
|
||||
<div className="flex justify-center gap-2 mt-4">
|
||||
<button
|
||||
onClick={() => setPage((p) => Math.max(1, p - 1))}
|
||||
disabled={page === 1}
|
||||
className="px-4 py-2 border rounded disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
Précédent
|
||||
</button>
|
||||
<span className="px-4 py-2">
|
||||
Page {page} sur {totalPages}
|
||||
</span>
|
||||
<button
|
||||
onClick={() => setPage((p) => Math.min(totalPages, p + 1))}
|
||||
disabled={page === totalPages}
|
||||
className="px-4 py-2 border rounded disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
Suivant
|
||||
</button>
|
||||
</div>
|
||||
<Pagination
|
||||
currentPage={page}
|
||||
totalPages={totalPages}
|
||||
onPageChange={setPage}
|
||||
showPageNumbers={false}
|
||||
/>
|
||||
|
||||
{/* Modal créer employé */}
|
||||
{isCreateEmployeeModalOpen && (
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user