correct user settings manager (and password reset)

This commit is contained in:
LathanDevers
2026-08-04 16:51:00 +02:00
parent 84d7b7e847
commit 85adfaab2d
11 changed files with 339 additions and 78 deletions
+30
View File
@@ -0,0 +1,30 @@
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<User | null>(null);
const [company, setCompany] = useState<Company | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const fetchInformations = async () => {
setIsLoading(true);
try {
const userRecords = await pb.collection('aegis_users').getFullList<User>();
setUser(userRecords[0]);
const companyRecords = await pb.collection('aegis_companies').getFullList<Company>();
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 };
};