This commit is contained in:
VividTruthKeeper 2023-03-07 15:46:59 +05:00
commit a0ff63c035
2 changed files with 53 additions and 36 deletions

View File

@ -1,19 +1,19 @@
// Modules
import { v4 as uuidv4 } from "uuid";
import { useState, useEffect } from "react";
import { url } from "../../url";
import { Api } from "../../api/Api";
import { asideParams } from "../../api/params";
import { v4 as uuidv4 } from 'uuid';
import { useState, useEffect } from 'react';
import { url } from '../../url';
import { Api } from '../../api/Api';
import { asideParams } from '../../api/params';
// Components
import SectionTitle from "../global/SectionTitle";
import AsideNews from "./AsideNews";
import Calendar from "./Calendar";
import { IPostsData } from "../../types/data.types";
import Loader from "../global/Loader";
import SectionTitle from '../global/SectionTitle';
import AsideNews from './AsideNews';
import Calendar from './Calendar';
import { IPostsData } from '../../types/data.types';
import Loader from '../global/Loader';
interface Props {
type: "latest" | "popular";
type: 'latest' | 'popular';
}
interface IData {
@ -21,10 +21,8 @@ interface IData {
}
const Aside = ({ type }: Props) => {
const api = new Api(
url + `${type === "popular" ? "/popular" : ""}/posts`,
asideParams
);
const api = new Api(url + `${type === 'popular' ? '/popular' : ''}/posts`, asideParams);
const language = api.language;
const [data, setData] = useState<IData>();
@ -36,10 +34,26 @@ const Aside = ({ type }: Props) => {
<div className="aside">
<div className="aside-wrapper">
<SectionTitle
title={type === "latest" ? "Последние новости" : "Самое читаемое"}
title={
type === 'latest'
? `${
language === 'EN'
? 'Latest news'
: language === 'RU'
? 'Последние новости'
: 'Soňky habarlar'
}`
: `${
language === 'EN'
? 'Most read'
: language === 'RU'
? 'Самое читаемое'
: 'Köp okalýar'
}`
}
/>
<div className="aside-inner">
{type === "popular" ? (
{type === 'popular' ? (
data ? (
(data as any).data.map((el: any) => {
return (

View File

@ -1,29 +1,27 @@
// Modules
import { useEffect, useState } from "react";
import { v4 as uuiv4 } from "uuid";
import { useSelector, useDispatch } from "react-redux";
import { useEffect, useState } from 'react';
import { v4 as uuiv4 } from 'uuid';
import { useSelector, useDispatch } from 'react-redux';
// Components
import SectionTitle from "../global/SectionTitle";
import VideosItem from "./VideosItem";
import SectionTitle from '../global/SectionTitle';
import VideosItem from './VideosItem';
// Types
import { RootState } from "../../types/store.types";
import { RootState } from '../../types/store.types';
// Api
import { Api } from "../../api/Api";
import { url } from "../../url";
import { videoParams } from "../../api/params";
import { Api } from '../../api/Api';
import { url } from '../../url';
import { videoParams } from '../../api/params';
// Actions
import { setVideo } from "../../actions/setData";
import Loader from "../global/Loader";
import { setVideo } from '../../actions/setData';
import Loader from '../global/Loader';
const Videos = () => {
const data = useSelector<RootState, RootState["video"]["data"]>(
(state) => state.video.data
);
const api = new Api(url + "/pagination/posts", videoParams);
const data = useSelector<RootState, RootState['video']['data']>((state) => state.video.data);
const api = new Api(url + '/pagination/posts', videoParams);
const language = api.language;
const dispatch = useDispatch();
const [lastLanguage, setLastLanguage] = useState<typeof language>(language);
@ -38,9 +36,14 @@ const Videos = () => {
<section className="videos">
<div className="videos-inner">
<SectionTitle
title="Видео"
givenClass="videos"
linkData={{ link: "/all?type=video", title: "Посмотреть все" }}
title={language === 'EN' ? 'Videos' : language === 'RU' ? 'Видео' : 'Videolar'}
linkData={{
link: '/all',
title: `${
language === 'EN' ? 'View all' : language === 'RU' ? 'Посмотреть все' : 'Doly gör'
}`,
}}
/>
<div className="videos-items">
{data.status_code > 0 ? (
@ -49,11 +52,11 @@ const Videos = () => {
return (
<VideosItem
key={uuiv4()}
url={videosDataItem.video || ""}
url={videosDataItem.video || ''}
placeholder={
videosDataItem.featured_images[0]
? videosDataItem.featured_images[0].path
: ""
: ''
}
date={videosDataItem.published_at}
excerpt={videosDataItem.excerpt}