Skip to content

Commit

Permalink
Add setSetupErrorCode action.
Browse files Browse the repository at this point in the history
  • Loading branch information
hussain-t committed Jul 3, 2024
1 parent 65ec299 commit bac7eab
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions assets/js/googlesitekit/datastore/site/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const RECEIVE_SITE_INFO = 'RECEIVE_SITE_INFO';
const RECEIVE_PERMALINK_PARAM = 'RECEIVE_PERMALINK_PARAM';
const SET_SITE_KIT_AUTO_UPDATES_ENABLED = 'SET_SITE_KIT_AUTO_UPDATES_ENABLED';
const SET_KEY_METRICS_SETUP_COMPLETED_BY = 'SET_KEY_METRICS_SETUP_COMPLETED_BY';
const SET_SETUP_ERROR_CODE = 'SET_SETUP_ERROR_CODE';

export const initialState = {
siteInfo: undefined,
Expand Down Expand Up @@ -126,6 +127,27 @@ export const actions = {
type: SET_KEY_METRICS_SETUP_COMPLETED_BY,
};
},

/**
* Sets `setupErrorCode` value.
*
* @since n.e.x.t
*
* @param {string|null} setupErrorCode Error code from setup, or `null` if no error.
* @return {Object} Redux-style action.
*/
setSetupErrorCode( setupErrorCode ) {
// setupErrorCode can be a string or null.
invariant(
typeof setupErrorCode === 'string' || setupErrorCode === null,
'setupErrorCode must be a string or null.'
);

return {
payload: { setupErrorCode },
type: SET_SETUP_ERROR_CODE,
};
},
};

export const controls = {};
Expand Down Expand Up @@ -228,6 +250,16 @@ export const reducer = ( state, { payload, type } ) => {
},
};

case SET_SETUP_ERROR_CODE:
const { setupErrorCode } = payload;
return {
...state,
siteInfo: {
...state.siteInfo,
setupErrorCode,
},
};

default: {
return state;
}
Expand Down

0 comments on commit bac7eab

Please sign in to comment.