import { redirect } from '@sveltejs/kit';
import type { LayoutServerLoad } from './$types';

export const load: LayoutServerLoad = async ({ locals, parent }) => {
	if (!locals.member) {
		throw redirect(303, '/login');
	}

	const { pakaiHutangPiutang } = await parent();
	if (!pakaiHutangPiutang) {
		throw redirect(303, '/langganan');
	}

	return { member: locals.member };
};
