/** @type {import('./$types').PageLoad} */

import { events_func } from '$lib/ae_events_functions';

export async function load({ params, parent, url }) { // route
    // console.log(`ae_events_leads +page.ts data.params:`, params);
    // console.log(`ae_events_leads +page.ts data.route:`, route);
    // console.log(`ae_events_leads +page.ts data.url:`, url);

    let data = await parent();
    // console.log(`ae_events_leads +page.ts data:`, data);

    // console.log(`ae_events_leads +page.ts data.ae_loc:`, data.ae_loc);
    if (data.ae_loc.account_id) {
    } else {
        console.log(`The account_id was not found in the data.ae_loc!!!`);
        return false;
    }

    data.ae_events_leads_page_ts = true;

    let submenu = {
        main: {name: 'Main', href: '/events_leads', access: false},
        manage: {name: 'Manage', href: '/events_leads/manage', access: 'administrator', disable: true, hide: true},
        review: {name: 'Exhibitor', href: '/events_leads/exhibitor', access: false, disable: false, hide: false},
        };
    data.submenu = submenu

    // Do not wait on these:
    let event_id = url.searchParams.get('event_id');
    let load_event_obj = events_func.handle_load_ae_obj_id__event({api_cfg: data.ae_api, event_id:  event_id, try_cache: false});
    // console.log(`load_event_obj = `, load_event_obj);

    let load_event_exhibit_obj_li = events_func.handle_load_ae_obj_li__exhibit({api_cfg: data.ae_api, event_id:  event_id, try_cache: false});
    // console.log(`load_event_exhibit_obj_li = `, load_event_exhibit_obj_li);

    // let exhibit_id = data.params.slug;
    // let load_event_exhibit_obj = events_func.handle_load_ae_obj_id__exhibit({api_cfg: data.ae_api, exhibit_id:  exhibit_id, try_cache: false});
    // console.log(`load_event_exhibit_obj = `, load_event_exhibit_obj);

    return data;
}
