Enhance order ID handling and navigation in ProfilePage and OrdersTab: Updated hash processing to validate order IDs, improved tab navigation, and added console logging for better debugging. Adjusted navigation to ensure correct hash updates when switching tabs and viewing orders.
This commit is contained in:
10
src/App.js
10
src/App.js
@@ -107,9 +107,13 @@ const AppContent = ({ currentTheme, onThemeChange }) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
if (location.hash && location.hash.startsWith("#ORD-")) {
|
||||
if (location.pathname !== "/profile") {
|
||||
navigate(`/profile${location.hash}`, { replace: true });
|
||||
if (location.hash && location.hash.length > 1) {
|
||||
// Check if it's a potential order ID (starts with # and has alphanumeric characters with dashes)
|
||||
const potentialOrderId = location.hash.substring(1);
|
||||
if (/^[A-Z0-9]+-[A-Z0-9]+$/i.test(potentialOrderId)) {
|
||||
if (location.pathname !== "/profile") {
|
||||
navigate(`/profile${location.hash}`, { replace: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [location, navigate]);
|
||||
|
||||
Reference in New Issue
Block a user