diff --git a/frontend/src/routes/company/+page.svelte b/frontend/src/routes/company/+page.svelte index 894aae6..3ce6e22 100644 --- a/frontend/src/routes/company/+page.svelte +++ b/frontend/src/routes/company/+page.svelte @@ -20,6 +20,7 @@ import TableDropDownEllipsis from '$lib/components/table/TableDropDownEllipsis.svelte'; import DeleteAlert from '$lib/components/modal/DeleteAlert.svelte'; import TableDropDownButton from '$lib/components/table/TableDropDownButton.svelte'; + import Alert from '$lib/components/Alert.svelte'; // bindings let form = null; @@ -46,6 +47,10 @@ let isViewCommentModalVisible = false; let viewCommentCompany = null; + let isExportCompanyModalVisible = false; + let isExportSharedModalVisible = false; + let exportCompany = null; + $: { modalText = modalMode === 'create' ? 'New company' : 'Update company'; } @@ -236,13 +241,49 @@ viewCommentCompany = null; }; - const onClickExport = async (id) => { + const openExportCompanyModal = (company) => { + exportCompany = company; + isExportCompanyModalVisible = true; + }; + + const closeExportCompanyModal = () => { + isExportCompanyModalVisible = false; + exportCompany = null; + }; + + const openExportSharedModal = () => { + isExportSharedModalVisible = true; + }; + + const closeExportSharedModal = () => { + isExportSharedModalVisible = false; + }; + + const onConfirmExportCompany = async () => { try { showIsLoading(); - api.company.export(id); + api.company.export(exportCompany.id); + closeExportCompanyModal(); + return { success: true }; } catch (e) { addToast('Failed to export company events', 'Error'); console.error('failed to export company events', e); + return { success: false, error: e }; + } finally { + hideIsLoading(); + } + }; + + const onConfirmExportShared = async () => { + try { + showIsLoading(); + api.company.export(); + closeExportSharedModal(); + return { success: true }; + } catch (e) { + addToast('Failed to export shared events', 'Error'); + console.error('failed to export shared events', e); + return { success: false, error: e }; } finally { hideIsLoading(); } @@ -253,7 +294,7 @@
Companies New company - onClickExport()}>Export shared + Export shared openViewCommentModal(company)} /> - onClickExport(company.id)} /> + openExportCompanyModal(company)} /> openDeleteAlert(company)} /> @@ -387,4 +428,37 @@ onClick={() => onClickDelete(deleteValues.id)} bind:isVisible={isDeleteAlertVisible} > + + +
+ {#if exportCompany} +

Are you sure you want to export all data for:

+
+

{exportCompany.name}

+
+

+ This will download a ZIP file containing all company data, recipients, and campaign + events. +

+ {/if} +
+
+ + +
+

Are you sure you want to export all shared data?

+

+ This will download a ZIP file containing all recipients and campaign events that are not + assigned to any specific company. +

+
+