diff --git a/src/components/robot/pages/RobotConfigPage.tsx b/src/components/robot/pages/RobotConfigPage.tsx index 5923842a..902518eb 100644 --- a/src/components/robot/pages/RobotConfigPage.tsx +++ b/src/components/robot/pages/RobotConfigPage.tsx @@ -1,14 +1,15 @@ import React from 'react'; -import { - Box, - Typography, - Button, +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; @@ -23,6 +24,7 @@ interface RobotConfigPageProps { icon?: React.ReactNode; onBackToSelection?: () => void; backToSelectionText?: string; + onArrowBack?: () => void; // Optional prop for custom back action } export const RobotConfigPage: React.FC = ({ @@ -30,50 +32,72 @@ export const RobotConfigPage: React.FC = ({ children, onSave, onCancel, - saveButtonText = "Save", - cancelButtonText = "Cancel", + saveButtonText, + cancelButtonText, showSaveButton = true, showCancelButton = true, isLoading = false, icon, onBackToSelection, - backToSelectionText = "← Back" + 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 ( - - @@ -82,9 +106,9 @@ export const RobotConfigPage: React.FC = ({ {icon} )} - = ({ - {children} + {/* Action Buttons */} {(showSaveButton || showCancelButton || onBackToSelection) && ( + {/* Left side - Back to Selection button */} {onBackToSelection && ( )} + {/* Right side - Save/Cancel buttons */} - {showCancelButton && ( - - )} - {showSaveButton && onSave && ( - + )} + {showSaveButton && onSave && ( + - )} + }} + > + {isLoading ? t("buttons.saving") : (saveButtonText || t("buttons.save"))} + + )} )}