
• Полная миграция 64 компонентов с useAuth на AuthContext • Исправлена race condition в SMS регистрации • Улучшена SSR совместимость с таймаутами • Удалена дублирующая система регистрации • Обновлена документация архитектуры аутентификации Технические изменения: - AuthContext.tsx: централизованная система состояния - auth-flow.tsx: убрана агрессивная логика logout - confirmation-step.tsx: исправлена передача телефона - page.tsx: добавлена синхронизация состояния - 64 файла: миграция useAuth → useAuthContext 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
97 lines
3.7 KiB
TypeScript
97 lines
3.7 KiB
TypeScript
'use client'
|
||
|
||
import { Building2, Phone } from 'lucide-react'
|
||
import { useRouter } from 'next/navigation'
|
||
import { useEffect } from 'react'
|
||
|
||
import { Card } from '@/components/ui/card'
|
||
import { useAuthContext } from '@/contexts/AuthContext'
|
||
import { useSidebar } from '@/hooks/useSidebar'
|
||
|
||
import { Sidebar } from './sidebar'
|
||
|
||
export function DashboardHome() {
|
||
const { user } = useAuthContext()
|
||
const { getSidebarMargin } = useSidebar()
|
||
const router = useRouter()
|
||
|
||
// Перенаправляем в зависимости от типа организации
|
||
useEffect(() => {
|
||
if (user?.organization?.type) {
|
||
switch (user.organization.type) {
|
||
case 'LOGIST':
|
||
router.replace('/logistics/home')
|
||
break
|
||
case 'SELLER':
|
||
router.replace('/seller/home')
|
||
break
|
||
case 'FULFILLMENT':
|
||
router.replace('/fulfillment/home')
|
||
break
|
||
case 'WHOLESALE':
|
||
router.replace('/wholesale/home')
|
||
break
|
||
}
|
||
}
|
||
}, [user, router])
|
||
|
||
const getOrganizationName = () => {
|
||
if (user?.organization?.name) {
|
||
return user.organization.name
|
||
}
|
||
if (user?.organization?.fullName) {
|
||
return user.organization.fullName
|
||
}
|
||
return 'Вашей организации'
|
||
}
|
||
|
||
return (
|
||
<div className="h-screen flex overflow-hidden">
|
||
<Sidebar />
|
||
<main className={`flex-1 ${getSidebarMargin()} px-6 py-4 overflow-hidden transition-all duration-300`}>
|
||
<div className="p-8">
|
||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||
{/* Информация об организации */}
|
||
<Card className="bg-white/10 backdrop-blur border-white/20 p-6">
|
||
<div className="flex items-center space-x-3 mb-4">
|
||
<Building2 className="h-8 w-8 text-purple-400" />
|
||
<h3 className="text-xl font-semibold text-white">Организация</h3>
|
||
</div>
|
||
<div className="space-y-2">
|
||
<p className="text-white font-medium">{getOrganizationName()}</p>
|
||
{user?.organization?.inn && <p className="text-white/60 text-sm">ИНН: {user.organization.inn}</p>}
|
||
</div>
|
||
</Card>
|
||
|
||
{/* Контактная информация */}
|
||
<Card className="bg-white/10 backdrop-blur border-white/20 p-6">
|
||
<div className="flex items-center space-x-3 mb-4">
|
||
<Phone className="h-8 w-8 text-green-400" />
|
||
<h3 className="text-xl font-semibold text-white">Контакты</h3>
|
||
</div>
|
||
<div className="space-y-2">
|
||
<p className="text-white font-medium">+{user?.phone}</p>
|
||
<p className="text-white/60 text-sm">Основной номер</p>
|
||
</div>
|
||
</Card>
|
||
|
||
{/* Статистика или дополнительная информация */}
|
||
<Card className="bg-white/10 backdrop-blur border-white/20 p-6">
|
||
<div className="flex items-center space-x-3 mb-4">
|
||
<div className="h-8 w-8 bg-blue-500 rounded-full flex items-center justify-center">
|
||
<span className="text-white text-sm font-bold">SF</span>
|
||
</div>
|
||
<h3 className="text-xl font-semibold text-white">SferaV</h3>
|
||
</div>
|
||
<div className="space-y-2">
|
||
<p className="text-white font-medium">Система управления бизнесом</p>
|
||
<p className="text-white/60 text-sm">Версия 1.0</p>
|
||
</div>
|
||
</Card>
|
||
</div>
|
||
</div>
|
||
</main>
|
||
</div>
|
||
)
|
||
}
|