Обновлен Dockerfile для установки wget и добавлены зависимости в компонентах. Исправлены зависимости в хуках и компонентах, улучшено логирование и обработка ошибок. Удалены неиспользуемые импорты и оптимизированы некоторые функции. Обновлены компоненты для работы с изображениями и улучшена структура кода.

This commit is contained in:
Bivekich
2025-07-17 11:18:32 +03:00
parent 99e91287f3
commit 83ed577a44
24 changed files with 80 additions and 119 deletions

View File

@ -3,6 +3,7 @@
import { useState } from 'react'
import { useQuery, useMutation } from '@apollo/client'
import { Card } from '@/components/ui/card'
import Image from 'next/image'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
@ -47,7 +48,7 @@ export function SuppliesTab() {
imageUrl: ''
})
const [imageFile, setImageFile] = useState<File | null>(null)
const [isUploading, setIsUploading] = useState(false)
const [isUploading] = useState(false)
// GraphQL запросы и мутации
const { data, loading, error, refetch } = useQuery(GET_MY_SUPPLIES, {
@ -96,35 +97,7 @@ export function SuppliesTab() {
}
}
const handleImageUpload = async (file: File) => {
if (!user?.id) return
setIsUploading(true)
try {
const formData = new FormData()
formData.append('file', file)
formData.append('userId', user.id)
formData.append('type', 'supply')
const response = await fetch('/api/upload-service-image', {
method: 'POST',
body: formData
})
if (!response.ok) {
throw new Error('Failed to upload image')
}
const result = await response.json()
console.log('Upload result:', result)
setFormData(prev => ({ ...prev, imageUrl: result.url }))
} catch (error) {
console.error('Error uploading image:', error)
toast.error('Ошибка при загрузке изображения')
} finally {
setIsUploading(false)
}
}
const uploadImageAndGetUrl = async (file: File): Promise<string> => {
if (!user?.id) throw new Error('User not found')
@ -300,9 +273,11 @@ export function SuppliesTab() {
/>
{formData.imageUrl && (
<div className="mt-3">
<img
<Image
src={formData.imageUrl}
alt="Preview"
width={80}
height={80}
className="w-20 h-20 object-cover rounded-lg border border-purple-400/30 shadow-lg"
/>
</div>
@ -409,9 +384,11 @@ export function SuppliesTab() {
<td className="p-4 text-white/80">{index + 1}</td>
<td className="p-4">
{supply.imageUrl ? (
<img
<Image
src={supply.imageUrl}
alt={supply.name}
width={48}
height={48}
className="w-12 h-12 object-cover rounded border border-white/20"
/>
) : (