This commit is contained in:
Kakabay 2023-02-14 14:27:50 +05:00
parent ac3baf77a1
commit 54c26806b3
1 changed files with 18 additions and 18 deletions

View File

@ -1,30 +1,30 @@
// Modules
import { useLocation } from "react-router-dom";
import { v4 as uuidv4 } from "uuid";
import { useDispatch, useSelector } from "react-redux";
import { useEffect, useState } from "react";
import { useLocation } from 'react-router-dom';
import { v4 as uuidv4 } from 'uuid';
import { useDispatch, useSelector } from 'react-redux';
import { useEffect, useState } from 'react';
// Types
import { RootState } from "../../types/store.types";
import { ICategoriesData } from "../../types/data.types";
import { RootState } from '../../types/store.types';
import { ICategoriesData } from '../../types/data.types';
// Actions
import { setActiveLink } from "../../actions/setActiveLink.action";
import { setActiveLink } from '../../actions/setActiveLink.action';
// Api
import { Api } from "../../api/Api";
import { url } from "../../url";
import { Api } from '../../api/Api';
import { url } from '../../url';
// Components
import Loader from "../global/Loader";
import SubNavLi from "./SubNavLi";
import Loader from '../global/Loader';
import SubNavLi from './SubNavLi';
const SubNav = () => {
const activeLink = useSelector<RootState, RootState["activeLink"]["active"]>(
(state) => state.activeLink.active
const activeLink = useSelector<RootState, RootState['activeLink']['active']>(
(state) => state.activeLink.active,
);
const language = useSelector<RootState, RootState["language"]["title"]>(
(state) => state.language.title
const language = useSelector<RootState, RootState['language']['title']>(
(state) => state.language.title,
);
const dispatch = useDispatch();
@ -36,7 +36,7 @@ const SubNav = () => {
const [data, setData] = useState<ICategoriesData>();
// Api
const api = new Api(url + "/categories");
const api = new Api(url + '/categories');
useEffect(() => {
api.get(data, setData);
@ -44,7 +44,7 @@ const SubNav = () => {
const location = useLocation();
useEffect(() => {
if (!location.pathname.includes("category")) return;
if (!location.pathname.includes('category')) return;
const category = location.pathname[location.pathname.length - 1];
onClickLink(parseInt(category));
}, [location]);
@ -57,7 +57,7 @@ const SubNav = () => {
<>
<SubNavLi
isNotCategory
dataEl={{ id: 0, name: "Главная" }}
dataEl={{ id: 0, name: 'Главная' }}
activeLink={activeLink}
onClickLink={onClickLink}
/>