export const state = {
    isAuthenticated: false,
    authMode: "login",
    me: null,
    phase: null,
    prevPhase: null,
    counts: null,
    mySuggestions: [],
    allSuggestions: [],
    allSuggestionsSig: null,
    myVotes: [],
    results: [],
    votesRendered: false,
};

export function clearUserState() {
    state.me = null;
    state.phase = null;
    state.prevPhase = null;
    state.counts = null;
    state.mySuggestions = [];
    state.allSuggestions = [];
    state.myVotes = [];
    state.results = [];
    state.votesRendered = false;
    const adminCard = document.getElementById("admin-card");
    if (adminCard) adminCard.classList.add("hidden");
}

export const getSavedUsername = () =>
    localStorage.getItem("last_username") || "";
export const setSavedUsername = (name) =>
    localStorage.setItem("last_username", name);
