diff --git a/src/components/aside/Calendar.tsx b/src/components/aside/Calendar.tsx index 2272d24..d689b70 100644 --- a/src/components/aside/Calendar.tsx +++ b/src/components/aside/Calendar.tsx @@ -1,74 +1,67 @@ // Modules -import { useState, useEffect, useCallback, useRef, useMemo } from 'react'; -import { Calendar as ReactCalendar } from 'react-calendar'; -import { LazyLoadComponent } from 'react-lazy-load-image-component'; -import { v4 as uuiv4 } from 'uuid'; +import { useState, useEffect, useCallback, useMemo } from "react"; +import { Calendar as ReactCalendar } from "react-calendar"; +import { LazyLoadComponent } from "react-lazy-load-image-component"; +import { v4 as uuiv4 } from "uuid"; // -import { Api } from '../../api/Api'; -import { url } from '../../url'; -import { IPostData } from '../../types/store.types'; -import Loader from '../global/Loader'; +import { Api } from "../../api/Api"; +import { url } from "../../url"; +import { IPostData } from "../../types/store.types"; +import Loader from "../global/Loader"; +import { Link } from "react-router-dom"; const Calendar = () => { const [value, onChange] = useState(new Date()); const [data, setData] = useState(); - const [popup, setPopup] = useState(false); - const ref = useRef(false); const valueMemo = useMemo(() => ({ value, onChange }), [value, onChange]); const dataMemo = useMemo(() => ({ data, setData }), [data, setData]); const constructDateParam = useCallback(() => { return `${value.getFullYear()}-${ - value.getDate().toString().length < 2 ? '0' + value.getDate() : value.getDate() + value.getDate().toString().length < 2 + ? "0" + value.getDate() + : value.getDate() }-${ (value.getMonth() + 1).toString().length < 2 - ? '0' + (value.getMonth() + 1) + ? "0" + (value.getMonth() + 1) : value.getMonth() + 1 }`; }, [valueMemo.value]); - const api = new Api(url + `/posts`, [{ name: 'date', value: constructDateParam() }]); + const api = new Api(url + `/posts`, [ + { name: "date", value: constructDateParam() }, + ]); useEffect(() => { - if (!ref.current) { - ref.current = true; - console.log(dataMemo.data); - setPopup(false); - return; - } api.get(dataMemo.data, dataMemo.setData); - setPopup(true); }, [value]); return (
- {popup ? ( -
- {data ? ( - // data.map((el: any, index: number) => ( - //
- //

{el.title}

- //
- // )) - data[0] ? ( -
-

{data[0].title}

-
- ) : ( -
-

Нет событий

-
- ) - ) : ( - - )} -
- ) : null} +
+ {data ? ( + data[0] ? ( + +

{data[0].title}

+ + ) : ( +
+

Нет событий

+
+ ) + ) : ( + + )} +
); }; diff --git a/src/components/global/CustomNewsScroll.tsx b/src/components/global/CustomNewsScroll.tsx index 9a2f1bb..07c2407 100644 --- a/src/components/global/CustomNewsScroll.tsx +++ b/src/components/global/CustomNewsScroll.tsx @@ -1,5 +1,4 @@ // Modules -import { SetStateAction } from "react"; import { v4 as uuidv4 } from "uuid"; // Components @@ -8,6 +7,7 @@ import Pagination from "./Pagination"; // Types import { INewPostsData } from "../../types/posts.types"; +import Loader from "./Loader"; interface IProps { data: INewPostsData; @@ -27,11 +27,12 @@ const CustomNewsScroll = ({ pageMemo, avoidFirst, }: IProps) => { + console.log(data); return (
- {data?.data[0].id > -1 ? ( + {data ? ( data.data.map((dataEl, index) => { if (avoidFirst) { if (index > 0) { @@ -68,7 +69,7 @@ const CustomNewsScroll = ({ )}
{pagination ? ( - data?.data[0].id > -1 ? ( + data ? (