import type { DocumentType } from '@sber-pprb-efsdf/rapid-ui-core';

import {
	COVENANTS_MODAL_TITLE,
	COVENANTS_PROTOTYPE_FOOTER_ACTION_BUTTONS,
	COVENANTS_STANDARD_EKI_FOOTER_ACTION_BUTTONS,
	COVENANTS_STANDARD_EKI_INFO_PANEL,
	COVENANTS_STANDARD_FOOTER_ACTION_BUTTONS,
	COVENANTS_STANDARD_INFO_PANEL,
	DC_MODAL_TITLE,
	DC_STANDARD_FOOTER_ACTION_BUTTONS,
	DC_STANDARD_INFO_PANELS,
	EDITED_LABEL,
	KFUL_NEED_FIX_ERRORS_CONDITIONS,
} from '../consts';
import type { ConditionConfiguratorProps } from '../types';

export const createConditionConfiguratorProps = (documentType: DocumentType) => {
	const configuredProps: ConditionConfiguratorProps = {
		isSimplifiedFormulation: false,
		infoPanelErrorText: '',
		infoPanels: null,
		editedLabel: '',
		showResetButton: false,
		modalTitle: '',
		footerActionButtons: [],
		shouldUsePollingForStatusAndId: false,
		shouldUseAdditionalTextForInfoPanel: true,
		showChangeFormulationButton: true,
		subscribeMOInputsOnCommonParamsCheckbox: false,
	};

	switch (documentType) {
		case 'COVENANTS_PROTOTYPE_EKI':
		case 'COVENANTS_PROTOTYPE': {
			return {
				...configuredProps,
				infoPanelErrorText: KFUL_NEED_FIX_ERRORS_CONDITIONS,
				editedLabel: EDITED_LABEL,
				showResetButton: true,
				modalTitle: COVENANTS_MODAL_TITLE,
				footerActionButtons: COVENANTS_PROTOTYPE_FOOTER_ACTION_BUTTONS,
				shouldUsePollingForStatusAndId: true,
				shouldUseAdditionalTextForInfoPanel: false,
				showChangeFormulationButton: false,
				subscribeMOInputsOnCommonParamsCheckbox: true,
			};
		}

		case 'COVENANTS_STANDARD_EKI': {
			return {
				...configuredProps,
				infoPanels: [COVENANTS_STANDARD_EKI_INFO_PANEL],
				modalTitle: COVENANTS_MODAL_TITLE,
				footerActionButtons: COVENANTS_STANDARD_EKI_FOOTER_ACTION_BUTTONS,
			};
		}
		case 'COVENANTS_STANDARD': {
			return {
				...configuredProps,
				infoPanels: [COVENANTS_STANDARD_INFO_PANEL],
				modalTitle: COVENANTS_MODAL_TITLE,
				footerActionButtons: COVENANTS_STANDARD_FOOTER_ACTION_BUTTONS,
			};
		}
		case 'DELAYED_CONDITIONS_STANDARD': {
			return {
				...configuredProps,
				infoPanels: DC_STANDARD_INFO_PANELS,
				isSimplifiedFormulation: true,
				modalTitle: DC_MODAL_TITLE,
				footerActionButtons: DC_STANDARD_FOOTER_ACTION_BUTTONS,
			};
		}
		default: {
			return configuredProps;
		}
	}
};
import { createConditionConfiguratorProps } from '../createConditionConfiguratorProps';
import {
	COVENANTS_MODAL_TITLE,
	COVENANTS_PROTOTYPE_FOOTER_ACTION_BUTTONS,
	COVENANTS_STANDARD_FOOTER_ACTION_BUTTONS,
	COVENANTS_STANDARD_INFO_PANEL,
	DC_MODAL_TITLE,
	DC_STANDARD_FOOTER_ACTION_BUTTONS,
	DC_STANDARD_INFO_PANELS,
	EDITED_LABEL,
	KFUL_NEED_FIX_ERRORS_CONDITIONS,
} from '../../consts';

