/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import React from "react";
import "./StepIndicator.css";
import { useTranslation } from "react-i18next";
interface Props {
current: number;
segments: Array<{
label: string;
}>;
showStepChart: boolean;
showStepText: boolean;
}
function StepIndicator(props: Props) {
const { t } = useTranslation();
if (props.current >= props.segments.length || props.current < 0) {
return null;
}
const stepChart = (
{props.segments.map((segment, index) => {
return (
);
})}
);
const stepText = (
{t("Step")}
{props.current + 1}
{t("Of")} {props.segments.length}
{props.current < props.segments.length && props.segments[props.current].label}
);
return (
{props.showStepChart ? stepChart : ""}
{props.showStepText ? stepText : ""}
);
}
interface SegmentProps {
current?: boolean;
complete?: boolean;
label: string;
}
function Segment(props: SegmentProps) {
const { t } = useTranslation();
if (props.current) {
return (
{props.label}
);
}
if (props.complete) {
return (
{props.label}
{" "}
{t("Completed")}
);
}
return (
{props.label}
{" "}
{t("NotCompleted")}
);
}
export default StepIndicator;