-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NUX: Refactor step site topic state (#29736)
* Adding siteVertical to the state tree. * Granularizing selectors to fetch individual properties. Migrating submit action from site topic actions. * Replacing siteTopic state usage with siteVertical state * Simplify function return syntax * Remove `siteTopic` state tree files. * Update client/signup/site-mockup/index.jsx Updating selector name to correct one: `getSiteVerticalName` Co-Authored-By: ramonjd <[email protected]> * Update client/signup/site-mockup/index.jsx Updating selector name to the correct one: `getSiteVerticalName` Co-Authored-By: ramonjd <[email protected]>
- Loading branch information
Showing
21 changed files
with
181 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** @format */ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
|
||
import { SIGNUP_STEPS_SITE_VERTICAL_SET } from 'state/action-types'; | ||
import SignupActions from 'lib/signup/actions'; | ||
|
||
export function setSiteVertical( { name, slug } ) { | ||
return { | ||
type: SIGNUP_STEPS_SITE_VERTICAL_SET, | ||
name, | ||
slug, | ||
}; | ||
} | ||
|
||
// It's a thunk since there is still Flux involved, so it can't be a plain object yet. | ||
// If the signup state is fully reduxified, we can just keep setSiteVertical() and | ||
// keep all the dependency filling and progress filling in a middleware. | ||
export const submitSiteVertical = ( { name, slug } ) => dispatch => { | ||
dispatch( setSiteVertical( { name, slug } ) ); | ||
SignupActions.submitSignupStep( { stepName: 'site-topic' }, [], { siteTopic: name } ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** @format */ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
|
||
import { SIGNUP_COMPLETE_RESET, SIGNUP_STEPS_SITE_VERTICAL_SET } from 'state/action-types'; | ||
|
||
import { createReducer } from 'state/utils'; | ||
import { siteVerticalSchema } from './schema'; | ||
|
||
export default createReducer( | ||
{}, | ||
{ | ||
[ SIGNUP_STEPS_SITE_VERTICAL_SET ]: ( state, { name, slug } ) => { | ||
return { | ||
name, | ||
slug, | ||
}; | ||
}, | ||
[ SIGNUP_COMPLETE_RESET ]: () => { | ||
return {}; | ||
}, | ||
}, | ||
siteVerticalSchema | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** @format */ | ||
export const siteVerticalSchema = { | ||
type: 'object', | ||
additionalProperties: false, | ||
properties: { | ||
name: { | ||
type: 'string', | ||
}, | ||
slug: { | ||
type: 'string', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** @format */ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
|
||
import { get } from 'lodash'; | ||
|
||
export function getSiteVerticalName( state ) { | ||
return get( state, 'signup.steps.siteVertical.name', '' ); | ||
} | ||
|
||
export function getSiteVerticalSlug( state ) { | ||
return get( state, 'signup.steps.siteVertical.slug', '' ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** @format */ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { setSiteVertical } from '../actions'; | ||
import { SIGNUP_STEPS_SITE_VERTICAL_SET } from 'state/action-types'; | ||
|
||
describe( 'setSiteVertical()', () => { | ||
test( 'should return the expected action object', () => { | ||
const siteVertical = { | ||
name: 'heureux', | ||
slug: 'happy', | ||
}; | ||
|
||
expect( setSiteVertical( siteVertical ) ).toEqual( { | ||
type: SIGNUP_STEPS_SITE_VERTICAL_SET, | ||
...siteVertical, | ||
} ); | ||
} ); | ||
} ); |
Oops, something went wrong.