diff --git a/src/Component/Comments/Comments.tsx b/src/Component/Comments/Comments.tsx index a511a48..e863014 100644 --- a/src/Component/Comments/Comments.tsx +++ b/src/Component/Comments/Comments.tsx @@ -2,7 +2,7 @@ import "./_comments.scss" import {Comment} from "../Comment/Comment.tsx"; import {Form} from "react-bootstrap"; import {useAppDispatch , useAppSelector} from "../../redux/store.ts"; -import {useEffect , useState} from "react"; +import {FormEvent , useEffect , useState} from "react"; import {GetCommentsThunk , postCommentsThunk} from "../../redux/commentSlice.ts"; @@ -33,7 +33,7 @@ export function Comments({videoId, totalComments} : CommentsProps){ (comment) => comment.snippet.topLevelComment.snippet ) - function handleSubmit(e){ + function handleSubmit(e : FormEvent){ e.preventDefault() setCommentText(commentText) if(commentText.length == 0) return diff --git a/src/Component/Header/header.tsx b/src/Component/Header/header.tsx index 7664b77..70a8cef 100644 --- a/src/Component/Header/header.tsx +++ b/src/Component/Header/header.tsx @@ -4,11 +4,15 @@ import {AiOutlineSearch} from "react-icons/ai"; import {MdApps , MdNotifications} from "react-icons/md"; import ytLogo from "../../public/Youtube_logo.png" import "./_header.scss" -import { useState} from "react"; +import {FormEvent , useState} from "react"; import {useNavigate} from "react-router-dom"; import { useAppSelector} from "../../redux/store.ts"; -export function Header({handleToggleSidebar}){ +type HeaderProps = { + handleToggleSidebar : () => void +} + +export function Header({handleToggleSidebar} : HeaderProps){ const [input, setInput] = useState("") const navigate= useNavigate() @@ -16,7 +20,7 @@ export function Header({handleToggleSidebar}){ const { user } = useAppSelector(state => state.auth) - function handleSubmit(e){ + function handleSubmit(e : FormEvent){ e.preventDefault() setInput(input) if(input.trim() !== "") navigate(`search/${input}`) diff --git a/src/Component/Sidebar/sidebar.tsx b/src/Component/Sidebar/sidebar.tsx index 093ca7a..cf427ff 100644 --- a/src/Component/Sidebar/sidebar.tsx +++ b/src/Component/Sidebar/sidebar.tsx @@ -31,7 +31,7 @@ import {getsubscriptionsThunk} from "../../redux/subscriptionsSlice.ts"; const cache = new Map(); -export function Sidebar({showSidebar}){ +export function Sidebar({showSidebar} : {showSidebar : boolean}){ if (window.scrollY) { window.scroll(0, 0); // reset the scroll position to the top left of the document. @@ -57,7 +57,7 @@ export function Sidebar({showSidebar}){ const { subscriptions } = useAppSelector(state => state.subscriptions) - function handleClick(channelId){ + function handleClick(channelId : string){ navigate(`/feed/${channelId}`) } diff --git a/src/Component/Video/video.tsx b/src/Component/Video/video.tsx index 38f4dda..5db8d4b 100644 --- a/src/Component/Video/video.tsx +++ b/src/Component/Video/video.tsx @@ -5,7 +5,14 @@ import moment from 'moment' import numeral from 'numeral' import { useNavigate} from "react-router-dom"; -export function Video({item, channelScreen, duration, channelIcon}){ +type videoProps = { + item : any, + channelScreen? : any, + duration : any, + channelIcon : any +} + +export function Video({item, channelScreen, duration, channelIcon} : videoProps){ const { id, @@ -89,7 +96,7 @@ export function Video({item, channelScreen, duration, channelIcon}){ {!channelScreen && (
{/**/} - + channelIcon

{channelTitle}

diff --git a/src/Component/VideoHorizontal/VideoHorizontal.tsx b/src/Component/VideoHorizontal/VideoHorizontal.tsx index e0ee460..a1f4c77 100644 --- a/src/Component/VideoHorizontal/VideoHorizontal.tsx +++ b/src/Component/VideoHorizontal/VideoHorizontal.tsx @@ -4,7 +4,15 @@ import moment from "moment"; import numeral from "numeral"; import { useNavigate} from "react-router-dom"; -export function VideoHorizontal({videos, searchScreen, searchresult, subScreen, channelIcons, viewsDuration}){ +type VideoHorizontalProps = { + videos : any, + searchScreen? : any, + searchresult? : boolean, + subScreen? : any, + channelIcon? : any, + viewsDuration : any +} +export function VideoHorizontal({videos, searchScreen, searchresult, subScreen, channelIcon, viewsDuration} : VideoHorizontalProps){ // const [views, setViews] = useState() // const [duration, setDuration] = useState() @@ -127,14 +135,14 @@ export function VideoHorizontal({videos, searchScreen, searchresult, subScreen, {subScreen &&
- {channelIcons?.snippet?.customUrl} . {' '} - {numeral ( channelIcons?.statistics?.subscriberCount ).format ( '0.a' )} Subscribers + {channelIcon?.snippet?.customUrl} . {' '} + {numeral ( channelIcon?.statistics?.subscriberCount ).format ( '0.a' )} Subscribers
}
{isVideo && searchresult && - + } { isVideo && searchresult &&

{ channelTitle }

}
diff --git a/src/Component/VideoMetaData/VideoMetaData.tsx b/src/Component/VideoMetaData/VideoMetaData.tsx index add091a..973e6d9 100644 --- a/src/Component/VideoMetaData/VideoMetaData.tsx +++ b/src/Component/VideoMetaData/VideoMetaData.tsx @@ -14,7 +14,7 @@ type videoMetadataProps = { videoID : string |undefined } -export function VideoMetaData({video ,videoID} : videoMetadataProps) { +export function VideoMetaData({video } : videoMetadataProps) { const dispatch = useAppDispatch() diff --git a/src/Data/SampelData.ts b/src/Data/SampelData.ts index ff2b5c5..bc879c5 100644 --- a/src/Data/SampelData.ts +++ b/src/Data/SampelData.ts @@ -1,308 +1,308 @@ -// Sample JSON for /videos endpoint, paginated with 20 items - -const videoItem = [ - { - "kind": "youtube#video", - "etag": "etag_value", - "id": "video_id_1", - "snippet": { - "publishedAt": "2023-09-29T00:00:00Z", - "channelId": "channel_id_1", - "title": "Video Title 1", - "description": "Video description 1", - "thumbnails": { - "default": { - "url": "https://example.com/thumbnail1.jpg", - "width": 120, - "height": 90 - }, - "medium": { - "url": "https://example.com/thumbnail1.jpg", - "width": 320, - "height": 180 - }, - "high": { - "url": "https://example.com/thumbnail1.jpg", - "width": 480, - "height": 360 - } - }, - "channelTitle": "Channel Title 1", - "tags": ["tag1", "tag2"], - "categoryId": "22", - "liveBroadcastContent": "none", - "localized": { - "title": "Localized Title 1", - "description": "Localized description 1" - } - }, - "contentDetails": { - "duration": "PT10M34S", - "dimension": "2d", - "definition": "hd", - "caption": "false", - "licensedContent": true, - "projection": "rectangular" - }, - "statistics": { - "viewCount": "123456", - "likeCount": "4567", - "dislikeCount": "123", - "favoriteCount": "0", - "commentCount": "89" - } - } -] -const repeat = (arr, n) => [].concat(...Array(n).fill(arr)); - -export const videosResponse = { - "kind": "youtube#videoListResponse", - "etag": "etag_value", - "nextPageToken": "CAUQAA", - "prevPageToken": (Math.random() * 10000).toString(), - "pageInfo": { - "totalResults": 200, - "resultsPerPage": 20 - }, - "items": repeat(videoItem, 20) -}; - - - -// Sample JSON for /search by keyword endpoint -export const searchResponse = { - "kind": "youtube#searchListResponse", - "etag": "etag_value", - "nextPageToken": "CAoQAA", - "prevPageToken": "CAAQAA", - "regionCode": "US", - "pageInfo": { - "totalResults": 1000000, - "resultsPerPage": 20 - }, - "items": [ - { - "kind": "youtube#searchResult", - "etag": "etag_value", - "id": { - "kind": "youtube#video", - "videoId": "video_id_1" - }, - "snippet": { - "publishedAt": "2023-09-29T00:00:00Z", - "channelId": "channel_id_1", - "title": "Search Result Video Title 1", - "description": "Search result video description 1", - "thumbnails": { - "default": { - "url": "https://example.com/thumbnail1.jpg", - "width": 120, - "height": 90 - }, - "medium": { - "url": "https://example.com/thumbnail1.jpg", - "width": 320, - "height": 180 - }, - "high": { - "url": "https://example.com/thumbnail1.jpg", - "width": 480, - "height": 360 - } - }, - "channelTitle": "Search Result Channel Title 1", - "liveBroadcastContent": "none", - "publishTime": "2023-09-29T00:00:00Z" - } - }, - { - "kind": "youtube#searchResult", - "etag": "etag_value", - "id": { - "kind": "youtube#video", - "videoId": "video_id_2" - }, - "snippet": { - "publishedAt": "2023-09-28T00:00:00Z", - "channelId": "channel_id_2", - "title": "Search Result Video Title 2", - "description": "Search result video description 2", - "thumbnails": { - "default": { - "url": "https://example.com/thumbnail2.jpg", - "width": 120, - "height": 90 - }, - "medium": { - "url": "https://example.com/thumbnail2.jpg", - "width": 320, - "height": 180 - }, - "high": { - "url": "https://example.com/thumbnail2.jpg", - "width": 480, - "height": 360 - } - }, - "channelTitle": "Search Result Channel Title 2", - "liveBroadcastContent": "none", - "publishTime": "2023-09-28T00:00:00Z" - } - } - // ...more items (20 items total) - ] -}; - -export const commentThreadsResponse = { - "kind": "youtube#commentThreadListResponse", - "etag": "etag_value", - "nextPageToken": "CAEQAA", - "pageInfo": { - "totalResults": 100, - "resultsPerPage": 20 - }, - "items": repeat([ - { - "kind": "youtube#commentThread", - "etag": "etag_value", - "id": "comment_thread_id_1", - "snippet": { - "videoId": "video_id_1", - "topLevelComment": { - "kind": "youtube#comment", - "etag": "etag_value", - "id": "comment_id_1", - "snippet": { - "authorDisplayName": "User 1", - "authorProfileImageUrl": "https://example.com/profile1.jpg", - "authorChannelUrl": "https://www.youtube.com/channel/channel_id_1", - "authorChannelId": { - "value": "channel_id_1" - }, - "textOriginal": "This is a sample top-level comment 1", - "textDisplay": "This is a sample top-level comment 1", - "likeCount": 10, - "publishedAt": "2023-09-29T00:00:00Z", - "updatedAt": "2023-09-29T00:00:00Z" - } - }, - "canReply": true, - "totalReplyCount": 5, - "isPublic": true - }, - "replies": { - "comments": [ - { - "kind": "youtube#comment", - "etag": "etag_value", - "id": "reply_id_1", - "snippet": { - "authorDisplayName": "User 2", - "authorProfileImageUrl": "https://example.com/profile2.jpg", - "authorChannelUrl": "https://www.youtube.com/channel/channel_id_2", - "authorChannelId": { - "value": "channel_id_2" - }, - "textOriginal": "This is a sample reply 1", - "textDisplay": "This is a sample reply 1", - "likeCount": 3, - "publishedAt": "2023-09-29T01:00:00Z", - "updatedAt": "2023-09-29T01:00:00Z" - } - } - ] - } - } - ], 20) -}; - -// Sample JSON for /subscriptions endpoint -export const subscriptionsResponse = { - "kind": "youtube#subscriptionListResponse", - "etag": "etag_value", - "nextPageToken": "CAoQAA", - "pageInfo": { - "totalResults": 100, - "resultsPerPage": 20 - }, - "items": repeat([ - { - "kind": "youtube#subscription", - "etag": "etag_value", - "id": "subscription_id_1", - "snippet": { - "publishedAt": "2023-09-29T00:00:00Z", - "title": "Sample Channel 1", - "description": "This is a sample subscription", - "resourceId": { - "kind": "youtube#channel", - "channelId": "channel_id_1" - }, - "thumbnails": { - "default": { - "url": "https://example.com/thumbnail1.jpg", - "width": 88, - "height": 88 - }, - "medium": { - "url": "https://example.com/thumbnail1.jpg", - "width": 240, - "height": 240 - }, - "high": { - "url": "https://example.com/thumbnail1.jpg", - "width": 800, - "height": 800 - } - }, - "channelTitle": "Sample Channel Title 1" - } - } - ], 20) -}; - -// Sample JSON for /channel by ID endpoint -export const channelByIdResponse = { - "kind": "youtube#channelListResponse", - "etag": "etag_value", - "pageInfo": { - "totalResults": 1, - "resultsPerPage": 1 - }, - "items": repeat([ - { - "kind": "youtube#channel", - "etag": "etag_value", - "id": "channel_id_1", - "snippet": { - "title": "Sample Channel Title 1", - "description": "This is a sample channel description", - "publishedAt": "2010-06-09T00:00:00Z", - "thumbnails": { - "default": { - "url": "https://example.com/thumbnail1.jpg", - "width": 88, - "height": 88 - }, - "medium": { - "url": "https://example.com/thumbnail1.jpg", - "width": 240, - "height": 240 - }, - "high": { - "url": "https://example.com/thumbnail1.jpg", - "width": 800, - "height": 800 - } - }, - "country": "US" - }, - "statistics": { - "viewCount": "12345678", - "subscriberCount": "1000000", - "hiddenSubscriberCount": false, - "videoCount": "500" - } - } - ], 1) -}; \ No newline at end of file +// // Sample JSON for /videos endpoint, paginated with 20 items +// +// const videoItem = [ +// { +// "kind": "youtube#video", +// "etag": "etag_value", +// "id": "video_id_1", +// "snippet": { +// "publishedAt": "2023-09-29T00:00:00Z", +// "channelId": "channel_id_1", +// "title": "Video Title 1", +// "description": "Video description 1", +// "thumbnails": { +// "default": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 120, +// "height": 90 +// }, +// "medium": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 320, +// "height": 180 +// }, +// "high": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 480, +// "height": 360 +// } +// }, +// "channelTitle": "Channel Title 1", +// "tags": ["tag1", "tag2"], +// "categoryId": "22", +// "liveBroadcastContent": "none", +// "localized": { +// "title": "Localized Title 1", +// "description": "Localized description 1" +// } +// }, +// "contentDetails": { +// "duration": "PT10M34S", +// "dimension": "2d", +// "definition": "hd", +// "caption": "false", +// "licensedContent": true, +// "projection": "rectangular" +// }, +// "statistics": { +// "viewCount": "123456", +// "likeCount": "4567", +// "dislikeCount": "123", +// "favoriteCount": "0", +// "commentCount": "89" +// } +// } +// ] +// const repeat = (arr , n) => [].concat(...Array(n).fill(arr)); +// +// export const videosResponse = { +// "kind": "youtube#videoListResponse", +// "etag": "etag_value", +// "nextPageToken": "CAUQAA", +// "prevPageToken": (Math.random() * 10000).toString(), +// "pageInfo": { +// "totalResults": 200, +// "resultsPerPage": 20 +// }, +// "items": repeat(videoItem, 20) +// }; +// +// +// +// // Sample JSON for /search by keyword endpoint +// export const searchResponse = { +// "kind": "youtube#searchListResponse", +// "etag": "etag_value", +// "nextPageToken": "CAoQAA", +// "prevPageToken": "CAAQAA", +// "regionCode": "US", +// "pageInfo": { +// "totalResults": 1000000, +// "resultsPerPage": 20 +// }, +// "items": [ +// { +// "kind": "youtube#searchResult", +// "etag": "etag_value", +// "id": { +// "kind": "youtube#video", +// "videoId": "video_id_1" +// }, +// "snippet": { +// "publishedAt": "2023-09-29T00:00:00Z", +// "channelId": "channel_id_1", +// "title": "Search Result Video Title 1", +// "description": "Search result video description 1", +// "thumbnails": { +// "default": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 120, +// "height": 90 +// }, +// "medium": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 320, +// "height": 180 +// }, +// "high": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 480, +// "height": 360 +// } +// }, +// "channelTitle": "Search Result Channel Title 1", +// "liveBroadcastContent": "none", +// "publishTime": "2023-09-29T00:00:00Z" +// } +// }, +// { +// "kind": "youtube#searchResult", +// "etag": "etag_value", +// "id": { +// "kind": "youtube#video", +// "videoId": "video_id_2" +// }, +// "snippet": { +// "publishedAt": "2023-09-28T00:00:00Z", +// "channelId": "channel_id_2", +// "title": "Search Result Video Title 2", +// "description": "Search result video description 2", +// "thumbnails": { +// "default": { +// "url": "https://example.com/thumbnail2.jpg", +// "width": 120, +// "height": 90 +// }, +// "medium": { +// "url": "https://example.com/thumbnail2.jpg", +// "width": 320, +// "height": 180 +// }, +// "high": { +// "url": "https://example.com/thumbnail2.jpg", +// "width": 480, +// "height": 360 +// } +// }, +// "channelTitle": "Search Result Channel Title 2", +// "liveBroadcastContent": "none", +// "publishTime": "2023-09-28T00:00:00Z" +// } +// } +// // ...more items (20 items total) +// ] +// }; +// +// export const commentThreadsResponse = { +// "kind": "youtube#commentThreadListResponse", +// "etag": "etag_value", +// "nextPageToken": "CAEQAA", +// "pageInfo": { +// "totalResults": 100, +// "resultsPerPage": 20 +// }, +// "items": repeat([ +// { +// "kind": "youtube#commentThread", +// "etag": "etag_value", +// "id": "comment_thread_id_1", +// "snippet": { +// "videoId": "video_id_1", +// "topLevelComment": { +// "kind": "youtube#comment", +// "etag": "etag_value", +// "id": "comment_id_1", +// "snippet": { +// "authorDisplayName": "User 1", +// "authorProfileImageUrl": "https://example.com/profile1.jpg", +// "authorChannelUrl": "https://www.youtube.com/channel/channel_id_1", +// "authorChannelId": { +// "value": "channel_id_1" +// }, +// "textOriginal": "This is a sample top-level comment 1", +// "textDisplay": "This is a sample top-level comment 1", +// "likeCount": 10, +// "publishedAt": "2023-09-29T00:00:00Z", +// "updatedAt": "2023-09-29T00:00:00Z" +// } +// }, +// "canReply": true, +// "totalReplyCount": 5, +// "isPublic": true +// }, +// "replies": { +// "comments": [ +// { +// "kind": "youtube#comment", +// "etag": "etag_value", +// "id": "reply_id_1", +// "snippet": { +// "authorDisplayName": "User 2", +// "authorProfileImageUrl": "https://example.com/profile2.jpg", +// "authorChannelUrl": "https://www.youtube.com/channel/channel_id_2", +// "authorChannelId": { +// "value": "channel_id_2" +// }, +// "textOriginal": "This is a sample reply 1", +// "textDisplay": "This is a sample reply 1", +// "likeCount": 3, +// "publishedAt": "2023-09-29T01:00:00Z", +// "updatedAt": "2023-09-29T01:00:00Z" +// } +// } +// ] +// } +// } +// ], 20) +// }; +// +// // Sample JSON for /subscriptions endpoint +// export const subscriptionsResponse = { +// "kind": "youtube#subscriptionListResponse", +// "etag": "etag_value", +// "nextPageToken": "CAoQAA", +// "pageInfo": { +// "totalResults": 100, +// "resultsPerPage": 20 +// }, +// "items": repeat([ +// { +// "kind": "youtube#subscription", +// "etag": "etag_value", +// "id": "subscription_id_1", +// "snippet": { +// "publishedAt": "2023-09-29T00:00:00Z", +// "title": "Sample Channel 1", +// "description": "This is a sample subscription", +// "resourceId": { +// "kind": "youtube#channel", +// "channelId": "channel_id_1" +// }, +// "thumbnails": { +// "default": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 88, +// "height": 88 +// }, +// "medium": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 240, +// "height": 240 +// }, +// "high": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 800, +// "height": 800 +// } +// }, +// "channelTitle": "Sample Channel Title 1" +// } +// } +// ], 20) +// }; +// +// // Sample JSON for /channel by ID endpoint +// export const channelByIdResponse = { +// "kind": "youtube#channelListResponse", +// "etag": "etag_value", +// "pageInfo": { +// "totalResults": 1, +// "resultsPerPage": 1 +// }, +// "items": repeat([ +// { +// "kind": "youtube#channel", +// "etag": "etag_value", +// "id": "channel_id_1", +// "snippet": { +// "title": "Sample Channel Title 1", +// "description": "This is a sample channel description", +// "publishedAt": "2010-06-09T00:00:00Z", +// "thumbnails": { +// "default": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 88, +// "height": 88 +// }, +// "medium": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 240, +// "height": 240 +// }, +// "high": { +// "url": "https://example.com/thumbnail1.jpg", +// "width": 800, +// "height": 800 +// } +// }, +// "country": "US" +// }, +// "statistics": { +// "viewCount": "12345678", +// "subscriberCount": "1000000", +// "hiddenSubscriberCount": false, +// "videoCount": "500" +// } +// } +// ], 1) +// }; \ No newline at end of file diff --git a/src/Data/fetchApi.ts b/src/Data/fetchApi.ts index 3c819a6..b5bff0f 100644 --- a/src/Data/fetchApi.ts +++ b/src/Data/fetchApi.ts @@ -7,7 +7,7 @@ export const FetchApi = axios.create({ } }) -export async function getyoutubeVideos(getState){ +export async function getyoutubeVideos(getState : () => any){ try { const res = await FetchApi("/videos",{ params : { @@ -26,7 +26,7 @@ export async function getyoutubeVideos(getState){ } } -export async function getVideosByKeyword( keyword : string, getState ){ +export async function getVideosByKeyword( keyword : string, getState : () => any ){ try { const res = await FetchApi("/search",{ params : { @@ -45,7 +45,7 @@ export async function getVideosByKeyword( keyword : string, getState ){ } } -export async function getsubscriptions(getState){ +export async function getsubscriptions(getState : () => any){ try { const res = await FetchApi("/subscriptions",{ params : { @@ -130,7 +130,7 @@ export async function GetComments(id : string | undefined ){ } } -export async function postComments(text : string, getState ,id : string, ){ +export async function postComments(text : string, getState : () => any ,id : string, ){ const obj = { "snippet" : { @@ -177,7 +177,7 @@ export async function channelBYID(id : string | undefined){ } } -export async function SubStat(channelID : string, getState){ +export async function SubStat(channelID : string, getState : () => any){ try { const res = await FetchApi("/subscriptions",{ params : { @@ -229,7 +229,7 @@ export async function getVideosByChannel(uploadPlaylistId : string | undefined){ } } -export async function getDurationView(videoIds : string){ +export async function getDurationView(videoIds : string[] | string){ try { const res = await FetchApi('/videos',{ params:{ diff --git a/src/Page/Home.tsx b/src/Page/Home.tsx index e30eccf..7680719 100644 --- a/src/Page/Home.tsx +++ b/src/Page/Home.tsx @@ -1,15 +1,15 @@ import {Header} from "../Component/Header/header.tsx"; import {Sidebar} from "../Component/Sidebar/sidebar.tsx"; import {Container} from "react-bootstrap"; -import { useState} from "react"; -import {useAppSelector} from "../redux/store.ts"; -import {useNavigate} from "react-router-dom"; +import {ReactNode , useState} from "react"; +// import {useAppSelector} from "../redux/store.ts"; +// import {useNavigate} from "react-router-dom"; -export function Home({children}){ +export function Home({children} : {children : ReactNode}){ const [showSidebar, toggleSidebar] = useState(false) - const { loading,accessToken, user, error} = useAppSelector((state) => state.auth) - const navigate = useNavigate() + // const { loading,accessToken, user, error} = useAppSelector((state) => state.auth) + // const navigate = useNavigate() const handleToggleSidebar = () => { toggleSidebar(value => !value) diff --git a/src/Screen/Homescreen.tsx b/src/Screen/Homescreen.tsx index 103d924..5f92d31 100644 --- a/src/Screen/Homescreen.tsx +++ b/src/Screen/Homescreen.tsx @@ -1,7 +1,7 @@ import {Col , Container} from "react-bootstrap"; import {CategoryBar} from "../Component/Category/CategoryBar.tsx"; import {Video} from "../Component/Video/video.tsx"; -import {useEffect , useState} from "react"; +import {useEffect } from "react"; import {useAppDispatch , useAppSelector} from "../redux/store.ts"; // import {getVideosByKeyword , getyoutubeVideos} from "../redux/videoSlice.ts"; import InfiniteScroll from "react-infinite-scroll-component"; @@ -46,7 +46,7 @@ export function HomeScreen() { activeCategory , loading , nextPageToken , - videoIds , + // videoIds , duration , channelIcon } = useAppSelector ( (state) => state.homeVideos ) @@ -54,8 +54,8 @@ export function HomeScreen() { const category = sessionStorage.getItem ( "keyword" ) // const[homeVideos, setHomeVideos] = useState([]) - const [allVideoIDs , setAllVideoIDs] = useState ( [] ) - const [icons , setIcons] = useState ( [] ) + // const [allVideoIDs , setAllVideoIDs] = useState ( [] ) + // const [icons , setIcons] = useState ( [] ) useEffect ( () => { @@ -71,6 +71,8 @@ export function HomeScreen() { // getyoutubeVideos().then(()=>{}) } else { + if(!category) return + console.log ( JSON.parse ( category ) ) dispatch ( getVideosByKeywordThunk ( { keyword : JSON.parse ( category ) } ) ) @@ -117,7 +119,7 @@ export function HomeScreen() { videos.map ( (item , index) => (