fix: integration bot deactive resolved and redis type error

This commit is contained in:
Akhil Mohan
2023-09-16 16:47:41 +05:30
parent d8d480f2bc
commit 750c1b46da
3 changed files with 23 additions and 21 deletions
@@ -51,17 +51,20 @@ export const IntegrationsPage = withProjectPermission(
const { data: cloudIntegrations, isLoading: isCloudIntegrationsLoading } =
useGetCloudIntegrations();
const { data: integrationAuths, isLoading: isIntegrationAuthLoading } =
useGetWorkspaceAuthorizations(
workspaceId,
useCallback((data: IntegrationAuth[]) => {
const groupBy: Record<string, IntegrationAuth> = {};
data.forEach((el) => {
groupBy[el.integration] = el;
});
return groupBy;
}, [])
);
const {
data: integrationAuths,
isLoading: isIntegrationAuthLoading,
isFetching: isIntegrationAuthFetching
} = useGetWorkspaceAuthorizations(
workspaceId,
useCallback((data: IntegrationAuth[]) => {
const groupBy: Record<string, IntegrationAuth> = {};
data.forEach((el) => {
groupBy[el.integration] = el;
});
return groupBy;
}, [])
);
// mutation
const {
data: integrations,
@@ -77,18 +80,18 @@ export const IntegrationsPage = withProjectPermission(
const { mutateAsync: deleteIntegration } = useDeleteIntegration();
const {
mutateAsync: deleteIntegrationAuth,
isLoading: isDeleteIntegrationAuthSuccess,
isSuccess: isDeleteIntegrationAuthSuccess,
reset: resetDeleteIntegrationAuth
} = useDeleteIntegrationAuth();
// summary: this use effect is trigger when all integration auths are removed thus deactivate bot
// details: so onsuccessfully deleting an integration auth, immediately integration list is refeteched
// After the refetch is completed check if its empty. Then set bot active and reset the submit hook
// details: so on successfully deleting an integration auth, immediately integration list is refeteched
// After the refetch is completed check if its empty. Then set bot active and reset the submit hook for isSuccess to go back to false
useEffect(() => {
if (
isDeleteIntegrationAuthSuccess &&
!isIntegrationFetching &&
!isIntegrationAuthLoading &&
!isIntegrationAuthFetching &&
!integrations?.length &&
!integrationAuths?.length
) {
@@ -103,7 +106,7 @@ export const IntegrationsPage = withProjectPermission(
}, [
isIntegrationFetching,
isDeleteIntegrationAuthSuccess,
isIntegrationAuthLoading,
isIntegrationAuthFetching,
integrationAuths?.length,
integrations?.length
]);