import React from 'react'; import { ProgressBar, Intent } from '@blueprintjs/core'; import * as R from 'ramda'; import { useJob, useCurrentOrganization } from 'hooks/query'; import { FormattedMessage as T } from 'components'; import withOrganizationActions from 'containers/Organization/withOrganizationActions'; import withCurrentOrganization from 'containers/Organization/withCurrentOrganization'; import withOrganization from '../Organization/withOrganization'; import 'style/pages/Setup/Initializing.scss'; /** * Setup initializing step form. */ function SetupInitializingForm({ setOrganizationSetupCompleted, organization, }) { const { refetch, isSuccess } = useCurrentOrganization({ enabled: false }); // Job done state. const [isJobDone, setIsJobDone] = React.useState(false); const { data: { running, queued, failed, completed }, isFetching: isJobFetching, } = useJob(organization?.build_job_id, { refetchInterval: 2000, enabled: !!organization?.build_job_id, }); React.useEffect(() => { if (completed) { refetch(); setIsJobDone(true); } }, [refetch, completed, setOrganizationSetupCompleted]); React.useEffect(() => { if (isSuccess && isJobDone) { setOrganizationSetupCompleted(true); setIsJobDone(false); } }, [setOrganizationSetupCompleted, isJobDone, isSuccess]); return (