From 7dfee09361a7c38d2e996cac28a67e3e704fd469 Mon Sep 17 00:00:00 2001 From: VividTruthKeeper Date: Fri, 19 Aug 2022 23:17:50 +0500 Subject: [PATCH] api fetch type fixed --- src/components/global/VideoPlayer.tsx | 6 ++++-- src/components/main/CalendarSection.tsx | 22 +++++++++++++++------- src/pages/AboutUs.tsx | 15 ++++++++++++--- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/components/global/VideoPlayer.tsx b/src/components/global/VideoPlayer.tsx index 2d834b8..37b1ada 100644 --- a/src/components/global/VideoPlayer.tsx +++ b/src/components/global/VideoPlayer.tsx @@ -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 (
{ const [video, setVideo]: playerType = useState(""); - const [videoData, setVideoData]: any = useState(); + const [videoData, setVideoData]: [Video[], React.Dispatch] = + 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 (
@@ -52,7 +60,7 @@ const CalendarSection = () => { slidesPerView={widthBounds ? 2 : 3} loop={false} > - {videoData + {videoData[0].id !== -1 ? videoData.map((vid: any) => { return ( diff --git a/src/pages/AboutUs.tsx b/src/pages/AboutUs.tsx index 2d7cc97..7a3470d 100644 --- a/src/pages/AboutUs.tsx +++ b/src/pages/AboutUs.tsx @@ -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] = useState(); - const [video, setVideo]: [any, React.Dispatch] = useState(); + const [video, setVideo]: [Video[], React.Dispatch] = 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 = () => {
- {video ? ( + {video[0].id !== -1 ? ( ) : (