All files / src/components/Playbooks/card InfoRender.tsx

0% Statements 0/14
0% Branches 0/4
0% Functions 0/1
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                                                               
import React from "react";
import { StepInformationType } from "../../../utils/playbook/stepInformation/handleStepInformation.ts";
import { InfoTypes } from "../../../utils/playbook/stepInformation/InfoTypes.ts";
import Text from "./info/Text.tsx";
import Chips from "./info/Chips.tsx";
import getNestedValue from "../../../utils/common/getNestedValue.ts";
import MarkdownOutput from "./MarkdownOutput.tsx";
import useCurrentTask from "../../../hooks/playbooks/task/useCurrentTask.ts";
 
type InfoRenderPropTypes = {
  taskId: string;
  info: StepInformationType;
};
 
function InfoRender({ taskId, info }: InfoRenderPropTypes) {
  const [, , , taskData] = useCurrentTask(taskId);
  const value = getNestedValue(taskData, info.key);
 
  switch (info.type) {
    case InfoTypes.TEXT:
      return <Text value={value} />;
    case InfoTypes.CHIPS:
      return <Chips value={value} />;
    case InfoTypes.MARKDOWN:
      return <MarkdownOutput className="!p-0" content={value} />;
    default:
      return <></>;
  }
}
 
export default InfoRender;