Style fix

This commit is contained in:
moon 2022-05-11 12:25:07 -07:00
parent b395fb0ce9
commit dd6f161467
1 changed files with 14 additions and 14 deletions

View File

@ -9,42 +9,42 @@ import { apiFetch } from '@wordpress/data-controls';
import TYPES from './action-types'; import TYPES from './action-types';
import { EXPERIMENT_NAME_PREFIX, TRANSIENT_NAME_PREFIX } from './constants'; import { EXPERIMENT_NAME_PREFIX, TRANSIENT_NAME_PREFIX } from './constants';
function toggleFrontendExperiment(experimentName, newVariation) { function toggleFrontendExperiment( experimentName, newVariation ) {
const storageItem = JSON.parse( const storageItem = JSON.parse(
window.localStorage.getItem(EXPERIMENT_NAME_PREFIX + experimentName) window.localStorage.getItem( EXPERIMENT_NAME_PREFIX + experimentName )
); );
storageItem.variationName = newVariation; storageItem.variationName = newVariation;
window.localStorage.setItem( window.localStorage.setItem(
EXPERIMENT_NAME_PREFIX + experimentName, EXPERIMENT_NAME_PREFIX + experimentName,
JSON.stringify(storageItem) JSON.stringify( storageItem )
); );
} }
function* toggleBackendExperiment(experimentName, newVariation) { function* toggleBackendExperiment( experimentName, newVariation ) {
try { try {
const payload = {}; const payload = {};
payload[TRANSIENT_NAME_PREFIX + experimentName] = newVariation; payload[ TRANSIENT_NAME_PREFIX + experimentName ] = newVariation;
yield apiFetch({ yield apiFetch( {
method: 'POST', method: 'POST',
path: '/wc-admin/options', path: '/wc-admin/options',
headers: { 'content-type': 'application/json' }, headers: { 'content-type': 'application/json' },
body: JSON.stringify(payload), body: JSON.stringify( payload ),
}); } );
} catch (error) { } catch ( error ) {
throw new Error(); throw new Error();
} }
} }
export function* toggleExperiment(experimentName, currentVariation, source) { export function* toggleExperiment( experimentName, currentVariation, source ) {
const newVariation = const newVariation =
currentVariation === 'control' ? 'treatment' : 'control'; currentVariation === 'control' ? 'treatment' : 'control';
if (source === 'frontend') { if ( source === 'frontend' ) {
toggleFrontendExperiment(experimentName, newVariation); toggleFrontendExperiment( experimentName, newVariation );
} else { } else {
yield toggleBackendExperiment(experimentName, newVariation); yield toggleBackendExperiment( experimentName, newVariation );
} }
return { return {
@ -55,7 +55,7 @@ export function* toggleExperiment(experimentName, currentVariation, source) {
}; };
} }
export function setExperiments(experiments) { export function setExperiments( experiments ) {
return { return {
type: TYPES.SET_EXPERIMENTS, type: TYPES.SET_EXPERIMENTS,
experiments, experiments,