change and add into components, widgets and pages

This commit is contained in:
LathanDevers
2026-07-30 14:08:49 +02:00
parent ec900efe3a
commit 057aa628a3
39 changed files with 1620 additions and 1062 deletions
+31
View File
@@ -0,0 +1,31 @@
import { useState, useEffect, useCallback } from 'react';
import { pb } from '@/services/pocketbase';
import type { Ticket } from '@/types/Ticket';
export const useTickets = () => {
const [tickets, setTickets] = useState<Ticket[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const fetchTickets = useCallback(async () => {
setIsLoading(true);
setError(null);
try {
const records = await pb.collection('aegis_tickets').getFullList<Ticket>({
sort: '-created', // Du plus récent au plus ancien
});
setTickets(records);
} catch (err) {
console.error("Erreur lors de la récupération des tickets :", err);
setError("Impossible de charger l'historique de vos requêtes.");
} finally {
setIsLoading(false);
}
}, []);
useEffect(() => {
fetchTickets();
}, [fetchTickets]);
return { tickets, isLoading, error, refetch: fetchTickets };
};