feat: update sidebar ui

This commit is contained in:
ivannoskov
2026-01-21 10:36:08 +03:00
parent 1f36a074af
commit 0af5cd7458
8 changed files with 214 additions and 160 deletions

View File

@@ -0,0 +1,5 @@
import { redirect } from "next/navigation"
export default function AnalyticsPage({ params }: { params: { workspaceId: string } }) {
redirect(`/dashboard/${params.workspaceId}/analytics/projects`)
}

View File

@@ -127,7 +127,7 @@ const getCreativeWord = (count: number): string => {
export default function CreativesPage() {
const params = useParams();
const workspaceId = params?.workspaceId as string;
const { selectedProjects, getProjectFilterId, allProjectsSelected, hasPermission } = useWorkspace();
const { selectedProjects, getProjectFilterId, allProjectsSelected, hasPermission, currentProject } = useWorkspace();
const projectFilterId = getProjectFilterId();
const [creatives, setCreatives] = useState<Creative[]>([]);
@@ -613,22 +613,25 @@ export default function CreativesPage() {
<li>Креатив автоматически отобразится на платформе</li>
</ol>
</div>
<div className="flex justify-end gap-2 pt-2">
<Button
variant="outline"
onClick={() => setShowCreateDialog(false)}
>
Понятно
</Button>
<Button
onClick={() => {
window.open(`https://t.me/${BOT_USERNAME}`, "_blank");
setShowCreateDialog(false);
}}
>
Открыть бота
</Button>
</div>
<div className="flex justify-end gap-2 pt-2">
<Button
variant="outline"
onClick={() => setShowCreateDialog(false)}
>
Понятно
</Button>
<Button
onClick={() => {
const botUrl = currentProject
? `https://t.me/${BOT_USERNAME}?start=project_${currentProject.id}_createcreative`
: `https://t.me/${BOT_USERNAME}`;
window.open(botUrl, "_blank");
setShowCreateDialog(false);
}}
>
Открыть бота
</Button>
</div>
</div>
</DialogContent>
</Dialog>

View File

@@ -342,8 +342,8 @@ export default function PurchasePlanDetailPage() {
<DashboardHeader
breadcrumbs={[
{ label: "Главная", href: `/dashboard/${workspaceId}` },
{ label: "Планы закупок", href: `/dashboard/${workspaceId}/purchase-plans` },
{ label: project?.title || "План закупок" },
{ label: "Планы закупов", href: `/dashboard/${workspaceId}/purchase-plans` },
{ label: project?.title || "План закупов" },
]}
/>
@@ -360,7 +360,7 @@ export default function PurchasePlanDetailPage() {
</Button>
<div>
<h1 className="text-2xl font-bold tracking-tight">
План закупок: {project?.title}
План закупов: {project?.title}
</h1>
<p className="text-muted-foreground">
{stats.totalChannels} каналов Планируемый бюджет:{" "}
@@ -577,7 +577,7 @@ export default function PurchasePlanDetailPage() {
<DialogHeader>
<DialogTitle>Добавить канал в план</DialogTitle>
<DialogDescription>
Выберите канал из каталога для добавления в план закупок
Выберите канал из каталога для добавления в план закупов
</DialogDescription>
</DialogHeader>
@@ -723,7 +723,7 @@ export default function PurchasePlanDetailPage() {
<AlertDialogHeader>
<AlertDialogTitle>Удалить канал из плана?</AlertDialogTitle>
<AlertDialogDescription>
Канал "{deletingChannel?.channel.title}" будет удалён из плана закупок.
Канал "{deletingChannel?.channel.title}" будет удалён из плана закупов.
Это действие нельзя отменить.
</AlertDialogDescription>
</AlertDialogHeader>

View File

@@ -116,16 +116,16 @@ export default function PurchasePlansPage() {
<DashboardHeader
breadcrumbs={[
{ label: "Главная", href: `/dashboard/${workspaceId}` },
{ label: "Планы закупок" },
{ label: "Планы закупов" },
]}
/>
<div className="flex flex-1 flex-col gap-4 p-4 pt-0 mt-4">
<div className="flex items-center justify-between">
<div>
<h1 className="text-2xl font-bold tracking-tight">Планы закупок</h1>
<h1 className="text-2xl font-bold tracking-tight">Планы закупов</h1>
<p className="text-muted-foreground">
Управление планами закупок по проектам
Управление планами закупов по проектам
</p>
</div>
</div>
@@ -140,7 +140,7 @@ export default function PurchasePlansPage() {
<ClipboardList className="h-12 w-12 text-muted-foreground mb-4" />
<h3 className="text-lg font-semibold mb-2">Нет проектов</h3>
<p className="text-muted-foreground text-center mb-4">
Добавьте проект через Telegram бота для создания плана закупок
Добавьте проект через Telegram бота для создания плана закупов
</p>
<Button asChild>
<Link href={`/dashboard/${workspaceId}/projects`}>

View File

@@ -8,6 +8,7 @@ import * as React from "react";
import { useParams } from "next/navigation";
import Link from "next/link";
import {
ArrowUpRight,
BarChart3,
BookmarkCheck,
Building2,
@@ -128,19 +129,12 @@ interface HelpItem {
action?: () => void;
}
interface SupportLink {
title: string;
icon: LucideIcon;
href: string;
external?: boolean;
}
const TRAINING_STEPS: TrainingStep[] = [
{
id: "dashboard",
title: "Главная панель",
description:
"Это стартовая точка: отсюда видно общее состояние закупок, статус проектов и свежие уведомления. Сюда возвращаемся, чтобы понять, что делать дальше и какие задачи горят.",
"Это стартовая точка: отсюда видно общее состояние закупов, статус проектов и свежие уведомления. Сюда возвращаемся, чтобы понять, что делать дальше и какие задачи горят.",
navItemTitle: "Главная",
icon: LayoutDashboard,
sections: [
@@ -509,53 +503,50 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
}, [isTrainingOpen, currentTrainingStep]);
const isTrainingVisible = isTrainingOpen && Boolean(currentTrainingStep);
const supportLinks = React.useMemo<SupportLink[]>(
const channelLink = React.useMemo<SupportLink>(
() => ({
title: "Наш канал",
href: "https://t.me/+xqHlRelJ2etkMGIy",
icon: Megaphone,
external: true,
}),
[]
);
const helpSubItems = React.useMemo<HelpItem[]>(
() => [
{
title: "Наш канал",
href: "https://t.me/+xqHlRelJ2etkMGIy",
icon: Megaphone,
external: true,
},
{
title: "Поддержка",
description: "Свяжитесь с нашей службой поддержки.",
href: "https://t.me/smartpost_help_bot",
icon: MessageCircle,
external: true,
},
{
title: "База знаний",
description: "Документация и инструкции по использованию.",
href: "https://docs.smartpost.ru",
icon: BookOpen,
external: true,
},
{
title: "Демо аккаунт",
description: "Посмотрите пример рабочего пространства.",
href: buildRoute.dashboard(DEMO_WORKSPACE_ID),
icon: Sparkles,
},
],
[]
);
const extraHelpItems = React.useMemo<HelpItem[]>(
() => [
{
title: "Демо дашборд",
description: "Посмотрите пример рабочего пространства со всеми разделами.",
href: buildRoute.dashboard(DEMO_WORKSPACE_ID),
icon: Sparkles,
},
{
title: "Открыть обучение",
description: "Запустите интерактивный тур по основным разделам.",
action: openTraining,
icon: MonitorPlay,
},
],
[openTraining]
);
const renderExtraHelpItem = React.useCallback((item: HelpItem) => {
const renderHelpSubItem = React.useCallback((item: HelpItem) => {
const content = (
<>
<item.icon className="mt-1.5 size-3 shrink-0 text-muted-foreground" />
<p className="text-xs font-light mt-1.5">{item.title}</p>
<item.icon className="mt-1.5 size-3 shrink-0 !text-muted-foreground/90" />
<p className="text-xs font-light mt-1.5 text-muted-foreground/90 flex-1">{item.title}</p>
{item.external && (
<ArrowUpRight className="mt-1.5 size-3 shrink-0 !text-muted-foreground/60" />
)}
</>
);
@@ -639,17 +630,17 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
style={expandedLogoDimensions}
>
<Image
src="/logo_full_dark.webp"
width={expandedLogoWidth}
height={expandedLogoHeight}
src="/logo_full_dark.png"
width={expandedLogoWidth*2}
height={expandedLogoHeight*2}
alt="Smartpost"
className="shrink-0 dark:hidden"
style={expandedLogoDimensions}
/>
<Image
src="/logo_full_white_2.png"
width={expandedLogoWidth}
height={expandedLogoHeight}
src="/logo_full_white.png"
width={expandedLogoWidth*2}
height={expandedLogoHeight*2}
alt="Smartpost"
className="hidden shrink-0 dark:block"
style={expandedLogoDimensions}
@@ -675,33 +666,40 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
<SidebarGroup className="px-0">
<SidebarGroupContent>
<SidebarMenu>
{supportLinks.map((link) => (
<SidebarMenuItem key={link.title}>
<SidebarMenuButton
asChild
size="sm"
tooltip={isSidebarCollapsed ? link.title : undefined}
{/* Наш канал */}
<SidebarMenuItem>
<SidebarMenuButton
asChild
size="sm"
tooltip={isSidebarCollapsed ? channelLink.title : undefined}
>
<a
href={channelLink.href}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-2"
>
{link.external ? (
<a
href={link.href}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-2"
>
<link.icon className="size-4" />
<span>{link.title}</span>
</a>
) : (
<Link href={link.href} className="flex items-center gap-2">
<link.icon className="size-4" />
<span>{link.title}</span>
</Link>
)}
</SidebarMenuButton>
</SidebarMenuItem>
))}
<channelLink.icon className="size-4 text-muted-foreground/90" />
<span className="text-muted-foreground/90">{channelLink.title}</span>
<ArrowUpRight className="ml-auto size-3.5 text-muted-foreground/60" />
</a>
</SidebarMenuButton>
</SidebarMenuItem>
{/* Обучение */}
<SidebarMenuItem>
<SidebarMenuButton
size="sm"
tooltip={isSidebarCollapsed ? "Обучение" : undefined}
onClick={openTraining}
className="cursor-pointer"
>
<MonitorPlay className="size-4 text-muted-foreground/90" />
<span className="text-muted-foreground/90">Обучение</span>
</SidebarMenuButton>
</SidebarMenuItem>
{/* Помощь с подменю */}
{isSidebarCollapsed ? (
<SidebarMenuItem>
<DropdownMenu>
@@ -712,10 +710,10 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
className="justify-between"
>
<div className="flex items-center gap-2">
<LifeBuoy className="size-4" />
<span>Помощь</span>
<LifeBuoy className="size-4 text-muted-foreground/90" />
<span className="text-muted-foreground/90">Помощь</span>
</div>
<ChevronRight className="size-4 opacity-60" />
<ChevronRight className="size-4 text-muted-foreground/60" />
</SidebarMenuButton>
</DropdownMenuTrigger>
<DropdownMenuContent
@@ -723,9 +721,9 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
align="start"
className="min-w-[280px] space-y-1"
>
{extraHelpItems.map((item) => (
{helpSubItems.map((item) => (
<DropdownMenuItem key={item.title} asChild>
{renderExtraHelpItem(item)}
{renderHelpSubItem(item)}
</DropdownMenuItem>
))}
</DropdownMenuContent>
@@ -740,18 +738,18 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
className="justify-between"
>
<div className="flex items-center gap-2">
<LifeBuoy className="size-4" />
<span>Помощь</span>
<LifeBuoy className="size-4 text-muted-foreground/90" />
<span className="text-muted-foreground/90">Помощь</span>
</div>
<ChevronRight className="size-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" />
<ChevronRight className="size-4 text-muted-foreground/60 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" />
</SidebarMenuButton>
</CollapsibleTrigger>
<CollapsibleContent>
<SidebarMenuSub>
{extraHelpItems.map((item) => (
{helpSubItems.map((item) => (
<SidebarMenuSubItem key={item.title}>
<SidebarMenuSubButton asChild className="">
{renderExtraHelpItem(item)}
{renderHelpSubItem(item)}
</SidebarMenuSubButton>
</SidebarMenuSubItem>
))}

View File

@@ -64,6 +64,9 @@ export function NavMain({
const hasActiveSubmenu =
hasSubmenu && item.items!.some((sub) => pathname === sub.url);
const shouldForceOpen = guideState?.expandedItems?.includes(item.title);
const shouldHighlightButton = item.title === "Аналитика"
? false
: isActive;
const isGuideHighlight = highlightedItem === item.title;
const highlightedButtonClass = isGuideHighlight
? "ring-2 ring-primary/70"
@@ -77,19 +80,27 @@ export function NavMain({
<DropdownMenuTrigger asChild>
<SidebarMenuButton
tooltip={item.title}
isActive={isActive || hasActiveSubmenu}
isActive={shouldHighlightButton}
className={cn(highlightedButtonClass)}
>
{item.icon && (
<item.icon
className={cn(
"h-4 w-4",
// (isActive || hasActiveSubmenu) &&
// "text-[#2B1D49] dark:text-[#5F31F4]"
"h-4 w-4 transition-colors duration-200",
shouldHighlightButton
? "text-[hsl(262_83%_65%)] drop-shadow-[0_0_8px_rgba(147_51_234_0.25)]"
: "text-muted-foreground/90"
)}
/>
)}
<span>{item.title}</span>
<span
className={cn(
"transition-colors duration-200",
shouldHighlightButton
? "text-foreground font-medium"
: "text-muted-foreground/90"
)}
>{item.title}</span>
</SidebarMenuButton>
</DropdownMenuTrigger>
<DropdownMenuContent
@@ -104,23 +115,28 @@ export function NavMain({
<Link
href={subItem.url}
className={cn(
"flex items-center gap-2",
"flex items-center gap-2 transition-colors duration-200",
isSubActive
? "bg-accent text-accent-foreground"
: ""
: "text-muted-foreground hover:text-foreground"
)}
>
{subItem.icon && (
<subItem.icon
className={cn(
"h-4 w-4",
// isSubActive &&
// "text-[#2B1D49] dark:text-[#5F31F4]"
)}
/>
)}
<span>{subItem.title}</span>
</Link>
{subItem.icon && (
<subItem.icon
className={cn(
"h-4 w-4 transition-colors duration-200",
isSubActive
? "!text-[hsl(262_83%_65%)] drop-shadow-[0_0_8px_rgba(147_51_234_0.25)]"
: "!text-muted-foreground/90"
)}
/>
)}
<span className={cn(
isSubActive
? "text-foreground font-medium"
: "text-muted-foreground/90"
)}>{subItem.title}</span>
</Link>
</DropdownMenuItem>
);
})}
@@ -144,47 +160,71 @@ export function NavMain({
{hasSubmenu ? (
<>
<CollapsibleTrigger asChild>
<SidebarMenuButton
tooltip={item.title}
isActive={isActive || hasActiveSubmenu}
className={cn(highlightedButtonClass)}
>
{item.icon && (
<item.icon
className={cn(
"h-4 w-4",
// (isActive || hasActiveSubmenu) &&
// "text-[#2B1D49] dark:text-[#5F31F4]"
)}
/>
<SidebarMenuButton
tooltip={item.title}
isActive={shouldHighlightButton}
className={cn(highlightedButtonClass)}
>
{item.icon && (
<item.icon
className={cn(
"h-4 w-4 transition-colors duration-200",
shouldHighlightButton
? "text-[hsl(262_83%_65%)] drop-shadow-[0_0_8px_rgba(147_51_234_0.25)]"
: "text-muted-foreground/90"
)}
/>
)}
<span
className={cn(
"transition-colors duration-200",
shouldHighlightButton
? "text-foreground font-medium"
: "text-muted-foreground/90"
)}
<span>{item.title}</span>
<ChevronRight className="ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" />
</SidebarMenuButton>
</CollapsibleTrigger>
>{item.title}</span>
<ChevronRight
className={cn(
"ml-auto transition-transform duration-200",
shouldHighlightButton
? "text-[hsl(262_83%_65%)]"
: "text-muted-foreground/60",
"group-data-[state=open]/collapsible:rotate-90"
)}
/>
</SidebarMenuButton>
</CollapsibleTrigger>
<CollapsibleContent>
<SidebarMenuSub>
{item.items!.map((subItem) => {
const isSubActive = pathname === subItem.url;
return (
<SidebarMenuSubItem key={subItem.title}>
<SidebarMenuSubButton
asChild
isActive={isSubActive}
>
<Link href={subItem.url} className="flex items-center gap-2">
{subItem.icon && (
<subItem.icon
<SidebarMenuSubButton
asChild
isActive={isSubActive}
>
<Link href={subItem.url} className="flex items-center gap-2">
{subItem.icon && (
<subItem.icon
className={cn(
"h-4 w-4 transition-colors duration-200",
isSubActive
? "!text-[hsl(262_83%_65%)] drop-shadow-[0_0_8px_rgba(147_51_234_0.25)]"
: "!text-muted-foreground/90"
)}
/>
)}
<span
className={cn(
"h-4 w-4",
// isSubActive &&
// "text-[#2B1D49] dark:text-[#5F31F4]"
"transition-colors duration-200",
isSubActive
? "text-foreground font-medium"
: "text-muted-foreground/90"
)}
/>
)}
<span>{subItem.title}</span>
</Link>
</SidebarMenuSubButton>
>{subItem.title}</span>
</Link>
</SidebarMenuSubButton>
</SidebarMenuSubItem>
);
})}
@@ -195,20 +235,28 @@ export function NavMain({
<SidebarMenuButton
asChild
tooltip={item.title}
isActive={isActive}
isActive={shouldHighlightButton}
className={cn(highlightedButtonClass)}
>
<Link href={item.url} className="flex items-center gap-2">
{item.icon && (
<item.icon
className={cn(
"h-4 w-4",
// isActive &&
// "text-[#2B1D49] dark:text-[#5F31F4]"
"h-4 w-4 transition-colors duration-200",
shouldHighlightButton
? "text-[hsl(262_83%_65%)] drop-shadow-[0_0_8px_rgba(147_51_234_0.25)]"
: "text-muted-foreground/90"
)}
/>
)}
<span>{item.title}</span>
<span
className={cn(
"transition-colors duration-200",
shouldHighlightButton
? "text-foreground font-medium"
: "text-muted-foreground/90"
)}
>{item.title}</span>
</Link>
</SidebarMenuButton>
)}

View File

@@ -67,7 +67,7 @@ export const buildRoute = {
`/dashboard/${workspaceId}/placements/${placementId}`,
// Analytics
analytics: (workspaceId: string) => `/dashboard/${workspaceId}/analytics/projects`,
analytics: (workspaceId: string) => `/dashboard/${workspaceId}/analytics`,
analyticsProjects: (workspaceId: string) =>
`/dashboard/${workspaceId}/analytics/projects`,
analyticsCreatives: (workspaceId: string) =>

View File

@@ -228,4 +228,4 @@ CPM — Cost Per Mile — метрика отражающая стоимость
* Отображать средний CPF в списках закупов, креативов и внешних каналов
* Отображать средний CPM в списках закупов, креативов и внешних каналов
* Отображать столбчатую диаграмму с объемом закупок с группировкой по дате (день, неделя, месяц, квартал, год) и возможностью фильтрации по целевым каналам на отдельном экране “Аналитика” → “Затраты”
* Отображать столбчатую диаграмму с объемом закупов с группировкой по дате (день, неделя, месяц, квартал, год) и возможностью фильтрации по целевым каналам на отдельном экране “Аналитика” → “Затраты”