This commit is contained in:
Benjamin Toby 2025-01-05 08:05:15 +01:00
parent 4776018c3c
commit f0850146be

View File

@ -1,25 +0,0 @@
import { LocalStorageDict } from "@/dict/local-storage-dict";
import { DATASQUIREL_LoggedInUser } from "@moduletrace/datasquirel/package-shared/types";
import React from "react";
export default function useLocalUser() {
const [user, setUser] = React.useState<
DATASQUIREL_LoggedInUser | null | undefined
>(undefined);
React.useEffect(() => {
try {
const localUserJSON = localStorage.getItem(
LocalStorageDict["User"]
);
if (localUserJSON) {
const localUser = JSON.parse(localUserJSON);
setUser(localUser);
}
} catch (error) {
setUser(null);
}
}, []);
return { user };
}