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

META-INF.resources.js.components.ObjectView.BasicInfoScreen.BasicInfoScreen.tsx 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 ClayForm, {ClayCheckbox} from '@clayui/form';
import {
	Card,
	Input,
	constantsUtils,
	invalidateRequired,
	stringUtils,
} from '@liferay/object-js-components-web';
import React from 'react';

import {TYPES, useViewContext} from '../objectViewContext';

export default function BasicInfoScreen() {
	const [{creationLanguageId, objectView}, dispatch] = useViewContext();

	const handleChangeName = (newName: string) => {
		dispatch({
			payload: {newName},
			type: TYPES.CHANGE_OBJECT_VIEW_NAME,
		});
	};

	const handleChangeChecked = (checked: boolean) => {
		dispatch({
			payload: {checked},
			type: TYPES.SET_OBJECT_VIEW_AS_DEFAULT,
		});
	};

	let error: string | undefined;

	if (
		invalidateRequired(
			stringUtils.getLocalizableLabel({
				fallbackLanguageId: creationLanguageId,
				labels: objectView.name,
			})
		)
	) {
		error = constantsUtils.REQUIRED_MSG;
	}

	return (
		
			
				 {
						handleChangeName(value);
					}}
					required
					value={stringUtils.getLocalizableLabel({
						fallbackLanguageId: creationLanguageId,
						labels: objectView.name,
					})}
				/>
			

			
				 {
						handleChangeChecked(checked);
					}}
				/>
			
		
	);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy