import { create } from 'zustand'

const useAuthStore = create((set) => ({
  token: localStorage.getItem('sysadmin_token') || null,

  login(token) {
    localStorage.setItem('sysadmin_token', token)
    set({ token })
  },

  logout() {
    localStorage.removeItem('sysadmin_token')
    set({ token: null })
  },
}))

export default useAuthStore
