Files
Dwinzo_Demo/app/src/functions/getUserData.ts

37 lines
720 B
TypeScript
Raw Normal View History

2025-06-10 15:28:23 +05:30
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");
2025-06-10 15:28:23 +05:30
}
const [organization] = emailDomain.split(".");
return {
email: email,
userId: userId,
userName: userName ?? undefined,
organization,
};
};