diff --git a/ecc/blocks/event-creation-form/event-creation-form.js b/ecc/blocks/event-creation-form/event-creation-form.js index e8eff792..6d9b6765 100644 --- a/ecc/blocks/event-creation-form/event-creation-form.js +++ b/ecc/blocks/event-creation-form/event-creation-form.js @@ -440,26 +440,26 @@ async function save(props, toPublish = false) { let resp = props.response; - const onSave = async () => { + if (!resp.eventId) { + resp = await createEvent(quickFilter(props.payload)); + props.eventDataResp = { ...props.eventDataResp, ...resp }; + updateDashboardLink(props); if (resp?.eventId) await handleEventUpdate(props); if (!resp.error) { showSaveSuccessMessage(props); } - }; - - if (!resp.eventId) { - resp = await createEvent(quickFilter(props.payload)); - props.eventDataResp = { ...props.eventDataResp, ...resp }; - updateDashboardLink(props); - await onSave(); } else if (!toPublish) { resp = await updateEvent( getFilteredCachedResponse().eventId, getJoinedData(), ); props.eventDataResp = { ...props.eventDataResp, ...resp }; - await onSave(); + if (resp?.eventId) await handleEventUpdate(props); + + if (!resp.error) { + showSaveSuccessMessage(props); + } } else if (toPublish) { resp = await publishEvent( getFilteredCachedResponse().eventId, diff --git a/ecc/blocks/series-creation-form/series-creation-form.js b/ecc/blocks/series-creation-form/series-creation-form.js index 5a19a1cd..efa873d4 100644 --- a/ecc/blocks/series-creation-form/series-creation-form.js +++ b/ecc/blocks/series-creation-form/series-creation-form.js @@ -402,25 +402,31 @@ async function save(props, toPublish = false) { let resp = props.response; const onSave = async () => { - if (resp?.seriesId) await handleSeriesUpdate(props); - if (!resp.error) { - showSaveSuccessMessage(props); - } }; if (!resp.seriesId) { resp = await createSeries(quickFilter(props.payload)); props.response = { ...props.response, ...resp }; updateDashboardLink(props); - await onSave(); + + if (resp?.seriesId) await handleSeriesUpdate(props); + + if (!resp.error) { + showSaveSuccessMessage(props); + } } else if (!toPublish) { resp = await updateSeries( resp.seriesId, getJoinedData(), ); props.response = { ...props.response, ...resp }; - await onSave(); + + if (resp?.seriesId) await handleSeriesUpdate(props); + + if (!resp.error) { + showSaveSuccessMessage(props); + } } else if (toPublish) { resp = await publishSeries( resp.seriesId, diff --git a/ecc/scripts/esp-controller.js b/ecc/scripts/esp-controller.js index 7ce6c2ce..3a0df942 100644 --- a/ecc/scripts/esp-controller.js +++ b/ecc/scripts/esp-controller.js @@ -841,7 +841,7 @@ export async function getSeriesById(seriesId) { export async function createSeries(seriesData) { const { host } = API_CONFIG.esp[getEventServiceEnv()]; - const raw = JSON.stringify(seriesData); + const raw = JSON.stringify({ ...seriesData, seriesStatus: 'draft' }); const options = await constructRequestOptions('POST', raw); try {