Files
Dwinzo_Demo/app/src/functions/getUserData.ts
Jerald-Golden-B b49f431ebf Refactor error handling in API services to use console.error instead of throwing errors
- 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.
2025-06-24 09:31:45 +05:30

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,
};
};