|
1 |
| -import { FC, useState } from 'react'; |
| 1 | +import { FC, useContext, useState } from 'react'; |
2 | 2 | import { useTranslation } from 'react-i18next';
|
3 | 3 | import { MdWarning } from 'react-icons/md';
|
4 | 4 | import { useGetStopDetails, useRequiredParams } from '../../../../hooks';
|
5 | 5 | import { Container, Visible } from '../../../../layoutComponents';
|
6 | 6 | import { mapToShortDate } from '../../../../time';
|
7 | 7 | import { LoadingWrapper } from '../../../../uiComponents/LoadingWrapper';
|
| 8 | +import { navigationBlockerContext } from '../../../forms/common/NavigationBlocker'; |
8 | 9 | import { BasicDetailsSection } from './basic-details/BasicDetailsSection';
|
9 | 10 | import {
|
10 | 11 | DetailTabSelector,
|
@@ -33,12 +34,17 @@ const testIds = {
|
33 | 34 | };
|
34 | 35 |
|
35 | 36 | export const StopDetailsPage: FC = () => {
|
36 |
| - const { stopDetails, loading, error } = useGetStopDetails(); |
37 | 37 | const { t } = useTranslation();
|
38 |
| - const [activeDetailTab, selectDetailTab] = useState( |
| 38 | + const { label } = useRequiredParams<{ label: string }>(); |
| 39 | + |
| 40 | + const [activeDetailTab, setActiveDetailTab] = useState( |
39 | 41 | DetailTabType.BasicDetailsTab,
|
40 | 42 | );
|
41 |
| - const { label } = useRequiredParams<{ label: string }>(); |
| 43 | + const { requestNavigation } = useContext(navigationBlockerContext); |
| 44 | + const selectDetailTab = (nextTab: DetailTabType) => |
| 45 | + requestNavigation(() => setActiveDetailTab(nextTab)); |
| 46 | + |
| 47 | + const { stopDetails, loading, error } = useGetStopDetails(); |
42 | 48 |
|
43 | 49 | return (
|
44 | 50 | <Container testId={testIds.page}>
|
|
0 commit comments