StickerAI-Front/src/components/generation/GenerationButton.tsx

44 lines
1.2 KiB
TypeScript

import React from 'react';
import BlockRenderer from '../blocks/BlockRenderer';
import { homeScreenConfig } from '../../config/homeScreen';
import styles from '../../screens/Home.module.css';
interface GenerationButtonProps {
onStartGeneration: () => void;
isGenerating: boolean;
}
/**
* Компонент кнопки генерации
*/
const GenerationButton: React.FC<GenerationButtonProps> = ({
onStartGeneration,
isGenerating
}) => {
// Находим блок кнопки генерации в конфигурации
const generateButton = homeScreenConfig.homeScreen.blocks.find(block => block.type === 'generateButton');
if (!generateButton) {
return null;
}
// Обработчик нажатия на кнопку генерации
const handleAction = (actionType: string, actionValue: string) => {
if (actionType === 'function' && actionValue === 'startGeneration' && !isGenerating) {
onStartGeneration();
}
};
return (
<div className={styles.generateButtonContainer}>
<BlockRenderer
block={generateButton}
onAction={handleAction}
extraProps={{ disabled: isGenerating }}
/>
</div>
);
};
export default GenerationButton;