import { getStoredClientSession, hasModuleAccess, hasStoredClientSession } from '$lib/session';
import { api } from '$lib/api';

export async function load({ fetch }) {
  if (!hasStoredClientSession()) {
    return {
      mixes: []
    };
  }

  const session = getStoredClientSession();

  try {
    return {
      mixes: hasModuleAccess(session, 'mix_master') ? await api.mixes(fetch) : []
    };
  } catch {
    return {
      mixes: []
    };
  }
}
