mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
✨ Introduce “completed” flag for Redux store
This commit is contained in:
parent
b369756cfd
commit
dbd37fc282
5 changed files with 39 additions and 1 deletions
|
@ -3,6 +3,7 @@ export default {
|
|||
SET_IS_SAVING_ONBOARDING_DETAILS: 'SET_IS_SAVING_ONBOARDING_DETAILS',
|
||||
|
||||
// Persistent data.
|
||||
SET_ONBOARDING_COMPLETED: 'SET_ONBOARDING_COMPLETED',
|
||||
SET_ONBOARDING_DETAILS: 'SET_ONBOARDING_DETAILS',
|
||||
SET_ONBOARDING_STEP: 'SET_ONBOARDING_STEP',
|
||||
SET_SANDBOX_MODE: 'SET_SANDBOX_MODE',
|
||||
|
|
|
@ -16,6 +16,19 @@ export const setIsSaving = ( isSaving ) => {
|
|||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Persistent.Set the "onboarding completed" flag which shows or hides the wizard.
|
||||
*
|
||||
* @param {boolean} completed
|
||||
* @return {{type: string, payload}} The action.
|
||||
*/
|
||||
export const setCompleted = ( completed ) => {
|
||||
return {
|
||||
type: ACTION_TYPES.SET_ONBOARDING_COMPLETED,
|
||||
completed,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Persistent. Set the full onboarding details, usually during app initialization.
|
||||
*
|
||||
|
|
|
@ -3,6 +3,7 @@ import ACTION_TYPES from './action-types';
|
|||
const defaultState = {
|
||||
isSaving: false,
|
||||
data: {
|
||||
completed: false,
|
||||
step: 0,
|
||||
useSandbox: false,
|
||||
useManualConnection: false,
|
||||
|
|
|
@ -57,6 +57,7 @@ class OnboardingProfile extends AbstractDataModel {
|
|||
*/
|
||||
protected function get_defaults() : array {
|
||||
return array(
|
||||
'completed' => false,
|
||||
'step' => 0,
|
||||
'use_sandbox' => false,
|
||||
'use_manual_connection' => false,
|
||||
|
@ -70,6 +71,24 @@ class OnboardingProfile extends AbstractDataModel {
|
|||
|
||||
// -----
|
||||
|
||||
/**
|
||||
* Gets the 'completed' flag.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function get_completed() : bool {
|
||||
return (bool) $this->data['completed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the 'completed' flag.
|
||||
*
|
||||
* @param bool $step Whether the onboarding process has been completed.
|
||||
*/
|
||||
public function set_completed( bool $step ) : void {
|
||||
$this->data['completed'] = $step;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the 'step' setting.
|
||||
*
|
||||
|
@ -82,7 +101,7 @@ class OnboardingProfile extends AbstractDataModel {
|
|||
/**
|
||||
* Sets the 'step' setting.
|
||||
*
|
||||
* @param int $step Whether to use sandbox mode.
|
||||
* @param int $step The current onboarding step.
|
||||
*/
|
||||
public function set_step( int $step ) : void {
|
||||
$this->data['step'] = $step;
|
||||
|
|
|
@ -41,6 +41,10 @@ class OnboardingRestEndpoint extends RestEndpoint {
|
|||
* @var array
|
||||
*/
|
||||
private array $field_map = array(
|
||||
'completed' => array(
|
||||
'js_name' => 'completed',
|
||||
'sanitize' => 'to_boolean',
|
||||
),
|
||||
'step' => array(
|
||||
'js_name' => 'step',
|
||||
'sanitize' => 'to_number',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue