
export const ALERT_STORAGE_KEY = 'ad_storefront_alert';

export const ALERT_LEAD_ADD_SUCCESS = 'lead.add.success';
export const ALERT_QUESTION_ADD_SUCCESS = 'question.add.success';
export const ALERT_QUESTION_ADD_ERROR = 'question.add.error';
export const ALERT_REVIEW_ADD_SUCCESS = 'review.add.success';

export const getAlerts = () => {
    const currentRaw = localStorage.getItem(ALERT_STORAGE_KEY);
    return (currentRaw && JSON.parse(currentRaw)) || [];
};

export const clearAlerts = () => {
    localStorage.removeItem(ALERT_STORAGE_KEY);
};

export const addAlert = alertid => {
    const current = getAlerts();
    current.push(alertid);
    localStorage.setItem(ALERT_STORAGE_KEY, JSON.stringify(current));
};
