11'use client' ;
22
3- import {
4- FeaturedSongsDtoType ,
5- SongPreviewDtoType ,
6- TimespanType ,
7- } from '@nbw/database' ;
3+ import { TIMESPANS } from '@nbw/config' ;
4+ import { type FeaturedSongsDto , type SongPreviewDto } from '@nbw/database' ;
85import { createContext , useContext , useEffect , useState } from 'react' ;
6+ type TimespanType = ( typeof TIMESPANS ) [ number ] ;
97
108type FeaturedSongsContextType = {
11- featuredSongsPage : SongPreviewDtoType [ ] ;
9+ featuredSongsPage : SongPreviewDto [ ] ;
1210 timespan : TimespanType ;
1311 setTimespan : ( timespan : TimespanType ) => void ;
1412 timespanEmpty : Record < string , boolean > ;
@@ -23,14 +21,14 @@ export function FeaturedSongsProvider({
2321 initialFeaturedSongs,
2422} : {
2523 children : React . ReactNode ;
26- initialFeaturedSongs : FeaturedSongsDtoType ;
24+ initialFeaturedSongs : FeaturedSongsDto ;
2725} ) {
2826 // Featured songs
29- const [ featuredSongs ] = useState < FeaturedSongsDtoType > ( initialFeaturedSongs ) ;
27+ const [ featuredSongs ] = useState < FeaturedSongsDto > ( initialFeaturedSongs ) ;
3028
31- const [ featuredSongsPage , setFeaturedSongsPage ] = useState <
32- SongPreviewDtoType [ ]
33- > ( initialFeaturedSongs . week ) ;
29+ const [ featuredSongsPage , setFeaturedSongsPage ] = useState < SongPreviewDto [ ] > (
30+ initialFeaturedSongs . week ,
31+ ) ;
3432
3533 const [ timespan , setTimespan ] = useState < TimespanType > ( 'week' ) ;
3634
@@ -43,7 +41,6 @@ export function FeaturedSongsProvider({
4341 ) ;
4442
4543 useEffect ( ( ) => {
46- // eslint-disable-next-line react-hooks/exhaustive-deps
4744 setFeaturedSongsPage ( featuredSongs [ timespan ] ) ;
4845 } , [ featuredSongs , timespan ] ) ;
4946
0 commit comments