import { browser } from '$app/environment';

const STORAGE_KEY = 'zoe-shaldon-rsvp-submitted';

export function createRsvpStatus() {
	let submitted = $state(false);

	$effect(() => {
		if (!browser) return;
		submitted = localStorage.getItem(STORAGE_KEY) === 'true';
	});

	function markSubmitted() {
		submitted = true;
		if (browser) localStorage.setItem(STORAGE_KEY, 'true');
	}

	return {
		get submitted() {
			return submitted;
		},
		markSubmitted
	};
}
