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

META-INF.resources.js.components.ObjectAction.tabs.ActionContainer.SingleSelectNotification.tsx Maven / Gradle / Ivy

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

import {Option, Text} from '@clayui/core';
import ClayLabel from '@clayui/label';
import {SingleSelect} from '@liferay/object-js-components-web';
import React from 'react';

import {ActionError} from '../../ObjectActionContainer';
import {NotificationTemplateAction} from './ThenContainer';
import {updateUsePreferredLanguageForGuestsParameter} from './updateUsePreferredLanguageForGuestsParameter';

import './SingleSelectNotification.scss';

interface SingleSelectAddObejctEntryProps {
	errors: ActionError;
	notificationTemplates: NotificationTemplateAction[];
	setSelectedNotificationTemplate: (
		value: Partial
	) => void;
	setValues: (values: Partial) => void;
	values: Partial;
}

export function SingleSelectNotification({
	errors,
	notificationTemplates,
	setSelectedNotificationTemplate,
	setValues,
	values,
}: SingleSelectAddObejctEntryProps) {
	return (
		
			className="lfr-object__action-builder-notification-then"
			disabled={values.system}
			error={errors.objectActionExecutorKey}
			items={notificationTemplates}
			onSelectionChange={(value) => {
				const selectedNotificationTemplate = notificationTemplates.find(
					(notificationTemplate) => {
						return notificationTemplate.value === value;
					}
				);

				if (selectedNotificationTemplate) {
					setSelectedNotificationTemplate(
						selectedNotificationTemplate
					);

					const parameters =
						updateUsePreferredLanguageForGuestsParameter(
							values,
							selectedNotificationTemplate.type
						);

					setValues({
						...values,
						parameters: {
							...parameters,
							notificationTemplateExternalReferenceCode:
								selectedNotificationTemplate.value,
						},
					});
				}
			}}
			required
			selectedKey={
				values.parameters?.notificationTemplateExternalReferenceCode
			}
		>
			{(item) => (
				
			)}
		
	);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy