diff --git a/src/routes/events/[event_id]/(pres_mgmt)/session/[session_id]/ae_comp__event_session_poc_form_agree.svelte b/src/routes/events/[event_id]/(pres_mgmt)/session/[session_id]/ae_comp__event_session_poc_form_agree.svelte index e0434c76..e843418e 100644 --- a/src/routes/events/[event_id]/(pres_mgmt)/session/[session_id]/ae_comp__event_session_poc_form_agree.svelte +++ b/src/routes/events/[event_id]/(pres_mgmt)/session/[session_id]/ae_comp__event_session_poc_form_agree.svelte @@ -97,20 +97,12 @@ async function handle_submit_form(event: SubmitEvent) { console.log(`opt_out_do:`, opt_out_do); - let event_session_data = { - poc_kv_json: lq__event_session_obj.poc_kv_json - }; - console.log('event_session_data:', event_session_data); + // poc_kv_json may be null if no POC data has been saved yet — initialize before writing. + const kv: key_val = { ...(lq__event_session_obj.poc_kv_json ?? {}) }; + if (!kv[poc_type]) kv[poc_type] = {}; + kv[poc_type] = { ...kv[poc_type], ...opt_out_do }; - // Check if poc_type exists in the event_session_data.poc_kv_json - if (!event_session_data.poc_kv_json[poc_type]) { - event_session_data.poc_kv_json[poc_type] = {}; - } - - event_session_data.poc_kv_json[poc_type] = { - ...event_session_data.poc_kv_json[poc_type], - ...opt_out_do - }; + let event_session_data = { poc_kv_json: kv }; // Use this in the future if we need to store the agreements in a more complex way? // let event_session_data = {poc_kv_json: lq__event_session_obj?.poc_kv_json}; @@ -201,7 +193,7 @@ async function handle_submit_form(event: SubmitEvent) { class="checkbox preset-tonal-warning border-warning-500 checked:preset-filled-warning-500 hover:preset-filled-error-500 border" id="optout_audio" name="optout_audio" - checked={lq__event_session_obj.poc_kv_json[poc_type] + checked={lq__event_session_obj.poc_kv_json?.[poc_type] ?.optout_audio} value={true} /> Opt-out - Audio Reproduction of Presentation @@ -215,7 +207,7 @@ async function handle_submit_form(event: SubmitEvent) { class="checkbox preset-tonal-warning border-warning-500 checked:preset-filled-warning-500 hover:preset-filled-error-500 border" id="optout_video" name="optout_video" - checked={lq__event_session_obj.poc_kv_json[poc_type] + checked={lq__event_session_obj.poc_kv_json?.[poc_type] ?.optout_video} value={true} /> Opt-out - Video Reproduction of Presentation @@ -229,7 +221,7 @@ async function handle_submit_form(event: SubmitEvent) { class="checkbox preset-tonal-warning border-warning-500 checked:preset-filled-warning-500 hover:preset-filled-error-500 border" id="optout_transcription_and_publication" name="optout_transcription_and_publication" - checked={lq__event_session_obj.poc_kv_json[poc_type] + checked={lq__event_session_obj.poc_kv_json?.[poc_type] ?.optout_transcription_and_publication} value={true} /> Opt-out - Transcription and Publication of Presentation on LCI @@ -244,7 +236,7 @@ async function handle_submit_form(event: SubmitEvent) { class="checkbox preset-tonal-warning border-warning-500 checked:preset-filled-warning-500 hover:preset-filled-error-500 border" id="optout_publication_in_app" name="optout_publication_in_app" - checked={lq__event_session_obj.poc_kv_json[poc_type] + checked={lq__event_session_obj.poc_kv_json?.[poc_type] ?.optout_publication_in_app} value={true} /> Opt-out - Publication of Presentation on LCI Congress App diff --git a/src/routes/events/[event_id]/(pres_mgmt)/session/[session_id]/ae_comp__event_session_poc_profile.svelte b/src/routes/events/[event_id]/(pres_mgmt)/session/[session_id]/ae_comp__event_session_poc_profile.svelte index 42e4828d..28e1b27a 100644 --- a/src/routes/events/[event_id]/(pres_mgmt)/session/[session_id]/ae_comp__event_session_poc_profile.svelte +++ b/src/routes/events/[event_id]/(pres_mgmt)/session/[session_id]/ae_comp__event_session_poc_profile.svelte @@ -135,19 +135,13 @@ let clipboard_success = $state(false); disabled={ae_tmp.biography == lq__event_session_obj.biography} onclick={() => { - let event_session_data = { - poc_kv_json: lq__event_session_obj.poc_kv_json - }; + // poc_kv_json may be null if no POC data has been saved yet — initialize before writing. + const kv: key_val = { ...(lq__event_session_obj.poc_kv_json ?? {}) }; + if (!kv[poc_type]) kv[poc_type] = {}; + kv[poc_type]['biography'] = ae_tmp.biography; + kv[poc_type]['biography_updated_on'] = new Date().toISOString(); - if (!event_session_data.poc_kv_json[poc_type]) { - event_session_data.poc_kv_json[poc_type] = {}; - } - - event_session_data.poc_kv_json[poc_type]['biography'] = - ae_tmp.biography; - event_session_data.poc_kv_json[poc_type][ - 'biography_updated_on' - ] = new Date().toISOString(); + let event_session_data = { poc_kv_json: kv }; ae_promises.update__event_session_obj = events_func .update_ae_obj__event_session({ @@ -171,11 +165,10 @@ let clipboard_success = $state(false); Save Biography - {#if lq__event_session_obj.poc_kv_json[poc_type]?.biography_updated_on} + {#if lq__event_session_obj.poc_kv_json?.[poc_type]?.biography_updated_on} Last saved: {ae_util.iso_datetime_formatter( - lq__event_session_obj.poc_kv_json[poc_type] - ?.biography_updated_on, + lq__event_session_obj.poc_kv_json?.[poc_type]?.biography_updated_on, 'datetime_12_long' )}