import * as React from 'react'; import { useQuery } from '@apollo/client'; import Stack from '@mui/material/Stack'; import ErrorIcon from '@mui/icons-material/Error'; import CheckCircleIcon from '@mui/icons-material/CheckCircle'; import Tabs from '@mui/material/Tabs'; import Tab from '@mui/material/Tab'; import Typography from '@mui/material/Typography'; import Box from '@mui/material/Box'; import type { IApp, IExecutionStep, IStep } from '@automatisch/types'; import TabPanel from 'components/TabPanel'; import SearchableJSONViewer from 'components/SearchableJSONViewer'; import AppIcon from 'components/AppIcon'; import { GET_APPS } from 'graphql/queries/get-apps'; import useFormatMessage from 'hooks/useFormatMessage'; import { AppIconWrapper, AppIconStatusIconWrapper, Content, Header, Wrapper, } from './style'; type ExecutionStepProps = { collapsed?: boolean; step: IStep; index?: number; executionStep: IExecutionStep; }; const validIcon = ; const errorIcon = ; export default function ExecutionStep( props: ExecutionStepProps ): React.ReactElement | null { const { executionStep } = props; const [activeTabIndex, setActiveTabIndex] = React.useState(0); const step: IStep = executionStep.step; const isTrigger = step.type === 'trigger'; const isAction = step.type === 'action'; const formatMessage = useFormatMessage(); const { data } = useQuery(GET_APPS, { variables: { onlyWithTriggers: isTrigger, onlyWithActions: isAction }, }); const apps: IApp[] = data?.getApps; const app = apps?.find((currentApp: IApp) => currentApp.key === step.appKey); if (!apps) return null; const validationStatusIcon = executionStep.status === 'success' ? validIcon : errorIcon; const hasError = !!executionStep.errorDetails; return ( {validationStatusIcon} {isTrigger ? formatMessage('flowStep.triggerType') : formatMessage('flowStep.actionType')} {step.position}. {app?.name} setActiveTabIndex(tabIndex)} > {hasError && } {hasError && ( )} ); }