Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AA storm display panel #1387

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ const props = {
const mockStore = configureStore([]);

const store = mockStore({
anticipatoryActionState: {
anticipatoryActionDroughtState: {
availableDates: undefined,
},
anticipatoryActionStormState: {
availableDates: undefined,
},
mapState: {
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/MapView/DateSelector/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ test('renders as expected', () => {
panelSize: PanelSize.medium,
},
serverState: { availableDates: {}, loading: false },
anticipatoryActionState: {
anticipatoryActionDroughtState: {
availableDates: undefined,
},
anticipatoryActionStormState: {
availableDates: undefined,
},
});
Expand Down
14 changes: 6 additions & 8 deletions frontend/src/components/MapView/DateSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import { format } from 'date-fns';
import { leftPanelTabValueSelector } from 'context/leftPanelStateSlice';
import { updateDateRange } from 'context/mapStateSlice';
import { getRequestDate } from 'utils/server-utils';
import { AAAvailableDatesSelector } from 'context/anticipatoryActionStateSlice';
import { isAnticipatoryActionLayer } from 'config/utils';
import { AAAvailableDatesSelector } from 'context/anticipatoryAction/AADroughtStateSlice';
import TickSvg from './tick.svg';
import DateSelectorInput from './DateSelectorInput';
import TimelineItems from './TimelineItems';
Expand All @@ -57,10 +56,10 @@ const POINTER_ID = 'datePointerSelector';
const calculateStartAndEndDates = (startDate: Date, selectedTab: string) => {
const year =
startDate.getFullYear() -
(isAnticipatoryActionLayer(selectedTab) && startDate.getMonth() < 3
(selectedTab === Panel.AnticipatoryActionDrought && startDate.getMonth() < 3
? 1
: 0);
const startMonth = isAnticipatoryActionLayer(selectedTab) ? 3 : 0; // April for anticipatory_action, January otherwise
const startMonth = selectedTab === Panel.AnticipatoryActionDrought ? 3 : 0; // April for anticipatory_action, January otherwise
const start = new Date(year, startMonth, 1);
const end = new Date(year, startMonth + 11, 31);

Expand Down Expand Up @@ -153,8 +152,8 @@ const DateSelector = memo(() => {
// eslint-disable-next-line fp/no-mutating-methods
selectedLayers
.sort((a, b) => {
const aIsAnticipatory = a.id.includes('anticipatory_action');
const bIsAnticipatory = b.id.includes('anticipatory_action');
const aIsAnticipatory = a.id.includes('anticipatory_action_drought');
const bIsAnticipatory = b.id.includes('anticipatory_action_drought');
if (aIsAnticipatory && !bIsAnticipatory) {
return -1;
}
Expand All @@ -163,8 +162,7 @@ const DateSelector = memo(() => {
}
return 0;
})
.filter(l => l.type !== AnticipatoryAction.storm) // disable showing anticipatory action storm data
.map(l => (isAnticipatoryActionLayer(l.type) ? AALayers : l))
.map(l => (l.id === 'anticipatory_action_drought' ? AALayers : l))
.flat(),
[selectedLayers, AALayers],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import {
setAAMarkers,
setAASelectedDistrict,
setAAView,
} from 'context/anticipatoryActionStateSlice';
import { getAAColor } from 'components/MapView/LeftPanel/AnticipatoryActionPanel/utils';
} from 'context/anticipatoryAction/AADroughtStateSlice';
import { getAAColor } from 'components/MapView/LeftPanel/AnticipatoryActionPanel/AnticipatoryActionDroughtPanel/utils';
import {
calculateCentroids,
useAAMarkerScalePercent,
Expand All @@ -37,8 +37,8 @@ import { getBoundaryLayersByAdminLevel } from 'config/utils';
import {
calculateAAMarkers,
calculateCombinedAAMapData,
} from 'context/anticipatoryActionStateSlice/utils';
import { AAView } from 'context/anticipatoryActionStateSlice/types';
} from 'context/anticipatoryAction/AADroughtStateSlice/utils';
import { AAView } from 'context/anticipatoryAction/AADroughtStateSlice/types';
import { Tooltip } from '@material-ui/core';

// Use admin level 2 boundary layer for Anticipatory Action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`AAStormLandfallPopup component renders as expected 1`] = `
classname="makeStyles-text-4 makeStyles-title-5"
variant="body1"
>
Report date:
Forecast date:
2024-03-01 6pm
</mock-typography>
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { render } from '@testing-library/react';
import { AACategory } from 'context/anticipatoryAction/AAStormStateSlice/types';
import PopupContent from '.';

describe('AAStormLandfallPopup component', () => {
it('renders as expected', () => {
const reportDate = '2024-03-01 18:00:00';
const landfallInfo = {
landfall_time: ['2024-03-12 01:00:00', '2024-03-12 06:00:00'],
landfall_impact_district: 'Inhassoro',
landfall_impact_intensity: [
'severe tropical storm',
'moderate tropical storm',
],
time: ['2024-03-12 01:00:00', '2024-03-12 06:00:00'],
district: 'Inhassoro',
severity: [AACategory.Severe, AACategory.Moderate],
};
const timelineDate = '2024-03-12 00:00:00';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createStyles, makeStyles, Typography } from '@material-ui/core';
import { LandfallInfo } from 'context/anticipatoryAction/AAStormStateSlice/types';
import {
formatLandfallDate,
formatLandfallEstimatedLeadtime,
Expand All @@ -19,7 +20,7 @@ function PopupContent({
variant="body1"
className={`${classes.text} ${classes.title}`}
>
Report date: {formatReportDate(reportDate)}
Forecast date: {formatReportDate(reportDate)}
</Typography>
<div className={classes.itemContainer}>
<Typography variant="body1" className={classes.text}>
Expand All @@ -29,9 +30,9 @@ function PopupContent({
variant="body1"
className={`${classes.text} ${classes.textAlignRight}`}
>
{formatLandfallDate(landfallInfo.landfall_time)}
{formatLandfallDate(landfallInfo.time)}
<span className={classes.block}>
{formatLandfallTimeRange(landfallInfo.landfall_time)}
{formatLandfallTimeRange(landfallInfo.time)}
</span>
</Typography>
</div>
Expand All @@ -44,10 +45,7 @@ function PopupContent({
variant="body1"
className={`${classes.text} ${classes.textAlignRight}`}
>
{formatLandfallEstimatedLeadtime(
landfallInfo.landfall_time,
timelineDate,
)}
{formatLandfallEstimatedLeadtime(landfallInfo.time, timelineDate)}
</Typography>
</div>
<div className={classes.itemContainer}>
Expand All @@ -59,7 +57,7 @@ function PopupContent({
variant="body1"
className={`${classes.text} ${classes.textAlignRight}`}
>
{landfallInfo.landfall_impact_district}
{landfallInfo.district}
</Typography>
</div>
</div>
Expand Down Expand Up @@ -97,12 +95,6 @@ const useStyles = makeStyles(() =>
}),
);

export interface LandfallInfo {
landfall_time: string[];
landfall_impact_district: string;
landfall_impact_intensity: string[];
}

interface PopupContentProps {
landfallInfo: LandfallInfo;
reportDate: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createStyles, makeStyles } from '@material-ui/core';
import { Point } from 'geojson';
import { Popup } from 'react-map-gl/maplibre';
import PopupContent, { LandfallInfo } from './PopupContent';
import { LandfallInfo } from 'context/anticipatoryAction/AAStormStateSlice/types';
import PopupContent from './PopupContent';

function AAStormLandfallPopup({
point,
Expand Down
Loading
Loading