import { Badge, Container, Copy, Heading, StatusBadge, Text, clx, } from "@medusajs/ui" import { useTranslation } from "react-i18next" import { getTransactionState, getTransactionStateColor } from "../../../utils" import { HttpTypes } from "@medusajs/types" import { TransactionState, TransactionStepState } from "../../../types" type WorkflowExecutionGeneralSectionProps = { execution: HttpTypes.AdminWorkflowExecution } export const WorkflowExecutionGeneralSection = ({ execution, }: WorkflowExecutionGeneralSectionProps) => { const { t } = useTranslation() const cleanId = execution.id.replace("wf_exec_", "") const translatedState = getTransactionState( t, execution.state as TransactionState ) const stateColor = getTransactionStateColor( execution.state as TransactionState ) return (
{cleanId}
{translatedState}
{t("workflowExecutions.workflowIdLabel")} {execution.workflow_id}
{t("workflowExecutions.transactionIdLabel")} {execution.transaction_id}
{t("workflowExecutions.progressLabel")}
) } const ROOT_PREFIX = "_root" const Progress = ({ steps, }: { steps?: Record | null }) => { const { t } = useTranslation() if (!steps) { return ( {t("workflowExecutions.stepsCompletedLabel", { completed: 0, total: 0, })} ) } const actionableSteps = Object.values(steps).filter( (step) => step.id !== ROOT_PREFIX ) const completedSteps = actionableSteps.filter( (step) => step.invoke.state === TransactionStepState.DONE ) return (
{actionableSteps.map((step) => (
))}
{t("workflowExecutions.stepsCompletedLabel", { completed: completedSteps.length, count: actionableSteps.length, })}
) }