import { pb } from "@/services/pocketbase"; import type { Company } from "@/types/Company"; import type { User } from "@/types/User"; import { useEffect, useState } from "react"; export const useUserInformations = () => { const [user, setUser] = useState(null); const [company, setCompany] = useState(null); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchInformations = async () => { setIsLoading(true); try { const userRecords = await pb.collection('aegis_users').getFullList(); setUser(userRecords[0]); const companyRecords = await pb.collection('aegis_companies').getFullList(); setCompany(companyRecords[0]) } catch (err) { setError("Erreur lors de la récupération des infos utilisateur :"+err); } finally { setIsLoading(false); } }; fetchInformations(); }, []); return { user, company, isLoading, error }; };