- Updated various API service files to replace error throwing with console.error for better logging. - This change affects services related to aisles, assets, cameras, collaboration, comments, environment, lines, marketplace, simulation, visualization, and zones. - The modifications aim to improve error handling by logging errors to the console instead of interrupting the flow with thrown errors.
37 lines
720 B
TypeScript
37 lines
720 B
TypeScript
interface UserData {
|
|
email: string;
|
|
userId: string;
|
|
userName?: string; // Optional
|
|
organization: string;
|
|
}
|
|
|
|
export const getUserData = (): UserData => {
|
|
const email = localStorage.getItem("email");
|
|
const userId = localStorage.getItem("userId");
|
|
const userName = localStorage.getItem("userName");
|
|
|
|
if (!email || !userId) {
|
|
return {
|
|
email: '',
|
|
userId: '',
|
|
userName: '',
|
|
organization: '',
|
|
};
|
|
}
|
|
|
|
const [_, emailDomain] = email.split("@");
|
|
|
|
if (!emailDomain) {
|
|
console.error("Invalid email format");
|
|
}
|
|
|
|
const [organization] = emailDomain.split(".");
|
|
|
|
return {
|
|
email: email,
|
|
userId: userId,
|
|
userName: userName ?? undefined,
|
|
organization,
|
|
};
|
|
};
|