

const TOKEN_KEY = 'CurrentUser';


export const setCurrentUser = (user) => {
  localStorage.setItem(TOKEN_KEY, user);
};

export const getCurrentUser = () => {
  return JSON.parse(localStorage.getItem(TOKEN_KEY));
};

export const getToken = () => {
  const userData = localStorage.getItem(TOKEN_KEY);
  return userData ? JSON.parse(userData).token : null;
};


export const removeCurrentUser = () => {
  localStorage.removeItem(TOKEN_KEY);
};


export const isTokenAvailable = () => {
  return !!localStorage.getItem(TOKEN_KEY); // Returns true if token exists
};




