Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import { FC, useMemo } from 'react';
import { FC, useEffect, useMemo, useState } from 'react';
import { HeaderLayout } from '@/layouts/HeaderLayout';
import { Props } from './Header.props';
import style from './Header.module.css';
Expand All @@ -18,10 +18,17 @@ import { useLogout } from '@/hooks/auth/useLogout';

export const Header: FC<Props> = ({ activePath, className, ...props }) => {
const activeNextPathName = usePathname();
const [isNavigating, setIsNavigating] = useState(false);

activePath = activePath === undefined ? activeNextPathName : activePath;
const { data: userData } = useGetUserMe();
const { logout } = useLogout();

useEffect(() => {
// как только роут сменился — считаем, что навигация завершена
setIsNavigating(false);
}, [activeNextPathName]);

const visibleLinks = useMemo(() => {
const isAdmin = userData?.role === Role.Admin;
return Links.filter((link) => {
Expand Down Expand Up @@ -49,6 +56,13 @@ export const Header: FC<Props> = ({ activePath, className, ...props }) => {
<Link
key={link.direction}
href={link.direction}
onClick={(event) => {
if (activePath === link.direction || isNavigating) {
event.preventDefault();
return;
}
setIsNavigating(true);
}}
className={cn(
style.link,
activePath === link.direction ? style.linkActive : style.linkHover,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ export const ScriptElement: FC<Props> = ({
href={`/script/${id}`}
className={cn(className, styles.scriptElement, basicStyles.layout)}
{...props}>
<div className={styles.scriptElement__supblock}>
<h2 className={styles.scriptElement__title}>{name}</h2>
</div>

<h2 className={styles.scriptElement__title}>{name}</h2>
<h3 className={styles.scriptElement__subtitle}>{desc || ''}</h3>
<div className={styles.scriptElement__info}>
<TextWithIcon icon={<PersonIcon />} className={styles.scriptElement__author}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
z-index: 11;
overflow-y: auto;
max-height: 80%;
max-width: 70%;
scrollbar-color: var(--color-gray-light2) transparent;
scrollbar-width: thin;

Expand Down Expand Up @@ -212,13 +213,14 @@
padding: 1rem;
background: var(--color-white-main);
border: 1px solid var(--color-gray-border);
white-space: pre-line;
white-space: pre;
font-family: Consolas, monospace;
font-weight: 400;
font-size: 0.875rem;
line-height: 1.25rem;
color: var(--color-gray-code);
margin: 0;
overflow-x: auto;
}

.errorSection {
Expand Down