diff --git a/src/lib/ae_sponsorships_functions.ts b/src/lib/ae_sponsorships_functions.ts
index 8b636f2c..507166ad 100644
--- a/src/lib/ae_sponsorships_functions.ts
+++ b/src/lib/ae_sponsorships_functions.ts
@@ -66,8 +66,47 @@ async function handle_load_ae_obj_id__sponsorship_cfg(
}
+async function handle_download_export__sponsorship(
+ {
+ api_cfg,
+ account_id,
+ file_type='CSV', // 'CSV' or 'Excel'
+ return_file=true,
+ filename='no_filename.csv',
+ auto_download=false,
+ params={}, // key value object is expected
+ log_lvl=0
+ } : {
+ api_cfg: any,
+ account_id: string,
+ file_type?: string,
+ return_file?: boolean,
+ filename?: string,
+ auto_download?: boolean,
+ params?: key_val,
+ log_lvl?: number
+ }
+ ) {
+console.log('*** stores_event_api.js: get_sponsorship_export() ***');
+
+const endpoint = `/v2/crud/sponsorship/list`;
+params['for_obj_type'] = 'account';
+params['for_obj_id'] = account_id;
+
+if (file_type == 'CSV' || file_type == 'Excel') {
+ params['file_type'] = file_type;
+}
+params['return_file'] = true;
+
+ae_promises.download__sponsorship_export_file = await api.get_object({api_cfg: api_cfg, endpoint: endpoint, params: params, return_blob: return_file, filename: filename, auto_download: auto_download, log_lvl: log_lvl});
+
+console.log('ae_promises.download__sponsorship_export_file:', ae_promises.download__sponsorship_export_file);
+return ae_promises.download__sponsorship_export_file;
+}
+
let export_obj = {
handle_load_ae_obj_id__sponsorship_cfg: handle_load_ae_obj_id__sponsorship_cfg,
+ handle_download_export__sponsorship: handle_download_export__sponsorship,
};
export let spons_func = export_obj;
diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts
index 1edf4e68..afb0776f 100644
--- a/src/lib/ae_stores.ts
+++ b/src/lib/ae_stores.ts
@@ -45,6 +45,8 @@ export let ae_app_local_data_struct: key_val = {
'debug': false, // A simple flag to know if we should show debug information.
'account_id': ae_account_id, // OSIT Demo _XY7DXtc9MY
+ 'account_code': 'not_set',
+ 'account_name': 'Account Name Not Set',
'site_domain': null, // https://example.com, https://dev.example.com, etc.
'site_cfg_json': {
slct__event_id: null,
diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts
index 995627e0..6d3283e8 100644
--- a/src/routes/+layout.ts
+++ b/src/routes/+layout.ts
@@ -147,6 +147,9 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
ae_api_init['headers']['x-no-account-id'] = null;
ae_loc_init['account_id'] = site_domain_results.account_id_random;
+ ae_loc_init['account_code'] = site_domain_results.account_code; // Useful for export file naming
+ ae_loc_init['account_name'] = site_domain_results.account_name; // Generally useful for display
+
ae_loc_init['site_id'] = site_domain_results.site_id_random;
ae_loc_init['site_domain_id'] = site_domain_results.site_domain_id_random;
ae_loc_init['site_enable'] = site_domain_results.enable;
diff --git a/src/routes/sponsorships/+page.svelte b/src/routes/sponsorships/+page.svelte
index 554b188b..7b5430d7 100644
--- a/src/routes/sponsorships/+page.svelte
+++ b/src/routes/sponsorships/+page.svelte
@@ -21,11 +21,13 @@ import { api } from '$lib/api';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils';
import type { key_val } from '$lib/ae_stores';
+import { spons_func } from '$lib/ae_sponsorships_functions';
import Edit_modal_sponsorship_obj from './10_edit_modal__sponsorship_obj.svelte';
import List_sponsorship_obj from './10_list__sponsorship_obj.svelte';
import View_modal_sponsorship_obj from './10_view_modal__sponsorship_obj.svelte';
+let ae_promises: key_val = {};
// Editing
const modalComponentEditSponsorshipObj: ModalComponent = { ref: Edit_modal_sponsorship_obj, props: {container_class_li: 'w-full p-4 space-y-4 card ae_modal_scrollfix'} };
@@ -392,32 +394,38 @@ async function handle_load_ae_obj_id__sponsorship({sponsorship_id, try_cache=fal
Start Sponsor Submission Form
-
+ if (!confirm('Download exported data Excel file?')) {
+ return false;
+ }
+ ae_promises.download__sponsorships_export = spons_func.handle_download_export__sponsorship({
+ api_cfg: $ae_api,
+ account_id: $slct.account_id,
+ file_type: 'Excel',
+ return_file: true,
+ filename: `lead_retrieval_export_${$ae_loc.account_code.replaceAll(' ', '_')}.xlsx`,
+ auto_download: true,
+ log_lvl: 2
+ });
-
-
-
+ {#await ae_promises.download__sponsorship_export}
+
+
+ {:then}
+
+ {/await}
+ Export Data
+
+ {/if}