All files / src/components TemplateModificationStepRenderer.tsx

92.3% Statements 12/13
75% Branches 3/4
100% Functions 2/2
91.66% Lines 11/12

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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49        4x 4x 4x   4x                           4x 33x 33x   29x     2x                     2x           33x    
/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
import React from "react";
import { TemplateModificationStepOne } from "./TemplateModificationStepOne";
import { TemplateModificationStepThree } from "./TemplateModificationStepThree";
import type { Configuration } from "./EC3/Template";
import { TemplateModificationStepTwo } from "./TemplateModificationStepTwo";
import type { Report } from "@itwin/insights-client";
 
export interface TemplateModificationStepRendererProps {
  currentStep: number;
  updateCurrentStep: (currentStep: number) => void;
  childTemplate: Configuration;
  updateChildTemplate: (childTemplate: Configuration) => void;
  onCancelClick: () => void;
  onSaveClick: () => Promise<void>;
  fetchedReports: Report[];
  isLoading: boolean;
}
 
export const TemplateModificationStepRenderer = (props: TemplateModificationStepRendererProps) => {
  const renderSteps = () => {
    switch (props.currentStep) {
      case 0: {
        return <TemplateModificationStepOne {...props} />;
      }
      case 1: {
        return (
          <TemplateModificationStepTwo
            template={props.childTemplate}
            updateCurrentStep={props.updateCurrentStep}
            onCancelClick={props.onCancelClick}
            setTemplate={props.updateChildTemplate}
            fetchedReports={props.fetchedReports}
          />
        );
      }
      case 2: {
        return <TemplateModificationStepThree {...props} />;
      }
      default:
        return null;
    }
  };
  return renderSteps();
};