describe('createConditionConfiguratorProps', () => {
	test('should return correct props for COVENANTS_PROTOTYPE_EKI', () => {
		const result = createConditionConfiguratorProps('COVENANTS_PROTOTYPE_EKI');

		expect(result).toEqual({
			isSimplifiedFormulation: false,
			infoPanelErrorText: KFUL_NEED_FIX_ERRORS_CONDITIONS,
			infoPanels: null,
			editedLabel: EDITED_LABEL,
			showResetButton: true,
			modalTitle: COVENANTS_MODAL_TITLE,
			footerActionButtons: COVENANTS_PROTOTYPE_FOOTER_ACTION_BUTTONS,
			shouldUsePollingForStatusAndId: true,
			shouldUseAdditionalTextForInfoPanel: false,
			showChangeFormulationButton: false,
			subscribeMOInputsOnCommonParamsCheckbox: true,
		});
	});

	test('should return correct props for COVENANTS_PROTOTYPE', () => {
		const result = createConditionConfiguratorProps('COVENANTS_PROTOTYPE');

		expect(result).toEqual({
			isSimplifiedFormulation: false,
			infoPanelErrorText: KFUL_NEED_FIX_ERRORS_CONDITIONS,
			infoPanels: null,
			editedLabel: EDITED_LABEL,
			showResetButton: true,
			modalTitle: COVENANTS_MODAL_TITLE,
			footerActionButtons: COVENANTS_PROTOTYPE_FOOTER_ACTION_BUTTONS,
			shouldUsePollingForStatusAndId: true,
			shouldUseAdditionalTextForInfoPanel: false,
			showChangeFormulationButton: false,
			subscribeMOInputsOnCommonParamsCheckbox: true,
		});
	});

	test('should return correct props for COVENANTS_STANDARD_EKI', () => {
		const result = createConditionConfiguratorProps('COVENANTS_STANDARD_EKI');

		expect(result).toEqual({
			isSimplifiedFormulation: false,
			infoPanelErrorText: '',
			infoPanels: [COVENANTS_STANDARD_INFO_PANEL],
			editedLabel: '',
			showResetButton: false,
			modalTitle: COVENANTS_MODAL_TITLE,
			footerActionButtons: COVENANTS_STANDARD_FOOTER_ACTION_BUTTONS,
			shouldUsePollingForStatusAndId: false,
			shouldUseAdditionalTextForInfoPanel: true,
			showChangeFormulationButton: true,
			subscribeMOInputsOnCommonParamsCheckbox: false,
		});
	});

	test('should return correct props for COVENANTS_STANDARD', () => {
		const result = createConditionConfiguratorProps('COVENANTS_STANDARD');

		expect(result).toEqual({
			isSimplifiedFormulation: false,
			infoPanelErrorText: '',
			infoPanels: [COVENANTS_STANDARD_INFO_PANEL],
			editedLabel: '',
			showResetButton: false,
			modalTitle: COVENANTS_MODAL_TITLE,
			footerActionButtons: COVENANTS_STANDARD_FOOTER_ACTION_BUTTONS,
			shouldUsePollingForStatusAndId: false,
			shouldUseAdditionalTextForInfoPanel: true,
			showChangeFormulationButton: true,
			subscribeMOInputsOnCommonParamsCheckbox: false,
		});
	});

	test('should return correct props for DELAYED_CONDITIONS_STANDARD', () => {
		const result = createConditionConfiguratorProps('DELAYED_CONDITIONS_STANDARD');

		expect(result).toEqual({
			isSimplifiedFormulation: true,
			infoPanelErrorText: '',
			infoPanels: DC_STANDARD_INFO_PANELS,
			editedLabel: '',
			showResetButton: false,
			modalTitle: DC_MODAL_TITLE,
			footerActionButtons: DC_STANDARD_FOOTER_ACTION_BUTTONS,
			shouldUsePollingForStatusAndId: false,
			shouldUseAdditionalTextForInfoPanel: true,
			showChangeFormulationButton: true,
			subscribeMOInputsOnCommonParamsCheckbox: false,
		});
	});
});
поправь тесты