diff --git a/src/components/Settings/integrations/Organization/OrganizationAccordion.tsx b/src/components/Settings/integrations/Organization/OrganizationAccordion.tsx index d0547799b..bd5bff654 100644 --- a/src/components/Settings/integrations/Organization/OrganizationAccordion.tsx +++ b/src/components/Settings/integrations/Organization/OrganizationAccordion.tsx @@ -87,15 +87,6 @@ export const OrganizationAccordion: React.FC = ({ handleAccordionChange, expandedPanel, }) => { - const [selectedOrganization, setSelectedOrganization] = - useState(null); - const [showAddAccountModal, setShowAddAccountModal] = useState(false); - const [showImportDataSyncModal, setShowImportDataSyncModal] = useState(false); - const [showDeleteOrganizationModal, setShowDeleteOrganizationModal] = - useState(false); - const [showEditOrganizationModal, setShowEditOrganizationModal] = - useState(false); - const { t } = useTranslation(); const accountListId = useAccountListId(); const { enqueueSnackbar } = useSnackbar(); @@ -104,6 +95,14 @@ export const OrganizationAccordion: React.FC = ({ const [syncOrganizationAccount] = useSyncOrganizationAccountMutation(); const { getOrganizationOauthUrl: getOauthUrl } = useOauthUrl(); + const [showAddAccountModal, setShowAddAccountModal] = useState(false); + const [importDataSyncModal, setImportDataSyncModal] = + useState(null); + const [deleteOrganizationModal, setDeleteOrganizationModal] = + useState(null); + const [editOrganizationModal, setEditOrganizationModal] = + useState(null); + const { data, loading, @@ -178,27 +177,6 @@ export const OrganizationAccordion: React.FC = ({ }); }; - const handleOpenEditOrganizationModal = ( - organizationAccount: OrganizationAccountPartial, - ) => { - setShowEditOrganizationModal(true); - setSelectedOrganization(organizationAccount); - }; - - const handleOpenDeleteOrganizationModal = ( - organizationAccount: OrganizationAccountPartial, - ) => { - setShowDeleteOrganizationModal(true); - setSelectedOrganization(organizationAccount); - }; - - const handleOpenImportDataSyncModal = ( - organizationAccount: OrganizationAccountPartial, - ) => { - setShowImportDataSyncModal(true); - setSelectedOrganization(organizationAccount); - }; - return ( = ({ size="small" sx={{ m: '0 0 0 10px' }} onClick={() => - handleOpenImportDataSyncModal(organizationAccount) + setImportDataSyncModal(organizationAccount) } > {t('Import TntConnect DataSync file')} @@ -304,7 +282,7 @@ export const OrganizationAccordion: React.FC = ({ {type === OrganizationTypesEnum.LOGIN && ( - handleOpenEditOrganizationModal(organizationAccount) + setEditOrganizationModal(organizationAccount) } > @@ -312,7 +290,7 @@ export const OrganizationAccordion: React.FC = ({ )} - handleOpenDeleteOrganizationModal(organizationAccount) + setDeleteOrganizationModal(organizationAccount) } > @@ -365,31 +343,31 @@ export const OrganizationAccordion: React.FC = ({ /> )} - {showImportDataSyncModal && selectedOrganization && ( + {importDataSyncModal && ( setShowImportDataSyncModal(false)} - organizationId={selectedOrganization.id} - organizationName={selectedOrganization.organization.name} + handleClose={() => setImportDataSyncModal(null)} + organizationId={importDataSyncModal.id} + organizationName={importDataSyncModal.organization.name} accountListId={accountListId ?? ''} /> )} - {showEditOrganizationModal && selectedOrganization && ( + {editOrganizationModal && ( setShowEditOrganizationModal(false)} - organizationId={selectedOrganization.id} + handleClose={() => setEditOrganizationModal(null)} + organizationId={editOrganizationModal.id} /> )} - {showDeleteOrganizationModal && selectedOrganization && ( + {deleteOrganizationModal && ( setShowDeleteOrganizationModal(false)} - mutation={() => handleDelete(selectedOrganization.id)} + handleClose={() => setDeleteOrganizationModal(null)} + mutation={() => handleDelete(deleteOrganizationModal.id)} /> )}