From d8951347e176a5b0240ff0fe6b5daaa96a55db61 Mon Sep 17 00:00:00 2001 From: Elizabeth Thompson Date: Wed, 18 Aug 2021 13:18:36 -0700 Subject: [PATCH] adjust initial state (#16329) --- .../src/components/ReportModal/index.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/superset-frontend/src/components/ReportModal/index.tsx b/superset-frontend/src/components/ReportModal/index.tsx index 3770aadeda1f4..292d3b7414b2e 100644 --- a/superset-frontend/src/components/ReportModal/index.tsx +++ b/superset-frontend/src/components/ReportModal/index.tsx @@ -143,22 +143,23 @@ const reportReducer = ( action: ReportActionType, ): Partial | 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; } @@ -178,7 +179,7 @@ const ReportModal: FunctionComponent = ({ : NOTIFICATION_FORMATS.PNG; const [currentReport, setCurrentReport] = useReducer< Reducer | null, ReportActionType> - >(reportReducer, { report_format: defaultNotificationFormat }); + >(reportReducer, null); const onChange = useCallback((type: any, payload: any) => { setCurrentReport({ type, payload }); }, []); @@ -224,7 +225,7 @@ const ReportModal: FunctionComponent = ({ type: 'Report', creation_method: props.props.creationMethod, active: true, - report_format: currentReport?.report_format, + report_format: currentReport?.report_format || defaultNotificationFormat, timezone: currentReport?.timezone, };