Улучшена проверка наличия аватара и фотографии паспорта в компонентах EmployeeEditInlineForm, EmployeeForm и EmployeeInlineForm. Добавлены условия для проверки пустых строк перед отображением изображений. Обновлен компонент CreateConsumablesSupplyPage: изменена логика отображения изображений товаров с учетом нового формата данных. Обновлен компонент ProductForm: добавлено сообщение о отсутствии изображения, если оно не загружено.
This commit is contained in:
@ -227,7 +227,7 @@ export function EmployeeEditInlineForm({ employee, onSave, onCancel, isLoading =
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
<Avatar className="h-20 w-20 ring-2 ring-white/20">
|
||||
{formData.avatar ? (
|
||||
{formData.avatar && formData.avatar.trim() !== '' ? (
|
||||
<AvatarImage
|
||||
src={formData.avatar}
|
||||
alt="Фото сотрудника"
|
||||
@ -288,7 +288,7 @@ export function EmployeeEditInlineForm({ employee, onSave, onCancel, isLoading =
|
||||
</Label>
|
||||
|
||||
<div className="space-y-3">
|
||||
{formData.passportPhoto ? (
|
||||
{formData.passportPhoto && formData.passportPhoto.trim() !== '' ? (
|
||||
<div className="relative">
|
||||
<Image
|
||||
src={formData.passportPhoto}
|
||||
@ -549,13 +549,15 @@ export function EmployeeEditInlineForm({ employee, onSave, onCancel, isLoading =
|
||||
<DialogTitle className="text-white">Фото паспорта</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src={formData.passportPhoto}
|
||||
alt="Паспорт"
|
||||
width={600}
|
||||
height={800}
|
||||
className="max-w-full max-h-[70vh] object-contain rounded-lg"
|
||||
/>
|
||||
{formData.passportPhoto && formData.passportPhoto.trim() !== '' && (
|
||||
<Image
|
||||
src={formData.passportPhoto}
|
||||
alt="Паспорт"
|
||||
width={600}
|
||||
height={800}
|
||||
className="max-w-full max-h-[70vh] object-contain rounded-lg"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
@ -351,7 +351,7 @@ export function EmployeeForm({ employee, onSave, onCancel }: EmployeeFormProps)
|
||||
<div className="flex items-start gap-6 mb-6">
|
||||
<div className="flex flex-col items-center gap-3">
|
||||
<Avatar className="h-24 w-24 ring-2 ring-white/20">
|
||||
{formData.avatar ? (
|
||||
{formData.avatar && formData.avatar.trim() !== '' ? (
|
||||
<AvatarImage src={formData.avatar} alt="Аватар сотрудника" />
|
||||
) : null}
|
||||
<AvatarFallback className="bg-gradient-to-br from-purple-500 to-purple-600 text-white text-lg font-semibold">
|
||||
|
@ -338,7 +338,7 @@ export function EmployeeInlineForm({ onSave, onCancel, isLoading = false }: Empl
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
<Avatar className="h-20 w-20 ring-2 ring-white/20">
|
||||
{formData.avatar ? (
|
||||
{formData.avatar && formData.avatar.trim() !== '' ? (
|
||||
<AvatarImage src={formData.avatar} alt="Фото сотрудника" />
|
||||
) : null}
|
||||
<AvatarFallback className="bg-gradient-to-br from-purple-500 to-purple-600 text-white text-lg font-semibold">
|
||||
@ -391,7 +391,7 @@ export function EmployeeInlineForm({ onSave, onCancel, isLoading = false }: Empl
|
||||
</Label>
|
||||
|
||||
<div className="space-y-3">
|
||||
{formData.passportPhoto ? (
|
||||
{formData.passportPhoto && formData.passportPhoto.trim() !== '' ? (
|
||||
<div className="relative">
|
||||
<Image
|
||||
src={formData.passportPhoto}
|
||||
@ -652,13 +652,15 @@ export function EmployeeInlineForm({ onSave, onCancel, isLoading = false }: Empl
|
||||
<DialogTitle className="text-white">Фото паспорта</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src={formData.passportPhoto}
|
||||
alt="Паспорт"
|
||||
width={600}
|
||||
height={800}
|
||||
className="max-w-full max-h-[70vh] object-contain rounded-lg"
|
||||
/>
|
||||
{formData.passportPhoto && formData.passportPhoto.trim() !== '' && (
|
||||
<Image
|
||||
src={formData.passportPhoto}
|
||||
alt="Паспорт"
|
||||
width={600}
|
||||
height={800}
|
||||
className="max-w-full max-h-[70vh] object-contain rounded-lg"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
@ -49,7 +49,8 @@ interface ConsumableProduct {
|
||||
description?: string;
|
||||
price: number;
|
||||
category?: { name: string };
|
||||
images?: Array<{ url: string }>;
|
||||
images: string[];
|
||||
mainImage?: string;
|
||||
organization: {
|
||||
id: string;
|
||||
name: string;
|
||||
@ -439,9 +440,17 @@ export function CreateConsumablesSupplyPage() {
|
||||
<div className="space-y-3">
|
||||
{/* Изображение товара */}
|
||||
<div className="aspect-square bg-white/5 rounded-lg overflow-hidden">
|
||||
{product.images && product.images.length > 0 ? (
|
||||
{product.images && product.images.length > 0 && product.images[0] ? (
|
||||
<Image
|
||||
src={product.images[0].url}
|
||||
src={product.images[0]}
|
||||
alt={product.name}
|
||||
width={200}
|
||||
height={200}
|
||||
className="w-full h-full object-cover"
|
||||
/>
|
||||
) : product.mainImage ? (
|
||||
<Image
|
||||
src={product.mainImage}
|
||||
alt={product.name}
|
||||
width={200}
|
||||
height={200}
|
||||
|
@ -419,7 +419,7 @@ export function ProductForm({ product, onSave, onCancel }: ProductFormProps) {
|
||||
<div className="aspect-square bg-white/10 rounded-lg flex items-center justify-center">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-2 border-white border-t-transparent"></div>
|
||||
</div>
|
||||
) : (
|
||||
) : imageUrl ? (
|
||||
<>
|
||||
<Image
|
||||
src={imageUrl}
|
||||
@ -460,6 +460,10 @@ export function ProductForm({ product, onSave, onCancel }: ProductFormProps) {
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="aspect-square bg-white/10 rounded-lg flex items-center justify-center">
|
||||
<div className="text-white/40 text-sm">Нет изображения</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
|
Reference in New Issue
Block a user