From 271b3227614e91a4edd9ff893f7836ba7aab23e3 Mon Sep 17 00:00:00 2001 From: iamsivin Date: Sat, 9 Nov 2024 14:06:33 +0530 Subject: [PATCH] feat: Contact exporting --- .../ContactHeader/ContactExportDialog.vue | 76 +++++++++++++++++++ .../ContactHeader/ContactImportDialog.vue | 9 ++- .../ContactHeader/ContactMoreActions.vue | 5 ++ .../dashboard/i18n/locale/en/contact.json | 7 ++ .../store/modules/contacts/actions.js | 11 +-- .../dashboard/store/modules/contacts/index.js | 2 + 6 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 app/javascript/dashboard/components-next/Contacts/ContactHeader/ContactExportDialog.vue diff --git a/app/javascript/dashboard/components-next/Contacts/ContactHeader/ContactExportDialog.vue b/app/javascript/dashboard/components-next/Contacts/ContactHeader/ContactExportDialog.vue new file mode 100644 index 000000000..692c12001 --- /dev/null +++ b/app/javascript/dashboard/components-next/Contacts/ContactHeader/ContactExportDialog.vue @@ -0,0 +1,76 @@ + + + diff --git a/app/javascript/dashboard/components-next/Contacts/ContactHeader/ContactImportDialog.vue b/app/javascript/dashboard/components-next/Contacts/ContactHeader/ContactImportDialog.vue index c412b3139..ef76c9267 100644 --- a/app/javascript/dashboard/components-next/Contacts/ContactHeader/ContactImportDialog.vue +++ b/app/javascript/dashboard/components-next/Contacts/ContactHeader/ContactImportDialog.vue @@ -1,6 +1,6 @@ @@ -62,4 +66,5 @@ const handleContactAction = ({ action }) => { + diff --git a/app/javascript/dashboard/i18n/locale/en/contact.json b/app/javascript/dashboard/i18n/locale/en/contact.json index 77a40c54f..35689afdb 100644 --- a/app/javascript/dashboard/i18n/locale/en/contact.json +++ b/app/javascript/dashboard/i18n/locale/en/contact.json @@ -414,6 +414,13 @@ "SUCCESS_MESSAGE": "You will be notified via email when the import is complete.", "ERROR_MESSAGE": "There was an error, please try again" }, + "EXPORT_CONTACT": { + "TITLE": "Export contacts", + "DESCRIPTION": "Quickly export a csv file with comprehensive details of your contacts", + "CONFIRM": "Export", + "SUCCESS_MESSAGE": "Export is in progress. You will be notified on email when the export file is ready to download.", + "ERROR_MESSAGE": "There was an error, please try again" + }, "SORT_BY": { "LABEL": "Sort by", "OPTIONS": { diff --git a/app/javascript/dashboard/store/modules/contacts/actions.js b/app/javascript/dashboard/store/modules/contacts/actions.js index deb1c96d1..0169f2f2b 100644 --- a/app/javascript/dashboard/store/modules/contacts/actions.js +++ b/app/javascript/dashboard/store/modules/contacts/actions.js @@ -126,12 +126,12 @@ export const actions = { }, import: async ({ commit }, file) => { - commit(types.SET_CONTACT_UI_FLAG, { isCreating: true }); + commit(types.SET_CONTACT_UI_FLAG, { isImporting: true }); try { await ContactAPI.importContacts(file); - commit(types.SET_CONTACT_UI_FLAG, { isCreating: false }); + commit(types.SET_CONTACT_UI_FLAG, { isImporting: false }); } catch (error) { - commit(types.SET_CONTACT_UI_FLAG, { isCreating: false }); + commit(types.SET_CONTACT_UI_FLAG, { isImporting: false }); if (error.response?.data?.message) { throw new ExceptionWithMessage(error.response.data.message); } @@ -139,12 +139,13 @@ export const actions = { }, export: async ({ commit }, { payload, label }) => { + commit(types.SET_CONTACT_UI_FLAG, { isExporting: true }); try { await ContactAPI.exportContacts({ payload, label }); - commit(types.SET_CONTACT_UI_FLAG, { isCreating: false }); + commit(types.SET_CONTACT_UI_FLAG, { isExporting: false }); } catch (error) { - commit(types.SET_CONTACT_UI_FLAG, { isCreating: false }); + commit(types.SET_CONTACT_UI_FLAG, { isExporting: false }); if (error.response?.data?.message) { throw new Error(error.response.data.message); } else { diff --git a/app/javascript/dashboard/store/modules/contacts/index.js b/app/javascript/dashboard/store/modules/contacts/index.js index ba8d47642..eb1e92434 100644 --- a/app/javascript/dashboard/store/modules/contacts/index.js +++ b/app/javascript/dashboard/store/modules/contacts/index.js @@ -15,6 +15,8 @@ const state = { isUpdating: false, isMerging: false, isDeleting: false, + isExporting: false, + isImporting: false, }, sortOrder: [], appliedFilters: [],