excerpt -> title
This commit is contained in:
parent
a0ff63c035
commit
bcf44ee7ea
|
|
@ -1,27 +1,29 @@
|
||||||
// Modules
|
// Modules
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from "react";
|
||||||
import { v4 as uuiv4 } from 'uuid';
|
import { v4 as uuiv4 } from "uuid";
|
||||||
import { useSelector, useDispatch } from 'react-redux';
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import SectionTitle from '../global/SectionTitle';
|
import SectionTitle from "../global/SectionTitle";
|
||||||
import VideosItem from './VideosItem';
|
import VideosItem from "./VideosItem";
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { RootState } from '../../types/store.types';
|
import { RootState } from "../../types/store.types";
|
||||||
|
|
||||||
// Api
|
// Api
|
||||||
import { Api } from '../../api/Api';
|
import { Api } from "../../api/Api";
|
||||||
import { url } from '../../url';
|
import { url } from "../../url";
|
||||||
import { videoParams } from '../../api/params';
|
import { videoParams } from "../../api/params";
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
import { setVideo } from '../../actions/setData';
|
import { setVideo } from "../../actions/setData";
|
||||||
import Loader from '../global/Loader';
|
import Loader from "../global/Loader";
|
||||||
|
|
||||||
const Videos = () => {
|
const Videos = () => {
|
||||||
const data = useSelector<RootState, RootState['video']['data']>((state) => state.video.data);
|
const data = useSelector<RootState, RootState["video"]["data"]>(
|
||||||
const api = new Api(url + '/pagination/posts', videoParams);
|
(state) => state.video.data
|
||||||
|
);
|
||||||
|
const api = new Api(url + "/pagination/posts", videoParams);
|
||||||
const language = api.language;
|
const language = api.language;
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [lastLanguage, setLastLanguage] = useState<typeof language>(language);
|
const [lastLanguage, setLastLanguage] = useState<typeof language>(language);
|
||||||
|
|
@ -37,11 +39,21 @@ const Videos = () => {
|
||||||
<div className="videos-inner">
|
<div className="videos-inner">
|
||||||
<SectionTitle
|
<SectionTitle
|
||||||
givenClass="videos"
|
givenClass="videos"
|
||||||
title={language === 'EN' ? 'Videos' : language === 'RU' ? 'Видео' : 'Videolar'}
|
title={
|
||||||
|
language === "EN"
|
||||||
|
? "Videos"
|
||||||
|
: language === "RU"
|
||||||
|
? "Видео"
|
||||||
|
: "Videolar"
|
||||||
|
}
|
||||||
linkData={{
|
linkData={{
|
||||||
link: '/all',
|
link: "/all",
|
||||||
title: `${
|
title: `${
|
||||||
language === 'EN' ? 'View all' : language === 'RU' ? 'Посмотреть все' : 'Doly gör'
|
language === "EN"
|
||||||
|
? "View all"
|
||||||
|
: language === "RU"
|
||||||
|
? "Посмотреть все"
|
||||||
|
: "Doly gör"
|
||||||
}`,
|
}`,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
@ -52,14 +64,14 @@ const Videos = () => {
|
||||||
return (
|
return (
|
||||||
<VideosItem
|
<VideosItem
|
||||||
key={uuiv4()}
|
key={uuiv4()}
|
||||||
url={videosDataItem.video || ''}
|
url={videosDataItem.video || ""}
|
||||||
placeholder={
|
placeholder={
|
||||||
videosDataItem.featured_images[0]
|
videosDataItem.featured_images[0]
|
||||||
? videosDataItem.featured_images[0].path
|
? videosDataItem.featured_images[0].path
|
||||||
: ''
|
: ""
|
||||||
}
|
}
|
||||||
date={videosDataItem.published_at}
|
date={videosDataItem.published_at}
|
||||||
excerpt={videosDataItem.excerpt}
|
title={videosDataItem.title}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,26 @@
|
||||||
// Modules
|
// Modules
|
||||||
import ReactPlayer from 'react-player';
|
import ReactPlayer from "react-player";
|
||||||
import { LazyLoadComponent } from 'react-lazy-load-image-component';
|
import { LazyLoadComponent } from "react-lazy-load-image-component";
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { videosDataType } from '../../types/videos.types';
|
import { videosDataType } from "../../types/videos.types";
|
||||||
|
|
||||||
const VideosItem = ({ url, placeholder, date, excerpt }: videosDataType) => {
|
const VideosItem = ({ url, placeholder, date, title }: videosDataType) => {
|
||||||
return (
|
return (
|
||||||
<div className="videos-item">
|
<div className="videos-item">
|
||||||
<LazyLoadComponent useIntersectionObserver>
|
<LazyLoadComponent useIntersectionObserver>
|
||||||
<div className="videos-item-video">
|
<div className="videos-item-video">
|
||||||
<ReactPlayer url={url} controls light={placeholder} width="100%" height="100%" />
|
<ReactPlayer
|
||||||
|
url={url}
|
||||||
|
controls
|
||||||
|
light={placeholder}
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="videos-item-data">
|
<div className="videos-item-data">
|
||||||
<span>{date}</span>
|
<span>{date}</span>
|
||||||
<p>{excerpt}</p>
|
<p>{title}</p>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoadComponent>
|
</LazyLoadComponent>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@ export interface videosDataType {
|
||||||
url: string;
|
url: string;
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
date: string;
|
date: string;
|
||||||
excerpt: string;
|
title: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue