110 lines
4.0 KiB
TypeScript
110 lines
4.0 KiB
TypeScript
/** @type {import('./$types').PageLoad} */
|
|
import { error } from '@sveltejs/kit';
|
|
console.log(`ae_events_pres_mgmt_event [slug] +page.ts start`);
|
|
|
|
import { browser } from '$app/environment';
|
|
import { events_func } from '$lib/ae_events_functions';
|
|
|
|
export async function load({ params, parent }) { // route
|
|
let log_lvl = 0;
|
|
|
|
let data = await parent();
|
|
// console.log(`ae events_pres_mgmt session [slug] +page.ts data:`, data);
|
|
|
|
let account_id = data.account_id;
|
|
let ae_acct = data[account_id];
|
|
// console.log(`ae_acct = `, ae_acct);
|
|
|
|
// if (!account_id) {
|
|
// console.log(`ae events_pres_mgmt session [slug] +page.ts: The account_id was not found in the data!!!`);
|
|
// return false;
|
|
// }
|
|
|
|
data.ae_events_pres_mgmt_event_slug_page_ts = true;
|
|
|
|
let event_session_id = params.slug;
|
|
if (!event_session_id) {
|
|
console.log(`ae events_pres_mgmt session [slug] +page.ts: The event_session_id was not found in the params!!!`);
|
|
error(404, {
|
|
message: 'Session not found'
|
|
});
|
|
}
|
|
ae_acct.slct.event_session_id = event_session_id;
|
|
|
|
if (browser) {
|
|
// Load event session object
|
|
let load_event_session_obj = events_func.load_ae_obj_id__event_session({
|
|
api_cfg: ae_acct.api,
|
|
event_session_id: event_session_id,
|
|
try_cache: true
|
|
});
|
|
|
|
ae_acct.slct.event_session_obj = load_event_session_obj;
|
|
|
|
// Load event presentations for the session
|
|
let load_event_presentation_obj_li = events_func.load_ae_obj_li__event_presentation({
|
|
api_cfg: ae_acct.api,
|
|
event_session_id: event_session_id,
|
|
params: {enabled: 'all', qry__limit: 50},
|
|
try_cache: true
|
|
})
|
|
.then((event_presentation_obj_li) => {
|
|
if (log_lvl) {
|
|
console.log(`event_presentation_obj_li = `, event_presentation_obj_li);
|
|
}
|
|
for (let index = 0; index < event_presentation_obj_li.length; index++) {
|
|
let event_presentation_obj = event_presentation_obj_li[index];
|
|
let event_presentation_id = event_presentation_obj.event_presentation_id_random;
|
|
|
|
let load_event_presenter_obj_li = events_func.load_ae_obj_li__event_presenter({
|
|
api_cfg: ae_acct.api,
|
|
for_obj_type: 'event_presentation',
|
|
for_obj_id: event_presentation_id,
|
|
params: {qry__enabled: 'all', qry__limit: 15},
|
|
try_cache: true
|
|
});
|
|
if (log_lvl) {
|
|
console.log(`load_event_presenter_obj_li = `, load_event_presenter_obj_li);
|
|
}
|
|
event_presentation_obj_li[index].event_presenter_li = load_event_presenter_obj_li;
|
|
}
|
|
|
|
return event_presentation_obj_li;
|
|
});
|
|
if (log_lvl) {
|
|
console.log(`load_event_presentation_obj_li = `, load_event_presentation_obj_li);
|
|
}
|
|
ae_acct.slct.event_presentation_obj_li = load_event_presentation_obj_li;
|
|
|
|
// Load event files for the session
|
|
let ae_params = {
|
|
qry__enabled: 'all',
|
|
qry__hidden: 'all',
|
|
qry__limit: 50
|
|
}
|
|
|
|
let load_event_file_obj_li = await events_func.handle_load_ae_obj_li__event_file({
|
|
api_cfg: ae_acct.api,
|
|
for_obj_type: 'event_session',
|
|
for_obj_id: event_session_id,
|
|
params: ae_params,
|
|
try_cache: true
|
|
})
|
|
.then((event_file_obj_li) => {
|
|
if (log_lvl) {
|
|
console.log(`event_file_obj_li = `, event_file_obj_li);
|
|
}
|
|
return event_file_obj_li;
|
|
});
|
|
if (log_lvl) {
|
|
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
|
}
|
|
ae_acct.slct.event_file_obj_li = load_event_file_obj_li;
|
|
}
|
|
|
|
// WARNING: Precaution against shared data between sites and presentations.
|
|
data[account_id] = ae_acct;
|
|
|
|
return data;
|
|
}
|