Добавлен новый компонент TimesheetDemo и соответствующие вкладки в UIKitSection. Обновлены стили и структура кода для улучшения взаимодействия с пользователем. Оптимизированы импорты и форматирование кода в компоненте BusinessDemo.

This commit is contained in:
Veronika Smirnova
2025-07-23 13:42:15 +03:00
parent 0a790c538b
commit 331d59281a
3 changed files with 4049 additions and 163 deletions

View File

@ -1,20 +1,21 @@
"use client"
"use client";
import { useState } from 'react'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import { Progress } from '@/components/ui/progress'
import { Input } from '@/components/ui/input'
import { useState } from "react";
import { TimesheetDemo } from "./timesheet-demo";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Progress } from "@/components/ui/progress";
import { Input } from "@/components/ui/input";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
import {
} from "@/components/ui/select";
import {
Calendar,
Check,
X,
@ -43,69 +44,71 @@ import {
ChevronRight,
Hash,
Package2,
Truck
} from 'lucide-react'
Truck,
} from "lucide-react";
export function BusinessDemo() {
const [selectedProduct] = useState(null)
const [cartQuantity, setCartQuantity] = useState(1)
const [expandedSeller, setExpandedSeller] = useState(false)
const [selectedProduct] = useState(null);
const [cartQuantity, setCartQuantity] = useState(1);
const [expandedSeller, setExpandedSeller] = useState(false);
// Данные для демонстрации
const scheduleData = Array.from({ length: 30 }, (_, i) => ({
day: i + 1,
status: ['work', 'work', 'work', 'work', 'work', 'weekend', 'weekend'][i % 7],
hours: [8, 8, 8, 8, 8, 0, 0][i % 7]
}))
status: ["work", "work", "work", "work", "work", "weekend", "weekend"][
i % 7
],
hours: [8, 8, 8, 8, 8, 0, 0][i % 7],
}));
const products = [
{
id: '1',
name: 'iPhone 15 Pro Max 256GB',
article: 'APL-IP15PM-256',
id: "1",
name: "iPhone 15 Pro Max 256GB",
article: "APL-IP15PM-256",
price: 89990,
oldPrice: 99990,
quantity: 45,
category: 'Электроника',
brand: 'Apple',
category: "Электроника",
brand: "Apple",
rating: 4.8,
reviews: 1234,
image: '/placeholder-phone.jpg',
seller: 'TechStore Moscow',
image: "/placeholder-phone.jpg",
seller: "TechStore Moscow",
isNew: true,
inStock: true
inStock: true,
},
{
id: '2',
name: 'Беспроводные наушники AirPods Pro',
article: 'APL-APP-PRO',
id: "2",
name: "Беспроводные наушники AirPods Pro",
article: "APL-APP-PRO",
price: 24990,
quantity: 23,
category: 'Аксессуары',
brand: 'Apple',
category: "Аксессуары",
brand: "Apple",
rating: 4.6,
reviews: 856,
image: '/placeholder-headphones.jpg',
seller: 'Audio Expert',
image: "/placeholder-headphones.jpg",
seller: "Audio Expert",
isNew: false,
inStock: true
inStock: true,
},
{
id: '3',
name: 'Ноутбук MacBook Air M2',
article: 'APL-MBA-M2',
id: "3",
name: "Ноутбук MacBook Air M2",
article: "APL-MBA-M2",
price: 0,
quantity: 0,
category: 'Компьютеры',
brand: 'Apple',
category: "Компьютеры",
brand: "Apple",
rating: 4.9,
reviews: 445,
image: '/placeholder-laptop.jpg',
seller: 'Digital World',
image: "/placeholder-laptop.jpg",
seller: "Digital World",
isNew: false,
inStock: false
}
]
inStock: false,
},
];
// Данные для поставки фулфилмента
const fulfillmentSupply = {
@ -128,106 +131,129 @@ export function BusinessDemo() {
logisticsPartnerId: "log1",
status: "planned",
totalValue: 2500000,
}
};
const employees = [
{ id: "emp1", firstName: "Иван", lastName: "Петров", position: "Менеджер склада" },
{ id: "emp2", firstName: "Мария", lastName: "Сидорова", position: "Логист" }
]
{
id: "emp1",
firstName: "Иван",
lastName: "Петров",
position: "Менеджер склада",
},
{
id: "emp2",
firstName: "Мария",
lastName: "Сидорова",
position: "Логист",
},
];
const logisticsPartners = [
{ id: "log1", name: "ТК Энергия", fullName: "ООО ТК Энергия" },
{ id: "log2", name: "СДЭК", fullName: "ООО СДЭК" }
]
{ id: "log2", name: "СДЭК", fullName: "ООО СДЭК" },
];
const wholesalers = [
{
id: '1',
name: 'ТехноОпт Москва',
id: "1",
name: "ТехноОпт Москва",
fullName: 'ООО "Технологии Оптом"',
inn: '7735123456',
type: 'WHOLESALE',
avatar: '/placeholder-company.jpg',
inn: "7735123456",
type: "WHOLESALE",
avatar: "/placeholder-company.jpg",
rating: 4.8,
reviewsCount: 2345,
productsCount: 15670,
completedOrders: 8934,
responseTime: '2 часа',
categories: ['Электроника', 'Компьютеры', 'Аксессуары'],
location: 'Москва, Россия',
workingSince: '2018',
verifiedBadges: ['verified', 'premium', 'fast-delivery'],
description: 'Крупнейший поставщик электроники и компьютерной техники в России',
responseTime: "2 часа",
categories: ["Электроника", "Компьютеры", "Аксессуары"],
location: "Москва, Россия",
workingSince: "2018",
verifiedBadges: ["verified", "premium", "fast-delivery"],
description:
"Крупнейший поставщик электроники и компьютерной техники в России",
specialOffers: 3,
minOrder: 50000
minOrder: 50000,
},
{
id: '2',
name: 'СтройБаза Регион',
fullName: 'ИП Строительные материалы',
inn: '7735987654',
type: 'WHOLESALE',
avatar: '/placeholder-construction.jpg',
id: "2",
name: "СтройБаза Регион",
fullName: "ИП Строительные материалы",
inn: "7735987654",
type: "WHOLESALE",
avatar: "/placeholder-construction.jpg",
rating: 4.5,
reviewsCount: 1876,
productsCount: 8430,
completedOrders: 5621,
responseTime: '4 часа',
categories: ['Стройматериалы', 'Инструменты', 'Сантехника'],
location: 'Екатеринбург, Россия',
workingSince: '2015',
verifiedBadges: ['verified', 'eco-friendly'],
description: 'Надежный поставщик строительных материалов по всей России',
responseTime: "4 часа",
categories: ["Стройматериалы", "Инструменты", "Сантехника"],
location: "Екатеринбург, Россия",
workingSince: "2015",
verifiedBadges: ["verified", "eco-friendly"],
description: "Надежный поставщик строительных материалов по всей России",
specialOffers: 1,
minOrder: 30000
}
]
minOrder: 30000,
},
];
const getStatusColor = (status: string) => {
switch (status) {
case 'work': return 'bg-green-500'
case 'weekend': return 'bg-gray-400'
case 'vacation': return 'bg-blue-500'
case 'sick': return 'bg-yellow-500'
case 'absent': return 'bg-red-500'
default: return 'bg-gray-400'
case "work":
return "bg-green-500";
case "weekend":
return "bg-gray-400";
case "vacation":
return "bg-blue-500";
case "sick":
return "bg-yellow-500";
case "absent":
return "bg-red-500";
default:
return "bg-gray-400";
}
}
};
const getStatusText = (status: string) => {
switch (status) {
case 'work': return 'Работа'
case 'weekend': return 'Выходной'
case 'vacation': return 'Отпуск'
case 'sick': return 'Больничный'
case 'absent': return 'Прогул'
default: return 'Неизвестно'
case "work":
return "Работа";
case "weekend":
return "Выходной";
case "vacation":
return "Отпуск";
case "sick":
return "Больничный";
case "absent":
return "Прогул";
default:
return "Неизвестно";
}
}
};
const formatPrice = (price: number) => {
return new Intl.NumberFormat('ru-RU', {
style: 'currency',
currency: 'RUB',
minimumFractionDigits: 0
}).format(price)
}
return new Intl.NumberFormat("ru-RU", {
style: "currency",
currency: "RUB",
minimumFractionDigits: 0,
}).format(price);
};
const formatCurrency = (amount: number) => {
return new Intl.NumberFormat("ru-RU", {
style: "currency",
currency: "RUB",
minimumFractionDigits: 0,
}).format(amount)
}
}).format(amount);
};
const formatDate = (dateString: string) => {
return new Date(dateString).toLocaleDateString("ru-RU", {
day: "2-digit",
month: "2-digit",
year: "numeric",
})
}
});
};
const getStatusBadge = (status: string) => {
const statusConfig = {
@ -247,17 +273,17 @@ export function BusinessDemo() {
color: "text-purple-300 border-purple-400/30",
label: "Обрабатывается",
},
}
};
const config =
statusConfig[status as keyof typeof statusConfig] || statusConfig.planned
statusConfig[status as keyof typeof statusConfig] || statusConfig.planned;
return (
<Badge variant="outline" className={`glass-secondary ${config.color}`}>
{config.label}
</Badge>
)
}
);
};
return (
<div className="space-y-6">
@ -272,11 +298,15 @@ export function BusinessDemo() {
<div className="flex items-center space-x-3">
<Avatar className="h-10 w-10">
<AvatarImage src="/placeholder-employee.jpg" />
<AvatarFallback className="bg-purple-600 text-white">ИИ</AvatarFallback>
<AvatarFallback className="bg-purple-600 text-white">
ИИ
</AvatarFallback>
</Avatar>
<div>
<h4 className="text-white font-medium">Иванов Иван Иванович</h4>
<p className="text-white/60 text-sm">Менеджер по продажам Март 2024</p>
<p className="text-white/60 text-sm">
Менеджер по продажам Март 2024
</p>
</div>
</div>
<div className="text-right">
@ -296,21 +326,29 @@ export function BusinessDemo() {
<div>Сб</div>
<div>Вс</div>
</div>
<div className="grid grid-cols-7 gap-2">
{scheduleData.map((day, index) => (
<div
key={index}
className={`
relative p-3 rounded-lg border border-white/10 text-center transition-all hover:border-white/30
${day.status === 'work' ? 'bg-green-500/20' : ''}
${day.status === 'weekend' ? 'bg-gray-500/20' : ''}
${day.status === "work" ? "bg-green-500/20" : ""}
${day.status === "weekend" ? "bg-gray-500/20" : ""}
`}
>
<div className="text-white text-sm font-medium">{day.day}</div>
<div className={`w-2 h-2 rounded-full mx-auto mt-1 ${getStatusColor(day.status)}`}></div>
<div className="text-white text-sm font-medium">
{day.day}
</div>
<div
className={`w-2 h-2 rounded-full mx-auto mt-1 ${getStatusColor(
day.status
)}`}
></div>
{day.hours > 0 && (
<div className="text-white/60 text-xs mt-1">{day.hours}ч</div>
<div className="text-white/60 text-xs mt-1">
{day.hours}ч
</div>
)}
</div>
))}
@ -371,29 +409,44 @@ export function BusinessDemo() {
<CardContent className="space-y-6">
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{products.map((product) => (
<div key={product.id} className="glass-card p-4 rounded-lg border border-white/10 group hover:border-white/30 transition-all">
<div
key={product.id}
className="glass-card p-4 rounded-lg border border-white/10 group hover:border-white/30 transition-all"
>
{/* Изображение товара */}
<div className="relative mb-3">
<div className="w-full h-40 bg-white/10 rounded-lg flex items-center justify-center">
<Package className="h-16 w-16 text-white/40" />
</div>
{/* Бейджи */}
<div className="absolute top-2 left-2 flex flex-col gap-1">
{product.isNew && (
<Badge className="bg-green-600 text-white text-xs">Новинка</Badge>
<Badge className="bg-green-600 text-white text-xs">
Новинка
</Badge>
)}
{product.oldPrice && (
<Badge className="bg-red-600 text-white text-xs">Скидка</Badge>
<Badge className="bg-red-600 text-white text-xs">
Скидка
</Badge>
)}
</div>
{/* Кнопки действий */}
<div className="absolute top-2 right-2 flex flex-col gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
<Button size="sm" variant="outline" className="bg-white/20 hover:bg-white/30 text-white border-white/30 h-8 w-8 p-0">
<Button
size="sm"
variant="outline"
className="bg-white/20 hover:bg-white/30 text-white border-white/30 h-8 w-8 p-0"
>
<Heart className="h-3 w-3" />
</Button>
<Button size="sm" variant="outline" className="bg-white/20 hover:bg-white/30 text-white border-white/30 h-8 w-8 p-0">
<Button
size="sm"
variant="outline"
className="bg-white/20 hover:bg-white/30 text-white border-white/30 h-8 w-8 p-0"
>
<Eye className="h-3 w-3" />
</Button>
</div>
@ -402,25 +455,39 @@ export function BusinessDemo() {
{/* Информация о товаре */}
<div className="space-y-2">
<div>
<h4 className="text-white font-medium text-sm line-clamp-2">{product.name}</h4>
<p className="text-white/60 text-xs">Артикул: {product.article}</p>
<h4 className="text-white font-medium text-sm line-clamp-2">
{product.name}
</h4>
<p className="text-white/60 text-xs">
Артикул: {product.article}
</p>
</div>
{/* Рейтинг и отзывы */}
<div className="flex items-center gap-2">
<div className="flex items-center gap-1">
<Star className="h-3 w-3 fill-yellow-400 text-yellow-400" />
<span className="text-white/80 text-xs">{product.rating}</span>
<span className="text-white/80 text-xs">
{product.rating}
</span>
</div>
<span className="text-white/60 text-xs">({product.reviews} отзывов)</span>
<span className="text-white/60 text-xs">
({product.reviews} отзывов)
</span>
</div>
{/* Категория и бренд */}
<div className="flex flex-wrap gap-1">
<Badge variant="outline" className="text-xs border-white/30 text-white/70">
<Badge
variant="outline"
className="text-xs border-white/30 text-white/70"
>
{product.category}
</Badge>
<Badge variant="outline" className="text-xs border-white/30 text-white/70">
<Badge
variant="outline"
className="text-xs border-white/30 text-white/70"
>
{product.brand}
</Badge>
</div>
@ -429,17 +496,25 @@ export function BusinessDemo() {
<div className="space-y-1">
{product.price > 0 ? (
<div className="flex items-center gap-2">
<span className="text-white font-bold">{formatPrice(product.price)}</span>
<span className="text-white font-bold">
{formatPrice(product.price)}
</span>
{product.oldPrice && (
<span className="text-white/60 text-sm line-through">{formatPrice(product.oldPrice)}</span>
<span className="text-white/60 text-sm line-through">
{formatPrice(product.oldPrice)}
</span>
)}
</div>
) : (
<span className="text-red-400 font-medium">Нет в наличии</span>
<span className="text-red-400 font-medium">
Нет в наличии
</span>
)}
{product.inStock && product.quantity > 0 && (
<p className="text-green-400 text-xs">В наличии: {product.quantity} шт.</p>
<p className="text-green-400 text-xs">
В наличии: {product.quantity} шт.
</p>
)}
</div>
@ -453,21 +528,37 @@ export function BusinessDemo() {
{product.inStock && product.price > 0 ? (
<>
<div className="flex items-center border border-white/30 rounded">
<Button size="sm" variant="ghost" className="h-7 w-7 p-0 text-white hover:bg-white/20">
<Button
size="sm"
variant="ghost"
className="h-7 w-7 p-0 text-white hover:bg-white/20"
>
<Minus className="h-3 w-3" />
</Button>
<span className="px-2 text-white text-sm">{cartQuantity}</span>
<Button size="sm" variant="ghost" className="h-7 w-7 p-0 text-white hover:bg-white/20">
<span className="px-2 text-white text-sm">
{cartQuantity}
</span>
<Button
size="sm"
variant="ghost"
className="h-7 w-7 p-0 text-white hover:bg-white/20"
>
<Plus className="h-3 w-3" />
</Button>
</div>
<Button size="sm" className="flex-1 bg-purple-600 hover:bg-purple-700 text-white">
<ShoppingCart className="h-3 w-3 mr-1" />
В корзину
<Button
size="sm"
className="flex-1 bg-purple-600 hover:bg-purple-700 text-white"
>
<ShoppingCart className="h-3 w-3 mr-1" />В корзину
</Button>
</>
) : (
<Button size="sm" disabled className="w-full bg-gray-600 text-white/50">
<Button
size="sm"
disabled
className="w-full bg-gray-600 text-white/50"
>
Недоступно
</Button>
)}
@ -482,7 +573,9 @@ export function BusinessDemo() {
{/* Карточка поставки фулфилмента */}
<Card className="glass-card border-white/10">
<CardHeader>
<CardTitle className="text-white">Карточка поставки фулфилмента</CardTitle>
<CardTitle className="text-white">
Карточка поставки фулфилмента
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<Card className="glass-card p-4 hover:bg-white/10 transition-colors">
@ -641,10 +734,10 @@ export function BusinessDemo() {
{/* Ответственный сотрудник */}
<div className="col-span-1">
<p className="text-white/60 text-xs mb-1">
Ответственный
</p>
<Select defaultValue={fulfillmentSupply.responsibleEmployeeId}>
<p className="text-white/60 text-xs mb-1">Ответственный</p>
<Select
defaultValue={fulfillmentSupply.responsibleEmployeeId}
>
<SelectTrigger className="h-8 glass-input bg-white/10 border-white/20 text-white hover:bg-white/15 focus:bg-white/15 focus:ring-1 focus:ring-purple-400/50 text-xs">
<SelectValue placeholder="Выберите" />
</SelectTrigger>
@ -685,7 +778,9 @@ export function BusinessDemo() {
>
<div className="flex flex-col">
<span className="font-medium">
{partner.name || partner.fullName || "Без названия"}
{partner.name ||
partner.fullName ||
"Без названия"}
</span>
<span className="text-xs text-white/60">
Логистический партнер
@ -719,7 +814,10 @@ export function BusinessDemo() {
<CardContent className="space-y-6">
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
{wholesalers.map((wholesaler) => (
<div key={wholesaler.id} className="glass-card p-6 rounded-lg border border-white/10 hover:border-white/30 transition-all">
<div
key={wholesaler.id}
className="glass-card p-6 rounded-lg border border-white/10 hover:border-white/30 transition-all"
>
{/* Заголовок карточки */}
<div className="flex items-start gap-4 mb-4">
<Avatar className="h-16 w-16">
@ -728,27 +826,39 @@ export function BusinessDemo() {
{wholesaler.name.charAt(0)}
</AvatarFallback>
</Avatar>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 mb-1">
<h4 className="text-white font-semibold text-lg truncate">{wholesaler.name}</h4>
{wholesaler.verifiedBadges.includes('verified') && (
<Badge className="bg-green-600 text-white text-xs">Проверен</Badge>
<h4 className="text-white font-semibold text-lg truncate">
{wholesaler.name}
</h4>
{wholesaler.verifiedBadges.includes("verified") && (
<Badge className="bg-green-600 text-white text-xs">
Проверен
</Badge>
)}
{wholesaler.verifiedBadges.includes('premium') && (
<Badge className="bg-yellow-600 text-white text-xs">Premium</Badge>
{wholesaler.verifiedBadges.includes("premium") && (
<Badge className="bg-yellow-600 text-white text-xs">
Premium
</Badge>
)}
</div>
<p className="text-white/70 text-sm mb-2">{wholesaler.fullName}</p>
<p className="text-white/60 text-xs">ИНН: {wholesaler.inn}</p>
<p className="text-white/70 text-sm mb-2">
{wholesaler.fullName}
</p>
<p className="text-white/60 text-xs">
ИНН: {wholesaler.inn}
</p>
{/* Рейтинг и статистика */}
<div className="flex items-center gap-4 mt-2 text-sm">
<div className="flex items-center gap-1">
<Star className="h-4 w-4 fill-yellow-400 text-yellow-400" />
<span className="text-white">{wholesaler.rating}</span>
<span className="text-white/60">({wholesaler.reviewsCount})</span>
<span className="text-white/60">
({wholesaler.reviewsCount})
</span>
</div>
<div className="text-white/60">
{wholesaler.completedOrders} заказов
@ -769,15 +879,19 @@ export function BusinessDemo() {
<Package className="h-4 w-4 text-purple-400" />
<span className="text-white/70 text-xs">Товаров</span>
</div>
<div className="text-white font-bold">{wholesaler.productsCount.toLocaleString()}</div>
<div className="text-white font-bold">
{wholesaler.productsCount.toLocaleString()}
</div>
</div>
<div className="bg-white/5 rounded-lg p-3">
<div className="flex items-center gap-2 mb-1">
<Clock className="h-4 w-4 text-green-400" />
<span className="text-white/70 text-xs">Ответ</span>
</div>
<div className="text-white font-bold">{wholesaler.responseTime}</div>
<div className="text-white font-bold">
{wholesaler.responseTime}
</div>
</div>
</div>
@ -786,7 +900,11 @@ export function BusinessDemo() {
<p className="text-white/70 text-xs mb-2">Категории:</p>
<div className="flex flex-wrap gap-1">
{wholesaler.categories.map((category, index) => (
<Badge key={index} variant="outline" className="text-xs border-white/30 text-white/70">
<Badge
key={index}
variant="outline"
className="text-xs border-white/30 text-white/70"
>
{category}
</Badge>
))}
@ -827,10 +945,16 @@ export function BusinessDemo() {
<Eye className="h-4 w-4 mr-2" />
Смотреть товары
</Button>
<Button variant="outline" className="bg-white/10 hover:bg-white/20 text-white border-white/30">
<Button
variant="outline"
className="bg-white/10 hover:bg-white/20 text-white border-white/30"
>
<Phone className="h-4 w-4" />
</Button>
<Button variant="outline" className="bg-white/10 hover:bg-white/20 text-white border-white/30">
<Button
variant="outline"
className="bg-white/10 hover:bg-white/20 text-white border-white/30"
>
<Mail className="h-4 w-4" />
</Button>
</div>
@ -839,6 +963,9 @@ export function BusinessDemo() {
</div>
</CardContent>
</Card>
{/* Космически-галактические табели рабочего времени */}
<TimesheetDemo />
</div>
)
}
);
}