Videos count changed

This commit is contained in:
Kakabay 2023-03-13 16:20:45 +05:00
parent 61eb48f45d
commit 64556cf5d6
1 changed files with 20 additions and 32 deletions

View File

@ -1,31 +1,29 @@
// 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';
import { dateParse } from "../../helpers/dateParser";
import { dateParse } from '../../helpers/dateParser';
// 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/new/posts", videoParams);
const data = useSelector<RootState, RootState['video']['data']>((state) => state.video.data);
const api = new Api(url + '/pagination/new/posts', videoParams);
const language = api.language;
const dispatch = useDispatch();
const [lastLanguage, setLastLanguage] = useState<typeof language>(language);
@ -41,36 +39,26 @@ const Videos = () => {
<div className="videos-inner">
<SectionTitle
givenClass="videos"
title={
language === "EN"
? "Videos"
: language === "RU"
? "Видео"
: "Videolar"
}
title={language === 'EN' ? 'Videos' : language === 'RU' ? 'Видео' : 'Videolar'}
linkData={{
link: "/all?type=video",
link: '/all?type=video',
title: `${
language === "EN"
? "View all"
: language === "RU"
? "Посмотреть все"
: "Doly gör"
language === 'EN' ? 'View all' : language === 'RU' ? 'Посмотреть все' : 'Doly gör'
}`,
}}
/>
<div className="videos-items">
{data.data[0].id > -1 ? (
data.data.map((videosDataItem, index) => {
if (index <= 4) {
if (index <= 3) {
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}