Files
aegis/src/hooks/useInfrastructureNodes.ts
T
LathanDevers 41433b4859
Sécurité - Architecture Git-Flow / validate-flow (pull_request) Successful in 0s
Contrôle Qualité & Sécurité (QA) / qa-s-check (pull_request) Failing after 20s
fix: correction des erreurs de linting pour le QA
2026-08-03 15:57:11 +02:00

29 lines
861 B
TypeScript

import { useState, useEffect } from 'react';
import { pb } from '@services/pocketbase';
import type { InfrastructureNode } from '@/types/InfrastructureNode';
export const useInfrastructureNodes = () => {
const [nodes, setNodes] = useState<InfrastructureNode[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const fetchNodes = async () => {
try {
setIsLoading(true);
const records = await pb.collection('aegis_infrastructure_nodes').getFullList<InfrastructureNode>({
sort: 'created',
});
setNodes(records);
} catch {
setError("Impossible de charger l'infrastructure.");
} finally {
setIsLoading(false);
}
};
fetchNodes();
}, []);
return { nodes, isLoading, error };
};