'use client'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import styles from './Navigation.module.css'; import Image from 'next/image'; import { useEffect, useState } from 'react'; import { usePlayerStore } from '@/store/player.state'; import { useTasksStore } from '@/store/tasks.state'; import { ProvidersProps } from '@/components/providers/Providers'; const Navigation = ({ id }: Pick) => { const pathname = usePathname(); const { player } = usePlayerStore(); const [isLoading, setIsLoading] = useState(true); const { tasks } = useTasksStore(); const countTasks = tasks.length - (player?.attributes.finished_tasks.data?.length || 0); useEffect(() => { if (isLoading) { setIsLoading(false); } }, [isLoading]); const getNavLink = (endpoint: string) => { return `/${id}/${endpoint}`; }; return (
{pathname === '/' ? ( {'pickaxe-icon'} ) : ( {'pickaxe-icon'} )} Главная
{pathname === '/shop' ? ( {'shop-icon'} ) : ( {'shop-icon'} )} Магазин
{countTasks !== 0 &&
{countTasks}
}
{pathname === '/tasks' ? ( {'task-list-icon'} ) : ( {'task-list-icon'} )} Задания
{pathname === '/friends' ? ( {'friends-icon'} ) : ( {'friends-icon'} )} Друзья
); }; export default Navigation;