import CookieManager from '@react-native-cookies/cookies';

const TOP_LEVEL_DOMAIN = 'https://denetme.net';

export const setCookie = (key: any, value: any, options?: any) => {
	return CookieManager.set(TOP_LEVEL_DOMAIN, {
		name: key,
		value,
		domain: options?.domain,
		path: options?.path,
		version: options?.version,
		expires: options?.expires,
	});
};

export const getCookie = (key: any) => {
	return new Promise(res => {
		CookieManager.get(TOP_LEVEL_DOMAIN).then((data: any) => {
			if (data && data[key]) {
				res(data[key].value);
			} else {
				res(null);
			}
		});
	});
};
