'use client' import { useTranslation } from 'react-i18next' import { useRouter } from 'next/navigation' import { useCallback } from 'react' import s from './index.module.css' import cn from '@/utils/classnames' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' type IStepsNavBarProps = { step: number datasetId?: string } const STEP_T_MAP: Record = { 1: 'datasetCreation.steps.one', 2: 'datasetCreation.steps.two', 3: 'datasetCreation.steps.three', } const STEP_LIST = [1, 2, 3] const StepsNavBar = ({ step, datasetId, }: IStepsNavBarProps) => { const { t } = useTranslation() const router = useRouter() const media = useBreakpoints() const isMobile = media === MediaType.mobile const navBackHandle = useCallback(() => { if (!datasetId) router.replace('/datasets') else router.replace(`/datasets/${datasetId}/documents`) }, [router, datasetId]) return (
{!isMobile && (!datasetId ? t('datasetCreation.steps.header.creation') : t('datasetCreation.steps.header.update'))}
{STEP_LIST.map(item => (
item && s.done, isMobile && 'px-0')} >
{step > item ? '' : item}
{isMobile ? '' : t(STEP_T_MAP[item])}
))}
) } export default StepsNavBar