refactor: Update getUserData function to return empty user data object instead of throwing an error when localStorage is missing values

This commit is contained in:
Jerald-Golden-B 2025-06-10 11:51:39 +05:30
parent 0892d0dd53
commit 6c8eb7d2f3
1 changed files with 6 additions and 1 deletions

View File

@ -11,7 +11,12 @@ export const getUserData = (): UserData => {
const userName = localStorage.getItem("userName"); const userName = localStorage.getItem("userName");
if (!email || !userId) { if (!email || !userId) {
throw new Error("User data not found in localStorage"); return {
email: '',
userId: '',
userName: '',
organization: '',
};
} }
const [_, emailDomain] = email.split("@"); const [_, emailDomain] = email.split("@");