import { LocalStore } from '@/services/local-store';
import { setCookie, getCookie, deleteCookie, hasCookie } from 'cookies-next';

export class CookiesStore implements LocalStore {
    get(key: string) {
        if (hasCookie(key)) {
            return getCookie(key);
        } else {
            return undefined;
        }
    }
    save(key: string, data: string) {
        setCookie(key, data, {
            expires: new Date('2099.01.01'),
        });
    }
    delete(key: string) {
        deleteCookie(key);
    }
    resetStore() {
        document.cookie = '';
    }
}
