import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Dialog, DialogTitle, DialogActions, DialogContent, DialogContentText, Button, TextField, useTheme, Typography, } from '@mui/material'; import { useNavigate } from 'react-router-dom'; interface Props { open: boolean; onClose: () => void; } const GoToOrder = ({ open, onClose }: Props): React.JSX.Element => { const { t } = useTranslation(); const theme = useTheme(); const navigate = useNavigate(); const [orderUrl, setOrderUrl] = useState(); const [error, setError] = useState(false); const navigateToOrder = () => { if (orderUrl && orderUrl !== '') { const pattern = /^(https?:\/\/[^\s/]+\/order\/([^/]+)\/([^/]+))\/?$/; const match = orderUrl.match(pattern); if (match) { const coordinator = match[2]; const orderId = match[3]; navigate(`/order/${coordinator}/${orderId}`); } else { setError(true); } } else { setError(true); } }; return ( {t('Search order')} {t("Enter here an order URL to search for it, even if it's password protected")} setOrderUrl(e.target.value)} /> ); }; export default GoToOrder;