diff --git a/pages/HottestSongs.tsx b/pages/HottestSongs.tsx index 8310c2b6..f4355add 100644 --- a/pages/HottestSongs.tsx +++ b/pages/HottestSongs.tsx @@ -31,6 +31,7 @@ const {Text,Title} = Typography; // context imports import { WalletContext } from "../src/contexts/WalletContext"; +import {SelectedSongProvider} from '../src/contexts/selectedSong' // custom-components imports import MintSongButton from "../src/components/MintSongButton/MintSongButton"; @@ -58,12 +59,17 @@ const HottestSongs: React.FC = () => { const [isFetchingBanner, setIsFetchingBanner] = useState(false); const [isPlaying, setIsPlaying] = useState(false); - // const { - // loading: isLoadingAllMusic, - // data: allMusicConnection, - // error: allMusicError, - // } = useQuery(GET_ALL_MUSIC, { variables: {} }); - + const { + loading: isLoadingAllMusic, + data: allMusicConnection, + error: allMusicError, + } = useQuery(GET_ALL_MUSIC, { + variables: { + currentTime: Math.floor(Date.now() / 1000).toString(), + }, + }); + + // function to handle toggling of minting modal const handleModal = () => { setDisplayModal(!displayModal); @@ -209,9 +215,12 @@ const HottestSongs: React.FC = () => { isVisible={displayModal} isMinting={isMinting} /> + {isPlaying && } - - {isPlaying && } + + {/* {isPlaying && } */} + + ); diff --git a/src/components/Mintmodal/MintModal.tsx b/src/components/Mintmodal/MintModal.tsx index 5c6a9a33..50a53c44 100644 --- a/src/components/Mintmodal/MintModal.tsx +++ b/src/components/Mintmodal/MintModal.tsx @@ -6,7 +6,7 @@ import { UploadOutlined } from "@ant-design/icons"; // types import {ModalProps} from './MintModal.types' // custom-components -import {MintForm} from './MintForm' +import MintForm from './MintForm/MintForm' const MintModal: React.FC = ({ diff --git a/src/components/SongList/SongList.tsx b/src/components/SongList/SongList.tsx index d273515e..348e4df2 100644 --- a/src/components/SongList/SongList.tsx +++ b/src/components/SongList/SongList.tsx @@ -1,4 +1,4 @@ -import {useState,useEffect} from 'react' +import {useState,useEffect,useContext} from 'react' // graphql imports import { useQuery } from "@apollo/client"; @@ -18,78 +18,73 @@ import {SongListProps} from './SongList.types' // custom-component imports import { TitleNode,SongNode } from './ListItemNodes'; - -const SongList: React.FC = ({playSong}) => { - const { - loading: isLoadingAllMusic, - data: allMusicConnection, - error: allMusicError, - } = useQuery(GET_ALL_MUSIC, { - variables: { - currentTime: Math.floor(Date.now() / 1000).toString(), - }, - }); - - // add useState hooks here - const [price, setPrice] = useState("100MATIC"); - const [views, setViews] = useState("100kViews"); - - const onChangePrice = (e: RadioChangeEvent) => { - console.log("radio checked", e.target.value); - setPrice(e.target.value); - }; - - // menu items for price dropdown filter - const priceFilterMenu = ( - - - 100 MATIC and under - 200 MATIC and under - 500 MATIC and under - - - ), - key: "1", - }, - ]} - /> - ); - - const onChangeViews = (e: RadioChangeEvent) => { - console.log("radio checked", e.target.value); - setViews(e.target.value); - }; - - // menu items for number of view dropdown filter - const viewsFilterMenu = ( - - - 1000 views and under - 10K views and under - 50K views and under - 100K views and under - 1 million+ views - - - ), - key: "1", - }, - ]} - /> - ); +// context imports +import {SelectedSongContext} from '../../contexts/selectedSong' + +const SongList: React.FC = ({dataSource,isLoadingMusic}) => { + + const targetSong = useContext(SelectedSongContext) + +// // add useState hooks here +// const [price, setPrice] = useState("100MATIC"); +// const [views, setViews] = useState("100kViews"); + +// const onChangePrice = (e: RadioChangeEvent) => { +// console.log("radio checked", e.target.value); +// setPrice(e.target.value); +// }; + +// // menu items for price dropdown filter +// const priceFilterMenu = ( +// +// +// 100 MATIC and under +// 200 MATIC and under +// 500 MATIC and under +// +// +// ), +// key: "1", +// }, +// ]} +// /> +// ); + +// const onChangeViews = (e: RadioChangeEvent) => { +// console.log("radio checked", e.target.value); +// setViews(e.target.value); +// }; + +// // menu items for number of view dropdown filter +// const viewsFilterMenu = ( +// +// +// 1000 views and under +// 10K views and under +// 50K views and under +// 100K views and under +// 1 million+ views +// +// +// ), +// key: "1", +// }, +// ]} +// /> +// ); return ( <> {/* start dropdowns */} - */} {/* end dropdowns */} {/* songlist */} ( = ({playSong}) => { } description={`Burna Boy`} /> - + )}/> diff --git a/src/components/SongList/SongList.types.ts b/src/components/SongList/SongList.types.ts index 67aa8d89..74af2123 100644 --- a/src/components/SongList/SongList.types.ts +++ b/src/components/SongList/SongList.types.ts @@ -1,5 +1,9 @@ +import { GetAllMusic_musicNFTs } from "../../graph-ql/queries/GET_ALL_MUSIC/__generated__/GetAllMusic"; + interface SongListProps{ - playSong:(uri:string)=>void + // playSong:(uri:string)=>void, + dataSource: GetAllMusic_musicNFTs[], + isLoadingMusic:boolean } export type {SongListProps} \ No newline at end of file diff --git a/src/components/StickyPlayer/StickyPlayer.tsx b/src/components/StickyPlayer/StickyPlayer.tsx index eeccbc5d..431df9a0 100644 --- a/src/components/StickyPlayer/StickyPlayer.tsx +++ b/src/components/StickyPlayer/StickyPlayer.tsx @@ -1,20 +1,29 @@ +import {useContext} from 'react' + // antd imports import {Typography} from 'antd' const {Text,Title} = Typography; +//context imports +import {SelectedSongContext} from '../../contexts/selectedSong' + // type imports import {songShape,StickyPlayerProps} from './StickyPlayer.types' const StickyPlayer: React.FC = ({selectedSong}) =>{ - console.log(selectedSong) + + const {isPlaying,currentSong} = useContext(SelectedSongContext); + + if(!isPlaying) return
+ return(
- {selectedSong?.name} - {selectedSong?.artist} + {currentSong.name} + {currentSong?.artist}
-
) diff --git a/src/contexts/selectedSong.js b/src/contexts/selectedSong.js new file mode 100644 index 00000000..bc297497 --- /dev/null +++ b/src/contexts/selectedSong.js @@ -0,0 +1,40 @@ +import React, {createContext,useState} from 'react' + +export const SelectedSongContext = createContext(); + + + +export function SelectedSongProvider({children}){ + const [isPlaying,setIsPlaying] = useState(false); + const [currentSong,setCurrentSong] = useState({}); + + const playSong = async(songId) =>{ + console.log(songId) + setIsPlaying(true); + try{ + // setIsFetchingBanner(true); + //set local state + setCurrentSong({ + name:'Last last', + artist: 'Burna Boy', + url: songId + }) + }catch(err){ + // setIsFetchingBanner(false); + } + // set selected Song state + // set banner place holder to start loading while fetching image from ipfs + + } + + const value ={ + isPlaying, + currentSong, + playSong + } + + return + {children} + +} + diff --git a/tsconfig.json b/tsconfig.json index acfbf8ad..3b6fb882 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,7 +23,7 @@ "next-env.d.ts", "**/*.ts", "**/*.tsx" ], - "exclude": [ +, "src/contexts/selectedSong.js" "exclude": [ "node_modules" ] }