api fetch type fixed
This commit is contained in:
parent
f63c820cab
commit
7dfee09361
|
|
@ -6,9 +6,11 @@ import { hosting } from "../../links";
|
|||
import PlayIcon from "./PlayIcon";
|
||||
|
||||
// Types
|
||||
import { playerInterface } from "../../types/players";
|
||||
interface Props {
|
||||
videoUrl: string;
|
||||
}
|
||||
|
||||
const VideoPlayer = ({ videoUrl }: playerInterface) => {
|
||||
const VideoPlayer = ({ videoUrl }: Props) => {
|
||||
return (
|
||||
<div className="player">
|
||||
<ReactPlayer
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// Modules
|
||||
import { useState, useEffect } from "react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Swiper, SwiperSlide } from "swiper/react";
|
||||
import "swiper/css";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
|
@ -11,6 +11,7 @@ import Calendar from "../global/Calendar";
|
|||
|
||||
// Types
|
||||
import { playerType } from "../../types/players";
|
||||
import { Video } from "../../types/video";
|
||||
|
||||
// Helpers
|
||||
import { getVideos } from "../../helpers/apiRequests";
|
||||
|
|
@ -22,14 +23,21 @@ import useMediaQuery from "../../hooks/useMediaQuery";
|
|||
|
||||
const CalendarSection = () => {
|
||||
const [video, setVideo]: playerType = useState("");
|
||||
const [videoData, setVideoData]: any = useState();
|
||||
const [videoData, setVideoData]: [Video[], React.Dispatch<Video[]>] =
|
||||
useState([
|
||||
{
|
||||
id: -1,
|
||||
video: "",
|
||||
poster: "",
|
||||
},
|
||||
]);
|
||||
|
||||
const widthBounds: boolean = useMediaQuery("(max-width: 750px)");
|
||||
|
||||
useEffect(() => {
|
||||
getVideos((res: any) => {
|
||||
setVideoData(res);
|
||||
setVideo(res[0].video);
|
||||
});
|
||||
getVideos(setVideoData, setVideo);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<section className="calendars-outer">
|
||||
<div className="container">
|
||||
|
|
@ -52,7 +60,7 @@ const CalendarSection = () => {
|
|||
slidesPerView={widthBounds ? 2 : 3}
|
||||
loop={false}
|
||||
>
|
||||
{videoData
|
||||
{videoData[0].id !== -1
|
||||
? videoData.map((vid: any) => {
|
||||
return (
|
||||
<SwiperSlide key={uuidv4()}>
|
||||
|
|
|
|||
|
|
@ -16,16 +16,25 @@ import VideoPlayer from "../components/global/VideoPlayer";
|
|||
import SectionTitle from "../components/global/SectionTitle";
|
||||
import TeamSlider from "../components/about_us/TeamSlider";
|
||||
|
||||
// Types
|
||||
import { Video } from "../types/video";
|
||||
|
||||
const AboutUs = () => {
|
||||
const [about, setAbout]: [any, React.Dispatch<any>] = useState();
|
||||
const [video, setVideo]: [any, React.Dispatch<any>] = useState();
|
||||
const [video, setVideo]: [Video[], React.Dispatch<Video[]>] = useState([
|
||||
{
|
||||
id: -1,
|
||||
video: "",
|
||||
poster: "",
|
||||
},
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
window.scrollTo(0, 0);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
getAbout(setAbout);
|
||||
getVideos(setVideo);
|
||||
getVideos(setVideo, () => null);
|
||||
}, []);
|
||||
|
||||
const breakpoint = useMediaQuery("(max-width: 500px)");
|
||||
|
|
@ -158,7 +167,7 @@ const AboutUs = () => {
|
|||
</div>
|
||||
<div className="about-us-video">
|
||||
<SectionTitle title="Вводный видео ролик" />
|
||||
{video ? (
|
||||
{video[0].id !== -1 ? (
|
||||
<VideoPlayer videoUrl={video[0].video} />
|
||||
) : (
|
||||
<Skeleton highlightColor={highlightColor} height={"40rem"} />
|
||||
|
|
|
|||
Loading…
Reference in New Issue