diff --git a/web/src/features/fba/components/ActualForecastControl.tsx b/web/src/features/fba/components/ActualForecastControl.tsx new file mode 100644 index 000000000..ce86cf78e --- /dev/null +++ b/web/src/features/fba/components/ActualForecastControl.tsx @@ -0,0 +1,61 @@ +import { FormControl, FormControlLabel, FormLabel, Radio, RadioGroup } from '@mui/material' +import React from 'react' +import { RunType } from 'features/fba/pages/FireBehaviourAdvisoryPage' +import { isNull } from 'lodash' +import { theme } from 'app/theme' + +export interface ActualForecastControlProps { + runType: RunType + setRunType: React.Dispatch> +} +const ActualForecastControl = ({ runType, setRunType }: ActualForecastControlProps) => { + const changeHandler = (_: React.ChangeEvent<{}>, value: any | null) => { + if (!isNull(value)) { + setRunType(value) + } + } + return ( + + + Time Frame + + + } /> + } + label="Actual" + /> + } /> + } + label="Forecast" + /> + + + ) +} + +export default React.memo(ActualForecastControl) diff --git a/web/src/features/fba/components/AdvisoryMetadata.tsx b/web/src/features/fba/components/AdvisoryMetadata.tsx deleted file mode 100644 index c3f2178bd..000000000 --- a/web/src/features/fba/components/AdvisoryMetadata.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { Autocomplete, TextField } from '@mui/material' -import React from 'react' -import { RunType } from 'features/fba/pages/FireBehaviourAdvisoryPage' -import { isNull } from 'lodash' - -export interface AdvisoryMetadataProps { - testId?: string - runType: string - setRunType: React.Dispatch> -} -const AdvisoryMetadata = ({ runType, setRunType }: AdvisoryMetadataProps) => { - const changeHandler = (_: React.ChangeEvent<{}>, value: any | null) => { - if (!isNull(value)) { - setRunType(value) - } - } - return ( - } - /> - ) -} - -export default React.memo(AdvisoryMetadata) diff --git a/web/src/features/fba/components/actualForecastControl.test.tsx b/web/src/features/fba/components/actualForecastControl.test.tsx new file mode 100644 index 000000000..bb8c69947 --- /dev/null +++ b/web/src/features/fba/components/actualForecastControl.test.tsx @@ -0,0 +1,22 @@ +import React from 'react' +import { render, fireEvent } from '@testing-library/react' +import ActualForecastControl from './ActualForecastControl' +import { RunType } from 'features/fba/pages/FireBehaviourAdvisoryPage' + +describe('ActualForecastControl', () => { + const mockSetRunType = jest.fn() + + it('should render the radio button selector with the correct default', () => { + const { getByTestId } = render() + const forecastButton = getByTestId('forecast-radio') + expect(forecastButton).toBeChecked() + }) + + it('should call setRunType with the correct value when a radio button is selected', () => { + const { getByTestId } = render() + fireEvent.click(getByTestId('actual-radio')) + expect(mockSetRunType).toHaveBeenCalledWith(RunType.ACTUAL) + fireEvent.click(getByTestId('forecast-radio')) + expect(mockSetRunType).toHaveBeenCalledWith(RunType.FORECAST) + }) +}) diff --git a/web/src/features/fba/pages/FireBehaviourAdvisoryPage.tsx b/web/src/features/fba/pages/FireBehaviourAdvisoryPage.tsx index 0aae6a79c..306ade7ca 100644 --- a/web/src/features/fba/pages/FireBehaviourAdvisoryPage.tsx +++ b/web/src/features/fba/pages/FireBehaviourAdvisoryPage.tsx @@ -21,7 +21,7 @@ import { ASA_DOC_TITLE, FIRE_BEHAVIOUR_ADVISORY_NAME, PST_UTC_OFFSET } from 'uti import WPSDatePicker from 'components/WPSDatePicker' import { AppDispatch } from 'app/store' import AdvisoryThresholdSlider from 'features/fba/components/map/AdvisoryThresholdSlider' -import AdvisoryMetadata from 'features/fba/components/AdvisoryMetadata' +import ActualForecastControl from 'features/fba/components/ActualForecastControl' import { fetchSFMSRunDates } from 'features/fba/slices/runDatesSlice' import { isNull, isUndefined } from 'lodash' import { fetchHighHFIFuels } from 'features/fba/slices/hfiFuelTypesSlice' @@ -45,11 +45,6 @@ export const FireCentreFormControl = styled(FormControl)({ minWidth: 280 }) -export const ForecastActualDropdownFormControl = styled(FormControl)({ - margin: theme.spacing(1), - minWidth: 280 -}) - const FireBehaviourAdvisoryPage: React.FunctionComponent = () => { const dispatch: AppDispatch = useDispatch() const { fireCenters } = useSelector(selectFireCenters) @@ -191,6 +186,11 @@ const FireBehaviourAdvisoryPage: React.FunctionComponent = () => { + + + + + { /> - - - - - - -