creating my polls page
This commit is contained in:
parent
28882e7038
commit
08b22b07c6
16 changed files with 266 additions and 24 deletions
|
|
@ -4,22 +4,28 @@ import styles from './Navigation.module.css'
|
|||
import NavigationItem from "../NavigationItem/NavigationItem.tsx";
|
||||
import SaveButton from "../SaveButton/SaveButton.tsx";
|
||||
|
||||
|
||||
const Navigation: React.FC = () => {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const activePage = location.pathname.split('/').pop() || 'questions'
|
||||
const isSurveyPage = /\/survey\/[^/]+/.test(location.pathname);
|
||||
const isNotCreateSurvey = !location.pathname.includes('/survey/create');
|
||||
const isMySurveysPage = isSurveyPage && isNotCreateSurvey;
|
||||
|
||||
const items = [
|
||||
const activePage = location.pathname.split('/').pop() ?? 'questions';
|
||||
|
||||
const baseItems = [
|
||||
{id: 'questions', title: 'Вопросы'},
|
||||
{id: 'settings', title: 'Настройки'},
|
||||
{id: 'results', title: 'Результаты'}
|
||||
]
|
||||
{id: 'settings', title: 'Настройки'}
|
||||
];
|
||||
|
||||
const handleNavigationClick = (padeId: string) => {
|
||||
navigate(`${padeId}`);
|
||||
}
|
||||
const items = isMySurveysPage
|
||||
? [...baseItems, {id: 'results', title: 'Результаты'}]
|
||||
: baseItems;
|
||||
|
||||
const handleNavigationClick = (pageId: string) => {
|
||||
navigate(`${pageId}`, { relative: 'path' });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.navContainer}>
|
||||
|
|
@ -35,7 +41,6 @@ const Navigation: React.FC = () => {
|
|||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<SaveButton />
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue