Skip to content

Commit

Permalink
adjust initial state (apache#16329)
Browse files Browse the repository at this point in the history
  • Loading branch information
eschutho authored and Emmanuel Bavoux committed Nov 14, 2021
1 parent b210142 commit 2a8a9bf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions superset-frontend/src/components/ReportModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,23 @@ const reportReducer = (
action: ReportActionType,
): Partial<ReportObject> | null => {
const initialState = {
name: state?.name || 'Weekly Report',
...(state || {}),
name: 'Weekly Report',
};

switch (action.type) {
case ActionType.inputChange:
return {
...initialState,
...state,
[action.payload.name]: action.payload.value,
};
case ActionType.fetched:
return {
...initialState,
...action.payload,
};
case ActionType.reset:
return null;
return { ...initialState };
default:
return state;
}
Expand All @@ -178,7 +179,7 @@ const ReportModal: FunctionComponent<ReportProps> = ({
: NOTIFICATION_FORMATS.PNG;
const [currentReport, setCurrentReport] = useReducer<
Reducer<Partial<ReportObject> | null, ReportActionType>
>(reportReducer, { report_format: defaultNotificationFormat });
>(reportReducer, null);
const onChange = useCallback((type: any, payload: any) => {
setCurrentReport({ type, payload });
}, []);
Expand Down Expand Up @@ -224,7 +225,7 @@ const ReportModal: FunctionComponent<ReportProps> = ({
type: 'Report',
creation_method: props.props.creationMethod,
active: true,
report_format: currentReport?.report_format,
report_format: currentReport?.report_format || defaultNotificationFormat,
timezone: currentReport?.timezone,
};

Expand Down

0 comments on commit 2a8a9bf

Please sign in to comment.