Hide gallery button in feedback notification
This commit is contained in:
parent
1a4d7477cb
commit
c43122dfba
@ -111,4 +111,36 @@
|
|||||||
margin: 0 var(--spacing-large);
|
margin: 0 var(--spacing-large);
|
||||||
max-width: 90vw;
|
max-width: 90vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Улучшения для работы с файлами на iOS */
|
||||||
|
.fileInput {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
font-size: 16px; /* Предотвращает масштабирование на iOS */
|
||||||
|
}
|
||||||
|
|
||||||
|
.addImageButton {
|
||||||
|
padding: 12px 16px; /* Увеличенная область нажатия для мобильных устройств */
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imagePreview {
|
||||||
|
width: 70px; /* Немного меньше для мобильных устройств */
|
||||||
|
height: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.removeImageButton {
|
||||||
|
width: 24px; /* Увеличенная область нажатия для кнопки удаления */
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Медиа-запрос для мобильных устройств */
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.imagePreviewContainer {
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textarea {
|
||||||
|
min-height: 80px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,14 +45,39 @@ const FeedbackModal: React.FC<FeedbackModalProps> = ({ isVisible, onClose, onSub
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Функция для обработки выбранного файла
|
||||||
|
const handleFileSelect = (file: File) => {
|
||||||
|
console.log('Обработка выбранного файла:', file.name, file.type);
|
||||||
|
|
||||||
|
// Проверяем, что это изображение
|
||||||
|
if (file && file.type.startsWith('image/')) {
|
||||||
|
console.log('Файл является изображением, добавляем в список');
|
||||||
|
|
||||||
|
// Добавляем файл в список изображений
|
||||||
|
setImages(prevImages => [...prevImages, file]);
|
||||||
|
} else {
|
||||||
|
console.error('Выбранный файл не является изображением');
|
||||||
|
setError('Пожалуйста, выберите файл изображения (JPEG, PNG и т.д.)');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Обработчик добавления изображений
|
// Обработчик добавления изображений
|
||||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
if (e.target.files && e.target.files.length > 0) {
|
console.log('Событие выбора файла сработало');
|
||||||
const newFiles = Array.from(e.target.files);
|
|
||||||
setImages(prevImages => [...prevImages, ...newFiles]);
|
|
||||||
|
|
||||||
// Сбрасываем значение input, чтобы можно было выбрать тот же файл повторно
|
try {
|
||||||
e.target.value = '';
|
const file = e.target.files?.[0];
|
||||||
|
console.log('Выбранный файл:', file ? `${file.name} (${file.type})` : 'нет файла');
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
handleFileSelect(file);
|
||||||
|
|
||||||
|
// Сбрасываем значение input, чтобы можно было выбрать тот же файл повторно
|
||||||
|
e.target.value = '';
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Ошибка при обработке выбранного файла:', err);
|
||||||
|
setError('Произошла ошибка при выборе файла. Пожалуйста, попробуйте еще раз.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -132,7 +157,6 @@ const FeedbackModal: React.FC<FeedbackModalProps> = ({ isVisible, onClose, onSub
|
|||||||
accept="image/*"
|
accept="image/*"
|
||||||
onChange={handleFileChange}
|
onChange={handleFileChange}
|
||||||
className={feedbackStyles.fileInput}
|
className={feedbackStyles.fileInput}
|
||||||
multiple
|
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ interface NotificationModalProps {
|
|||||||
promptText?: string;
|
promptText?: string;
|
||||||
onGalleryClick: () => void;
|
onGalleryClick: () => void;
|
||||||
onContinueClick: () => void;
|
onContinueClick: () => void;
|
||||||
|
showGalleryButton?: boolean; // Новый параметр для управления видимостью кнопки "В галерею"
|
||||||
}
|
}
|
||||||
|
|
||||||
const NotificationModal: React.FC<NotificationModalProps> = ({
|
const NotificationModal: React.FC<NotificationModalProps> = ({
|
||||||
@ -18,7 +19,8 @@ const NotificationModal: React.FC<NotificationModalProps> = ({
|
|||||||
isLoading = false,
|
isLoading = false,
|
||||||
promptText,
|
promptText,
|
||||||
onGalleryClick,
|
onGalleryClick,
|
||||||
onContinueClick
|
onContinueClick,
|
||||||
|
showGalleryButton = true // По умолчанию кнопка видима
|
||||||
}) => {
|
}) => {
|
||||||
if (!isVisible) return null;
|
if (!isVisible) return null;
|
||||||
|
|
||||||
@ -41,14 +43,16 @@ const NotificationModal: React.FC<NotificationModalProps> = ({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className={styles.buttons}>
|
<div className={styles.buttons}>
|
||||||
|
{showGalleryButton && (
|
||||||
|
<button
|
||||||
|
className={`${styles.button} ${styles.primaryButton}`}
|
||||||
|
onClick={onGalleryClick}
|
||||||
|
>
|
||||||
|
В галерею
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
<button
|
<button
|
||||||
className={`${styles.button} ${styles.primaryButton}`}
|
className={`${styles.button} ${!showGalleryButton ? styles.primaryButton : styles.secondaryButton}`}
|
||||||
onClick={onGalleryClick}
|
|
||||||
>
|
|
||||||
В галерею
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className={`${styles.button} ${styles.secondaryButton}`}
|
|
||||||
onClick={onContinueClick}
|
onClick={onContinueClick}
|
||||||
>
|
>
|
||||||
Продолжить
|
Продолжить
|
||||||
|
|||||||
@ -44,6 +44,7 @@ const Home: React.FC = () => {
|
|||||||
const [notificationMessage, setNotificationMessage] = useState('');
|
const [notificationMessage, setNotificationMessage] = useState('');
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [promptText, setPromptText] = useState('');
|
const [promptText, setPromptText] = useState('');
|
||||||
|
const [showGalleryButton, setShowGalleryButton] = useState(true);
|
||||||
|
|
||||||
// Состояние для хранения данных о последней успешной генерации
|
// Состояние для хранения данных о последней успешной генерации
|
||||||
const [lastGenerationData, setLastGenerationData] = useState<LastGenerationData>({});
|
const [lastGenerationData, setLastGenerationData] = useState<LastGenerationData>({});
|
||||||
@ -81,6 +82,7 @@ const Home: React.FC = () => {
|
|||||||
setNotificationTitle('Внимание');
|
setNotificationTitle('Внимание');
|
||||||
setNotificationMessage('Сначала загрузите изображение');
|
setNotificationMessage('Сначала загрузите изображение');
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений
|
||||||
setIsNotificationVisible(true);
|
setIsNotificationVisible(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -90,6 +92,7 @@ const Home: React.FC = () => {
|
|||||||
setNotificationTitle('Внимание');
|
setNotificationTitle('Внимание');
|
||||||
setNotificationMessage('Выберите образ для генерации');
|
setNotificationMessage('Выберите образ для генерации');
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений
|
||||||
setIsNotificationVisible(true);
|
setIsNotificationVisible(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -99,6 +102,7 @@ const Home: React.FC = () => {
|
|||||||
setNotificationTitle('Внимание');
|
setNotificationTitle('Внимание');
|
||||||
setNotificationMessage('Введите текст промпта');
|
setNotificationMessage('Введите текст промпта');
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений
|
||||||
setIsNotificationVisible(true);
|
setIsNotificationVisible(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -132,6 +136,7 @@ const Home: React.FC = () => {
|
|||||||
setNotificationTitle('Внимание');
|
setNotificationTitle('Внимание');
|
||||||
setNotificationMessage('Нельзя отправить одну и ту же комбинацию изображения и образа подряд. Пожалуйста, измените изображение или выберите другой образ.');
|
setNotificationMessage('Нельзя отправить одну и ту же комбинацию изображения и образа подряд. Пожалуйста, измените изображение или выберите другой образ.');
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений
|
||||||
setIsNotificationVisible(true);
|
setIsNotificationVisible(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -142,6 +147,7 @@ const Home: React.FC = () => {
|
|||||||
setNotificationMessage('Отправка запроса...');
|
setNotificationMessage('Отправка запроса...');
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setPromptText('');
|
setPromptText('');
|
||||||
|
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений о генерации
|
||||||
setIsNotificationVisible(true);
|
setIsNotificationVisible(true);
|
||||||
|
|
||||||
// Если выбран "Свой промпт" и введен текст, используем его
|
// Если выбран "Свой промпт" и введен текст, используем его
|
||||||
@ -202,6 +208,7 @@ const Home: React.FC = () => {
|
|||||||
setNotificationTitle('Ошибка');
|
setNotificationTitle('Ошибка');
|
||||||
setNotificationMessage('Не удалось начать генерацию');
|
setNotificationMessage('Не удалось начать генерацию');
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений
|
||||||
setIsNotificationVisible(true);
|
setIsNotificationVisible(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -299,6 +306,7 @@ const Home: React.FC = () => {
|
|||||||
promptText={promptText}
|
promptText={promptText}
|
||||||
onGalleryClick={handleGalleryClick}
|
onGalleryClick={handleGalleryClick}
|
||||||
onContinueClick={handleContinueClick}
|
onContinueClick={handleContinueClick}
|
||||||
|
showGalleryButton={showGalleryButton}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Компонент обработки обратной связи */}
|
{/* Компонент обработки обратной связи */}
|
||||||
@ -309,6 +317,7 @@ const Home: React.FC = () => {
|
|||||||
setNotificationTitle('Спасибо за обратную связь');
|
setNotificationTitle('Спасибо за обратную связь');
|
||||||
setNotificationMessage('Ваше сообщение успешно отправлено');
|
setNotificationMessage('Ваше сообщение успешно отправлено');
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setShowGalleryButton(false); // Скрываем кнопку "В галерею" для уведомления об обратной связи
|
||||||
setIsNotificationVisible(true);
|
setIsNotificationVisible(true);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user