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 { pakaiStok } = await parent();
	if (!pakaiStok) {
		throw redirect(303, '/dashboard');
	}

	return {
		member: locals.member
	};
};
