import type { PageServerLoad } from './$types';
import { GetMyNotificationsStore } from '$houdini';

export const load: PageServerLoad = async (event) => {
	const { url, locals } = event;
	const unreadOnly = url.searchParams.get('tab') === 'unread';

	const fetchParams = { event, metadata: { cookie: locals.cookie } };

	const result = await new GetMyNotificationsStore().fetch({
		...fetchParams,
		variables: {
			unreadOnly,
			limit: 50,
			offset: 0
		}
	});

	return {
		notifications: result
	};
};
