import React from 'react'; import { Box, Typography, Button, IconButton, Divider, useTheme } from '@mui/material'; import { ArrowBack } from '@mui/icons-material'; import { useNavigate, useLocation } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; interface RobotConfigPageProps { title: string; children: React.ReactNode; onSave?: () => void; onCancel?: () => void; saveButtonText?: string; cancelButtonText?: string; showSaveButton?: boolean; showCancelButton?: boolean; isLoading?: boolean; icon?: React.ReactNode; onBackToSelection?: () => void; backToSelectionText?: string; onArrowBack?: () => void; // Optional prop for custom back action } export const RobotConfigPage: React.FC = ({ title, children, onSave, onCancel, saveButtonText, cancelButtonText, showSaveButton = true, showCancelButton = true, isLoading = false, icon, onBackToSelection, backToSelectionText, onArrowBack, }) => { const navigate = useNavigate(); const location = useLocation(); const theme = useTheme(); const { t } = useTranslation(); const handleBack = () => { if (onCancel) { onCancel(); } else { // Try to determine the correct path based on current URL const currentPath = location.pathname; const basePath = currentPath.includes('/prebuilt-robots') ? '/prebuilt-robots' : '/robots'; navigate(basePath); } }; return ( {/* Header Section - Fixed Position */} {icon && ( {icon} )} {title} {/* Content Section */} {children} {/* Action Buttons */} {(showSaveButton || showCancelButton || onBackToSelection) && ( {/* Left side - Back to Selection button */} {onBackToSelection && ( )} {/* Right side - Save/Cancel buttons */} {showCancelButton && ( )} {showSaveButton && onSave && ( )} )} ); };