From a3bbb2963ea268e0347f5fa143ef0dae606e2d6d Mon Sep 17 00:00:00 2001 From: Akansha Sakhre Date: Fri, 6 Sep 2024 08:50:53 +0530 Subject: [PATCH] added loading for upload contacts dialog --- .../UploadContactsDialog.tsx | 59 ++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/containers/ContactManagement/UploadContactsDialog/UploadContactsDialog.tsx b/src/containers/ContactManagement/UploadContactsDialog/UploadContactsDialog.tsx index 6f7ba48f0..751bb75f3 100644 --- a/src/containers/ContactManagement/UploadContactsDialog/UploadContactsDialog.tsx +++ b/src/containers/ContactManagement/UploadContactsDialog/UploadContactsDialog.tsx @@ -45,6 +45,11 @@ export const UploadContactsDialog = ({ setDialog, setShowStatus }: UploadContact }, }); + let groupOptions = []; + if (collections && collections.groups) { + groupOptions = collections.groups; + } + const [importContacts] = useMutation(IMPORT_CONTACTS, { onCompleted: (data: any) => { const { errors } = data.importContacts; @@ -73,10 +78,6 @@ export const UploadContactsDialog = ({ setDialog, setShowStatus }: UploadContact }); }; - if (loading || !collections) { - return ; - } - const validationSchema = Yup.object().shape({ collection: Yup.object().nullable().required(t('Collection is required')), optedIn: Yup.boolean() @@ -89,7 +90,7 @@ export const UploadContactsDialog = ({ setDialog, setShowStatus }: UploadContact component: AutoComplete, name: 'collection', placeholder: t('Select collection'), - options: collections.groups, + options: groupOptions, multiple: false, optionLabel: 'label', label: t('Collection'), @@ -105,7 +106,7 @@ export const UploadContactsDialog = ({ setDialog, setShowStatus }: UploadContact }, ]; - const form = ( + return ( -
- {formFieldItems.map((field: any) => ( - - ))} -
+ {loading ? ( + + ) : ( + <> +
+ {formFieldItems.map((field: any) => ( + + ))} +
-
- { - setFileName(media.name); - setCsvContent(result); - }} - fileType=".csv" - /> -
-
- Download Sample -
+
+ { + setFileName(media.name); + setCsvContent(result); + }} + fileType=".csv" + /> +
+
+ Download Sample +
+ + )} )}
); - - return <>{form}; }; export default UploadContactsDialog;