All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.page_editor.app.thunks.updateRule.ts Maven / Gradle / Ivy

The newest version!
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

import {Action} from '../../plugins/page_rules/components/Action';
import {Condition} from '../../plugins/page_rules/components/Condition';
import {ConditionType} from '../../plugins/page_rules/components/RuleBuilderSection';
import {State} from '../../types/State';
import updateNetwork from '../actions/updateNetwork';
import updateRuleAction from '../actions/updateRule';
import RulesService from '../services/RulesService';

type Props = {
	actions: Action[];
	conditionType: ConditionType;
	conditions: Condition[];
	name: string;
	ruleId: string;
};

export default function updateRule({
	actions,
	conditionType,
	conditions,
	name,
	ruleId,
}: Props) {
	return (
		dispatch: (
			action: ReturnType
		) => void,
		getState: () => State
	) => {
		const {segmentsExperienceId} = getState();

		return RulesService.updateRule({
			actions,
			conditionType,
			conditions,
			name,
			onNetworkStatus: dispatch,
			ruleId,
			segmentsExperienceId,
		}).then(({layoutData}) => {
			dispatch(updateRuleAction({layoutData, ruleId}));
		});
	};
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy