2024-10-22 15:15:55 +02:00
|
|
|
import ACTION_TYPES from './action-types';
|
2024-11-18 16:31:05 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {Object} Action An action object that is handled by a reducer or control.
|
|
|
|
* @property {string} type - The action type.
|
|
|
|
* @property {Object?} payload - Optional payload for the action.
|
|
|
|
*/
|
2024-10-22 15:15:55 +02:00
|
|
|
|
2024-10-30 16:55:44 +01:00
|
|
|
/**
|
|
|
|
* Special. Resets all values in the onboarding store to initial defaults.
|
|
|
|
*
|
|
|
|
* @return {{type: string}} The action.
|
|
|
|
*/
|
|
|
|
export const resetOnboarding = () => {
|
|
|
|
return { type: ACTION_TYPES.RESET_ONBOARDING };
|
|
|
|
};
|
|
|
|
|
2024-10-28 18:57:39 +01:00
|
|
|
/**
|
|
|
|
* Non-persistent. Marks the onboarding details as "ready", i.e., fully initialized.
|
|
|
|
*
|
|
|
|
* @param {boolean} isReady
|
|
|
|
* @return {{type: string, isReady}} The action.
|
|
|
|
*/
|
|
|
|
export const setIsReady = ( isReady ) => {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.SET_ONBOARDING_IS_READY,
|
|
|
|
isReady,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-24 12:47:30 +02:00
|
|
|
/**
|
|
|
|
* Non-persistent. Changes the "saving" flag.
|
|
|
|
*
|
|
|
|
* @param {boolean} isSaving
|
|
|
|
* @return {{type: string, isSaving}} The action.
|
|
|
|
*/
|
|
|
|
export const setIsSaving = ( isSaving ) => {
|
|
|
|
return {
|
2024-10-28 18:56:25 +01:00
|
|
|
type: ACTION_TYPES.SET_IS_SAVING_ONBOARDING,
|
2024-10-24 12:47:30 +02:00
|
|
|
isSaving,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-11-04 16:48:59 +01:00
|
|
|
/**
|
|
|
|
* Non-persistent. Changes the "manual connection is busy" flag.
|
|
|
|
*
|
|
|
|
* @param {boolean} isBusy
|
|
|
|
* @return {{type: string, isBusy}} The action.
|
|
|
|
*/
|
|
|
|
export const setManualConnectionIsBusy = ( isBusy ) => {
|
|
|
|
return {
|
2024-11-04 18:50:09 +01:00
|
|
|
type: ACTION_TYPES.SET_MANUAL_CONNECTION_BUSY,
|
2024-11-04 16:48:59 +01:00
|
|
|
isBusy,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-28 17:00:07 +01:00
|
|
|
/**
|
2024-10-28 18:11:04 +01:00
|
|
|
* Persistent. Set the full onboarding details, usually during app initialization.
|
2024-10-28 17:00:07 +01:00
|
|
|
*
|
2024-10-30 16:52:06 +01:00
|
|
|
* @param {{data: {}, flags?: {}}} payload
|
2024-10-28 17:00:07 +01:00
|
|
|
* @return {{type: string, payload}} The action.
|
|
|
|
*/
|
2024-10-28 18:11:04 +01:00
|
|
|
export const setOnboardingDetails = ( payload ) => {
|
2024-10-28 17:00:07 +01:00
|
|
|
return {
|
2024-10-28 18:11:04 +01:00
|
|
|
type: ACTION_TYPES.SET_ONBOARDING_DETAILS,
|
|
|
|
payload,
|
2024-10-28 17:00:07 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-22 15:15:55 +02:00
|
|
|
/**
|
2024-10-28 18:11:04 +01:00
|
|
|
* Persistent.Set the "onboarding completed" flag which shows or hides the wizard.
|
2024-10-22 15:15:55 +02:00
|
|
|
*
|
2024-10-28 18:11:04 +01:00
|
|
|
* @param {boolean} completed
|
2024-10-23 15:38:00 +02:00
|
|
|
* @return {{type: string, payload}} The action.
|
2024-10-22 15:15:55 +02:00
|
|
|
*/
|
2024-10-28 18:11:04 +01:00
|
|
|
export const setCompleted = ( completed ) => {
|
2024-10-22 15:15:55 +02:00
|
|
|
return {
|
2024-10-28 18:11:04 +01:00
|
|
|
type: ACTION_TYPES.SET_ONBOARDING_COMPLETED,
|
|
|
|
completed,
|
2024-10-22 15:15:55 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-22 18:56:37 +02:00
|
|
|
/**
|
|
|
|
* Persistent. Sets the onboarding wizard to a new step.
|
|
|
|
*
|
|
|
|
* @param {number} step
|
|
|
|
* @return {{type: string, step}} An action.
|
|
|
|
*/
|
|
|
|
export const setOnboardingStep = ( step ) => {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.SET_ONBOARDING_STEP,
|
|
|
|
step,
|
|
|
|
};
|
2024-10-23 15:38:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Persistent. Sets the sandbox mode on or off.
|
|
|
|
*
|
|
|
|
* @param {boolean} sandboxMode
|
|
|
|
* @return {{type: string, useSandbox}} An action.
|
|
|
|
*/
|
|
|
|
export const setSandboxMode = ( sandboxMode ) => {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.SET_SANDBOX_MODE,
|
|
|
|
useSandbox: sandboxMode,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Persistent. Toggles the "Manual Connection" mode on or off.
|
|
|
|
*
|
|
|
|
* @param {boolean} manualConnectionMode
|
|
|
|
* @return {{type: string, useManualConnection}} An action.
|
|
|
|
*/
|
|
|
|
export const setManualConnectionMode = ( manualConnectionMode ) => {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.SET_MANUAL_CONNECTION_MODE,
|
|
|
|
useManualConnection: manualConnectionMode,
|
|
|
|
};
|
2024-10-22 18:56:37 +02:00
|
|
|
};
|
|
|
|
|
2024-10-22 15:15:55 +02:00
|
|
|
/**
|
2024-10-24 12:47:30 +02:00
|
|
|
* Persistent. Changes the "client ID" value.
|
2024-10-23 18:15:37 +02:00
|
|
|
*
|
|
|
|
* @param {string} clientId
|
|
|
|
* @return {{type: string, clientId}} The action.
|
|
|
|
*/
|
|
|
|
export const setClientId = ( clientId ) => {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.SET_CLIENT_ID,
|
|
|
|
clientId,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2024-10-24 12:47:30 +02:00
|
|
|
* Persistent. Changes the "client secret" value.
|
2024-10-23 18:15:37 +02:00
|
|
|
*
|
|
|
|
* @param {string} clientSecret
|
|
|
|
* @return {{type: string, clientSecret}} The action.
|
|
|
|
*/
|
|
|
|
export const setClientSecret = ( clientSecret ) => {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.SET_CLIENT_SECRET,
|
|
|
|
clientSecret,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-30 16:56:42 +01:00
|
|
|
/**
|
|
|
|
* Persistent. Sets the "isCasualSeller" value.
|
|
|
|
*
|
|
|
|
* @param {boolean} isCasualSeller
|
|
|
|
* @return {{type: string, isCasualSeller}} The action.
|
|
|
|
*/
|
|
|
|
export const setIsCasualSeller = ( isCasualSeller ) => {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.SET_IS_CASUAL_SELLER,
|
|
|
|
isCasualSeller,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Persistent. Sets the "products" array.
|
|
|
|
*
|
|
|
|
* @param {string[]} products
|
|
|
|
* @return {{type: string, products}} The action.
|
|
|
|
*/
|
|
|
|
export const setProducts = ( products ) => {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.SET_PRODUCTS,
|
|
|
|
products,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-11-04 16:50:50 +01:00
|
|
|
/**
|
2024-11-18 16:31:05 +01:00
|
|
|
* Side effect. Triggers the persistence of onboarding data to the server.
|
2024-11-04 16:50:50 +01:00
|
|
|
*
|
2024-11-18 16:31:05 +01:00
|
|
|
* @return {Action} The action.
|
|
|
|
*/
|
|
|
|
export const persist = () => {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.DO_PERSIST_DATA,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Side effect. Initiates a manual connection attempt using the provided client ID and secret.
|
2024-10-22 15:15:55 +02:00
|
|
|
*
|
2024-11-18 16:31:05 +01:00
|
|
|
* @return {Action} The action.
|
|
|
|
*/
|
|
|
|
export const connectViaIdAndSecret = () => {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.DO_MANUAL_CONNECTION,
|
|
|
|
};
|
|
|
|
};
|